babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655
  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 dirty prepass flag value
  862. */
  863. static readonly MATERIAL_PrePassDirtyFlag: number;
  864. /**
  865. * The all dirty flag value
  866. */
  867. static readonly MATERIAL_AllDirtyFlag: number;
  868. /**
  869. * Returns the triangle fill mode
  870. */
  871. static readonly MATERIAL_TriangleFillMode: number;
  872. /**
  873. * Returns the wireframe mode
  874. */
  875. static readonly MATERIAL_WireFrameFillMode: number;
  876. /**
  877. * Returns the point fill mode
  878. */
  879. static readonly MATERIAL_PointFillMode: number;
  880. /**
  881. * Returns the point list draw mode
  882. */
  883. static readonly MATERIAL_PointListDrawMode: number;
  884. /**
  885. * Returns the line list draw mode
  886. */
  887. static readonly MATERIAL_LineListDrawMode: number;
  888. /**
  889. * Returns the line loop draw mode
  890. */
  891. static readonly MATERIAL_LineLoopDrawMode: number;
  892. /**
  893. * Returns the line strip draw mode
  894. */
  895. static readonly MATERIAL_LineStripDrawMode: number;
  896. /**
  897. * Returns the triangle strip draw mode
  898. */
  899. static readonly MATERIAL_TriangleStripDrawMode: number;
  900. /**
  901. * Returns the triangle fan draw mode
  902. */
  903. static readonly MATERIAL_TriangleFanDrawMode: number;
  904. /**
  905. * Stores the clock-wise side orientation
  906. */
  907. static readonly MATERIAL_ClockWiseSideOrientation: number;
  908. /**
  909. * Stores the counter clock-wise side orientation
  910. */
  911. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  912. /**
  913. * Nothing
  914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  915. */
  916. static readonly ACTION_NothingTrigger: number;
  917. /**
  918. * On pick
  919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  920. */
  921. static readonly ACTION_OnPickTrigger: number;
  922. /**
  923. * On left pick
  924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  925. */
  926. static readonly ACTION_OnLeftPickTrigger: number;
  927. /**
  928. * On right pick
  929. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  930. */
  931. static readonly ACTION_OnRightPickTrigger: number;
  932. /**
  933. * On center pick
  934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnCenterPickTrigger: number;
  937. /**
  938. * On pick down
  939. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickDownTrigger: number;
  942. /**
  943. * On double pick
  944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnDoublePickTrigger: number;
  947. /**
  948. * On pick up
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPickUpTrigger: number;
  952. /**
  953. * On pick out.
  954. * This trigger will only be raised if you also declared a OnPickDown
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickOutTrigger: number;
  958. /**
  959. * On long press
  960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  961. */
  962. static readonly ACTION_OnLongPressTrigger: number;
  963. /**
  964. * On pointer over
  965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  966. */
  967. static readonly ACTION_OnPointerOverTrigger: number;
  968. /**
  969. * On pointer out
  970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  971. */
  972. static readonly ACTION_OnPointerOutTrigger: number;
  973. /**
  974. * On every frame
  975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  976. */
  977. static readonly ACTION_OnEveryFrameTrigger: number;
  978. /**
  979. * On intersection enter
  980. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  981. */
  982. static readonly ACTION_OnIntersectionEnterTrigger: number;
  983. /**
  984. * On intersection exit
  985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  986. */
  987. static readonly ACTION_OnIntersectionExitTrigger: number;
  988. /**
  989. * On key down
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnKeyDownTrigger: number;
  993. /**
  994. * On key up
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnKeyUpTrigger: number;
  998. /**
  999. * Billboard mode will only apply to Y axis
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1002. /**
  1003. * Billboard mode will apply to all axes
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1006. /**
  1007. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1008. */
  1009. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1010. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1011. * Test order :
  1012. * Is the bounding sphere outside the frustum ?
  1013. * If not, are the bounding box vertices outside the frustum ?
  1014. * It not, then the cullable object is in the frustum.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1017. /** Culling strategy : Bounding Sphere Only.
  1018. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1019. * It's also less accurate than the standard because some not visible objects can still be selected.
  1020. * Test : is the bounding sphere outside the frustum ?
  1021. * If not, then the cullable object is in the frustum.
  1022. */
  1023. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1024. /** Culling strategy : Optimistic Inclusion.
  1025. * This in an inclusion test first, then the standard exclusion test.
  1026. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1027. * 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.
  1028. * Anyway, it's as accurate as the standard strategy.
  1029. * Test :
  1030. * Is the cullable object bounding sphere center in the frustum ?
  1031. * If not, apply the default culling strategy.
  1032. */
  1033. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1034. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1035. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1036. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1037. * 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.
  1038. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1039. * Test :
  1040. * Is the cullable object bounding sphere center in the frustum ?
  1041. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1042. */
  1043. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1044. /**
  1045. * No logging while loading
  1046. */
  1047. static readonly SCENELOADER_NO_LOGGING: number;
  1048. /**
  1049. * Minimal logging while loading
  1050. */
  1051. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1052. /**
  1053. * Summary logging while loading
  1054. */
  1055. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1056. /**
  1057. * Detailled logging while loading
  1058. */
  1059. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1060. /**
  1061. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1062. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1063. */
  1064. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1065. /**
  1066. * Constant used to retrieve the position texture index in the textures array in the prepass
  1067. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1068. */
  1069. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1070. /**
  1071. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1072. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1073. */
  1074. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1075. /**
  1076. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1077. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1078. */
  1079. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1080. /**
  1081. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1082. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1083. */
  1084. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1085. /**
  1086. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1087. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1088. */
  1089. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1090. /**
  1091. * Constant used to retrieve albedo index in the textures array in the prepass
  1092. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1093. */
  1094. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1095. }
  1096. }
  1097. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1098. import { Nullable } from "babylonjs/types";
  1099. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module "babylonjs/Engines/IPipelineContext" {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module "babylonjs/Meshes/dataBuffer" {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1189. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1190. /** @hidden */
  1191. export interface ProcessingOptions {
  1192. defines: string[];
  1193. indexParameters: any;
  1194. isFragment: boolean;
  1195. shouldUseHighPrecisionShader: boolean;
  1196. supportsUniformBuffers: boolean;
  1197. shadersRepository: string;
  1198. includesShadersStore: {
  1199. [key: string]: string;
  1200. };
  1201. processor?: IShaderProcessor;
  1202. version: string;
  1203. platformName: string;
  1204. lookForClosingBracketForUniformBuffer?: boolean;
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1208. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1234. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1235. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1236. /** @hidden */
  1237. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1238. process(preprocessors: {
  1239. [key: string]: string;
  1240. }, options: ProcessingOptions): string;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1244. /** @hidden */
  1245. export class ShaderDefineExpression {
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. private static _OperatorPriority;
  1250. private static _Stack;
  1251. static postfixToInfix(postfix: string[]): string;
  1252. static infixToPostfix(infix: string): string[];
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1256. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1257. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1258. /** @hidden */
  1259. export class ShaderCodeTestNode extends ShaderCodeNode {
  1260. testExpression: ShaderDefineExpression;
  1261. isValid(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1270. define: string;
  1271. not: boolean;
  1272. constructor(define: string, not?: boolean);
  1273. isTrue(preprocessors: {
  1274. [key: string]: string;
  1275. }): boolean;
  1276. }
  1277. }
  1278. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1279. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1280. /** @hidden */
  1281. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1282. leftOperand: ShaderDefineExpression;
  1283. rightOperand: ShaderDefineExpression;
  1284. isTrue(preprocessors: {
  1285. [key: string]: string;
  1286. }): boolean;
  1287. }
  1288. }
  1289. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1290. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1291. /** @hidden */
  1292. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1293. leftOperand: ShaderDefineExpression;
  1294. rightOperand: ShaderDefineExpression;
  1295. isTrue(preprocessors: {
  1296. [key: string]: string;
  1297. }): boolean;
  1298. }
  1299. }
  1300. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1301. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1302. /** @hidden */
  1303. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1304. define: string;
  1305. operand: string;
  1306. testValue: string;
  1307. constructor(define: string, operand: string, testValue: string);
  1308. isTrue(preprocessors: {
  1309. [key: string]: string;
  1310. }): boolean;
  1311. }
  1312. }
  1313. declare module "babylonjs/Offline/IOfflineProvider" {
  1314. /**
  1315. * Class used to enable access to offline support
  1316. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1317. */
  1318. export interface IOfflineProvider {
  1319. /**
  1320. * Gets a boolean indicating if scene must be saved in the database
  1321. */
  1322. enableSceneOffline: boolean;
  1323. /**
  1324. * Gets a boolean indicating if textures must be saved in the database
  1325. */
  1326. enableTexturesOffline: boolean;
  1327. /**
  1328. * Open the offline support and make it available
  1329. * @param successCallback defines the callback to call on success
  1330. * @param errorCallback defines the callback to call on error
  1331. */
  1332. open(successCallback: () => void, errorCallback: () => void): void;
  1333. /**
  1334. * Loads an image from the offline support
  1335. * @param url defines the url to load from
  1336. * @param image defines the target DOM image
  1337. */
  1338. loadImage(url: string, image: HTMLImageElement): void;
  1339. /**
  1340. * Loads a file from offline support
  1341. * @param url defines the URL to load from
  1342. * @param sceneLoaded defines a callback to call on success
  1343. * @param progressCallBack defines a callback to call when progress changed
  1344. * @param errorCallback defines a callback to call on error
  1345. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1346. */
  1347. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/filesInputStore" {
  1351. /**
  1352. * Class used to help managing file picking and drag'n'drop
  1353. * File Storage
  1354. */
  1355. export class FilesInputStore {
  1356. /**
  1357. * List of files ready to be loaded
  1358. */
  1359. static FilesToLoad: {
  1360. [key: string]: File;
  1361. };
  1362. }
  1363. }
  1364. declare module "babylonjs/Misc/retryStrategy" {
  1365. import { WebRequest } from "babylonjs/Misc/webRequest";
  1366. /**
  1367. * Class used to define a retry strategy when error happens while loading assets
  1368. */
  1369. export class RetryStrategy {
  1370. /**
  1371. * Function used to defines an exponential back off strategy
  1372. * @param maxRetries defines the maximum number of retries (3 by default)
  1373. * @param baseInterval defines the interval between retries
  1374. * @returns the strategy function to use
  1375. */
  1376. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1377. }
  1378. }
  1379. declare module "babylonjs/Misc/baseError" {
  1380. /**
  1381. * @ignore
  1382. * Application error to support additional information when loading a file
  1383. */
  1384. export abstract class BaseError extends Error {
  1385. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/fileTools" {
  1389. import { WebRequest } from "babylonjs/Misc/webRequest";
  1390. import { Nullable } from "babylonjs/types";
  1391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1392. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1393. import { BaseError } from "babylonjs/Misc/baseError";
  1394. /** @ignore */
  1395. export class LoadFileError extends BaseError {
  1396. request?: WebRequest;
  1397. file?: File;
  1398. /**
  1399. * Creates a new LoadFileError
  1400. * @param message defines the message of the error
  1401. * @param request defines the optional web request
  1402. * @param file defines the optional file
  1403. */
  1404. constructor(message: string, object?: WebRequest | File);
  1405. }
  1406. /** @ignore */
  1407. export class RequestFileError extends BaseError {
  1408. request: WebRequest;
  1409. /**
  1410. * Creates a new LoadFileError
  1411. * @param message defines the message of the error
  1412. * @param request defines the optional web request
  1413. */
  1414. constructor(message: string, request: WebRequest);
  1415. }
  1416. /** @ignore */
  1417. export class ReadFileError extends BaseError {
  1418. file: File;
  1419. /**
  1420. * Creates a new ReadFileError
  1421. * @param message defines the message of the error
  1422. * @param file defines the optional file
  1423. */
  1424. constructor(message: string, file: File);
  1425. }
  1426. /**
  1427. * @hidden
  1428. */
  1429. export class FileTools {
  1430. /**
  1431. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1432. */
  1433. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1434. /**
  1435. * Gets or sets the base URL to use to load assets
  1436. */
  1437. static BaseUrl: string;
  1438. /**
  1439. * Default behaviour for cors in the application.
  1440. * It can be a string if the expected behavior is identical in the entire app.
  1441. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1442. */
  1443. static CorsBehavior: string | ((url: string | string[]) => string);
  1444. /**
  1445. * Gets or sets a function used to pre-process url before using them to load assets
  1446. */
  1447. static PreprocessUrl: (url: string) => string;
  1448. /**
  1449. * Removes unwanted characters from an url
  1450. * @param url defines the url to clean
  1451. * @returns the cleaned url
  1452. */
  1453. private static _CleanUrl;
  1454. /**
  1455. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1456. * @param url define the url we are trying
  1457. * @param element define the dom element where to configure the cors policy
  1458. */
  1459. static SetCorsBehavior(url: string | string[], element: {
  1460. crossOrigin: string | null;
  1461. }): void;
  1462. /**
  1463. * Loads an image as an HTMLImageElement.
  1464. * @param input url string, ArrayBuffer, or Blob to load
  1465. * @param onLoad callback called when the image successfully loads
  1466. * @param onError callback called when the image fails to load
  1467. * @param offlineProvider offline provider for caching
  1468. * @param mimeType optional mime type
  1469. * @returns the HTMLImageElement of the loaded image
  1470. */
  1471. 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>;
  1472. /**
  1473. * Reads a file from a File object
  1474. * @param file defines the file to load
  1475. * @param onSuccess defines the callback to call when data is loaded
  1476. * @param onProgress defines the callback to call during loading process
  1477. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1478. * @param onError defines the callback to call when an error occurs
  1479. * @returns a file request object
  1480. */
  1481. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. */
  1492. 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;
  1493. /**
  1494. * Loads a file
  1495. * @param url url to load
  1496. * @param onSuccess callback called when the file successfully loads
  1497. * @param onProgress callback called while file is loading (if the server supports this mode)
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @param onOpened callback called when the web request is opened
  1501. * @returns a file request object
  1502. */
  1503. 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;
  1504. /**
  1505. * Checks if the loaded document was accessed via `file:`-Protocol.
  1506. * @returns boolean
  1507. */
  1508. static IsFileURL(): boolean;
  1509. }
  1510. }
  1511. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1512. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1513. import { WebRequest } from "babylonjs/Misc/webRequest";
  1514. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1515. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1517. /** @hidden */
  1518. export class ShaderProcessor {
  1519. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1520. private static _ProcessPrecision;
  1521. private static _ExtractOperation;
  1522. private static _BuildSubExpression;
  1523. private static _BuildExpression;
  1524. private static _MoveCursorWithinIf;
  1525. private static _MoveCursor;
  1526. private static _EvaluatePreProcessors;
  1527. private static _PreparePreProcessors;
  1528. private static _ProcessShaderConversion;
  1529. private static _ProcessIncludes;
  1530. /**
  1531. * Loads a file from a url
  1532. * @param url url to load
  1533. * @param onSuccess callback called when the file successfully loads
  1534. * @param onProgress callback called while file is loading (if the server supports this mode)
  1535. * @param offlineProvider defines the offline provider for caching
  1536. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1537. * @param onError callback called when the file fails to load
  1538. * @returns a file request object
  1539. * @hidden
  1540. */
  1541. 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;
  1542. }
  1543. }
  1544. declare module "babylonjs/Maths/math.like" {
  1545. import { float, int, DeepImmutable } from "babylonjs/types";
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IColor4Like {
  1550. r: float;
  1551. g: float;
  1552. b: float;
  1553. a: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IColor3Like {
  1559. r: float;
  1560. g: float;
  1561. b: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IVector4Like {
  1567. x: float;
  1568. y: float;
  1569. z: float;
  1570. w: float;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IVector3Like {
  1576. x: float;
  1577. y: float;
  1578. z: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IVector2Like {
  1584. x: float;
  1585. y: float;
  1586. }
  1587. /**
  1588. * @hidden
  1589. */
  1590. export interface IMatrixLike {
  1591. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1592. updateFlag: int;
  1593. }
  1594. /**
  1595. * @hidden
  1596. */
  1597. export interface IViewportLike {
  1598. x: float;
  1599. y: float;
  1600. width: float;
  1601. height: float;
  1602. }
  1603. /**
  1604. * @hidden
  1605. */
  1606. export interface IPlaneLike {
  1607. normal: IVector3Like;
  1608. d: float;
  1609. normalize(): void;
  1610. }
  1611. }
  1612. declare module "babylonjs/Materials/iEffectFallbacks" {
  1613. import { Effect } from "babylonjs/Materials/effect";
  1614. /**
  1615. * Interface used to define common properties for effect fallbacks
  1616. */
  1617. export interface IEffectFallbacks {
  1618. /**
  1619. * Removes the defines that should be removed when falling back.
  1620. * @param currentDefines defines the current define statements for the shader.
  1621. * @param effect defines the current effect we try to compile
  1622. * @returns The resulting defines with defines of the current rank removed.
  1623. */
  1624. reduce(currentDefines: string, effect: Effect): string;
  1625. /**
  1626. * Removes the fallback from the bound mesh.
  1627. */
  1628. unBindMesh(): void;
  1629. /**
  1630. * Checks to see if more fallbacks are still availible.
  1631. */
  1632. hasMoreFallbacks: boolean;
  1633. }
  1634. }
  1635. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1636. /**
  1637. * Class used to evalaute queries containing `and` and `or` operators
  1638. */
  1639. export class AndOrNotEvaluator {
  1640. /**
  1641. * Evaluate a query
  1642. * @param query defines the query to evaluate
  1643. * @param evaluateCallback defines the callback used to filter result
  1644. * @returns true if the query matches
  1645. */
  1646. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1647. private static _HandleParenthesisContent;
  1648. private static _SimplifyNegation;
  1649. }
  1650. }
  1651. declare module "babylonjs/Misc/tags" {
  1652. /**
  1653. * Class used to store custom tags
  1654. */
  1655. export class Tags {
  1656. /**
  1657. * Adds support for tags on the given object
  1658. * @param obj defines the object to use
  1659. */
  1660. static EnableFor(obj: any): void;
  1661. /**
  1662. * Removes tags support
  1663. * @param obj defines the object to use
  1664. */
  1665. static DisableFor(obj: any): void;
  1666. /**
  1667. * Gets a boolean indicating if the given object has tags
  1668. * @param obj defines the object to use
  1669. * @returns a boolean
  1670. */
  1671. static HasTags(obj: any): boolean;
  1672. /**
  1673. * Gets the tags available on a given object
  1674. * @param obj defines the object to use
  1675. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1676. * @returns the tags
  1677. */
  1678. static GetTags(obj: any, asString?: boolean): any;
  1679. /**
  1680. * Adds tags to an object
  1681. * @param obj defines the object to use
  1682. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1683. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1684. */
  1685. static AddTagsTo(obj: any, tagsString: string): void;
  1686. /**
  1687. * @hidden
  1688. */
  1689. static _AddTagTo(obj: any, tag: string): void;
  1690. /**
  1691. * Removes specific tags from a specific object
  1692. * @param obj defines the object to use
  1693. * @param tagsString defines the tags to remove
  1694. */
  1695. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _RemoveTagFrom(obj: any, tag: string): void;
  1700. /**
  1701. * Defines if tags hosted on an object match a given query
  1702. * @param obj defines the object to use
  1703. * @param tagsQuery defines the tag query
  1704. * @returns a boolean
  1705. */
  1706. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1707. }
  1708. }
  1709. declare module "babylonjs/Maths/math.scalar" {
  1710. /**
  1711. * Scalar computation library
  1712. */
  1713. export class Scalar {
  1714. /**
  1715. * Two pi constants convenient for computation.
  1716. */
  1717. static TwoPi: number;
  1718. /**
  1719. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. * @param a number
  1721. * @param b number
  1722. * @param epsilon (default = 1.401298E-45)
  1723. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1724. */
  1725. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1726. /**
  1727. * Returns a string : the upper case translation of the number i to hexadecimal.
  1728. * @param i number
  1729. * @returns the upper case translation of the number i to hexadecimal.
  1730. */
  1731. static ToHex(i: number): string;
  1732. /**
  1733. * Returns -1 if value is negative and +1 is value is positive.
  1734. * @param value the value
  1735. * @returns the value itself if it's equal to zero.
  1736. */
  1737. static Sign(value: number): number;
  1738. /**
  1739. * Returns the value itself if it's between min and max.
  1740. * Returns min if the value is lower than min.
  1741. * Returns max if the value is greater than max.
  1742. * @param value the value to clmap
  1743. * @param min the min value to clamp to (default: 0)
  1744. * @param max the max value to clamp to (default: 1)
  1745. * @returns the clamped value
  1746. */
  1747. static Clamp(value: number, min?: number, max?: number): number;
  1748. /**
  1749. * the log2 of value.
  1750. * @param value the value to compute log2 of
  1751. * @returns the log2 of value.
  1752. */
  1753. static Log2(value: number): number;
  1754. /**
  1755. * Loops the value, so that it is never larger than length and never smaller than 0.
  1756. *
  1757. * This is similar to the modulo operator but it works with floating point numbers.
  1758. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1759. * With t = 5 and length = 2.5, the result would be 0.0.
  1760. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1761. * @param value the value
  1762. * @param length the length
  1763. * @returns the looped value
  1764. */
  1765. static Repeat(value: number, length: number): number;
  1766. /**
  1767. * Normalize the value between 0.0 and 1.0 using min and max values
  1768. * @param value value to normalize
  1769. * @param min max to normalize between
  1770. * @param max min to normalize between
  1771. * @returns the normalized value
  1772. */
  1773. static Normalize(value: number, min: number, max: number): number;
  1774. /**
  1775. * Denormalize the value from 0.0 and 1.0 using min and max values
  1776. * @param normalized value to denormalize
  1777. * @param min max to denormalize between
  1778. * @param max min to denormalize between
  1779. * @returns the denormalized value
  1780. */
  1781. static Denormalize(normalized: number, min: number, max: number): number;
  1782. /**
  1783. * Calculates the shortest difference between two given angles given in degrees.
  1784. * @param current current angle in degrees
  1785. * @param target target angle in degrees
  1786. * @returns the delta
  1787. */
  1788. static DeltaAngle(current: number, target: number): number;
  1789. /**
  1790. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1791. * @param tx value
  1792. * @param length length
  1793. * @returns The returned value will move back and forth between 0 and length
  1794. */
  1795. static PingPong(tx: number, length: number): number;
  1796. /**
  1797. * Interpolates between min and max with smoothing at the limits.
  1798. *
  1799. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1800. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1801. * @param from from
  1802. * @param to to
  1803. * @param tx value
  1804. * @returns the smooth stepped value
  1805. */
  1806. static SmoothStep(from: number, to: number, tx: number): number;
  1807. /**
  1808. * Moves a value current towards target.
  1809. *
  1810. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1811. * Negative values of maxDelta pushes the value away from target.
  1812. * @param current current value
  1813. * @param target target value
  1814. * @param maxDelta max distance to move
  1815. * @returns resulting value
  1816. */
  1817. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1818. /**
  1819. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1820. *
  1821. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1822. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1823. * @param current current value
  1824. * @param target target value
  1825. * @param maxDelta max distance to move
  1826. * @returns resulting angle
  1827. */
  1828. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1829. /**
  1830. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1831. * @param start start value
  1832. * @param end target value
  1833. * @param amount amount to lerp between
  1834. * @returns the lerped value
  1835. */
  1836. static Lerp(start: number, end: number, amount: number): number;
  1837. /**
  1838. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1839. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1840. * @param start start value
  1841. * @param end target value
  1842. * @param amount amount to lerp between
  1843. * @returns the lerped value
  1844. */
  1845. static LerpAngle(start: number, end: number, amount: number): number;
  1846. /**
  1847. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1848. * @param a start value
  1849. * @param b target value
  1850. * @param value value between a and b
  1851. * @returns the inverseLerp value
  1852. */
  1853. static InverseLerp(a: number, b: number, value: number): number;
  1854. /**
  1855. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1856. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1857. * @param value1 spline value
  1858. * @param tangent1 spline value
  1859. * @param value2 spline value
  1860. * @param tangent2 spline value
  1861. * @param amount input value
  1862. * @returns hermite result
  1863. */
  1864. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1865. /**
  1866. * Returns a random float number between and min and max values
  1867. * @param min min value of random
  1868. * @param max max value of random
  1869. * @returns random value
  1870. */
  1871. static RandomRange(min: number, max: number): number;
  1872. /**
  1873. * This function returns percentage of a number in a given range.
  1874. *
  1875. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1876. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1877. * @param number to convert to percentage
  1878. * @param min min range
  1879. * @param max max range
  1880. * @returns the percentage
  1881. */
  1882. static RangeToPercent(number: number, min: number, max: number): number;
  1883. /**
  1884. * This function returns number that corresponds to the percentage in a given range.
  1885. *
  1886. * PercentToRange(0.34,0,100) will return 34.
  1887. * @param percent to convert to number
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the number
  1891. */
  1892. static PercentToRange(percent: number, min: number, max: number): number;
  1893. /**
  1894. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1895. * @param angle The angle to normalize in radian.
  1896. * @return The converted angle.
  1897. */
  1898. static NormalizeRadians(angle: number): number;
  1899. }
  1900. }
  1901. declare module "babylonjs/Maths/math.constants" {
  1902. /**
  1903. * Constant used to convert a value to gamma space
  1904. * @ignorenaming
  1905. */
  1906. export const ToGammaSpace: number;
  1907. /**
  1908. * Constant used to convert a value to linear space
  1909. * @ignorenaming
  1910. */
  1911. export const ToLinearSpace = 2.2;
  1912. /**
  1913. * Constant used to define the minimal number value in Babylon.js
  1914. * @ignorenaming
  1915. */
  1916. let Epsilon: number;
  1917. export { Epsilon };
  1918. }
  1919. declare module "babylonjs/Maths/math.viewport" {
  1920. /**
  1921. * Class used to represent a viewport on screen
  1922. */
  1923. export class Viewport {
  1924. /** viewport left coordinate */
  1925. x: number;
  1926. /** viewport top coordinate */
  1927. y: number;
  1928. /**viewport width */
  1929. width: number;
  1930. /** viewport height */
  1931. height: number;
  1932. /**
  1933. * Creates a Viewport object located at (x, y) and sized (width, height)
  1934. * @param x defines viewport left coordinate
  1935. * @param y defines viewport top coordinate
  1936. * @param width defines the viewport width
  1937. * @param height defines the viewport height
  1938. */
  1939. constructor(
  1940. /** viewport left coordinate */
  1941. x: number,
  1942. /** viewport top coordinate */
  1943. y: number,
  1944. /**viewport width */
  1945. width: number,
  1946. /** viewport height */
  1947. height: number);
  1948. /**
  1949. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1950. * @param renderWidth defines the rendering width
  1951. * @param renderHeight defines the rendering height
  1952. * @returns a new Viewport
  1953. */
  1954. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1955. /**
  1956. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1957. * @param renderWidth defines the rendering width
  1958. * @param renderHeight defines the rendering height
  1959. * @param ref defines the target viewport
  1960. * @returns the current viewport
  1961. */
  1962. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1963. /**
  1964. * Returns a new Viewport copied from the current one
  1965. * @returns a new Viewport
  1966. */
  1967. clone(): Viewport;
  1968. }
  1969. }
  1970. declare module "babylonjs/Misc/arrayTools" {
  1971. /**
  1972. * Class containing a set of static utilities functions for arrays.
  1973. */
  1974. export class ArrayTools {
  1975. /**
  1976. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1977. * @param size the number of element to construct and put in the array
  1978. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1979. * @returns a new array filled with new objects
  1980. */
  1981. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1982. }
  1983. }
  1984. declare module "babylonjs/Maths/math.plane" {
  1985. import { DeepImmutable } from "babylonjs/types";
  1986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1987. /**
  1988. * Represents a plane by the equation ax + by + cz + d = 0
  1989. */
  1990. export class Plane {
  1991. private static _TmpMatrix;
  1992. /**
  1993. * Normal of the plane (a,b,c)
  1994. */
  1995. normal: Vector3;
  1996. /**
  1997. * d component of the plane
  1998. */
  1999. d: number;
  2000. /**
  2001. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2002. * @param a a component of the plane
  2003. * @param b b component of the plane
  2004. * @param c c component of the plane
  2005. * @param d d component of the plane
  2006. */
  2007. constructor(a: number, b: number, c: number, d: number);
  2008. /**
  2009. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2010. */
  2011. asArray(): number[];
  2012. /**
  2013. * @returns a new plane copied from the current Plane.
  2014. */
  2015. clone(): Plane;
  2016. /**
  2017. * @returns the string "Plane".
  2018. */
  2019. getClassName(): string;
  2020. /**
  2021. * @returns the Plane hash code.
  2022. */
  2023. getHashCode(): number;
  2024. /**
  2025. * Normalize the current Plane in place.
  2026. * @returns the updated Plane.
  2027. */
  2028. normalize(): Plane;
  2029. /**
  2030. * Applies a transformation the plane and returns the result
  2031. * @param transformation the transformation matrix to be applied to the plane
  2032. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2033. */
  2034. transform(transformation: DeepImmutable<Matrix>): Plane;
  2035. /**
  2036. * Compute the dot product between the point and the plane normal
  2037. * @param point point to calculate the dot product with
  2038. * @returns the dot product (float) of the point coordinates and the plane normal.
  2039. */
  2040. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2041. /**
  2042. * Updates the current Plane from the plane defined by the three given points.
  2043. * @param point1 one of the points used to contruct the plane
  2044. * @param point2 one of the points used to contruct the plane
  2045. * @param point3 one of the points used to contruct the plane
  2046. * @returns the updated Plane.
  2047. */
  2048. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2049. /**
  2050. * Checks if the plane is facing a given direction
  2051. * @param direction the direction to check if the plane is facing
  2052. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2053. * @returns True is the vector "direction" is the same side than the plane normal.
  2054. */
  2055. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2056. /**
  2057. * Calculates the distance to a point
  2058. * @param point point to calculate distance to
  2059. * @returns the signed distance (float) from the given point to the Plane.
  2060. */
  2061. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2062. /**
  2063. * Creates a plane from an array
  2064. * @param array the array to create a plane from
  2065. * @returns a new Plane from the given array.
  2066. */
  2067. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2068. /**
  2069. * Creates a plane from three points
  2070. * @param point1 point used to create the plane
  2071. * @param point2 point used to create the plane
  2072. * @param point3 point used to create the plane
  2073. * @returns a new Plane defined by the three given points.
  2074. */
  2075. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2076. /**
  2077. * Creates a plane from an origin point and a normal
  2078. * @param origin origin of the plane to be constructed
  2079. * @param normal normal of the plane to be constructed
  2080. * @returns a new Plane the normal vector to this plane at the given origin point.
  2081. * Note : the vector "normal" is updated because normalized.
  2082. */
  2083. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2084. /**
  2085. * Calculates the distance from a plane and a point
  2086. * @param origin origin of the plane to be constructed
  2087. * @param normal normal of the plane to be constructed
  2088. * @param point point to calculate distance to
  2089. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2090. */
  2091. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2092. }
  2093. }
  2094. declare module "babylonjs/Engines/performanceConfigurator" {
  2095. /** @hidden */
  2096. export class PerformanceConfigurator {
  2097. /** @hidden */
  2098. static MatrixUse64Bits: boolean;
  2099. /** @hidden */
  2100. static MatrixTrackPrecisionChange: boolean;
  2101. /** @hidden */
  2102. static MatrixCurrentType: any;
  2103. /** @hidden */
  2104. static MatrixTrackedMatrices: Array<any> | null;
  2105. /** @hidden */
  2106. static SetMatrixPrecision(use64bits: boolean): void;
  2107. }
  2108. }
  2109. declare module "babylonjs/Maths/math.vector" {
  2110. import { Viewport } from "babylonjs/Maths/math.viewport";
  2111. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2112. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2113. import { Plane } from "babylonjs/Maths/math.plane";
  2114. /**
  2115. * Class representing a vector containing 2 coordinates
  2116. */
  2117. export class Vector2 {
  2118. /** defines the first coordinate */
  2119. x: number;
  2120. /** defines the second coordinate */
  2121. y: number;
  2122. /**
  2123. * Creates a new Vector2 from the given x and y coordinates
  2124. * @param x defines the first coordinate
  2125. * @param y defines the second coordinate
  2126. */
  2127. constructor(
  2128. /** defines the first coordinate */
  2129. x?: number,
  2130. /** defines the second coordinate */
  2131. y?: number);
  2132. /**
  2133. * Gets a string with the Vector2 coordinates
  2134. * @returns a string with the Vector2 coordinates
  2135. */
  2136. toString(): string;
  2137. /**
  2138. * Gets class name
  2139. * @returns the string "Vector2"
  2140. */
  2141. getClassName(): string;
  2142. /**
  2143. * Gets current vector hash code
  2144. * @returns the Vector2 hash code as a number
  2145. */
  2146. getHashCode(): number;
  2147. /**
  2148. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2149. * @param array defines the source array
  2150. * @param index defines the offset in source array
  2151. * @returns the current Vector2
  2152. */
  2153. toArray(array: FloatArray, index?: number): Vector2;
  2154. /**
  2155. * Update the current vector from an array
  2156. * @param array defines the destination array
  2157. * @param index defines the offset in the destination array
  2158. * @returns the current Vector3
  2159. */
  2160. fromArray(array: FloatArray, index?: number): Vector2;
  2161. /**
  2162. * Copy the current vector to an array
  2163. * @returns a new array with 2 elements: the Vector2 coordinates.
  2164. */
  2165. asArray(): number[];
  2166. /**
  2167. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2168. * @param source defines the source Vector2
  2169. * @returns the current updated Vector2
  2170. */
  2171. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets the Vector2 coordinates with the given floats
  2174. * @param x defines the first coordinate
  2175. * @param y defines the second coordinate
  2176. * @returns the current updated Vector2
  2177. */
  2178. copyFromFloats(x: number, y: number): Vector2;
  2179. /**
  2180. * Sets the Vector2 coordinates with the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns the current updated Vector2
  2184. */
  2185. set(x: number, y: number): Vector2;
  2186. /**
  2187. * Add another vector with the current one
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2190. */
  2191. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns a new Vector2
  2209. */
  2210. addVector3(otherVector: Vector3): Vector2;
  2211. /**
  2212. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. subtract(otherVector: Vector2): Vector2;
  2217. /**
  2218. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2219. * @param otherVector defines the other vector
  2220. * @param result defines the target vector
  2221. * @returns the unmodified current Vector2
  2222. */
  2223. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2224. /**
  2225. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2226. * @param otherVector defines the other vector
  2227. * @returns the current updated Vector2
  2228. */
  2229. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Multiplies in place the current Vector2 coordinates by the given ones
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2238. * @param otherVector defines the other vector
  2239. * @returns a new Vector2
  2240. */
  2241. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @param result defines the target vector
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2251. * @param x defines the first coordinate
  2252. * @param y defines the second coordinate
  2253. * @returns a new Vector2
  2254. */
  2255. multiplyByFloats(x: number, y: number): Vector2;
  2256. /**
  2257. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2258. * @param otherVector defines the other vector
  2259. * @returns a new Vector2
  2260. */
  2261. divide(otherVector: Vector2): Vector2;
  2262. /**
  2263. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @param result defines the target vector
  2266. * @returns the unmodified current Vector2
  2267. */
  2268. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2269. /**
  2270. * Divides the current Vector2 coordinates by the given ones
  2271. * @param otherVector defines the other vector
  2272. * @returns the current updated Vector2
  2273. */
  2274. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2275. /**
  2276. * Gets a new Vector2 with current Vector2 negated coordinates
  2277. * @returns a new Vector2
  2278. */
  2279. negate(): Vector2;
  2280. /**
  2281. * Negate this vector in place
  2282. * @returns this
  2283. */
  2284. negateInPlace(): Vector2;
  2285. /**
  2286. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2287. * @param result defines the Vector3 object where to store the result
  2288. * @returns the current Vector2
  2289. */
  2290. negateToRef(result: Vector2): Vector2;
  2291. /**
  2292. * Multiply the Vector2 coordinates by scale
  2293. * @param scale defines the scaling factor
  2294. * @returns the current updated Vector2
  2295. */
  2296. scaleInPlace(scale: number): Vector2;
  2297. /**
  2298. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2299. * @param scale defines the scaling factor
  2300. * @returns a new Vector2
  2301. */
  2302. scale(scale: number): Vector2;
  2303. /**
  2304. * Scale the current Vector2 values by a factor to a given Vector2
  2305. * @param scale defines the scale factor
  2306. * @param result defines the Vector2 object where to store the result
  2307. * @returns the unmodified current Vector2
  2308. */
  2309. scaleToRef(scale: number, result: Vector2): Vector2;
  2310. /**
  2311. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2312. * @param scale defines the scale factor
  2313. * @param result defines the Vector2 object where to store the result
  2314. * @returns the unmodified current Vector2
  2315. */
  2316. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2317. /**
  2318. * Gets a boolean if two vectors are equals
  2319. * @param otherVector defines the other vector
  2320. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2321. */
  2322. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2323. /**
  2324. * Gets a boolean if two vectors are equals (using an epsilon value)
  2325. * @param otherVector defines the other vector
  2326. * @param epsilon defines the minimal distance to consider equality
  2327. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2328. */
  2329. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2330. /**
  2331. * Gets a new Vector2 from current Vector2 floored values
  2332. * @returns a new Vector2
  2333. */
  2334. floor(): Vector2;
  2335. /**
  2336. * Gets a new Vector2 from current Vector2 floored values
  2337. * @returns a new Vector2
  2338. */
  2339. fract(): Vector2;
  2340. /**
  2341. * Gets the length of the vector
  2342. * @returns the vector length (float)
  2343. */
  2344. length(): number;
  2345. /**
  2346. * Gets the vector squared length
  2347. * @returns the vector squared length (float)
  2348. */
  2349. lengthSquared(): number;
  2350. /**
  2351. * Normalize the vector
  2352. * @returns the current updated Vector2
  2353. */
  2354. normalize(): Vector2;
  2355. /**
  2356. * Gets a new Vector2 copied from the Vector2
  2357. * @returns a new Vector2
  2358. */
  2359. clone(): Vector2;
  2360. /**
  2361. * Gets a new Vector2(0, 0)
  2362. * @returns a new Vector2
  2363. */
  2364. static Zero(): Vector2;
  2365. /**
  2366. * Gets a new Vector2(1, 1)
  2367. * @returns a new Vector2
  2368. */
  2369. static One(): Vector2;
  2370. /**
  2371. * Gets a new Vector2 set from the given index element of the given array
  2372. * @param array defines the data source
  2373. * @param offset defines the offset in the data source
  2374. * @returns a new Vector2
  2375. */
  2376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2377. /**
  2378. * Sets "result" from the given index element of the given array
  2379. * @param array defines the data source
  2380. * @param offset defines the offset in the data source
  2381. * @param result defines the target vector
  2382. */
  2383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2384. /**
  2385. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2386. * @param value1 defines 1st point of control
  2387. * @param value2 defines 2nd point of control
  2388. * @param value3 defines 3rd point of control
  2389. * @param value4 defines 4th point of control
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * 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".
  2396. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2397. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2398. * @param value defines the value to clamp
  2399. * @param min defines the lower limit
  2400. * @param max defines the upper limit
  2401. * @returns a new Vector2
  2402. */
  2403. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2404. /**
  2405. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2406. * @param value1 defines the 1st control point
  2407. * @param tangent1 defines the outgoing tangent
  2408. * @param value2 defines the 2nd control point
  2409. * @param tangent2 defines the incoming tangent
  2410. * @param amount defines the interpolation factor
  2411. * @returns a new Vector2
  2412. */
  2413. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2416. * @param start defines the start vector
  2417. * @param end defines the end vector
  2418. * @param amount defines the interpolation factor
  2419. * @returns a new Vector2
  2420. */
  2421. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2422. /**
  2423. * Gets the dot product of the vector "left" and the vector "right"
  2424. * @param left defines first vector
  2425. * @param right defines second vector
  2426. * @returns the dot product (float)
  2427. */
  2428. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2429. /**
  2430. * Returns a new Vector2 equal to the normalized given vector
  2431. * @param vector defines the vector to normalize
  2432. * @returns a new Vector2
  2433. */
  2434. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2435. /**
  2436. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2437. * @param left defines 1st vector
  2438. * @param right defines 2nd vector
  2439. * @returns a new Vector2
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2442. /**
  2443. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2444. * @param left defines 1st vector
  2445. * @param right defines 2nd vector
  2446. * @returns a new Vector2
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2449. /**
  2450. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2451. * @param vector defines the vector to transform
  2452. * @param transformation defines the matrix to apply
  2453. * @returns a new Vector2
  2454. */
  2455. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2456. /**
  2457. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2458. * @param vector defines the vector to transform
  2459. * @param transformation defines the matrix to apply
  2460. * @param result defines the target vector
  2461. */
  2462. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2463. /**
  2464. * Determines if a given vector is included in a triangle
  2465. * @param p defines the vector to test
  2466. * @param p0 defines 1st triangle point
  2467. * @param p1 defines 2nd triangle point
  2468. * @param p2 defines 3rd triangle point
  2469. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2470. */
  2471. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2472. /**
  2473. * Gets the distance between the vectors "value1" and "value2"
  2474. * @param value1 defines first vector
  2475. * @param value2 defines second vector
  2476. * @returns the distance between vectors
  2477. */
  2478. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2479. /**
  2480. * Returns the squared distance between the vectors "value1" and "value2"
  2481. * @param value1 defines first vector
  2482. * @param value2 defines second vector
  2483. * @returns the squared distance between vectors
  2484. */
  2485. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2486. /**
  2487. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2488. * @param value1 defines first vector
  2489. * @param value2 defines second vector
  2490. * @returns a new Vector2
  2491. */
  2492. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2493. /**
  2494. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2495. * @param p defines the middle point
  2496. * @param segA defines one point of the segment
  2497. * @param segB defines the other point of the segment
  2498. * @returns the shortest distance
  2499. */
  2500. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2501. }
  2502. /**
  2503. * Class used to store (x,y,z) vector representation
  2504. * A Vector3 is the main object used in 3D geometry
  2505. * It can represent etiher the coordinates of a point the space, either a direction
  2506. * Reminder: js uses a left handed forward facing system
  2507. */
  2508. export class Vector3 {
  2509. private static _UpReadOnly;
  2510. private static _ZeroReadOnly;
  2511. /** @hidden */
  2512. _x: number;
  2513. /** @hidden */
  2514. _y: number;
  2515. /** @hidden */
  2516. _z: number;
  2517. /** @hidden */
  2518. _isDirty: boolean;
  2519. /** Gets or sets the x coordinate */
  2520. get x(): number;
  2521. set x(value: number);
  2522. /** Gets or sets the y coordinate */
  2523. get y(): number;
  2524. set y(value: number);
  2525. /** Gets or sets the z coordinate */
  2526. get z(): number;
  2527. set z(value: number);
  2528. /**
  2529. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2530. * @param x defines the first coordinates (on X axis)
  2531. * @param y defines the second coordinates (on Y axis)
  2532. * @param z defines the third coordinates (on Z axis)
  2533. */
  2534. constructor(x?: number, y?: number, z?: number);
  2535. /**
  2536. * Creates a string representation of the Vector3
  2537. * @returns a string with the Vector3 coordinates.
  2538. */
  2539. toString(): string;
  2540. /**
  2541. * Gets the class name
  2542. * @returns the string "Vector3"
  2543. */
  2544. getClassName(): string;
  2545. /**
  2546. * Creates the Vector3 hash code
  2547. * @returns a number which tends to be unique between Vector3 instances
  2548. */
  2549. getHashCode(): number;
  2550. /**
  2551. * Creates an array containing three elements : the coordinates of the Vector3
  2552. * @returns a new array of numbers
  2553. */
  2554. asArray(): number[];
  2555. /**
  2556. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2557. * @param array defines the destination array
  2558. * @param index defines the offset in the destination array
  2559. * @returns the current Vector3
  2560. */
  2561. toArray(array: FloatArray, index?: number): Vector3;
  2562. /**
  2563. * Update the current vector from an array
  2564. * @param array defines the destination array
  2565. * @param index defines the offset in the destination array
  2566. * @returns the current Vector3
  2567. */
  2568. fromArray(array: FloatArray, index?: number): Vector3;
  2569. /**
  2570. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2571. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2572. */
  2573. toQuaternion(): Quaternion;
  2574. /**
  2575. * Adds the given vector to the current Vector3
  2576. * @param otherVector defines the second operand
  2577. * @returns the current updated Vector3
  2578. */
  2579. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2580. /**
  2581. * Adds the given coordinates to the current Vector3
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2590. * @param otherVector defines the second operand
  2591. * @returns the resulting Vector3
  2592. */
  2593. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2594. /**
  2595. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2596. * @param otherVector defines the second operand
  2597. * @param result defines the Vector3 object where to store the result
  2598. * @returns the current Vector3
  2599. */
  2600. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2601. /**
  2602. * Subtract the given vector from the current Vector3
  2603. * @param otherVector defines the second operand
  2604. * @returns the current updated Vector3
  2605. */
  2606. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2607. /**
  2608. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the resulting Vector3
  2611. */
  2612. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2615. * @param otherVector defines the second operand
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the current Vector3
  2618. */
  2619. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2620. /**
  2621. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2622. * @param x defines the x coordinate of the operand
  2623. * @param y defines the y coordinate of the operand
  2624. * @param z defines the z coordinate of the operand
  2625. * @returns the resulting Vector3
  2626. */
  2627. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2628. /**
  2629. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @param result defines the Vector3 object where to store the result
  2634. * @returns the current Vector3
  2635. */
  2636. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2637. /**
  2638. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2639. * @returns a new Vector3
  2640. */
  2641. negate(): Vector3;
  2642. /**
  2643. * Negate this vector in place
  2644. * @returns this
  2645. */
  2646. negateInPlace(): Vector3;
  2647. /**
  2648. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2649. * @param result defines the Vector3 object where to store the result
  2650. * @returns the current Vector3
  2651. */
  2652. negateToRef(result: Vector3): Vector3;
  2653. /**
  2654. * Multiplies the Vector3 coordinates by the float "scale"
  2655. * @param scale defines the multiplier factor
  2656. * @returns the current updated Vector3
  2657. */
  2658. scaleInPlace(scale: number): Vector3;
  2659. /**
  2660. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns a new Vector3
  2663. */
  2664. scale(scale: number): Vector3;
  2665. /**
  2666. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2667. * @param scale defines the multiplier factor
  2668. * @param result defines the Vector3 object where to store the result
  2669. * @returns the current Vector3
  2670. */
  2671. scaleToRef(scale: number, result: Vector3): Vector3;
  2672. /**
  2673. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2674. * @param scale defines the scale factor
  2675. * @param result defines the Vector3 object where to store the result
  2676. * @returns the unmodified current Vector3
  2677. */
  2678. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2679. /**
  2680. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2681. * @param origin defines the origin of the projection ray
  2682. * @param plane defines the plane to project to
  2683. * @returns the projected vector3
  2684. */
  2685. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2686. /**
  2687. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2688. * @param origin defines the origin of the projection ray
  2689. * @param plane defines the plane to project to
  2690. * @param result defines the Vector3 where to store the result
  2691. */
  2692. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2693. /**
  2694. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2695. * @param otherVector defines the second operand
  2696. * @returns true if both vectors are equals
  2697. */
  2698. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2701. * @param otherVector defines the second operand
  2702. * @param epsilon defines the minimal distance to define values as equals
  2703. * @returns true if both vectors are distant less than epsilon
  2704. */
  2705. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2706. /**
  2707. * Returns true if the current Vector3 coordinates equals the given floats
  2708. * @param x defines the x coordinate of the operand
  2709. * @param y defines the y coordinate of the operand
  2710. * @param z defines the z coordinate of the operand
  2711. * @returns true if both vectors are equals
  2712. */
  2713. equalsToFloats(x: number, y: number, z: number): boolean;
  2714. /**
  2715. * Multiplies the current Vector3 coordinates by the given ones
  2716. * @param otherVector defines the second operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2720. /**
  2721. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2722. * @param otherVector defines the second operand
  2723. * @returns the new Vector3
  2724. */
  2725. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2728. * @param otherVector defines the second operand
  2729. * @param result defines the Vector3 object where to store the result
  2730. * @returns the current Vector3
  2731. */
  2732. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2735. * @param x defines the x coordinate of the operand
  2736. * @param y defines the y coordinate of the operand
  2737. * @param z defines the z coordinate of the operand
  2738. * @returns the new Vector3
  2739. */
  2740. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2743. * @param otherVector defines the second operand
  2744. * @returns the new Vector3
  2745. */
  2746. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2747. /**
  2748. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2749. * @param otherVector defines the second operand
  2750. * @param result defines the Vector3 object where to store the result
  2751. * @returns the current Vector3
  2752. */
  2753. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2754. /**
  2755. * Divides the current Vector3 coordinates by the given ones.
  2756. * @param otherVector defines the second operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. divideInPlace(otherVector: Vector3): Vector3;
  2760. /**
  2761. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2762. * @param other defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2774. * @param x defines the x coordinate of the operand
  2775. * @param y defines the y coordinate of the operand
  2776. * @param z defines the z coordinate of the operand
  2777. * @returns the current updated Vector3
  2778. */
  2779. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2780. /**
  2781. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2782. * @param x defines the x coordinate of the operand
  2783. * @param y defines the y coordinate of the operand
  2784. * @param z defines the z coordinate of the operand
  2785. * @returns the current updated Vector3
  2786. */
  2787. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2788. /**
  2789. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2790. * Check if is non uniform within a certain amount of decimal places to account for this
  2791. * @param epsilon the amount the values can differ
  2792. * @returns if the the vector is non uniform to a certain number of decimal places
  2793. */
  2794. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2795. /**
  2796. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2797. */
  2798. get isNonUniform(): boolean;
  2799. /**
  2800. * Gets a new Vector3 from current Vector3 floored values
  2801. * @returns a new Vector3
  2802. */
  2803. floor(): Vector3;
  2804. /**
  2805. * Gets a new Vector3 from current Vector3 floored values
  2806. * @returns a new Vector3
  2807. */
  2808. fract(): Vector3;
  2809. /**
  2810. * Gets the length of the Vector3
  2811. * @returns the length of the Vector3
  2812. */
  2813. length(): number;
  2814. /**
  2815. * Gets the squared length of the Vector3
  2816. * @returns squared length of the Vector3
  2817. */
  2818. lengthSquared(): number;
  2819. /**
  2820. * Normalize the current Vector3.
  2821. * Please note that this is an in place operation.
  2822. * @returns the current updated Vector3
  2823. */
  2824. normalize(): Vector3;
  2825. /**
  2826. * Reorders the x y z properties of the vector in place
  2827. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2828. * @returns the current updated vector
  2829. */
  2830. reorderInPlace(order: string): this;
  2831. /**
  2832. * Rotates the vector around 0,0,0 by a quaternion
  2833. * @param quaternion the rotation quaternion
  2834. * @param result vector to store the result
  2835. * @returns the resulting vector
  2836. */
  2837. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2838. /**
  2839. * Rotates a vector around a given point
  2840. * @param quaternion the rotation quaternion
  2841. * @param point the point to rotate around
  2842. * @param result vector to store the result
  2843. * @returns the resulting vector
  2844. */
  2845. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2846. /**
  2847. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2848. * The cross product is then orthogonal to both current and "other"
  2849. * @param other defines the right operand
  2850. * @returns the cross product
  2851. */
  2852. cross(other: Vector3): Vector3;
  2853. /**
  2854. * Normalize the current Vector3 with the given input length.
  2855. * Please note that this is an in place operation.
  2856. * @param len the length of the vector
  2857. * @returns the current updated Vector3
  2858. */
  2859. normalizeFromLength(len: number): Vector3;
  2860. /**
  2861. * Normalize the current Vector3 to a new vector
  2862. * @returns the new Vector3
  2863. */
  2864. normalizeToNew(): Vector3;
  2865. /**
  2866. * Normalize the current Vector3 to the reference
  2867. * @param reference define the Vector3 to update
  2868. * @returns the updated Vector3
  2869. */
  2870. normalizeToRef(reference: Vector3): Vector3;
  2871. /**
  2872. * Creates a new Vector3 copied from the current Vector3
  2873. * @returns the new Vector3
  2874. */
  2875. clone(): Vector3;
  2876. /**
  2877. * Copies the given vector coordinates to the current Vector3 ones
  2878. * @param source defines the source Vector3
  2879. * @returns the current updated Vector3
  2880. */
  2881. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Copies the given floats to the current Vector3 coordinates
  2884. * @param x defines the x coordinate of the operand
  2885. * @param y defines the y coordinate of the operand
  2886. * @param z defines the z coordinate of the operand
  2887. * @returns the current updated Vector3
  2888. */
  2889. copyFromFloats(x: number, y: number, z: number): Vector3;
  2890. /**
  2891. * Copies the given floats to the current Vector3 coordinates
  2892. * @param x defines the x coordinate of the operand
  2893. * @param y defines the y coordinate of the operand
  2894. * @param z defines the z coordinate of the operand
  2895. * @returns the current updated Vector3
  2896. */
  2897. set(x: number, y: number, z: number): Vector3;
  2898. /**
  2899. * Copies the given float to the current Vector3 coordinates
  2900. * @param v defines the x, y and z coordinates of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. setAll(v: number): Vector3;
  2904. /**
  2905. * Get the clip factor between two vectors
  2906. * @param vector0 defines the first operand
  2907. * @param vector1 defines the second operand
  2908. * @param axis defines the axis to use
  2909. * @param size defines the size along the axis
  2910. * @returns the clip factor
  2911. */
  2912. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2913. /**
  2914. * Get angle between two vectors
  2915. * @param vector0 angle between vector0 and vector1
  2916. * @param vector1 angle between vector0 and vector1
  2917. * @param normal direction of the normal
  2918. * @return the angle between vector0 and vector1
  2919. */
  2920. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2921. /**
  2922. * Returns a new Vector3 set from the index "offset" of the given array
  2923. * @param array defines the source array
  2924. * @param offset defines the offset in the source array
  2925. * @returns the new Vector3
  2926. */
  2927. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2930. * @param array defines the source array
  2931. * @param offset defines the offset in the source array
  2932. * @returns the new Vector3
  2933. * @deprecated Please use FromArray instead.
  2934. */
  2935. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2938. * @param array defines the source array
  2939. * @param offset defines the offset in the source array
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2943. /**
  2944. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2945. * @param array defines the source array
  2946. * @param offset defines the offset in the source array
  2947. * @param result defines the Vector3 where to store the result
  2948. * @deprecated Please use FromArrayToRef instead.
  2949. */
  2950. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2951. /**
  2952. * Sets the given vector "result" with the given floats.
  2953. * @param x defines the x coordinate of the source
  2954. * @param y defines the y coordinate of the source
  2955. * @param z defines the z coordinate of the source
  2956. * @param result defines the Vector3 where to store the result
  2957. */
  2958. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2961. * @returns a new empty Vector3
  2962. */
  2963. static Zero(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2966. * @returns a new unit Vector3
  2967. */
  2968. static One(): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2971. * @returns a new up Vector3
  2972. */
  2973. static Up(): Vector3;
  2974. /**
  2975. * Gets a up Vector3 that must not be updated
  2976. */
  2977. static get UpReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Gets a zero Vector3 that must not be updated
  2980. */
  2981. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2982. /**
  2983. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2984. * @returns a new down Vector3
  2985. */
  2986. static Down(): Vector3;
  2987. /**
  2988. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2989. * @param rightHandedSystem is the scene right-handed (negative z)
  2990. * @returns a new forward Vector3
  2991. */
  2992. static Forward(rightHandedSystem?: boolean): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2995. * @param rightHandedSystem is the scene right-handed (negative-z)
  2996. * @returns a new forward Vector3
  2997. */
  2998. static Backward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3001. * @returns a new right Vector3
  3002. */
  3003. static Right(): Vector3;
  3004. /**
  3005. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3006. * @returns a new left Vector3
  3007. */
  3008. static Left(): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3011. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3012. * @param vector defines the Vector3 to transform
  3013. * @param transformation defines the transformation matrix
  3014. * @returns the transformed Vector3
  3015. */
  3016. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3017. /**
  3018. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3019. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3020. * @param vector defines the Vector3 to transform
  3021. * @param transformation defines the transformation matrix
  3022. * @param result defines the Vector3 where to store the result
  3023. */
  3024. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3025. /**
  3026. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3027. * This method computes tranformed coordinates only, not transformed direction vectors
  3028. * @param x define the x coordinate of the source vector
  3029. * @param y define the y coordinate of the source vector
  3030. * @param z define the z coordinate of the source vector
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3037. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3038. * @param vector defines the Vector3 to transform
  3039. * @param transformation defines the transformation matrix
  3040. * @returns the new Vector3
  3041. */
  3042. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3043. /**
  3044. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3045. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3046. * @param vector defines the Vector3 to transform
  3047. * @param transformation defines the transformation matrix
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3051. /**
  3052. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3053. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3054. * @param x define the x coordinate of the source vector
  3055. * @param y define the y coordinate of the source vector
  3056. * @param z define the z coordinate of the source vector
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3063. * @param value1 defines the first control point
  3064. * @param value2 defines the second control point
  3065. * @param value3 defines the third control point
  3066. * @param value4 defines the fourth control point
  3067. * @param amount defines the amount on the spline to use
  3068. * @returns the new Vector3
  3069. */
  3070. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3071. /**
  3072. * 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"
  3073. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3074. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3075. * @param value defines the current value
  3076. * @param min defines the lower range value
  3077. * @param max defines the upper range value
  3078. * @returns the new Vector3
  3079. */
  3080. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3081. /**
  3082. * 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"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Checks if a given vector is inside a specific range
  3093. * @param v defines the vector to test
  3094. * @param min defines the minimum range
  3095. * @param max defines the maximum range
  3096. */
  3097. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3098. /**
  3099. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3100. * @param value1 defines the first control point
  3101. * @param tangent1 defines the first tangent vector
  3102. * @param value2 defines the second control point
  3103. * @param tangent2 defines the second tangent vector
  3104. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3105. * @returns the new Vector3
  3106. */
  3107. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3110. * @param start defines the start value
  3111. * @param end defines the end value
  3112. * @param amount max defines amount between both (between 0 and 1)
  3113. * @returns the new Vector3
  3114. */
  3115. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3118. * @param start defines the start value
  3119. * @param end defines the end value
  3120. * @param amount max defines amount between both (between 0 and 1)
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3124. /**
  3125. * Returns the dot product (float) between the vectors "left" and "right"
  3126. * @param left defines the left operand
  3127. * @param right defines the right operand
  3128. * @returns the dot product
  3129. */
  3130. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3133. * The cross product is then orthogonal to both "left" and "right"
  3134. * @param left defines the left operand
  3135. * @param right defines the right operand
  3136. * @returns the cross product
  3137. */
  3138. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3139. /**
  3140. * Sets the given vector "result" with the cross product of "left" and "right"
  3141. * The cross product is then orthogonal to both "left" and "right"
  3142. * @param left defines the left operand
  3143. * @param right defines the right operand
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3147. /**
  3148. * Returns a new Vector3 as the normalization of the given vector
  3149. * @param vector defines the Vector3 to normalize
  3150. * @returns the new Vector3
  3151. */
  3152. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3153. /**
  3154. * Sets the given vector "result" with the normalization of the given first vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @param result defines the Vector3 where to store the result
  3157. */
  3158. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3159. /**
  3160. * Project a Vector3 onto screen space
  3161. * @param vector defines the Vector3 to project
  3162. * @param world defines the world matrix to use
  3163. * @param transform defines the transform (view x projection) matrix to use
  3164. * @param viewport defines the screen viewport to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3168. /** @hidden */
  3169. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3170. /**
  3171. * Unproject from screen space to object space
  3172. * @param source defines the screen space Vector3 to use
  3173. * @param viewportWidth defines the current width of the viewport
  3174. * @param viewportHeight defines the current height of the viewport
  3175. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3176. * @param transform defines the transform (view x projection) matrix to use
  3177. * @returns the new Vector3
  3178. */
  3179. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3180. /**
  3181. * Unproject from screen space to object space
  3182. * @param source defines the screen space Vector3 to use
  3183. * @param viewportWidth defines the current width of the viewport
  3184. * @param viewportHeight defines the current height of the viewport
  3185. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3186. * @param view defines the view matrix to use
  3187. * @param projection defines the projection matrix to use
  3188. * @returns the new Vector3
  3189. */
  3190. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3191. /**
  3192. * Unproject from screen space to object space
  3193. * @param source defines the screen space Vector3 to use
  3194. * @param viewportWidth defines the current width of the viewport
  3195. * @param viewportHeight defines the current height of the viewport
  3196. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3197. * @param view defines the view matrix to use
  3198. * @param projection defines the projection matrix to use
  3199. * @param result defines the Vector3 where to store the result
  3200. */
  3201. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3202. /**
  3203. * Unproject from screen space to object space
  3204. * @param sourceX defines the screen space x coordinate to use
  3205. * @param sourceY defines the screen space y coordinate to use
  3206. * @param sourceZ defines the screen space z coordinate to use
  3207. * @param viewportWidth defines the current width of the viewport
  3208. * @param viewportHeight defines the current height of the viewport
  3209. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3210. * @param view defines the view matrix to use
  3211. * @param projection defines the projection matrix to use
  3212. * @param result defines the Vector3 where to store the result
  3213. */
  3214. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3215. /**
  3216. * Gets the minimal coordinate values between two Vector3
  3217. * @param left defines the first operand
  3218. * @param right defines the second operand
  3219. * @returns the new Vector3
  3220. */
  3221. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3222. /**
  3223. * Gets the maximal coordinate values between two Vector3
  3224. * @param left defines the first operand
  3225. * @param right defines the second operand
  3226. * @returns the new Vector3
  3227. */
  3228. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3229. /**
  3230. * Returns the distance between the vectors "value1" and "value2"
  3231. * @param value1 defines the first operand
  3232. * @param value2 defines the second operand
  3233. * @returns the distance
  3234. */
  3235. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3236. /**
  3237. * Returns the squared distance between the vectors "value1" and "value2"
  3238. * @param value1 defines the first operand
  3239. * @param value2 defines the second operand
  3240. * @returns the squared distance
  3241. */
  3242. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3243. /**
  3244. * Returns a new Vector3 located at the center between "value1" and "value2"
  3245. * @param value1 defines the first operand
  3246. * @param value2 defines the second operand
  3247. * @returns the new Vector3
  3248. */
  3249. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3250. /**
  3251. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3252. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3253. * to something in order to rotate it from its local system to the given target system
  3254. * Note: axis1, axis2 and axis3 are normalized during this operation
  3255. * @param axis1 defines the first axis
  3256. * @param axis2 defines the second axis
  3257. * @param axis3 defines the third axis
  3258. * @returns a new Vector3
  3259. */
  3260. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3261. /**
  3262. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3263. * @param axis1 defines the first axis
  3264. * @param axis2 defines the second axis
  3265. * @param axis3 defines the third axis
  3266. * @param ref defines the Vector3 where to store the result
  3267. */
  3268. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3269. }
  3270. /**
  3271. * Vector4 class created for EulerAngle class conversion to Quaternion
  3272. */
  3273. export class Vector4 {
  3274. /** x value of the vector */
  3275. x: number;
  3276. /** y value of the vector */
  3277. y: number;
  3278. /** z value of the vector */
  3279. z: number;
  3280. /** w value of the vector */
  3281. w: number;
  3282. /**
  3283. * Creates a Vector4 object from the given floats.
  3284. * @param x x value of the vector
  3285. * @param y y value of the vector
  3286. * @param z z value of the vector
  3287. * @param w w value of the vector
  3288. */
  3289. constructor(
  3290. /** x value of the vector */
  3291. x: number,
  3292. /** y value of the vector */
  3293. y: number,
  3294. /** z value of the vector */
  3295. z: number,
  3296. /** w value of the vector */
  3297. w: number);
  3298. /**
  3299. * Returns the string with the Vector4 coordinates.
  3300. * @returns a string containing all the vector values
  3301. */
  3302. toString(): string;
  3303. /**
  3304. * Returns the string "Vector4".
  3305. * @returns "Vector4"
  3306. */
  3307. getClassName(): string;
  3308. /**
  3309. * Returns the Vector4 hash code.
  3310. * @returns a unique hash code
  3311. */
  3312. getHashCode(): number;
  3313. /**
  3314. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3315. * @returns the resulting array
  3316. */
  3317. asArray(): number[];
  3318. /**
  3319. * Populates the given array from the given index with the Vector4 coordinates.
  3320. * @param array array to populate
  3321. * @param index index of the array to start at (default: 0)
  3322. * @returns the Vector4.
  3323. */
  3324. toArray(array: FloatArray, index?: number): Vector4;
  3325. /**
  3326. * Update the current vector from an array
  3327. * @param array defines the destination array
  3328. * @param index defines the offset in the destination array
  3329. * @returns the current Vector3
  3330. */
  3331. fromArray(array: FloatArray, index?: number): Vector4;
  3332. /**
  3333. * Adds the given vector to the current Vector4.
  3334. * @param otherVector the vector to add
  3335. * @returns the updated Vector4.
  3336. */
  3337. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3338. /**
  3339. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3340. * @param otherVector the vector to add
  3341. * @returns the resulting vector
  3342. */
  3343. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3344. /**
  3345. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3346. * @param otherVector the vector to add
  3347. * @param result the vector to store the result
  3348. * @returns the current Vector4.
  3349. */
  3350. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3351. /**
  3352. * Subtract in place the given vector from the current Vector4.
  3353. * @param otherVector the vector to subtract
  3354. * @returns the updated Vector4.
  3355. */
  3356. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3359. * @param otherVector the vector to add
  3360. * @returns the new vector with the result
  3361. */
  3362. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3365. * @param otherVector the vector to subtract
  3366. * @param result the vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3372. */
  3373. /**
  3374. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3375. * @param x value to subtract
  3376. * @param y value to subtract
  3377. * @param z value to subtract
  3378. * @param w value to subtract
  3379. * @returns new vector containing the result
  3380. */
  3381. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3382. /**
  3383. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3384. * @param x value to subtract
  3385. * @param y value to subtract
  3386. * @param z value to subtract
  3387. * @param w value to subtract
  3388. * @param result the vector to store the result in
  3389. * @returns the current Vector4.
  3390. */
  3391. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3392. /**
  3393. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3394. * @returns a new vector with the negated values
  3395. */
  3396. negate(): Vector4;
  3397. /**
  3398. * Negate this vector in place
  3399. * @returns this
  3400. */
  3401. negateInPlace(): Vector4;
  3402. /**
  3403. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3404. * @param result defines the Vector3 object where to store the result
  3405. * @returns the current Vector4
  3406. */
  3407. negateToRef(result: Vector4): Vector4;
  3408. /**
  3409. * Multiplies the current Vector4 coordinates by scale (float).
  3410. * @param scale the number to scale with
  3411. * @returns the updated Vector4.
  3412. */
  3413. scaleInPlace(scale: number): Vector4;
  3414. /**
  3415. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3416. * @param scale the number to scale with
  3417. * @returns a new vector with the result
  3418. */
  3419. scale(scale: number): Vector4;
  3420. /**
  3421. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3422. * @param scale the number to scale with
  3423. * @param result a vector to store the result in
  3424. * @returns the current Vector4.
  3425. */
  3426. scaleToRef(scale: number, result: Vector4): Vector4;
  3427. /**
  3428. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3429. * @param scale defines the scale factor
  3430. * @param result defines the Vector4 object where to store the result
  3431. * @returns the unmodified current Vector4
  3432. */
  3433. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3434. /**
  3435. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3436. * @param otherVector the vector to compare against
  3437. * @returns true if they are equal
  3438. */
  3439. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3440. /**
  3441. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3442. * @param otherVector vector to compare against
  3443. * @param epsilon (Default: very small number)
  3444. * @returns true if they are equal
  3445. */
  3446. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3447. /**
  3448. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3449. * @param x x value to compare against
  3450. * @param y y value to compare against
  3451. * @param z z value to compare against
  3452. * @param w w value to compare against
  3453. * @returns true if equal
  3454. */
  3455. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3456. /**
  3457. * Multiplies in place the current Vector4 by the given one.
  3458. * @param otherVector vector to multiple with
  3459. * @returns the updated Vector4.
  3460. */
  3461. multiplyInPlace(otherVector: Vector4): Vector4;
  3462. /**
  3463. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3464. * @param otherVector vector to multiple with
  3465. * @returns resulting new vector
  3466. */
  3467. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3468. /**
  3469. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3470. * @param otherVector vector to multiple with
  3471. * @param result vector to store the result
  3472. * @returns the current Vector4.
  3473. */
  3474. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3477. * @param x x value multiply with
  3478. * @param y y value multiply with
  3479. * @param z z value multiply with
  3480. * @param w w value multiply with
  3481. * @returns resulting new vector
  3482. */
  3483. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3484. /**
  3485. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3486. * @param otherVector vector to devide with
  3487. * @returns resulting new vector
  3488. */
  3489. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3490. /**
  3491. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3492. * @param otherVector vector to devide with
  3493. * @param result vector to store the result
  3494. * @returns the current Vector4.
  3495. */
  3496. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3497. /**
  3498. * Divides the current Vector3 coordinates by the given ones.
  3499. * @param otherVector vector to devide with
  3500. * @returns the updated Vector3.
  3501. */
  3502. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3503. /**
  3504. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3505. * @param other defines the second operand
  3506. * @returns the current updated Vector4
  3507. */
  3508. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3509. /**
  3510. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3511. * @param other defines the second operand
  3512. * @returns the current updated Vector4
  3513. */
  3514. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Gets a new Vector4 from current Vector4 floored values
  3517. * @returns a new Vector4
  3518. */
  3519. floor(): Vector4;
  3520. /**
  3521. * Gets a new Vector4 from current Vector3 floored values
  3522. * @returns a new Vector4
  3523. */
  3524. fract(): Vector4;
  3525. /**
  3526. * Returns the Vector4 length (float).
  3527. * @returns the length
  3528. */
  3529. length(): number;
  3530. /**
  3531. * Returns the Vector4 squared length (float).
  3532. * @returns the length squared
  3533. */
  3534. lengthSquared(): number;
  3535. /**
  3536. * Normalizes in place the Vector4.
  3537. * @returns the updated Vector4.
  3538. */
  3539. normalize(): Vector4;
  3540. /**
  3541. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3542. * @returns this converted to a new vector3
  3543. */
  3544. toVector3(): Vector3;
  3545. /**
  3546. * Returns a new Vector4 copied from the current one.
  3547. * @returns the new cloned vector
  3548. */
  3549. clone(): Vector4;
  3550. /**
  3551. * Updates the current Vector4 with the given one coordinates.
  3552. * @param source the source vector to copy from
  3553. * @returns the updated Vector4.
  3554. */
  3555. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3556. /**
  3557. * Updates the current Vector4 coordinates with the given floats.
  3558. * @param x float to copy from
  3559. * @param y float to copy from
  3560. * @param z float to copy from
  3561. * @param w float to copy from
  3562. * @returns the updated Vector4.
  3563. */
  3564. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3565. /**
  3566. * Updates the current Vector4 coordinates with the given floats.
  3567. * @param x float to set from
  3568. * @param y float to set from
  3569. * @param z float to set from
  3570. * @param w float to set from
  3571. * @returns the updated Vector4.
  3572. */
  3573. set(x: number, y: number, z: number, w: number): Vector4;
  3574. /**
  3575. * Copies the given float to the current Vector3 coordinates
  3576. * @param v defines the x, y, z and w coordinates of the operand
  3577. * @returns the current updated Vector3
  3578. */
  3579. setAll(v: number): Vector4;
  3580. /**
  3581. * Returns a new Vector4 set from the starting index of the given array.
  3582. * @param array the array to pull values from
  3583. * @param offset the offset into the array to start at
  3584. * @returns the new vector
  3585. */
  3586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3587. /**
  3588. * Updates the given vector "result" from the starting index of the given array.
  3589. * @param array the array to pull values from
  3590. * @param offset the offset into the array to start at
  3591. * @param result the vector to store the result in
  3592. */
  3593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3594. /**
  3595. * Updates the given vector "result" from the starting index of the given Float32Array.
  3596. * @param array the array to pull values from
  3597. * @param offset the offset into the array to start at
  3598. * @param result the vector to store the result in
  3599. */
  3600. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3601. /**
  3602. * Updates the given vector "result" coordinates from the given floats.
  3603. * @param x float to set from
  3604. * @param y float to set from
  3605. * @param z float to set from
  3606. * @param w float to set from
  3607. * @param result the vector to the floats in
  3608. */
  3609. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3610. /**
  3611. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3612. * @returns the new vector
  3613. */
  3614. static Zero(): Vector4;
  3615. /**
  3616. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3617. * @returns the new vector
  3618. */
  3619. static One(): Vector4;
  3620. /**
  3621. * Returns a new normalized Vector4 from the given one.
  3622. * @param vector the vector to normalize
  3623. * @returns the vector
  3624. */
  3625. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3626. /**
  3627. * Updates the given vector "result" from the normalization of the given one.
  3628. * @param vector the vector to normalize
  3629. * @param result the vector to store the result in
  3630. */
  3631. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3632. /**
  3633. * Returns a vector with the minimum values from the left and right vectors
  3634. * @param left left vector to minimize
  3635. * @param right right vector to minimize
  3636. * @returns a new vector with the minimum of the left and right vector values
  3637. */
  3638. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3639. /**
  3640. * Returns a vector with the maximum values from the left and right vectors
  3641. * @param left left vector to maximize
  3642. * @param right right vector to maximize
  3643. * @returns a new vector with the maximum of the left and right vector values
  3644. */
  3645. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Returns the distance (float) between the vectors "value1" and "value2".
  3648. * @param value1 value to calulate the distance between
  3649. * @param value2 value to calulate the distance between
  3650. * @return the distance between the two vectors
  3651. */
  3652. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3653. /**
  3654. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3655. * @param value1 value to calulate the distance between
  3656. * @param value2 value to calulate the distance between
  3657. * @return the distance between the two vectors squared
  3658. */
  3659. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3660. /**
  3661. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3662. * @param value1 value to calulate the center between
  3663. * @param value2 value to calulate the center between
  3664. * @return the center between the two vectors
  3665. */
  3666. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3667. /**
  3668. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3669. * This methods computes transformed normalized direction vectors only.
  3670. * @param vector the vector to transform
  3671. * @param transformation the transformation matrix to apply
  3672. * @returns the new vector
  3673. */
  3674. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3675. /**
  3676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3677. * This methods computes transformed normalized direction vectors only.
  3678. * @param vector the vector to transform
  3679. * @param transformation the transformation matrix to apply
  3680. * @param result the vector to store the result in
  3681. */
  3682. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3683. /**
  3684. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3685. * This methods computes transformed normalized direction vectors only.
  3686. * @param x value to transform
  3687. * @param y value to transform
  3688. * @param z value to transform
  3689. * @param w value to transform
  3690. * @param transformation the transformation matrix to apply
  3691. * @param result the vector to store the results in
  3692. */
  3693. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3694. /**
  3695. * Creates a new Vector4 from a Vector3
  3696. * @param source defines the source data
  3697. * @param w defines the 4th component (default is 0)
  3698. * @returns a new Vector4
  3699. */
  3700. static FromVector3(source: Vector3, w?: number): Vector4;
  3701. }
  3702. /**
  3703. * Class used to store quaternion data
  3704. * @see https://en.wikipedia.org/wiki/Quaternion
  3705. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3706. */
  3707. export class Quaternion {
  3708. /** @hidden */
  3709. _x: number;
  3710. /** @hidden */
  3711. _y: number;
  3712. /** @hidden */
  3713. _z: number;
  3714. /** @hidden */
  3715. _w: number;
  3716. /** @hidden */
  3717. _isDirty: boolean;
  3718. /** Gets or sets the x coordinate */
  3719. get x(): number;
  3720. set x(value: number);
  3721. /** Gets or sets the y coordinate */
  3722. get y(): number;
  3723. set y(value: number);
  3724. /** Gets or sets the z coordinate */
  3725. get z(): number;
  3726. set z(value: number);
  3727. /** Gets or sets the w coordinate */
  3728. get w(): number;
  3729. set w(value: number);
  3730. /**
  3731. * Creates a new Quaternion from the given floats
  3732. * @param x defines the first component (0 by default)
  3733. * @param y defines the second component (0 by default)
  3734. * @param z defines the third component (0 by default)
  3735. * @param w defines the fourth component (1.0 by default)
  3736. */
  3737. constructor(x?: number, y?: number, z?: number, w?: number);
  3738. /**
  3739. * Gets a string representation for the current quaternion
  3740. * @returns a string with the Quaternion coordinates
  3741. */
  3742. toString(): string;
  3743. /**
  3744. * Gets the class name of the quaternion
  3745. * @returns the string "Quaternion"
  3746. */
  3747. getClassName(): string;
  3748. /**
  3749. * Gets a hash code for this quaternion
  3750. * @returns the quaternion hash code
  3751. */
  3752. getHashCode(): number;
  3753. /**
  3754. * Copy the quaternion to an array
  3755. * @returns a new array populated with 4 elements from the quaternion coordinates
  3756. */
  3757. asArray(): number[];
  3758. /**
  3759. * Check if two quaternions are equals
  3760. * @param otherQuaternion defines the second operand
  3761. * @return true if the current quaternion and the given one coordinates are strictly equals
  3762. */
  3763. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3764. /**
  3765. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3766. * @param otherQuaternion defines the other quaternion
  3767. * @param epsilon defines the minimal distance to consider equality
  3768. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3769. */
  3770. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3771. /**
  3772. * Clone the current quaternion
  3773. * @returns a new quaternion copied from the current one
  3774. */
  3775. clone(): Quaternion;
  3776. /**
  3777. * Copy a quaternion to the current one
  3778. * @param other defines the other quaternion
  3779. * @returns the updated current quaternion
  3780. */
  3781. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the given float coordinates
  3784. * @param x defines the x coordinate
  3785. * @param y defines the y coordinate
  3786. * @param z defines the z coordinate
  3787. * @param w defines the w coordinate
  3788. * @returns the updated current quaternion
  3789. */
  3790. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3791. /**
  3792. * Updates the current quaternion from the given float coordinates
  3793. * @param x defines the x coordinate
  3794. * @param y defines the y coordinate
  3795. * @param z defines the z coordinate
  3796. * @param w defines the w coordinate
  3797. * @returns the updated current quaternion
  3798. */
  3799. set(x: number, y: number, z: number, w: number): Quaternion;
  3800. /**
  3801. * Adds two quaternions
  3802. * @param other defines the second operand
  3803. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3804. */
  3805. add(other: DeepImmutable<Quaternion>): Quaternion;
  3806. /**
  3807. * Add a quaternion to the current one
  3808. * @param other defines the quaternion to add
  3809. * @returns the current quaternion
  3810. */
  3811. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3812. /**
  3813. * Subtract two quaternions
  3814. * @param other defines the second operand
  3815. * @returns a new quaternion as the subtraction result of the given one from the current one
  3816. */
  3817. subtract(other: Quaternion): Quaternion;
  3818. /**
  3819. * Multiplies the current quaternion by a scale factor
  3820. * @param value defines the scale factor
  3821. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3822. */
  3823. scale(value: number): Quaternion;
  3824. /**
  3825. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3826. * @param scale defines the scale factor
  3827. * @param result defines the Quaternion object where to store the result
  3828. * @returns the unmodified current quaternion
  3829. */
  3830. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3831. /**
  3832. * Multiplies in place the current quaternion by a scale factor
  3833. * @param value defines the scale factor
  3834. * @returns the current modified quaternion
  3835. */
  3836. scaleInPlace(value: number): Quaternion;
  3837. /**
  3838. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3839. * @param scale defines the scale factor
  3840. * @param result defines the Quaternion object where to store the result
  3841. * @returns the unmodified current quaternion
  3842. */
  3843. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3844. /**
  3845. * Multiplies two quaternions
  3846. * @param q1 defines the second operand
  3847. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3848. */
  3849. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3850. /**
  3851. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3852. * @param q1 defines the second operand
  3853. * @param result defines the target quaternion
  3854. * @returns the current quaternion
  3855. */
  3856. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3857. /**
  3858. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3859. * @param q1 defines the second operand
  3860. * @returns the currentupdated quaternion
  3861. */
  3862. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3863. /**
  3864. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3865. * @param ref defines the target quaternion
  3866. * @returns the current quaternion
  3867. */
  3868. conjugateToRef(ref: Quaternion): Quaternion;
  3869. /**
  3870. * Conjugates in place (1-q) the current quaternion
  3871. * @returns the current updated quaternion
  3872. */
  3873. conjugateInPlace(): Quaternion;
  3874. /**
  3875. * Conjugates in place (1-q) the current quaternion
  3876. * @returns a new quaternion
  3877. */
  3878. conjugate(): Quaternion;
  3879. /**
  3880. * Gets length of current quaternion
  3881. * @returns the quaternion length (float)
  3882. */
  3883. length(): number;
  3884. /**
  3885. * Normalize in place the current quaternion
  3886. * @returns the current updated quaternion
  3887. */
  3888. normalize(): Quaternion;
  3889. /**
  3890. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3891. * @param order is a reserved parameter and is ignored for now
  3892. * @returns a new Vector3 containing the Euler angles
  3893. */
  3894. toEulerAngles(order?: string): Vector3;
  3895. /**
  3896. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3897. * @param result defines the vector which will be filled with the Euler angles
  3898. * @returns the current unchanged quaternion
  3899. */
  3900. toEulerAnglesToRef(result: Vector3): Quaternion;
  3901. /**
  3902. * Updates the given rotation matrix with the current quaternion values
  3903. * @param result defines the target matrix
  3904. * @returns the current unchanged quaternion
  3905. */
  3906. toRotationMatrix(result: Matrix): Quaternion;
  3907. /**
  3908. * Updates the current quaternion from the given rotation matrix values
  3909. * @param matrix defines the source matrix
  3910. * @returns the current updated quaternion
  3911. */
  3912. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3913. /**
  3914. * Creates a new quaternion from a rotation matrix
  3915. * @param matrix defines the source matrix
  3916. * @returns a new quaternion created from the given rotation matrix values
  3917. */
  3918. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3919. /**
  3920. * Updates the given quaternion with the given rotation matrix values
  3921. * @param matrix defines the source matrix
  3922. * @param result defines the target quaternion
  3923. */
  3924. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3925. /**
  3926. * Returns the dot product (float) between the quaternions "left" and "right"
  3927. * @param left defines the left operand
  3928. * @param right defines the right operand
  3929. * @returns the dot product
  3930. */
  3931. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3932. /**
  3933. * Checks if the two quaternions are close to each other
  3934. * @param quat0 defines the first quaternion to check
  3935. * @param quat1 defines the second quaternion to check
  3936. * @returns true if the two quaternions are close to each other
  3937. */
  3938. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3939. /**
  3940. * Creates an empty quaternion
  3941. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3942. */
  3943. static Zero(): Quaternion;
  3944. /**
  3945. * Inverse a given quaternion
  3946. * @param q defines the source quaternion
  3947. * @returns a new quaternion as the inverted current quaternion
  3948. */
  3949. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3950. /**
  3951. * Inverse a given quaternion
  3952. * @param q defines the source quaternion
  3953. * @param result the quaternion the result will be stored in
  3954. * @returns the result quaternion
  3955. */
  3956. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3957. /**
  3958. * Creates an identity quaternion
  3959. * @returns the identity quaternion
  3960. */
  3961. static Identity(): Quaternion;
  3962. /**
  3963. * Gets a boolean indicating if the given quaternion is identity
  3964. * @param quaternion defines the quaternion to check
  3965. * @returns true if the quaternion is identity
  3966. */
  3967. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3968. /**
  3969. * Creates a quaternion from a rotation around an axis
  3970. * @param axis defines the axis to use
  3971. * @param angle defines the angle to use
  3972. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3973. */
  3974. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3975. /**
  3976. * Creates a rotation around an axis and stores it into the given quaternion
  3977. * @param axis defines the axis to use
  3978. * @param angle defines the angle to use
  3979. * @param result defines the target quaternion
  3980. * @returns the target quaternion
  3981. */
  3982. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3983. /**
  3984. * Creates a new quaternion from data stored into an array
  3985. * @param array defines the data source
  3986. * @param offset defines the offset in the source array where the data starts
  3987. * @returns a new quaternion
  3988. */
  3989. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3990. /**
  3991. * Updates the given quaternion "result" from the starting index of the given array.
  3992. * @param array the array to pull values from
  3993. * @param offset the offset into the array to start at
  3994. * @param result the quaternion to store the result in
  3995. */
  3996. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3997. /**
  3998. * Create a quaternion from Euler rotation angles
  3999. * @param x Pitch
  4000. * @param y Yaw
  4001. * @param z Roll
  4002. * @returns the new Quaternion
  4003. */
  4004. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4005. /**
  4006. * Updates a quaternion from Euler rotation angles
  4007. * @param x Pitch
  4008. * @param y Yaw
  4009. * @param z Roll
  4010. * @param result the quaternion to store the result
  4011. * @returns the updated quaternion
  4012. */
  4013. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4014. /**
  4015. * Create a quaternion from Euler rotation vector
  4016. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4017. * @returns the new Quaternion
  4018. */
  4019. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4020. /**
  4021. * Updates a quaternion from Euler rotation vector
  4022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4023. * @param result the quaternion to store the result
  4024. * @returns the updated quaternion
  4025. */
  4026. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4027. /**
  4028. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4029. * @param yaw defines the rotation around Y axis
  4030. * @param pitch defines the rotation around X axis
  4031. * @param roll defines the rotation around Z axis
  4032. * @returns the new quaternion
  4033. */
  4034. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4035. /**
  4036. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4037. * @param yaw defines the rotation around Y axis
  4038. * @param pitch defines the rotation around X axis
  4039. * @param roll defines the rotation around Z axis
  4040. * @param result defines the target quaternion
  4041. */
  4042. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4043. /**
  4044. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4045. * @param alpha defines the rotation around first axis
  4046. * @param beta defines the rotation around second axis
  4047. * @param gamma defines the rotation around third axis
  4048. * @returns the new quaternion
  4049. */
  4050. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4051. /**
  4052. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4053. * @param alpha defines the rotation around first axis
  4054. * @param beta defines the rotation around second axis
  4055. * @param gamma defines the rotation around third axis
  4056. * @param result defines the target quaternion
  4057. */
  4058. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4059. /**
  4060. * 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)
  4061. * @param axis1 defines the first axis
  4062. * @param axis2 defines the second axis
  4063. * @param axis3 defines the third axis
  4064. * @returns the new quaternion
  4065. */
  4066. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4067. /**
  4068. * 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
  4069. * @param axis1 defines the first axis
  4070. * @param axis2 defines the second axis
  4071. * @param axis3 defines the third axis
  4072. * @param ref defines the target quaternion
  4073. */
  4074. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4075. /**
  4076. * Interpolates between two quaternions
  4077. * @param left defines first quaternion
  4078. * @param right defines second quaternion
  4079. * @param amount defines the gradient to use
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. /**
  4084. * Interpolates between two quaternions and stores it into a target quaternion
  4085. * @param left defines first quaternion
  4086. * @param right defines second quaternion
  4087. * @param amount defines the gradient to use
  4088. * @param result defines the target quaternion
  4089. */
  4090. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4091. /**
  4092. * Interpolate between two quaternions using Hermite interpolation
  4093. * @param value1 defines first quaternion
  4094. * @param tangent1 defines the incoming tangent
  4095. * @param value2 defines second quaternion
  4096. * @param tangent2 defines the outgoing tangent
  4097. * @param amount defines the target quaternion
  4098. * @returns the new interpolated quaternion
  4099. */
  4100. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4101. }
  4102. /**
  4103. * Class used to store matrix data (4x4)
  4104. */
  4105. export class Matrix {
  4106. /**
  4107. * Gets the precision of matrix computations
  4108. */
  4109. static get Use64Bits(): boolean;
  4110. private static _updateFlagSeed;
  4111. private static _identityReadOnly;
  4112. private _isIdentity;
  4113. private _isIdentityDirty;
  4114. private _isIdentity3x2;
  4115. private _isIdentity3x2Dirty;
  4116. /**
  4117. * Gets the update flag of the matrix which is an unique number for the matrix.
  4118. * It will be incremented every time the matrix data change.
  4119. * You can use it to speed the comparison between two versions of the same matrix.
  4120. */
  4121. updateFlag: number;
  4122. private readonly _m;
  4123. /**
  4124. * Gets the internal data of the matrix
  4125. */
  4126. get m(): DeepImmutable<Float32Array | Array<number>>;
  4127. /** @hidden */
  4128. _markAsUpdated(): void;
  4129. /** @hidden */
  4130. private _updateIdentityStatus;
  4131. /**
  4132. * Creates an empty matrix (filled with zeros)
  4133. */
  4134. constructor();
  4135. /**
  4136. * Check if the current matrix is identity
  4137. * @returns true is the matrix is the identity matrix
  4138. */
  4139. isIdentity(): boolean;
  4140. /**
  4141. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4142. * @returns true is the matrix is the identity matrix
  4143. */
  4144. isIdentityAs3x2(): boolean;
  4145. /**
  4146. * Gets the determinant of the matrix
  4147. * @returns the matrix determinant
  4148. */
  4149. determinant(): number;
  4150. /**
  4151. * Returns the matrix as a Float32Array or Array<number>
  4152. * @returns the matrix underlying array
  4153. */
  4154. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4155. /**
  4156. * Returns the matrix as a Float32Array or Array<number>
  4157. * @returns the matrix underlying array.
  4158. */
  4159. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4160. /**
  4161. * Inverts the current matrix in place
  4162. * @returns the current inverted matrix
  4163. */
  4164. invert(): Matrix;
  4165. /**
  4166. * Sets all the matrix elements to zero
  4167. * @returns the current matrix
  4168. */
  4169. reset(): Matrix;
  4170. /**
  4171. * Adds the current matrix with a second one
  4172. * @param other defines the matrix to add
  4173. * @returns a new matrix as the addition of the current matrix and the given one
  4174. */
  4175. add(other: DeepImmutable<Matrix>): Matrix;
  4176. /**
  4177. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4178. * @param other defines the matrix to add
  4179. * @param result defines the target matrix
  4180. * @returns the current matrix
  4181. */
  4182. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4183. /**
  4184. * Adds in place the given matrix to the current matrix
  4185. * @param other defines the second operand
  4186. * @returns the current updated matrix
  4187. */
  4188. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4189. /**
  4190. * Sets the given matrix to the current inverted Matrix
  4191. * @param other defines the target matrix
  4192. * @returns the unmodified current matrix
  4193. */
  4194. invertToRef(other: Matrix): Matrix;
  4195. /**
  4196. * add a value at the specified position in the current Matrix
  4197. * @param index the index of the value within the matrix. between 0 and 15.
  4198. * @param value the value to be added
  4199. * @returns the current updated matrix
  4200. */
  4201. addAtIndex(index: number, value: number): Matrix;
  4202. /**
  4203. * mutiply the specified position in the current Matrix by a value
  4204. * @param index the index of the value within the matrix. between 0 and 15.
  4205. * @param value the value to be added
  4206. * @returns the current updated matrix
  4207. */
  4208. multiplyAtIndex(index: number, value: number): Matrix;
  4209. /**
  4210. * Inserts the translation vector (using 3 floats) in the current matrix
  4211. * @param x defines the 1st component of the translation
  4212. * @param y defines the 2nd component of the translation
  4213. * @param z defines the 3rd component of the translation
  4214. * @returns the current updated matrix
  4215. */
  4216. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4217. /**
  4218. * Adds the translation vector (using 3 floats) in the current matrix
  4219. * @param x defines the 1st component of the translation
  4220. * @param y defines the 2nd component of the translation
  4221. * @param z defines the 3rd component of the translation
  4222. * @returns the current updated matrix
  4223. */
  4224. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4225. /**
  4226. * Inserts the translation vector in the current matrix
  4227. * @param vector3 defines the translation to insert
  4228. * @returns the current updated matrix
  4229. */
  4230. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4231. /**
  4232. * Gets the translation value of the current matrix
  4233. * @returns a new Vector3 as the extracted translation from the matrix
  4234. */
  4235. getTranslation(): Vector3;
  4236. /**
  4237. * Fill a Vector3 with the extracted translation from the matrix
  4238. * @param result defines the Vector3 where to store the translation
  4239. * @returns the current matrix
  4240. */
  4241. getTranslationToRef(result: Vector3): Matrix;
  4242. /**
  4243. * Remove rotation and scaling part from the matrix
  4244. * @returns the updated matrix
  4245. */
  4246. removeRotationAndScaling(): Matrix;
  4247. /**
  4248. * Multiply two matrices
  4249. * @param other defines the second operand
  4250. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4251. */
  4252. multiply(other: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Copy the current matrix from the given one
  4255. * @param other defines the source matrix
  4256. * @returns the current updated matrix
  4257. */
  4258. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Populates the given array from the starting index with the current matrix values
  4261. * @param array defines the target array
  4262. * @param offset defines the offset in the target array where to start storing values
  4263. * @returns the current matrix
  4264. */
  4265. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4266. /**
  4267. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4268. * @param other defines the second operand
  4269. * @param result defines the matrix where to store the multiplication
  4270. * @returns the current matrix
  4271. */
  4272. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4273. /**
  4274. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4275. * @param other defines the second operand
  4276. * @param result defines the array where to store the multiplication
  4277. * @param offset defines the offset in the target array where to start storing values
  4278. * @returns the current matrix
  4279. */
  4280. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4281. /**
  4282. * Check equality between this matrix and a second one
  4283. * @param value defines the second matrix to compare
  4284. * @returns true is the current matrix and the given one values are strictly equal
  4285. */
  4286. equals(value: DeepImmutable<Matrix>): boolean;
  4287. /**
  4288. * Clone the current matrix
  4289. * @returns a new matrix from the current matrix
  4290. */
  4291. clone(): Matrix;
  4292. /**
  4293. * Returns the name of the current matrix class
  4294. * @returns the string "Matrix"
  4295. */
  4296. getClassName(): string;
  4297. /**
  4298. * Gets the hash code of the current matrix
  4299. * @returns the hash code
  4300. */
  4301. getHashCode(): number;
  4302. /**
  4303. * Decomposes the current Matrix into a translation, rotation and scaling components
  4304. * @param scale defines the scale vector3 given as a reference to update
  4305. * @param rotation defines the rotation quaternion given as a reference to update
  4306. * @param translation defines the translation vector3 given as a reference to update
  4307. * @returns true if operation was successful
  4308. */
  4309. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4310. /**
  4311. * Gets specific row of the matrix
  4312. * @param index defines the number of the row to get
  4313. * @returns the index-th row of the current matrix as a new Vector4
  4314. */
  4315. getRow(index: number): Nullable<Vector4>;
  4316. /**
  4317. * Sets the index-th row of the current matrix to the vector4 values
  4318. * @param index defines the number of the row to set
  4319. * @param row defines the target vector4
  4320. * @returns the updated current matrix
  4321. */
  4322. setRow(index: number, row: Vector4): Matrix;
  4323. /**
  4324. * Compute the transpose of the matrix
  4325. * @returns the new transposed matrix
  4326. */
  4327. transpose(): Matrix;
  4328. /**
  4329. * Compute the transpose of the matrix and store it in a given matrix
  4330. * @param result defines the target matrix
  4331. * @returns the current matrix
  4332. */
  4333. transposeToRef(result: Matrix): Matrix;
  4334. /**
  4335. * Sets the index-th row of the current matrix with the given 4 x float values
  4336. * @param index defines the row index
  4337. * @param x defines the x component to set
  4338. * @param y defines the y component to set
  4339. * @param z defines the z component to set
  4340. * @param w defines the w component to set
  4341. * @returns the updated current matrix
  4342. */
  4343. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4344. /**
  4345. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4346. * @param scale defines the scale factor
  4347. * @returns a new matrix
  4348. */
  4349. scale(scale: number): Matrix;
  4350. /**
  4351. * Scale the current matrix values by a factor to a given result matrix
  4352. * @param scale defines the scale factor
  4353. * @param result defines the matrix to store the result
  4354. * @returns the current matrix
  4355. */
  4356. scaleToRef(scale: number, result: Matrix): Matrix;
  4357. /**
  4358. * Scale the current matrix values by a factor and add the result to a given matrix
  4359. * @param scale defines the scale factor
  4360. * @param result defines the Matrix to store the result
  4361. * @returns the current matrix
  4362. */
  4363. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4364. /**
  4365. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4366. * @param ref matrix to store the result
  4367. */
  4368. toNormalMatrix(ref: Matrix): void;
  4369. /**
  4370. * Gets only rotation part of the current matrix
  4371. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4372. */
  4373. getRotationMatrix(): Matrix;
  4374. /**
  4375. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4376. * @param result defines the target matrix to store data to
  4377. * @returns the current matrix
  4378. */
  4379. getRotationMatrixToRef(result: Matrix): Matrix;
  4380. /**
  4381. * Toggles model matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleModelMatrixHandInPlace(): void;
  4384. /**
  4385. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4386. */
  4387. toggleProjectionMatrixHandInPlace(): void;
  4388. /**
  4389. * Creates a matrix from an array
  4390. * @param array defines the source array
  4391. * @param offset defines an offset in the source array
  4392. * @returns a new Matrix set from the starting index of the given array
  4393. */
  4394. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4395. /**
  4396. * Copy the content of an array into a given matrix
  4397. * @param array defines the source array
  4398. * @param offset defines an offset in the source array
  4399. * @param result defines the target matrix
  4400. */
  4401. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4402. /**
  4403. * Stores an array into a matrix after having multiplied each component by a given factor
  4404. * @param array defines the source array
  4405. * @param offset defines the offset in the source array
  4406. * @param scale defines the scaling factor
  4407. * @param result defines the target matrix
  4408. */
  4409. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4410. /**
  4411. * Gets an identity matrix that must not be updated
  4412. */
  4413. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4414. /**
  4415. * Stores a list of values (16) inside a given matrix
  4416. * @param initialM11 defines 1st value of 1st row
  4417. * @param initialM12 defines 2nd value of 1st row
  4418. * @param initialM13 defines 3rd value of 1st row
  4419. * @param initialM14 defines 4th value of 1st row
  4420. * @param initialM21 defines 1st value of 2nd row
  4421. * @param initialM22 defines 2nd value of 2nd row
  4422. * @param initialM23 defines 3rd value of 2nd row
  4423. * @param initialM24 defines 4th value of 2nd row
  4424. * @param initialM31 defines 1st value of 3rd row
  4425. * @param initialM32 defines 2nd value of 3rd row
  4426. * @param initialM33 defines 3rd value of 3rd row
  4427. * @param initialM34 defines 4th value of 3rd row
  4428. * @param initialM41 defines 1st value of 4th row
  4429. * @param initialM42 defines 2nd value of 4th row
  4430. * @param initialM43 defines 3rd value of 4th row
  4431. * @param initialM44 defines 4th value of 4th row
  4432. * @param result defines the target matrix
  4433. */
  4434. 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;
  4435. /**
  4436. * Creates new matrix from a list of values (16)
  4437. * @param initialM11 defines 1st value of 1st row
  4438. * @param initialM12 defines 2nd value of 1st row
  4439. * @param initialM13 defines 3rd value of 1st row
  4440. * @param initialM14 defines 4th value of 1st row
  4441. * @param initialM21 defines 1st value of 2nd row
  4442. * @param initialM22 defines 2nd value of 2nd row
  4443. * @param initialM23 defines 3rd value of 2nd row
  4444. * @param initialM24 defines 4th value of 2nd row
  4445. * @param initialM31 defines 1st value of 3rd row
  4446. * @param initialM32 defines 2nd value of 3rd row
  4447. * @param initialM33 defines 3rd value of 3rd row
  4448. * @param initialM34 defines 4th value of 3rd row
  4449. * @param initialM41 defines 1st value of 4th row
  4450. * @param initialM42 defines 2nd value of 4th row
  4451. * @param initialM43 defines 3rd value of 4th row
  4452. * @param initialM44 defines 4th value of 4th row
  4453. * @returns the new matrix
  4454. */
  4455. 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;
  4456. /**
  4457. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4458. * @param scale defines the scale vector3
  4459. * @param rotation defines the rotation quaternion
  4460. * @param translation defines the translation vector3
  4461. * @returns a new matrix
  4462. */
  4463. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4464. /**
  4465. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4466. * @param scale defines the scale vector3
  4467. * @param rotation defines the rotation quaternion
  4468. * @param translation defines the translation vector3
  4469. * @param result defines the target matrix
  4470. */
  4471. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a new identity matrix
  4474. * @returns a new identity matrix
  4475. */
  4476. static Identity(): Matrix;
  4477. /**
  4478. * Creates a new identity matrix and stores the result in a given matrix
  4479. * @param result defines the target matrix
  4480. */
  4481. static IdentityToRef(result: Matrix): void;
  4482. /**
  4483. * Creates a new zero matrix
  4484. * @returns a new zero matrix
  4485. */
  4486. static Zero(): Matrix;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the X axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationX(angle: number): Matrix;
  4493. /**
  4494. * Creates a new matrix as the invert of a given matrix
  4495. * @param source defines the source matrix
  4496. * @returns the new matrix
  4497. */
  4498. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4501. * @param angle defines the angle (in radians) to use
  4502. * @param result defines the target matrix
  4503. */
  4504. static RotationXToRef(angle: number, result: Matrix): void;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Y axis
  4507. * @param angle defines the angle (in radians) to use
  4508. * @return the new matrix
  4509. */
  4510. static RotationY(angle: number): Matrix;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4513. * @param angle defines the angle (in radians) to use
  4514. * @param result defines the target matrix
  4515. */
  4516. static RotationYToRef(angle: number, result: Matrix): void;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the Z axis
  4519. * @param angle defines the angle (in radians) to use
  4520. * @return the new matrix
  4521. */
  4522. static RotationZ(angle: number): Matrix;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4525. * @param angle defines the angle (in radians) to use
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationZToRef(angle: number, result: Matrix): void;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the given axis
  4531. * @param axis defines the axis to use
  4532. * @param angle defines the angle (in radians) to use
  4533. * @return the new matrix
  4534. */
  4535. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4536. /**
  4537. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4538. * @param axis defines the axis to use
  4539. * @param angle defines the angle (in radians) to use
  4540. * @param result defines the target matrix
  4541. */
  4542. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4543. /**
  4544. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4545. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4546. * @param from defines the vector to align
  4547. * @param to defines the vector to align to
  4548. * @param result defines the target matrix
  4549. */
  4550. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Creates a rotation matrix
  4553. * @param yaw defines the yaw angle in radians (Y axis)
  4554. * @param pitch defines the pitch angle in radians (X axis)
  4555. * @param roll defines the roll angle in radians (Z axis)
  4556. * @returns the new rotation matrix
  4557. */
  4558. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4559. /**
  4560. * Creates a rotation matrix and stores it in a given matrix
  4561. * @param yaw defines the yaw angle in radians (Y axis)
  4562. * @param pitch defines the pitch angle in radians (X axis)
  4563. * @param roll defines the roll angle in radians (Z axis)
  4564. * @param result defines the target matrix
  4565. */
  4566. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4567. /**
  4568. * Creates a scaling matrix
  4569. * @param x defines the scale factor on X axis
  4570. * @param y defines the scale factor on Y axis
  4571. * @param z defines the scale factor on Z axis
  4572. * @returns the new matrix
  4573. */
  4574. static Scaling(x: number, y: number, z: number): Matrix;
  4575. /**
  4576. * Creates a scaling matrix and stores it in a given matrix
  4577. * @param x defines the scale factor on X axis
  4578. * @param y defines the scale factor on Y axis
  4579. * @param z defines the scale factor on Z axis
  4580. * @param result defines the target matrix
  4581. */
  4582. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4583. /**
  4584. * Creates a translation matrix
  4585. * @param x defines the translation on X axis
  4586. * @param y defines the translation on Y axis
  4587. * @param z defines the translationon Z axis
  4588. * @returns the new matrix
  4589. */
  4590. static Translation(x: number, y: number, z: number): Matrix;
  4591. /**
  4592. * Creates a translation matrix and stores it in a given matrix
  4593. * @param x defines the translation on X axis
  4594. * @param y defines the translation on Y axis
  4595. * @param z defines the translationon Z axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4599. /**
  4600. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4601. * @param startValue defines the start value
  4602. * @param endValue defines the end value
  4603. * @param gradient defines the gradient factor
  4604. * @returns the new matrix
  4605. */
  4606. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4607. /**
  4608. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4609. * @param startValue defines the start value
  4610. * @param endValue defines the end value
  4611. * @param gradient defines the gradient factor
  4612. * @param result defines the Matrix object where to store data
  4613. */
  4614. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Builds a new matrix whose values are computed by:
  4617. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4618. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4619. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4620. * @param startValue defines the first matrix
  4621. * @param endValue defines the second matrix
  4622. * @param gradient defines the gradient between the two matrices
  4623. * @returns the new matrix
  4624. */
  4625. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4626. /**
  4627. * Update a matrix to values which are computed by:
  4628. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4629. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4630. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4631. * @param startValue defines the first matrix
  4632. * @param endValue defines the second matrix
  4633. * @param gradient defines the gradient between the two matrices
  4634. * @param result defines the target matrix
  4635. */
  4636. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4637. /**
  4638. * 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"
  4639. * This function works in left handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * 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".
  4648. * This function works in left handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * 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"
  4657. * This function works in right handed mode
  4658. * @param eye defines the final position of the entity
  4659. * @param target defines where the entity should look at
  4660. * @param up defines the up vector for the entity
  4661. * @returns the new matrix
  4662. */
  4663. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4664. /**
  4665. * 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".
  4666. * This function works in right handed mode
  4667. * @param eye defines the final position of the entity
  4668. * @param target defines where the entity should look at
  4669. * @param up defines the up vector for the entity
  4670. * @param result defines the target matrix
  4671. */
  4672. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param width defines the viewport width
  4676. * @param height defines the viewport height
  4677. * @param znear defines the near clip plane
  4678. * @param zfar defines the far clip plane
  4679. * @returns a new matrix as a left-handed orthographic projection matrix
  4680. */
  4681. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4682. /**
  4683. * Store a left-handed orthographic projection to a given matrix
  4684. * @param width defines the viewport width
  4685. * @param height defines the viewport height
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Create a left-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a left-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a right-handed orthographic projection matrix
  4715. * @param left defines the viewport left coordinate
  4716. * @param right defines the viewport right coordinate
  4717. * @param bottom defines the viewport bottom coordinate
  4718. * @param top defines the viewport top coordinate
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed orthographic projection matrix
  4722. */
  4723. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed orthographic projection into a given matrix
  4726. * @param left defines the viewport left coordinate
  4727. * @param right defines the viewport right coordinate
  4728. * @param bottom defines the viewport bottom coordinate
  4729. * @param top defines the viewport top coordinate
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @param result defines the target matrix
  4733. */
  4734. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4735. /**
  4736. * Creates a left-handed perspective projection matrix
  4737. * @param width defines the viewport width
  4738. * @param height defines the viewport height
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a left-handed perspective projection matrix
  4742. */
  4743. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Creates a left-handed perspective projection matrix
  4746. * @param fov defines the horizontal field of view
  4747. * @param aspect defines the aspect ratio
  4748. * @param znear defines the near clip plane
  4749. * @param zfar defines the far clip plane
  4750. * @returns a new matrix as a left-handed perspective projection matrix
  4751. */
  4752. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4753. /**
  4754. * Stores a left-handed perspective projection into a given matrix
  4755. * @param fov defines the horizontal field of view
  4756. * @param aspect defines the aspect ratio
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @param result defines the target matrix
  4760. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4761. */
  4762. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4763. /**
  4764. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4765. * @param fov defines the horizontal field of view
  4766. * @param aspect defines the aspect ratio
  4767. * @param znear defines the near clip plane
  4768. * @param zfar not used as infinity is used as far clip
  4769. * @param result defines the target matrix
  4770. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4771. */
  4772. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4773. /**
  4774. * Creates a right-handed perspective projection matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @returns a new matrix as a right-handed perspective projection matrix
  4780. */
  4781. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4782. /**
  4783. * Stores a right-handed perspective projection into a given matrix
  4784. * @param fov defines the horizontal field of view
  4785. * @param aspect defines the aspect ratio
  4786. * @param znear defines the near clip plane
  4787. * @param zfar defines the far clip plane
  4788. * @param result defines the target matrix
  4789. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4790. */
  4791. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4792. /**
  4793. * Stores a right-handed perspective projection into a given matrix
  4794. * @param fov defines the horizontal field of view
  4795. * @param aspect defines the aspect ratio
  4796. * @param znear defines the near clip plane
  4797. * @param zfar not used as infinity is used as far clip
  4798. * @param result defines the target matrix
  4799. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4800. */
  4801. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4802. /**
  4803. * Stores a perspective projection for WebVR info a given matrix
  4804. * @param fov defines the field of view
  4805. * @param znear defines the near clip plane
  4806. * @param zfar defines the far clip plane
  4807. * @param result defines the target matrix
  4808. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4809. */
  4810. static PerspectiveFovWebVRToRef(fov: {
  4811. upDegrees: number;
  4812. downDegrees: number;
  4813. leftDegrees: number;
  4814. rightDegrees: number;
  4815. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4816. /**
  4817. * Computes a complete transformation matrix
  4818. * @param viewport defines the viewport to use
  4819. * @param world defines the world matrix
  4820. * @param view defines the view matrix
  4821. * @param projection defines the projection matrix
  4822. * @param zmin defines the near clip plane
  4823. * @param zmax defines the far clip plane
  4824. * @returns the transformation matrix
  4825. */
  4826. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4827. /**
  4828. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4829. * @param matrix defines the matrix to use
  4830. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4831. */
  4832. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4833. /**
  4834. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4835. * @param matrix defines the matrix to use
  4836. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4837. */
  4838. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4839. /**
  4840. * Compute the transpose of a given matrix
  4841. * @param matrix defines the matrix to transpose
  4842. * @returns the new matrix
  4843. */
  4844. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4845. /**
  4846. * Compute the transpose of a matrix and store it in a target matrix
  4847. * @param matrix defines the matrix to transpose
  4848. * @param result defines the target matrix
  4849. */
  4850. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4851. /**
  4852. * Computes a reflection matrix from a plane
  4853. * @param plane defines the reflection plane
  4854. * @returns a new matrix
  4855. */
  4856. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4857. /**
  4858. * Computes a reflection matrix from a plane
  4859. * @param plane defines the reflection plane
  4860. * @param result defines the target matrix
  4861. */
  4862. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4863. /**
  4864. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4865. * @param xaxis defines the value of the 1st axis
  4866. * @param yaxis defines the value of the 2nd axis
  4867. * @param zaxis defines the value of the 3rd axis
  4868. * @param result defines the target matrix
  4869. */
  4870. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4871. /**
  4872. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4873. * @param quat defines the quaternion to use
  4874. * @param result defines the target matrix
  4875. */
  4876. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4877. }
  4878. /**
  4879. * @hidden
  4880. */
  4881. export class TmpVectors {
  4882. static Vector2: Vector2[];
  4883. static Vector3: Vector3[];
  4884. static Vector4: Vector4[];
  4885. static Quaternion: Quaternion[];
  4886. static Matrix: Matrix[];
  4887. }
  4888. }
  4889. declare module "babylonjs/Maths/math.path" {
  4890. import { DeepImmutable, Nullable } from "babylonjs/types";
  4891. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4892. /**
  4893. * Defines potential orientation for back face culling
  4894. */
  4895. export enum Orientation {
  4896. /**
  4897. * Clockwise
  4898. */
  4899. CW = 0,
  4900. /** Counter clockwise */
  4901. CCW = 1
  4902. }
  4903. /** Class used to represent a Bezier curve */
  4904. export class BezierCurve {
  4905. /**
  4906. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4907. * @param t defines the time
  4908. * @param x1 defines the left coordinate on X axis
  4909. * @param y1 defines the left coordinate on Y axis
  4910. * @param x2 defines the right coordinate on X axis
  4911. * @param y2 defines the right coordinate on Y axis
  4912. * @returns the interpolated value
  4913. */
  4914. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4915. }
  4916. /**
  4917. * Defines angle representation
  4918. */
  4919. export class Angle {
  4920. private _radians;
  4921. /**
  4922. * Creates an Angle object of "radians" radians (float).
  4923. * @param radians the angle in radians
  4924. */
  4925. constructor(radians: number);
  4926. /**
  4927. * Get value in degrees
  4928. * @returns the Angle value in degrees (float)
  4929. */
  4930. degrees(): number;
  4931. /**
  4932. * Get value in radians
  4933. * @returns the Angle value in radians (float)
  4934. */
  4935. radians(): number;
  4936. /**
  4937. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4938. * @param a defines first point as the origin
  4939. * @param b defines point
  4940. * @returns a new Angle
  4941. */
  4942. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4943. /**
  4944. * Gets a new Angle object from the given float in radians
  4945. * @param radians defines the angle value in radians
  4946. * @returns a new Angle
  4947. */
  4948. static FromRadians(radians: number): Angle;
  4949. /**
  4950. * Gets a new Angle object from the given float in degrees
  4951. * @param degrees defines the angle value in degrees
  4952. * @returns a new Angle
  4953. */
  4954. static FromDegrees(degrees: number): Angle;
  4955. }
  4956. /**
  4957. * This represents an arc in a 2d space.
  4958. */
  4959. export class Arc2 {
  4960. /** Defines the start point of the arc */
  4961. startPoint: Vector2;
  4962. /** Defines the mid point of the arc */
  4963. midPoint: Vector2;
  4964. /** Defines the end point of the arc */
  4965. endPoint: Vector2;
  4966. /**
  4967. * Defines the center point of the arc.
  4968. */
  4969. centerPoint: Vector2;
  4970. /**
  4971. * Defines the radius of the arc.
  4972. */
  4973. radius: number;
  4974. /**
  4975. * Defines the angle of the arc (from mid point to end point).
  4976. */
  4977. angle: Angle;
  4978. /**
  4979. * Defines the start angle of the arc (from start point to middle point).
  4980. */
  4981. startAngle: Angle;
  4982. /**
  4983. * Defines the orientation of the arc (clock wise/counter clock wise).
  4984. */
  4985. orientation: Orientation;
  4986. /**
  4987. * Creates an Arc object from the three given points : start, middle and end.
  4988. * @param startPoint Defines the start point of the arc
  4989. * @param midPoint Defines the midlle point of the arc
  4990. * @param endPoint Defines the end point of the arc
  4991. */
  4992. constructor(
  4993. /** Defines the start point of the arc */
  4994. startPoint: Vector2,
  4995. /** Defines the mid point of the arc */
  4996. midPoint: Vector2,
  4997. /** Defines the end point of the arc */
  4998. endPoint: Vector2);
  4999. }
  5000. /**
  5001. * Represents a 2D path made up of multiple 2D points
  5002. */
  5003. export class Path2 {
  5004. private _points;
  5005. private _length;
  5006. /**
  5007. * If the path start and end point are the same
  5008. */
  5009. closed: boolean;
  5010. /**
  5011. * Creates a Path2 object from the starting 2D coordinates x and y.
  5012. * @param x the starting points x value
  5013. * @param y the starting points y value
  5014. */
  5015. constructor(x: number, y: number);
  5016. /**
  5017. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5018. * @param x the added points x value
  5019. * @param y the added points y value
  5020. * @returns the updated Path2.
  5021. */
  5022. addLineTo(x: number, y: number): Path2;
  5023. /**
  5024. * 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.
  5025. * @param midX middle point x value
  5026. * @param midY middle point y value
  5027. * @param endX end point x value
  5028. * @param endY end point y value
  5029. * @param numberOfSegments (default: 36)
  5030. * @returns the updated Path2.
  5031. */
  5032. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5033. /**
  5034. * Closes the Path2.
  5035. * @returns the Path2.
  5036. */
  5037. close(): Path2;
  5038. /**
  5039. * Gets the sum of the distance between each sequential point in the path
  5040. * @returns the Path2 total length (float).
  5041. */
  5042. length(): number;
  5043. /**
  5044. * Gets the points which construct the path
  5045. * @returns the Path2 internal array of points.
  5046. */
  5047. getPoints(): Vector2[];
  5048. /**
  5049. * Retreives the point at the distance aways from the starting point
  5050. * @param normalizedLengthPosition the length along the path to retreive the point from
  5051. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5052. */
  5053. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5054. /**
  5055. * Creates a new path starting from an x and y position
  5056. * @param x starting x value
  5057. * @param y starting y value
  5058. * @returns a new Path2 starting at the coordinates (x, y).
  5059. */
  5060. static StartingAt(x: number, y: number): Path2;
  5061. }
  5062. /**
  5063. * Represents a 3D path made up of multiple 3D points
  5064. */
  5065. export class Path3D {
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[];
  5070. private _curve;
  5071. private _distances;
  5072. private _tangents;
  5073. private _normals;
  5074. private _binormals;
  5075. private _raw;
  5076. private _alignTangentsWithPath;
  5077. private readonly _pointAtData;
  5078. /**
  5079. * new Path3D(path, normal, raw)
  5080. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5081. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5082. * @param path an array of Vector3, the curve axis of the Path3D
  5083. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5084. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5085. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5086. */
  5087. constructor(
  5088. /**
  5089. * an array of Vector3, the curve axis of the Path3D
  5090. */
  5091. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5092. /**
  5093. * Returns the Path3D array of successive Vector3 designing its curve.
  5094. * @returns the Path3D array of successive Vector3 designing its curve.
  5095. */
  5096. getCurve(): Vector3[];
  5097. /**
  5098. * Returns the Path3D array of successive Vector3 designing its curve.
  5099. * @returns the Path3D array of successive Vector3 designing its curve.
  5100. */
  5101. getPoints(): Vector3[];
  5102. /**
  5103. * @returns the computed length (float) of the path.
  5104. */
  5105. length(): number;
  5106. /**
  5107. * Returns an array populated with tangent vectors on each Path3D curve point.
  5108. * @returns an array populated with tangent vectors on each Path3D curve point.
  5109. */
  5110. getTangents(): Vector3[];
  5111. /**
  5112. * Returns an array populated with normal vectors on each Path3D curve point.
  5113. * @returns an array populated with normal vectors on each Path3D curve point.
  5114. */
  5115. getNormals(): Vector3[];
  5116. /**
  5117. * Returns an array populated with binormal vectors on each Path3D curve point.
  5118. * @returns an array populated with binormal vectors on each Path3D curve point.
  5119. */
  5120. getBinormals(): Vector3[];
  5121. /**
  5122. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5123. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5124. */
  5125. getDistances(): number[];
  5126. /**
  5127. * Returns an interpolated point along this path
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @returns a new Vector3 as the point
  5130. */
  5131. getPointAt(position: number): Vector3;
  5132. /**
  5133. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5134. * @param position the position of the point along this path, from 0.0 to 1.0
  5135. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5136. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5137. */
  5138. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5139. /**
  5140. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5141. * @param position the position of the point along this path, from 0.0 to 1.0
  5142. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5143. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5144. */
  5145. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5146. /**
  5147. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5150. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5151. */
  5152. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5153. /**
  5154. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5155. * @param position the position of the point along this path, from 0.0 to 1.0
  5156. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5157. */
  5158. getDistanceAt(position: number): number;
  5159. /**
  5160. * Returns the array index of the previous point of an interpolated point along this path
  5161. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5162. * @returns the array index
  5163. */
  5164. getPreviousPointIndexAt(position: number): number;
  5165. /**
  5166. * 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)
  5167. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5168. * @returns the sub position
  5169. */
  5170. getSubPositionAt(position: number): number;
  5171. /**
  5172. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5173. * @param target the vector of which to get the closest position to
  5174. * @returns the position of the closest virtual point on this path to the target vector
  5175. */
  5176. getClosestPositionTo(target: Vector3): number;
  5177. /**
  5178. * Returns a sub path (slice) of this path
  5179. * @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
  5180. * @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
  5181. * @returns a sub path (slice) of this path
  5182. */
  5183. slice(start?: number, end?: number): Path3D;
  5184. /**
  5185. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5186. * @param path path which all values are copied into the curves points
  5187. * @param firstNormal which should be projected onto the curve
  5188. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5189. * @returns the same object updated.
  5190. */
  5191. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5192. private _compute;
  5193. private _getFirstNonNullVector;
  5194. private _getLastNonNullVector;
  5195. private _normalVector;
  5196. /**
  5197. * Updates the point at data for an interpolated point along this curve
  5198. * @param position the position of the point along this curve, from 0.0 to 1.0
  5199. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5200. * @returns the (updated) point at data
  5201. */
  5202. private _updatePointAtData;
  5203. /**
  5204. * Updates the point at data from the specified parameters
  5205. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5206. * @param point the interpolated point
  5207. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5208. */
  5209. private _setPointAtData;
  5210. /**
  5211. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5212. */
  5213. private _updateInterpolationMatrix;
  5214. }
  5215. /**
  5216. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5217. * A Curve3 is designed from a series of successive Vector3.
  5218. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5219. */
  5220. export class Curve3 {
  5221. private _points;
  5222. private _length;
  5223. /**
  5224. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5225. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5226. * @param v1 (Vector3) the control point
  5227. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5234. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5235. * @param v1 (Vector3) the first control point
  5236. * @param v2 (Vector3) the second control point
  5237. * @param v3 (Vector3) the end point of the Cubic Bezier
  5238. * @param nbPoints (integer) the wanted number of points in the curve
  5239. * @returns the created Curve3
  5240. */
  5241. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5242. /**
  5243. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5244. * @param p1 (Vector3) the origin point of the Hermite Spline
  5245. * @param t1 (Vector3) the tangent vector at the origin point
  5246. * @param p2 (Vector3) the end point of the Hermite Spline
  5247. * @param t2 (Vector3) the tangent vector at the end point
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a CatmullRom Spline curve :
  5254. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5255. * @param nbPoints (integer) the wanted number of points between each curve control points
  5256. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5257. * @returns the created Curve3
  5258. */
  5259. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5260. /**
  5261. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5262. * A Curve3 is designed from a series of successive Vector3.
  5263. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5264. * @param points points which make up the curve
  5265. */
  5266. constructor(points: Vector3[]);
  5267. /**
  5268. * @returns the Curve3 stored array of successive Vector3
  5269. */
  5270. getPoints(): Vector3[];
  5271. /**
  5272. * @returns the computed length (float) of the curve.
  5273. */
  5274. length(): number;
  5275. /**
  5276. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5277. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5278. * curveA and curveB keep unchanged.
  5279. * @param curve the curve to continue from this curve
  5280. * @returns the newly constructed curve
  5281. */
  5282. continue(curve: DeepImmutable<Curve3>): Curve3;
  5283. private _computeLength;
  5284. }
  5285. }
  5286. declare module "babylonjs/Animations/easing" {
  5287. /**
  5288. * This represents the main contract an easing function should follow.
  5289. * Easing functions are used throughout the animation system.
  5290. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export interface IEasingFunction {
  5293. /**
  5294. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5295. * of the easing function.
  5296. * The link below provides some of the most common examples of easing functions.
  5297. * @see https://easings.net/
  5298. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5299. * @returns the corresponding value on the curve defined by the easing function
  5300. */
  5301. ease(gradient: number): number;
  5302. }
  5303. /**
  5304. * Base class used for every default easing function.
  5305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5306. */
  5307. export class EasingFunction implements IEasingFunction {
  5308. /**
  5309. * Interpolation follows the mathematical formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEIN: number;
  5312. /**
  5313. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5314. */
  5315. static readonly EASINGMODE_EASEOUT: number;
  5316. /**
  5317. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5318. */
  5319. static readonly EASINGMODE_EASEINOUT: number;
  5320. private _easingMode;
  5321. /**
  5322. * Sets the easing mode of the current function.
  5323. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5324. */
  5325. setEasingMode(easingMode: number): void;
  5326. /**
  5327. * Gets the current easing mode.
  5328. * @returns the easing mode
  5329. */
  5330. getEasingMode(): number;
  5331. /**
  5332. * @hidden
  5333. */
  5334. easeInCore(gradient: number): number;
  5335. /**
  5336. * Given an input gradient between 0 and 1, this returns the corresponding value
  5337. * of the easing function.
  5338. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5339. * @returns the corresponding value on the curve defined by the easing function
  5340. */
  5341. ease(gradient: number): number;
  5342. }
  5343. /**
  5344. * Easing function with a circle shape (see link below).
  5345. * @see https://easings.net/#easeInCirc
  5346. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5347. */
  5348. export class CircleEase extends EasingFunction implements IEasingFunction {
  5349. /** @hidden */
  5350. easeInCore(gradient: number): number;
  5351. }
  5352. /**
  5353. * Easing function with a ease back shape (see link below).
  5354. * @see https://easings.net/#easeInBack
  5355. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5356. */
  5357. export class BackEase extends EasingFunction implements IEasingFunction {
  5358. /** Defines the amplitude of the function */
  5359. amplitude: number;
  5360. /**
  5361. * Instantiates a back ease easing
  5362. * @see https://easings.net/#easeInBack
  5363. * @param amplitude Defines the amplitude of the function
  5364. */
  5365. constructor(
  5366. /** Defines the amplitude of the function */
  5367. amplitude?: number);
  5368. /** @hidden */
  5369. easeInCore(gradient: number): number;
  5370. }
  5371. /**
  5372. * Easing function with a bouncing shape (see link below).
  5373. * @see https://easings.net/#easeInBounce
  5374. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5375. */
  5376. export class BounceEase extends EasingFunction implements IEasingFunction {
  5377. /** Defines the number of bounces */
  5378. bounces: number;
  5379. /** Defines the amplitude of the bounce */
  5380. bounciness: number;
  5381. /**
  5382. * Instantiates a bounce easing
  5383. * @see https://easings.net/#easeInBounce
  5384. * @param bounces Defines the number of bounces
  5385. * @param bounciness Defines the amplitude of the bounce
  5386. */
  5387. constructor(
  5388. /** Defines the number of bounces */
  5389. bounces?: number,
  5390. /** Defines the amplitude of the bounce */
  5391. bounciness?: number);
  5392. /** @hidden */
  5393. easeInCore(gradient: number): number;
  5394. }
  5395. /**
  5396. * Easing function with a power of 3 shape (see link below).
  5397. * @see https://easings.net/#easeInCubic
  5398. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5399. */
  5400. export class CubicEase extends EasingFunction implements IEasingFunction {
  5401. /** @hidden */
  5402. easeInCore(gradient: number): number;
  5403. }
  5404. /**
  5405. * Easing function with an elastic shape (see link below).
  5406. * @see https://easings.net/#easeInElastic
  5407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5408. */
  5409. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5410. /** Defines the number of oscillations*/
  5411. oscillations: number;
  5412. /** Defines the amplitude of the oscillations*/
  5413. springiness: number;
  5414. /**
  5415. * Instantiates an elastic easing function
  5416. * @see https://easings.net/#easeInElastic
  5417. * @param oscillations Defines the number of oscillations
  5418. * @param springiness Defines the amplitude of the oscillations
  5419. */
  5420. constructor(
  5421. /** Defines the number of oscillations*/
  5422. oscillations?: number,
  5423. /** Defines the amplitude of the oscillations*/
  5424. springiness?: number);
  5425. /** @hidden */
  5426. easeInCore(gradient: number): number;
  5427. }
  5428. /**
  5429. * Easing function with an exponential shape (see link below).
  5430. * @see https://easings.net/#easeInExpo
  5431. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5432. */
  5433. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5434. /** Defines the exponent of the function */
  5435. exponent: number;
  5436. /**
  5437. * Instantiates an exponential easing function
  5438. * @see https://easings.net/#easeInExpo
  5439. * @param exponent Defines the exponent of the function
  5440. */
  5441. constructor(
  5442. /** Defines the exponent of the function */
  5443. exponent?: number);
  5444. /** @hidden */
  5445. easeInCore(gradient: number): number;
  5446. }
  5447. /**
  5448. * Easing function with a power shape (see link below).
  5449. * @see https://easings.net/#easeInQuad
  5450. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5451. */
  5452. export class PowerEase extends EasingFunction implements IEasingFunction {
  5453. /** Defines the power of the function */
  5454. power: number;
  5455. /**
  5456. * Instantiates an power base easing function
  5457. * @see https://easings.net/#easeInQuad
  5458. * @param power Defines the power of the function
  5459. */
  5460. constructor(
  5461. /** Defines the power of the function */
  5462. power?: number);
  5463. /** @hidden */
  5464. easeInCore(gradient: number): number;
  5465. }
  5466. /**
  5467. * Easing function with a power of 2 shape (see link below).
  5468. * @see https://easings.net/#easeInQuad
  5469. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5470. */
  5471. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5472. /** @hidden */
  5473. easeInCore(gradient: number): number;
  5474. }
  5475. /**
  5476. * Easing function with a power of 4 shape (see link below).
  5477. * @see https://easings.net/#easeInQuart
  5478. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5479. */
  5480. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5481. /** @hidden */
  5482. easeInCore(gradient: number): number;
  5483. }
  5484. /**
  5485. * Easing function with a power of 5 shape (see link below).
  5486. * @see https://easings.net/#easeInQuint
  5487. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5488. */
  5489. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. /**
  5494. * Easing function with a sin shape (see link below).
  5495. * @see https://easings.net/#easeInSine
  5496. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5497. */
  5498. export class SineEase extends EasingFunction implements IEasingFunction {
  5499. /** @hidden */
  5500. easeInCore(gradient: number): number;
  5501. }
  5502. /**
  5503. * Easing function with a bezier shape (see link below).
  5504. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5505. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5506. */
  5507. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5508. /** Defines the x component of the start tangent in the bezier curve */
  5509. x1: number;
  5510. /** Defines the y component of the start tangent in the bezier curve */
  5511. y1: number;
  5512. /** Defines the x component of the end tangent in the bezier curve */
  5513. x2: number;
  5514. /** Defines the y component of the end tangent in the bezier curve */
  5515. y2: number;
  5516. /**
  5517. * Instantiates a bezier function
  5518. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5519. * @param x1 Defines the x component of the start tangent in the bezier curve
  5520. * @param y1 Defines the y component of the start tangent in the bezier curve
  5521. * @param x2 Defines the x component of the end tangent in the bezier curve
  5522. * @param y2 Defines the y component of the end tangent in the bezier curve
  5523. */
  5524. constructor(
  5525. /** Defines the x component of the start tangent in the bezier curve */
  5526. x1?: number,
  5527. /** Defines the y component of the start tangent in the bezier curve */
  5528. y1?: number,
  5529. /** Defines the x component of the end tangent in the bezier curve */
  5530. x2?: number,
  5531. /** Defines the y component of the end tangent in the bezier curve */
  5532. y2?: number);
  5533. /** @hidden */
  5534. easeInCore(gradient: number): number;
  5535. }
  5536. }
  5537. declare module "babylonjs/Maths/math.color" {
  5538. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5539. /**
  5540. * Class used to hold a RBG color
  5541. */
  5542. export class Color3 {
  5543. /**
  5544. * Defines the red component (between 0 and 1, default is 0)
  5545. */
  5546. r: number;
  5547. /**
  5548. * Defines the green component (between 0 and 1, default is 0)
  5549. */
  5550. g: number;
  5551. /**
  5552. * Defines the blue component (between 0 and 1, default is 0)
  5553. */
  5554. b: number;
  5555. /**
  5556. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5557. * @param r defines the red component (between 0 and 1, default is 0)
  5558. * @param g defines the green component (between 0 and 1, default is 0)
  5559. * @param b defines the blue component (between 0 and 1, default is 0)
  5560. */
  5561. constructor(
  5562. /**
  5563. * Defines the red component (between 0 and 1, default is 0)
  5564. */
  5565. r?: number,
  5566. /**
  5567. * Defines the green component (between 0 and 1, default is 0)
  5568. */
  5569. g?: number,
  5570. /**
  5571. * Defines the blue component (between 0 and 1, default is 0)
  5572. */
  5573. b?: number);
  5574. /**
  5575. * Creates a string with the Color3 current values
  5576. * @returns the string representation of the Color3 object
  5577. */
  5578. toString(): string;
  5579. /**
  5580. * Returns the string "Color3"
  5581. * @returns "Color3"
  5582. */
  5583. getClassName(): string;
  5584. /**
  5585. * Compute the Color3 hash code
  5586. * @returns an unique number that can be used to hash Color3 objects
  5587. */
  5588. getHashCode(): number;
  5589. /**
  5590. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5591. * @param array defines the array where to store the r,g,b components
  5592. * @param index defines an optional index in the target array to define where to start storing values
  5593. * @returns the current Color3 object
  5594. */
  5595. toArray(array: FloatArray, index?: number): Color3;
  5596. /**
  5597. * Update the current color with values stored in an array from the starting index of the given array
  5598. * @param array defines the source array
  5599. * @param offset defines an offset in the source array
  5600. * @returns the current Color3 object
  5601. */
  5602. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5603. /**
  5604. * Returns a new Color4 object from the current Color3 and the given alpha
  5605. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5606. * @returns a new Color4 object
  5607. */
  5608. toColor4(alpha?: number): Color4;
  5609. /**
  5610. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5611. * @returns the new array
  5612. */
  5613. asArray(): number[];
  5614. /**
  5615. * Returns the luminance value
  5616. * @returns a float value
  5617. */
  5618. toLuminance(): number;
  5619. /**
  5620. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5621. * @param otherColor defines the second operand
  5622. * @returns the new Color3 object
  5623. */
  5624. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5625. /**
  5626. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5627. * @param otherColor defines the second operand
  5628. * @param result defines the Color3 object where to store the result
  5629. * @returns the current Color3
  5630. */
  5631. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5632. /**
  5633. * Determines equality between Color3 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgb values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color3>): boolean;
  5638. /**
  5639. * Determines equality between the current Color3 object and a set of r,b,g values
  5640. * @param r defines the red component to check
  5641. * @param g defines the green component to check
  5642. * @param b defines the blue component to check
  5643. * @returns true if the rgb values are equal to the given ones
  5644. */
  5645. equalsFloats(r: number, g: number, b: number): boolean;
  5646. /**
  5647. * Multiplies in place each rgb value by scale
  5648. * @param scale defines the scaling factor
  5649. * @returns the updated Color3
  5650. */
  5651. scale(scale: number): Color3;
  5652. /**
  5653. * Multiplies the rgb values by scale and stores the result into "result"
  5654. * @param scale defines the scaling factor
  5655. * @param result defines the Color3 object where to store the result
  5656. * @returns the unmodified current Color3
  5657. */
  5658. scaleToRef(scale: number, result: Color3): Color3;
  5659. /**
  5660. * Scale the current Color3 values by a factor and add the result to a given Color3
  5661. * @param scale defines the scale factor
  5662. * @param result defines color to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5666. /**
  5667. * Clamps the rgb values by the min and max values and stores the result into "result"
  5668. * @param min defines minimum clamping value (default is 0)
  5669. * @param max defines maximum clamping value (default is 1)
  5670. * @param result defines color to store the result into
  5671. * @returns the original Color3
  5672. */
  5673. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5674. /**
  5675. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5676. * @param otherColor defines the second operand
  5677. * @returns the new Color3
  5678. */
  5679. add(otherColor: DeepImmutable<Color3>): Color3;
  5680. /**
  5681. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5682. * @param otherColor defines the second operand
  5683. * @param result defines Color3 object to store the result into
  5684. * @returns the unmodified current Color3
  5685. */
  5686. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5687. /**
  5688. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5689. * @param otherColor defines the second operand
  5690. * @returns the new Color3
  5691. */
  5692. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5693. /**
  5694. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5695. * @param otherColor defines the second operand
  5696. * @param result defines Color3 object to store the result into
  5697. * @returns the unmodified current Color3
  5698. */
  5699. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5700. /**
  5701. * Copy the current object
  5702. * @returns a new Color3 copied the current one
  5703. */
  5704. clone(): Color3;
  5705. /**
  5706. * Copies the rgb values from the source in the current Color3
  5707. * @param source defines the source Color3 object
  5708. * @returns the updated Color3 object
  5709. */
  5710. copyFrom(source: DeepImmutable<Color3>): Color3;
  5711. /**
  5712. * Updates the Color3 rgb values from the given floats
  5713. * @param r defines the red component to read from
  5714. * @param g defines the green component to read from
  5715. * @param b defines the blue component to read from
  5716. * @returns the current Color3 object
  5717. */
  5718. copyFromFloats(r: number, g: number, b: number): Color3;
  5719. /**
  5720. * Updates the Color3 rgb values from the given floats
  5721. * @param r defines the red component to read from
  5722. * @param g defines the green component to read from
  5723. * @param b defines the blue component to read from
  5724. * @returns the current Color3 object
  5725. */
  5726. set(r: number, g: number, b: number): Color3;
  5727. /**
  5728. * Compute the Color3 hexadecimal code as a string
  5729. * @returns a string containing the hexadecimal representation of the Color3 object
  5730. */
  5731. toHexString(): string;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to linear space
  5734. * @returns a new Color3 object
  5735. */
  5736. toLinearSpace(): Color3;
  5737. /**
  5738. * Converts current color in rgb space to HSV values
  5739. * @returns a new color3 representing the HSV values
  5740. */
  5741. toHSV(): Color3;
  5742. /**
  5743. * Converts current color in rgb space to HSV values
  5744. * @param result defines the Color3 where to store the HSV values
  5745. */
  5746. toHSVToRef(result: Color3): void;
  5747. /**
  5748. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5749. * @param convertedColor defines the Color3 object where to store the linear space version
  5750. * @returns the unmodified Color3
  5751. */
  5752. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5753. /**
  5754. * Computes a new Color3 converted from the current one to gamma space
  5755. * @returns a new Color3 object
  5756. */
  5757. toGammaSpace(): Color3;
  5758. /**
  5759. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5760. * @param convertedColor defines the Color3 object where to store the gamma space version
  5761. * @returns the unmodified Color3
  5762. */
  5763. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5764. private static _BlackReadOnly;
  5765. /**
  5766. * Convert Hue, saturation and value to a Color3 (RGB)
  5767. * @param hue defines the hue
  5768. * @param saturation defines the saturation
  5769. * @param value defines the value
  5770. * @param result defines the Color3 where to store the RGB values
  5771. */
  5772. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5773. /**
  5774. * Creates a new Color3 from the string containing valid hexadecimal values
  5775. * @param hex defines a string containing valid hexadecimal values
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromHexString(hex: string): Color3;
  5779. /**
  5780. * Creates a new Color3 from the starting index of the given array
  5781. * @param array defines the source array
  5782. * @param offset defines an offset in the source array
  5783. * @returns a new Color3 object
  5784. */
  5785. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5786. /**
  5787. * Creates a new Color3 from the starting index element of the given array
  5788. * @param array defines the source array to read from
  5789. * @param offset defines the offset in the source array
  5790. * @param result defines the target Color3 object
  5791. */
  5792. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from integer values (< 256)
  5795. * @param r defines the red component to read from (value between 0 and 255)
  5796. * @param g defines the green component to read from (value between 0 and 255)
  5797. * @param b defines the blue component to read from (value between 0 and 255)
  5798. * @returns a new Color3 object
  5799. */
  5800. static FromInts(r: number, g: number, b: number): Color3;
  5801. /**
  5802. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5803. * @param start defines the start Color3 value
  5804. * @param end defines the end Color3 value
  5805. * @param amount defines the gradient value between start and end
  5806. * @returns a new Color3 object
  5807. */
  5808. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5809. /**
  5810. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5811. * @param left defines the start value
  5812. * @param right defines the end value
  5813. * @param amount defines the gradient factor
  5814. * @param result defines the Color3 object where to store the result
  5815. */
  5816. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5817. /**
  5818. * Returns a Color3 value containing a red color
  5819. * @returns a new Color3 object
  5820. */
  5821. static Red(): Color3;
  5822. /**
  5823. * Returns a Color3 value containing a green color
  5824. * @returns a new Color3 object
  5825. */
  5826. static Green(): Color3;
  5827. /**
  5828. * Returns a Color3 value containing a blue color
  5829. * @returns a new Color3 object
  5830. */
  5831. static Blue(): Color3;
  5832. /**
  5833. * Returns a Color3 value containing a black color
  5834. * @returns a new Color3 object
  5835. */
  5836. static Black(): Color3;
  5837. /**
  5838. * Gets a Color3 value containing a black color that must not be updated
  5839. */
  5840. static get BlackReadOnly(): DeepImmutable<Color3>;
  5841. /**
  5842. * Returns a Color3 value containing a white color
  5843. * @returns a new Color3 object
  5844. */
  5845. static White(): Color3;
  5846. /**
  5847. * Returns a Color3 value containing a purple color
  5848. * @returns a new Color3 object
  5849. */
  5850. static Purple(): Color3;
  5851. /**
  5852. * Returns a Color3 value containing a magenta color
  5853. * @returns a new Color3 object
  5854. */
  5855. static Magenta(): Color3;
  5856. /**
  5857. * Returns a Color3 value containing a yellow color
  5858. * @returns a new Color3 object
  5859. */
  5860. static Yellow(): Color3;
  5861. /**
  5862. * Returns a Color3 value containing a gray color
  5863. * @returns a new Color3 object
  5864. */
  5865. static Gray(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a teal color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Teal(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a random color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Random(): Color3;
  5876. }
  5877. /**
  5878. * Class used to hold a RBGA color
  5879. */
  5880. export class Color4 {
  5881. /**
  5882. * Defines the red component (between 0 and 1, default is 0)
  5883. */
  5884. r: number;
  5885. /**
  5886. * Defines the green component (between 0 and 1, default is 0)
  5887. */
  5888. g: number;
  5889. /**
  5890. * Defines the blue component (between 0 and 1, default is 0)
  5891. */
  5892. b: number;
  5893. /**
  5894. * Defines the alpha component (between 0 and 1, default is 1)
  5895. */
  5896. a: number;
  5897. /**
  5898. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5899. * @param r defines the red component (between 0 and 1, default is 0)
  5900. * @param g defines the green component (between 0 and 1, default is 0)
  5901. * @param b defines the blue component (between 0 and 1, default is 0)
  5902. * @param a defines the alpha component (between 0 and 1, default is 1)
  5903. */
  5904. constructor(
  5905. /**
  5906. * Defines the red component (between 0 and 1, default is 0)
  5907. */
  5908. r?: number,
  5909. /**
  5910. * Defines the green component (between 0 and 1, default is 0)
  5911. */
  5912. g?: number,
  5913. /**
  5914. * Defines the blue component (between 0 and 1, default is 0)
  5915. */
  5916. b?: number,
  5917. /**
  5918. * Defines the alpha component (between 0 and 1, default is 1)
  5919. */
  5920. a?: number);
  5921. /**
  5922. * Adds in place the given Color4 values to the current Color4 object
  5923. * @param right defines the second operand
  5924. * @returns the current updated Color4 object
  5925. */
  5926. addInPlace(right: DeepImmutable<Color4>): Color4;
  5927. /**
  5928. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5929. * @returns the new array
  5930. */
  5931. asArray(): number[];
  5932. /**
  5933. * Stores from the starting index in the given array the Color4 successive values
  5934. * @param array defines the array where to store the r,g,b components
  5935. * @param index defines an optional index in the target array to define where to start storing values
  5936. * @returns the current Color4 object
  5937. */
  5938. toArray(array: number[], index?: number): Color4;
  5939. /**
  5940. * Update the current color with values stored in an array from the starting index of the given array
  5941. * @param array defines the source array
  5942. * @param offset defines an offset in the source array
  5943. * @returns the current Color4 object
  5944. */
  5945. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5946. /**
  5947. * Determines equality between Color4 objects
  5948. * @param otherColor defines the second operand
  5949. * @returns true if the rgba values are equal to the given ones
  5950. */
  5951. equals(otherColor: DeepImmutable<Color4>): boolean;
  5952. /**
  5953. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5954. * @param right defines the second operand
  5955. * @returns a new Color4 object
  5956. */
  5957. add(right: DeepImmutable<Color4>): Color4;
  5958. /**
  5959. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5960. * @param right defines the second operand
  5961. * @returns a new Color4 object
  5962. */
  5963. subtract(right: DeepImmutable<Color4>): Color4;
  5964. /**
  5965. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5966. * @param right defines the second operand
  5967. * @param result defines the Color4 object where to store the result
  5968. * @returns the current Color4 object
  5969. */
  5970. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5971. /**
  5972. * Creates a new Color4 with the current Color4 values multiplied by scale
  5973. * @param scale defines the scaling factor to apply
  5974. * @returns a new Color4 object
  5975. */
  5976. scale(scale: number): Color4;
  5977. /**
  5978. * Multiplies the current Color4 values by scale and stores the result in "result"
  5979. * @param scale defines the scaling factor to apply
  5980. * @param result defines the Color4 object where to store the result
  5981. * @returns the current unmodified Color4
  5982. */
  5983. scaleToRef(scale: number, result: Color4): Color4;
  5984. /**
  5985. * Scale the current Color4 values by a factor and add the result to a given Color4
  5986. * @param scale defines the scale factor
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the unmodified current Color4
  5989. */
  5990. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5991. /**
  5992. * Clamps the rgb values by the min and max values and stores the result into "result"
  5993. * @param min defines minimum clamping value (default is 0)
  5994. * @param max defines maximum clamping value (default is 1)
  5995. * @param result defines color to store the result into.
  5996. * @returns the cuurent Color4
  5997. */
  5998. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5999. /**
  6000. * Multipy an Color4 value by another and return a new Color4 object
  6001. * @param color defines the Color4 value to multiply by
  6002. * @returns a new Color4 object
  6003. */
  6004. multiply(color: Color4): Color4;
  6005. /**
  6006. * Multipy a Color4 value by another and push the result in a reference value
  6007. * @param color defines the Color4 value to multiply by
  6008. * @param result defines the Color4 to fill the result in
  6009. * @returns the result Color4
  6010. */
  6011. multiplyToRef(color: Color4, result: Color4): Color4;
  6012. /**
  6013. * Creates a string with the Color4 current values
  6014. * @returns the string representation of the Color4 object
  6015. */
  6016. toString(): string;
  6017. /**
  6018. * Returns the string "Color4"
  6019. * @returns "Color4"
  6020. */
  6021. getClassName(): string;
  6022. /**
  6023. * Compute the Color4 hash code
  6024. * @returns an unique number that can be used to hash Color4 objects
  6025. */
  6026. getHashCode(): number;
  6027. /**
  6028. * Creates a new Color4 copied from the current one
  6029. * @returns a new Color4 object
  6030. */
  6031. clone(): Color4;
  6032. /**
  6033. * Copies the given Color4 values into the current one
  6034. * @param source defines the source Color4 object
  6035. * @returns the current updated Color4 object
  6036. */
  6037. copyFrom(source: Color4): Color4;
  6038. /**
  6039. * Copies the given float values into the current one
  6040. * @param r defines the red component to read from
  6041. * @param g defines the green component to read from
  6042. * @param b defines the blue component to read from
  6043. * @param a defines the alpha component to read from
  6044. * @returns the current updated Color4 object
  6045. */
  6046. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6047. /**
  6048. * Copies the given float values into the current one
  6049. * @param r defines the red component to read from
  6050. * @param g defines the green component to read from
  6051. * @param b defines the blue component to read from
  6052. * @param a defines the alpha component to read from
  6053. * @returns the current updated Color4 object
  6054. */
  6055. set(r: number, g: number, b: number, a: number): Color4;
  6056. /**
  6057. * Compute the Color4 hexadecimal code as a string
  6058. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6059. * @returns a string containing the hexadecimal representation of the Color4 object
  6060. */
  6061. toHexString(returnAsColor3?: boolean): string;
  6062. /**
  6063. * Computes a new Color4 converted from the current one to linear space
  6064. * @returns a new Color4 object
  6065. */
  6066. toLinearSpace(): Color4;
  6067. /**
  6068. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6069. * @param convertedColor defines the Color4 object where to store the linear space version
  6070. * @returns the unmodified Color4
  6071. */
  6072. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6073. /**
  6074. * Computes a new Color4 converted from the current one to gamma space
  6075. * @returns a new Color4 object
  6076. */
  6077. toGammaSpace(): Color4;
  6078. /**
  6079. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6080. * @param convertedColor defines the Color4 object where to store the gamma space version
  6081. * @returns the unmodified Color4
  6082. */
  6083. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6084. /**
  6085. * Creates a new Color4 from the string containing valid hexadecimal values
  6086. * @param hex defines a string containing valid hexadecimal values
  6087. * @returns a new Color4 object
  6088. */
  6089. static FromHexString(hex: string): Color4;
  6090. /**
  6091. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6092. * @param left defines the start value
  6093. * @param right defines the end value
  6094. * @param amount defines the gradient factor
  6095. * @returns a new Color4 object
  6096. */
  6097. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6098. /**
  6099. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6100. * @param left defines the start value
  6101. * @param right defines the end value
  6102. * @param amount defines the gradient factor
  6103. * @param result defines the Color4 object where to store data
  6104. */
  6105. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6106. /**
  6107. * Creates a new Color4 from a Color3 and an alpha value
  6108. * @param color3 defines the source Color3 to read from
  6109. * @param alpha defines the alpha component (1.0 by default)
  6110. * @returns a new Color4 object
  6111. */
  6112. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6113. /**
  6114. * Creates a new Color4 from the starting index element of the given array
  6115. * @param array defines the source array to read from
  6116. * @param offset defines the offset in the source array
  6117. * @returns a new Color4 object
  6118. */
  6119. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6120. /**
  6121. * Creates a new Color4 from the starting index element of the given array
  6122. * @param array defines the source array to read from
  6123. * @param offset defines the offset in the source array
  6124. * @param result defines the target Color4 object
  6125. */
  6126. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6127. /**
  6128. * Creates a new Color3 from integer values (< 256)
  6129. * @param r defines the red component to read from (value between 0 and 255)
  6130. * @param g defines the green component to read from (value between 0 and 255)
  6131. * @param b defines the blue component to read from (value between 0 and 255)
  6132. * @param a defines the alpha component to read from (value between 0 and 255)
  6133. * @returns a new Color3 object
  6134. */
  6135. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6136. /**
  6137. * Check the content of a given array and convert it to an array containing RGBA data
  6138. * If the original array was already containing count * 4 values then it is returned directly
  6139. * @param colors defines the array to check
  6140. * @param count defines the number of RGBA data to expect
  6141. * @returns an array containing count * 4 values (RGBA)
  6142. */
  6143. static CheckColors4(colors: number[], count: number): number[];
  6144. }
  6145. /**
  6146. * @hidden
  6147. */
  6148. export class TmpColors {
  6149. static Color3: Color3[];
  6150. static Color4: Color4[];
  6151. }
  6152. }
  6153. declare module "babylonjs/Animations/animationKey" {
  6154. /**
  6155. * Defines an interface which represents an animation key frame
  6156. */
  6157. export interface IAnimationKey {
  6158. /**
  6159. * Frame of the key frame
  6160. */
  6161. frame: number;
  6162. /**
  6163. * Value at the specifies key frame
  6164. */
  6165. value: any;
  6166. /**
  6167. * The input tangent for the cubic hermite spline
  6168. */
  6169. inTangent?: any;
  6170. /**
  6171. * The output tangent for the cubic hermite spline
  6172. */
  6173. outTangent?: any;
  6174. /**
  6175. * The animation interpolation type
  6176. */
  6177. interpolation?: AnimationKeyInterpolation;
  6178. }
  6179. /**
  6180. * Enum for the animation key frame interpolation type
  6181. */
  6182. export enum AnimationKeyInterpolation {
  6183. /**
  6184. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6185. */
  6186. STEP = 1
  6187. }
  6188. }
  6189. declare module "babylonjs/Animations/animationRange" {
  6190. /**
  6191. * Represents the range of an animation
  6192. */
  6193. export class AnimationRange {
  6194. /**The name of the animation range**/
  6195. name: string;
  6196. /**The starting frame of the animation */
  6197. from: number;
  6198. /**The ending frame of the animation*/
  6199. to: number;
  6200. /**
  6201. * Initializes the range of an animation
  6202. * @param name The name of the animation range
  6203. * @param from The starting frame of the animation
  6204. * @param to The ending frame of the animation
  6205. */
  6206. constructor(
  6207. /**The name of the animation range**/
  6208. name: string,
  6209. /**The starting frame of the animation */
  6210. from: number,
  6211. /**The ending frame of the animation*/
  6212. to: number);
  6213. /**
  6214. * Makes a copy of the animation range
  6215. * @returns A copy of the animation range
  6216. */
  6217. clone(): AnimationRange;
  6218. }
  6219. }
  6220. declare module "babylonjs/Animations/animationEvent" {
  6221. /**
  6222. * Composed of a frame, and an action function
  6223. */
  6224. export class AnimationEvent {
  6225. /** The frame for which the event is triggered **/
  6226. frame: number;
  6227. /** The event to perform when triggered **/
  6228. action: (currentFrame: number) => void;
  6229. /** Specifies if the event should be triggered only once**/
  6230. onlyOnce?: boolean | undefined;
  6231. /**
  6232. * Specifies if the animation event is done
  6233. */
  6234. isDone: boolean;
  6235. /**
  6236. * Initializes the animation event
  6237. * @param frame The frame for which the event is triggered
  6238. * @param action The event to perform when triggered
  6239. * @param onlyOnce Specifies if the event should be triggered only once
  6240. */
  6241. constructor(
  6242. /** The frame for which the event is triggered **/
  6243. frame: number,
  6244. /** The event to perform when triggered **/
  6245. action: (currentFrame: number) => void,
  6246. /** Specifies if the event should be triggered only once**/
  6247. onlyOnce?: boolean | undefined);
  6248. /** @hidden */
  6249. _clone(): AnimationEvent;
  6250. }
  6251. }
  6252. declare module "babylonjs/Behaviors/behavior" {
  6253. import { Nullable } from "babylonjs/types";
  6254. /**
  6255. * Interface used to define a behavior
  6256. */
  6257. export interface Behavior<T> {
  6258. /** gets or sets behavior's name */
  6259. name: string;
  6260. /**
  6261. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6262. */
  6263. init(): void;
  6264. /**
  6265. * Called when the behavior is attached to a target
  6266. * @param target defines the target where the behavior is attached to
  6267. */
  6268. attach(target: T): void;
  6269. /**
  6270. * Called when the behavior is detached from its target
  6271. */
  6272. detach(): void;
  6273. }
  6274. /**
  6275. * Interface implemented by classes supporting behaviors
  6276. */
  6277. export interface IBehaviorAware<T> {
  6278. /**
  6279. * Attach a behavior
  6280. * @param behavior defines the behavior to attach
  6281. * @returns the current host
  6282. */
  6283. addBehavior(behavior: Behavior<T>): T;
  6284. /**
  6285. * Remove a behavior from the current object
  6286. * @param behavior defines the behavior to detach
  6287. * @returns the current host
  6288. */
  6289. removeBehavior(behavior: Behavior<T>): T;
  6290. /**
  6291. * Gets a behavior using its name to search
  6292. * @param name defines the name to search
  6293. * @returns the behavior or null if not found
  6294. */
  6295. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6296. }
  6297. }
  6298. declare module "babylonjs/Misc/smartArray" {
  6299. /**
  6300. * Defines an array and its length.
  6301. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6302. */
  6303. export interface ISmartArrayLike<T> {
  6304. /**
  6305. * The data of the array.
  6306. */
  6307. data: Array<T>;
  6308. /**
  6309. * The active length of the array.
  6310. */
  6311. length: number;
  6312. }
  6313. /**
  6314. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6315. */
  6316. export class SmartArray<T> implements ISmartArrayLike<T> {
  6317. /**
  6318. * The full set of data from the array.
  6319. */
  6320. data: Array<T>;
  6321. /**
  6322. * The active length of the array.
  6323. */
  6324. length: number;
  6325. protected _id: number;
  6326. /**
  6327. * Instantiates a Smart Array.
  6328. * @param capacity defines the default capacity of the array.
  6329. */
  6330. constructor(capacity: number);
  6331. /**
  6332. * Pushes a value at the end of the active data.
  6333. * @param value defines the object to push in the array.
  6334. */
  6335. push(value: T): void;
  6336. /**
  6337. * Iterates over the active data and apply the lambda to them.
  6338. * @param func defines the action to apply on each value.
  6339. */
  6340. forEach(func: (content: T) => void): void;
  6341. /**
  6342. * Sorts the full sets of data.
  6343. * @param compareFn defines the comparison function to apply.
  6344. */
  6345. sort(compareFn: (a: T, b: T) => number): void;
  6346. /**
  6347. * Resets the active data to an empty array.
  6348. */
  6349. reset(): void;
  6350. /**
  6351. * Releases all the data from the array as well as the array.
  6352. */
  6353. dispose(): void;
  6354. /**
  6355. * Concats the active data with a given array.
  6356. * @param array defines the data to concatenate with.
  6357. */
  6358. concat(array: any): void;
  6359. /**
  6360. * Returns the position of a value in the active data.
  6361. * @param value defines the value to find the index for
  6362. * @returns the index if found in the active data otherwise -1
  6363. */
  6364. indexOf(value: T): number;
  6365. /**
  6366. * Returns whether an element is part of the active data.
  6367. * @param value defines the value to look for
  6368. * @returns true if found in the active data otherwise false
  6369. */
  6370. contains(value: T): boolean;
  6371. private static _GlobalId;
  6372. }
  6373. /**
  6374. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6375. * The data in this array can only be present once
  6376. */
  6377. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6378. private _duplicateId;
  6379. /**
  6380. * Pushes a value at the end of the active data.
  6381. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6382. * @param value defines the object to push in the array.
  6383. */
  6384. push(value: T): void;
  6385. /**
  6386. * Pushes a value at the end of the active data.
  6387. * If the data is already present, it won t be added again
  6388. * @param value defines the object to push in the array.
  6389. * @returns true if added false if it was already present
  6390. */
  6391. pushNoDuplicate(value: T): boolean;
  6392. /**
  6393. * Resets the active data to an empty array.
  6394. */
  6395. reset(): void;
  6396. /**
  6397. * Concats the active data with a given array.
  6398. * This ensures no dupplicate will be present in the result.
  6399. * @param array defines the data to concatenate with.
  6400. */
  6401. concatWithNoDuplicate(array: any): void;
  6402. }
  6403. }
  6404. declare module "babylonjs/Cameras/cameraInputsManager" {
  6405. import { Nullable } from "babylonjs/types";
  6406. import { Camera } from "babylonjs/Cameras/camera";
  6407. /**
  6408. * @ignore
  6409. * This is a list of all the different input types that are available in the application.
  6410. * Fo instance: ArcRotateCameraGamepadInput...
  6411. */
  6412. export var CameraInputTypes: {};
  6413. /**
  6414. * This is the contract to implement in order to create a new input class.
  6415. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6416. */
  6417. export interface ICameraInput<TCamera extends Camera> {
  6418. /**
  6419. * Defines the camera the input is attached to.
  6420. */
  6421. camera: Nullable<TCamera>;
  6422. /**
  6423. * Gets the class name of the current intput.
  6424. * @returns the class name
  6425. */
  6426. getClassName(): string;
  6427. /**
  6428. * Get the friendly name associated with the input class.
  6429. * @returns the input friendly name
  6430. */
  6431. getSimpleName(): string;
  6432. /**
  6433. * Attach the input controls to a specific dom element to get the input from.
  6434. * @param element Defines the element the controls should be listened from
  6435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6436. */
  6437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6438. /**
  6439. * Detach the current controls from the specified dom element.
  6440. * @param element Defines the element to stop listening the inputs from
  6441. */
  6442. detachControl(element: Nullable<HTMLElement>): void;
  6443. /**
  6444. * Update the current camera state depending on the inputs that have been used this frame.
  6445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6446. */
  6447. checkInputs?: () => void;
  6448. }
  6449. /**
  6450. * Represents a map of input types to input instance or input index to input instance.
  6451. */
  6452. export interface CameraInputsMap<TCamera extends Camera> {
  6453. /**
  6454. * Accessor to the input by input type.
  6455. */
  6456. [name: string]: ICameraInput<TCamera>;
  6457. /**
  6458. * Accessor to the input by input index.
  6459. */
  6460. [idx: number]: ICameraInput<TCamera>;
  6461. }
  6462. /**
  6463. * This represents the input manager used within a camera.
  6464. * It helps dealing with all the different kind of input attached to a camera.
  6465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6466. */
  6467. export class CameraInputsManager<TCamera extends Camera> {
  6468. /**
  6469. * Defines the list of inputs attahed to the camera.
  6470. */
  6471. attached: CameraInputsMap<TCamera>;
  6472. /**
  6473. * Defines the dom element the camera is collecting inputs from.
  6474. * This is null if the controls have not been attached.
  6475. */
  6476. attachedElement: Nullable<HTMLElement>;
  6477. /**
  6478. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6479. */
  6480. noPreventDefault: boolean;
  6481. /**
  6482. * Defined the camera the input manager belongs to.
  6483. */
  6484. camera: TCamera;
  6485. /**
  6486. * Update the current camera state depending on the inputs that have been used this frame.
  6487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6488. */
  6489. checkInputs: () => void;
  6490. /**
  6491. * Instantiate a new Camera Input Manager.
  6492. * @param camera Defines the camera the input manager blongs to
  6493. */
  6494. constructor(camera: TCamera);
  6495. /**
  6496. * Add an input method to a camera
  6497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6498. * @param input camera input method
  6499. */
  6500. add(input: ICameraInput<TCamera>): void;
  6501. /**
  6502. * Remove a specific input method from a camera
  6503. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6504. * @param inputToRemove camera input method
  6505. */
  6506. remove(inputToRemove: ICameraInput<TCamera>): void;
  6507. /**
  6508. * Remove a specific input type from a camera
  6509. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6510. * @param inputType the type of the input to remove
  6511. */
  6512. removeByType(inputType: string): void;
  6513. private _addCheckInputs;
  6514. /**
  6515. * Attach the input controls to the currently attached dom element to listen the events from.
  6516. * @param input Defines the input to attach
  6517. */
  6518. attachInput(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6521. * @param element Defines the dom element to collect the events from
  6522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6523. */
  6524. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6525. /**
  6526. * Detach the current manager inputs controls from a specific dom element.
  6527. * @param element Defines the dom element to collect the events from
  6528. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6529. */
  6530. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6531. /**
  6532. * Rebuild the dynamic inputCheck function from the current list of
  6533. * defined inputs in the manager.
  6534. */
  6535. rebuildInputCheck(): void;
  6536. /**
  6537. * Remove all attached input methods from a camera
  6538. */
  6539. clear(): void;
  6540. /**
  6541. * Serialize the current input manager attached to a camera.
  6542. * This ensures than once parsed,
  6543. * the input associated to the camera will be identical to the current ones
  6544. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6545. */
  6546. serialize(serializedCamera: any): void;
  6547. /**
  6548. * Parses an input manager serialized JSON to restore the previous list of inputs
  6549. * and states associated to a camera.
  6550. * @param parsedCamera Defines the JSON to parse
  6551. */
  6552. parse(parsedCamera: any): void;
  6553. }
  6554. }
  6555. declare module "babylonjs/Meshes/buffer" {
  6556. import { Nullable, DataArray } from "babylonjs/types";
  6557. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6558. /**
  6559. * Class used to store data that will be store in GPU memory
  6560. */
  6561. export class Buffer {
  6562. private _engine;
  6563. private _buffer;
  6564. /** @hidden */
  6565. _data: Nullable<DataArray>;
  6566. private _updatable;
  6567. private _instanced;
  6568. private _divisor;
  6569. /**
  6570. * Gets the byte stride.
  6571. */
  6572. readonly byteStride: number;
  6573. /**
  6574. * Constructor
  6575. * @param engine the engine
  6576. * @param data the data to use for this buffer
  6577. * @param updatable whether the data is updatable
  6578. * @param stride the stride (optional)
  6579. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6580. * @param instanced whether the buffer is instanced (optional)
  6581. * @param useBytes set to true if the stride in in bytes (optional)
  6582. * @param divisor sets an optional divisor for instances (1 by default)
  6583. */
  6584. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6585. /**
  6586. * Create a new VertexBuffer based on the current buffer
  6587. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6588. * @param offset defines offset in the buffer (0 by default)
  6589. * @param size defines the size in floats of attributes (position is 3 for instance)
  6590. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6591. * @param instanced defines if the vertex buffer contains indexed data
  6592. * @param useBytes defines if the offset and stride are in bytes *
  6593. * @param divisor sets an optional divisor for instances (1 by default)
  6594. * @returns the new vertex buffer
  6595. */
  6596. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6597. /**
  6598. * Gets a boolean indicating if the Buffer is updatable?
  6599. * @returns true if the buffer is updatable
  6600. */
  6601. isUpdatable(): boolean;
  6602. /**
  6603. * Gets current buffer's data
  6604. * @returns a DataArray or null
  6605. */
  6606. getData(): Nullable<DataArray>;
  6607. /**
  6608. * Gets underlying native buffer
  6609. * @returns underlying native buffer
  6610. */
  6611. getBuffer(): Nullable<DataBuffer>;
  6612. /**
  6613. * Gets the stride in float32 units (i.e. byte stride / 4).
  6614. * May not be an integer if the byte stride is not divisible by 4.
  6615. * @returns the stride in float32 units
  6616. * @deprecated Please use byteStride instead.
  6617. */
  6618. getStrideSize(): number;
  6619. /**
  6620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6621. * @param data defines the data to store
  6622. */
  6623. create(data?: Nullable<DataArray>): void;
  6624. /** @hidden */
  6625. _rebuild(): void;
  6626. /**
  6627. * Update current buffer data
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates the data directly.
  6633. * @param data the new data
  6634. * @param offset the new offset
  6635. * @param vertexCount the vertex count (optional)
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6639. /**
  6640. * Release all resources
  6641. */
  6642. dispose(): void;
  6643. }
  6644. /**
  6645. * Specialized buffer used to store vertex data
  6646. */
  6647. export class VertexBuffer {
  6648. /** @hidden */
  6649. _buffer: Buffer;
  6650. private _kind;
  6651. private _size;
  6652. private _ownsBuffer;
  6653. private _instanced;
  6654. private _instanceDivisor;
  6655. /**
  6656. * The byte type.
  6657. */
  6658. static readonly BYTE: number;
  6659. /**
  6660. * The unsigned byte type.
  6661. */
  6662. static readonly UNSIGNED_BYTE: number;
  6663. /**
  6664. * The short type.
  6665. */
  6666. static readonly SHORT: number;
  6667. /**
  6668. * The unsigned short type.
  6669. */
  6670. static readonly UNSIGNED_SHORT: number;
  6671. /**
  6672. * The integer type.
  6673. */
  6674. static readonly INT: number;
  6675. /**
  6676. * The unsigned integer type.
  6677. */
  6678. static readonly UNSIGNED_INT: number;
  6679. /**
  6680. * The float type.
  6681. */
  6682. static readonly FLOAT: number;
  6683. /**
  6684. * Gets or sets the instance divisor when in instanced mode
  6685. */
  6686. get instanceDivisor(): number;
  6687. set instanceDivisor(value: number);
  6688. /**
  6689. * Gets the byte stride.
  6690. */
  6691. readonly byteStride: number;
  6692. /**
  6693. * Gets the byte offset.
  6694. */
  6695. readonly byteOffset: number;
  6696. /**
  6697. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6698. */
  6699. readonly normalized: boolean;
  6700. /**
  6701. * Gets the data type of each component in the array.
  6702. */
  6703. readonly type: number;
  6704. /**
  6705. * Constructor
  6706. * @param engine the engine
  6707. * @param data the data to use for this vertex buffer
  6708. * @param kind the vertex buffer kind
  6709. * @param updatable whether the data is updatable
  6710. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6711. * @param stride the stride (optional)
  6712. * @param instanced whether the buffer is instanced (optional)
  6713. * @param offset the offset of the data (optional)
  6714. * @param size the number of components (optional)
  6715. * @param type the type of the component (optional)
  6716. * @param normalized whether the data contains normalized data (optional)
  6717. * @param useBytes set to true if stride and offset are in bytes (optional)
  6718. * @param divisor defines the instance divisor to use (1 by default)
  6719. */
  6720. 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);
  6721. /** @hidden */
  6722. _rebuild(): void;
  6723. /**
  6724. * Returns the kind of the VertexBuffer (string)
  6725. * @returns a string
  6726. */
  6727. getKind(): string;
  6728. /**
  6729. * Gets a boolean indicating if the VertexBuffer is updatable?
  6730. * @returns true if the buffer is updatable
  6731. */
  6732. isUpdatable(): boolean;
  6733. /**
  6734. * Gets current buffer's data
  6735. * @returns a DataArray or null
  6736. */
  6737. getData(): Nullable<DataArray>;
  6738. /**
  6739. * Gets underlying native buffer
  6740. * @returns underlying native buffer
  6741. */
  6742. getBuffer(): Nullable<DataBuffer>;
  6743. /**
  6744. * Gets the stride in float32 units (i.e. byte stride / 4).
  6745. * May not be an integer if the byte stride is not divisible by 4.
  6746. * @returns the stride in float32 units
  6747. * @deprecated Please use byteStride instead.
  6748. */
  6749. getStrideSize(): number;
  6750. /**
  6751. * Returns the offset as a multiple of the type byte length.
  6752. * @returns the offset in bytes
  6753. * @deprecated Please use byteOffset instead.
  6754. */
  6755. getOffset(): number;
  6756. /**
  6757. * Returns the number of components per vertex attribute (integer)
  6758. * @returns the size in float
  6759. */
  6760. getSize(): number;
  6761. /**
  6762. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6763. * @returns true if this buffer is instanced
  6764. */
  6765. getIsInstanced(): boolean;
  6766. /**
  6767. * Returns the instancing divisor, zero for non-instanced (integer).
  6768. * @returns a number
  6769. */
  6770. getInstanceDivisor(): number;
  6771. /**
  6772. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6773. * @param data defines the data to store
  6774. */
  6775. create(data?: DataArray): void;
  6776. /**
  6777. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6778. * This function will create a new buffer if the current one is not updatable
  6779. * @param data defines the data to store
  6780. */
  6781. update(data: DataArray): void;
  6782. /**
  6783. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6784. * Returns the directly updated WebGLBuffer.
  6785. * @param data the new data
  6786. * @param offset the new offset
  6787. * @param useBytes set to true if the offset is in bytes
  6788. */
  6789. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6790. /**
  6791. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6792. */
  6793. dispose(): void;
  6794. /**
  6795. * Enumerates each value of this vertex buffer as numbers.
  6796. * @param count the number of values to enumerate
  6797. * @param callback the callback function called for each value
  6798. */
  6799. forEach(count: number, callback: (value: number, index: number) => void): void;
  6800. /**
  6801. * Positions
  6802. */
  6803. static readonly PositionKind: string;
  6804. /**
  6805. * Normals
  6806. */
  6807. static readonly NormalKind: string;
  6808. /**
  6809. * Tangents
  6810. */
  6811. static readonly TangentKind: string;
  6812. /**
  6813. * Texture coordinates
  6814. */
  6815. static readonly UVKind: string;
  6816. /**
  6817. * Texture coordinates 2
  6818. */
  6819. static readonly UV2Kind: string;
  6820. /**
  6821. * Texture coordinates 3
  6822. */
  6823. static readonly UV3Kind: string;
  6824. /**
  6825. * Texture coordinates 4
  6826. */
  6827. static readonly UV4Kind: string;
  6828. /**
  6829. * Texture coordinates 5
  6830. */
  6831. static readonly UV5Kind: string;
  6832. /**
  6833. * Texture coordinates 6
  6834. */
  6835. static readonly UV6Kind: string;
  6836. /**
  6837. * Colors
  6838. */
  6839. static readonly ColorKind: string;
  6840. /**
  6841. * Matrix indices (for bones)
  6842. */
  6843. static readonly MatricesIndicesKind: string;
  6844. /**
  6845. * Matrix weights (for bones)
  6846. */
  6847. static readonly MatricesWeightsKind: string;
  6848. /**
  6849. * Additional matrix indices (for bones)
  6850. */
  6851. static readonly MatricesIndicesExtraKind: string;
  6852. /**
  6853. * Additional matrix weights (for bones)
  6854. */
  6855. static readonly MatricesWeightsExtraKind: string;
  6856. /**
  6857. * Deduces the stride given a kind.
  6858. * @param kind The kind string to deduce
  6859. * @returns The deduced stride
  6860. */
  6861. static DeduceStride(kind: string): number;
  6862. /**
  6863. * Gets the byte length of the given type.
  6864. * @param type the type
  6865. * @returns the number of bytes
  6866. */
  6867. static GetTypeByteLength(type: number): number;
  6868. /**
  6869. * Enumerates each value of the given parameters as numbers.
  6870. * @param data the data to enumerate
  6871. * @param byteOffset the byte offset of the data
  6872. * @param byteStride the byte stride of the data
  6873. * @param componentCount the number of components per element
  6874. * @param componentType the type of the component
  6875. * @param count the number of values to enumerate
  6876. * @param normalized whether the data is normalized
  6877. * @param callback the callback function called for each value
  6878. */
  6879. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6880. private static _GetFloatValue;
  6881. }
  6882. }
  6883. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6884. import { Vector3 } from "babylonjs/Maths/math.vector";
  6885. import { Mesh } from "babylonjs/Meshes/mesh";
  6886. /**
  6887. * The options Interface for creating a Capsule Mesh
  6888. */
  6889. export interface ICreateCapsuleOptions {
  6890. /** The Orientation of the capsule. Default : Vector3.Up() */
  6891. orientation?: Vector3;
  6892. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6893. subdivisions: number;
  6894. /** Number of cylindrical segments on the capsule. */
  6895. tessellation: number;
  6896. /** Height or Length of the capsule. */
  6897. height: number;
  6898. /** Radius of the capsule. */
  6899. radius: number;
  6900. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6901. capSubdivisions: number;
  6902. /** Overwrite for the top radius. */
  6903. radiusTop?: number;
  6904. /** Overwrite for the bottom radius. */
  6905. radiusBottom?: number;
  6906. /** Overwrite for the top capSubdivisions. */
  6907. topCapSubdivisions?: number;
  6908. /** Overwrite for the bottom capSubdivisions. */
  6909. bottomCapSubdivisions?: number;
  6910. }
  6911. /**
  6912. * Class containing static functions to help procedurally build meshes
  6913. */
  6914. export class CapsuleBuilder {
  6915. /**
  6916. * Creates a capsule or a pill mesh
  6917. * @param name defines the name of the mesh
  6918. * @param options The constructors options.
  6919. * @param scene The scene the mesh is scoped to.
  6920. * @returns Capsule Mesh
  6921. */
  6922. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/intersectionInfo" {
  6926. import { Nullable } from "babylonjs/types";
  6927. /**
  6928. * @hidden
  6929. */
  6930. export class IntersectionInfo {
  6931. bu: Nullable<number>;
  6932. bv: Nullable<number>;
  6933. distance: number;
  6934. faceId: number;
  6935. subMeshId: number;
  6936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6937. }
  6938. }
  6939. declare module "babylonjs/Culling/boundingSphere" {
  6940. import { DeepImmutable } from "babylonjs/types";
  6941. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6942. import { Plane } from "babylonjs/Maths/math.plane";
  6943. /**
  6944. * Class used to store bounding sphere information
  6945. */
  6946. export class BoundingSphere {
  6947. /**
  6948. * Gets the center of the bounding sphere in local space
  6949. */
  6950. readonly center: Vector3;
  6951. /**
  6952. * Radius of the bounding sphere in local space
  6953. */
  6954. radius: number;
  6955. /**
  6956. * Gets the center of the bounding sphere in world space
  6957. */
  6958. readonly centerWorld: Vector3;
  6959. /**
  6960. * Radius of the bounding sphere in world space
  6961. */
  6962. radiusWorld: number;
  6963. /**
  6964. * Gets the minimum vector in local space
  6965. */
  6966. readonly minimum: Vector3;
  6967. /**
  6968. * Gets the maximum vector in local space
  6969. */
  6970. readonly maximum: Vector3;
  6971. private _worldMatrix;
  6972. private static readonly TmpVector3;
  6973. /**
  6974. * Creates a new bounding sphere
  6975. * @param min defines the minimum vector (in local space)
  6976. * @param max defines the maximum vector (in local space)
  6977. * @param worldMatrix defines the new world matrix
  6978. */
  6979. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6980. /**
  6981. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6982. * @param min defines the new minimum vector (in local space)
  6983. * @param max defines the new maximum vector (in local space)
  6984. * @param worldMatrix defines the new world matrix
  6985. */
  6986. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6987. /**
  6988. * Scale the current bounding sphere by applying a scale factor
  6989. * @param factor defines the scale factor to apply
  6990. * @returns the current bounding box
  6991. */
  6992. scale(factor: number): BoundingSphere;
  6993. /**
  6994. * Gets the world matrix of the bounding box
  6995. * @returns a matrix
  6996. */
  6997. getWorldMatrix(): DeepImmutable<Matrix>;
  6998. /** @hidden */
  6999. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7000. /**
  7001. * Tests if the bounding sphere is intersecting the frustum planes
  7002. * @param frustumPlanes defines the frustum planes to test
  7003. * @returns true if there is an intersection
  7004. */
  7005. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7006. /**
  7007. * Tests if the bounding sphere center is in between the frustum planes.
  7008. * Used for optimistic fast inclusion.
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @returns true if the sphere center is in between the frustum planes
  7011. */
  7012. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a point is inside the bounding sphere
  7015. * @param point defines the point to test
  7016. * @returns true if the point is inside the bounding sphere
  7017. */
  7018. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7019. /**
  7020. * Checks if two sphere intersct
  7021. * @param sphere0 sphere 0
  7022. * @param sphere1 sphere 1
  7023. * @returns true if the speres intersect
  7024. */
  7025. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7026. }
  7027. }
  7028. declare module "babylonjs/Culling/boundingBox" {
  7029. import { DeepImmutable } from "babylonjs/types";
  7030. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7031. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7032. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7033. import { Plane } from "babylonjs/Maths/math.plane";
  7034. /**
  7035. * Class used to store bounding box information
  7036. */
  7037. export class BoundingBox implements ICullable {
  7038. /**
  7039. * Gets the 8 vectors representing the bounding box in local space
  7040. */
  7041. readonly vectors: Vector3[];
  7042. /**
  7043. * Gets the center of the bounding box in local space
  7044. */
  7045. readonly center: Vector3;
  7046. /**
  7047. * Gets the center of the bounding box in world space
  7048. */
  7049. readonly centerWorld: Vector3;
  7050. /**
  7051. * Gets the extend size in local space
  7052. */
  7053. readonly extendSize: Vector3;
  7054. /**
  7055. * Gets the extend size in world space
  7056. */
  7057. readonly extendSizeWorld: Vector3;
  7058. /**
  7059. * Gets the OBB (object bounding box) directions
  7060. */
  7061. readonly directions: Vector3[];
  7062. /**
  7063. * Gets the 8 vectors representing the bounding box in world space
  7064. */
  7065. readonly vectorsWorld: Vector3[];
  7066. /**
  7067. * Gets the minimum vector in world space
  7068. */
  7069. readonly minimumWorld: Vector3;
  7070. /**
  7071. * Gets the maximum vector in world space
  7072. */
  7073. readonly maximumWorld: Vector3;
  7074. /**
  7075. * Gets the minimum vector in local space
  7076. */
  7077. readonly minimum: Vector3;
  7078. /**
  7079. * Gets the maximum vector in local space
  7080. */
  7081. readonly maximum: Vector3;
  7082. private _worldMatrix;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * @hidden
  7086. */
  7087. _tag: number;
  7088. /**
  7089. * Creates a new bounding box
  7090. * @param min defines the minimum vector (in local space)
  7091. * @param max defines the maximum vector (in local space)
  7092. * @param worldMatrix defines the new world matrix
  7093. */
  7094. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7095. /**
  7096. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7097. * @param min defines the new minimum vector (in local space)
  7098. * @param max defines the new maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7102. /**
  7103. * Scale the current bounding box by applying a scale factor
  7104. * @param factor defines the scale factor to apply
  7105. * @returns the current bounding box
  7106. */
  7107. scale(factor: number): BoundingBox;
  7108. /**
  7109. * Gets the world matrix of the bounding box
  7110. * @returns a matrix
  7111. */
  7112. getWorldMatrix(): DeepImmutable<Matrix>;
  7113. /** @hidden */
  7114. _update(world: DeepImmutable<Matrix>): void;
  7115. /**
  7116. * Tests if the bounding box is intersecting the frustum planes
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @returns true if there is an intersection
  7119. */
  7120. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /**
  7122. * Tests if the bounding box is entirely inside the frustum planes
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if there is an inclusion
  7125. */
  7126. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if a point is inside the bounding box
  7129. * @param point defines the point to test
  7130. * @returns true if the point is inside the bounding box
  7131. */
  7132. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7133. /**
  7134. * Tests if the bounding box intersects with a bounding sphere
  7135. * @param sphere defines the sphere to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7139. /**
  7140. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7141. * @param min defines the min vector to use
  7142. * @param max defines the max vector to use
  7143. * @returns true if there is an intersection
  7144. */
  7145. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Tests if two bounding boxes are intersections
  7148. * @param box0 defines the first box to test
  7149. * @param box1 defines the second box to test
  7150. * @returns true if there is an intersection
  7151. */
  7152. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7153. /**
  7154. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7155. * @param minPoint defines the minimum vector of the bounding box
  7156. * @param maxPoint defines the maximum vector of the bounding box
  7157. * @param sphereCenter defines the sphere center
  7158. * @param sphereRadius defines the sphere radius
  7159. * @returns true if there is an intersection
  7160. */
  7161. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7162. /**
  7163. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7164. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7165. * @param frustumPlanes defines the frustum planes to test
  7166. * @return true if there is an inclusion
  7167. */
  7168. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7169. /**
  7170. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7171. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7172. * @param frustumPlanes defines the frustum planes to test
  7173. * @return true if there is an intersection
  7174. */
  7175. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7176. }
  7177. }
  7178. declare module "babylonjs/Collisions/collider" {
  7179. import { Nullable, IndicesArray } from "babylonjs/types";
  7180. import { Vector3 } from "babylonjs/Maths/math.vector";
  7181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. /** @hidden */
  7184. export class Collider {
  7185. /** Define if a collision was found */
  7186. collisionFound: boolean;
  7187. /**
  7188. * Define last intersection point in local space
  7189. */
  7190. intersectionPoint: Vector3;
  7191. /**
  7192. * Define last collided mesh
  7193. */
  7194. collidedMesh: Nullable<AbstractMesh>;
  7195. private _collisionPoint;
  7196. private _planeIntersectionPoint;
  7197. private _tempVector;
  7198. private _tempVector2;
  7199. private _tempVector3;
  7200. private _tempVector4;
  7201. private _edge;
  7202. private _baseToVertex;
  7203. private _destinationPoint;
  7204. private _slidePlaneNormal;
  7205. private _displacementVector;
  7206. /** @hidden */
  7207. _radius: Vector3;
  7208. /** @hidden */
  7209. _retry: number;
  7210. private _velocity;
  7211. private _basePoint;
  7212. private _epsilon;
  7213. /** @hidden */
  7214. _velocityWorldLength: number;
  7215. /** @hidden */
  7216. _basePointWorld: Vector3;
  7217. private _velocityWorld;
  7218. private _normalizedVelocity;
  7219. /** @hidden */
  7220. _initialVelocity: Vector3;
  7221. /** @hidden */
  7222. _initialPosition: Vector3;
  7223. private _nearestDistance;
  7224. private _collisionMask;
  7225. get collisionMask(): number;
  7226. set collisionMask(mask: number);
  7227. /**
  7228. * Gets the plane normal used to compute the sliding response (in local space)
  7229. */
  7230. get slidePlaneNormal(): Vector3;
  7231. /** @hidden */
  7232. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7233. /** @hidden */
  7234. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7235. /** @hidden */
  7236. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7237. /** @hidden */
  7238. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7239. /** @hidden */
  7240. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7241. /** @hidden */
  7242. _getResponse(pos: Vector3, vel: Vector3): void;
  7243. }
  7244. }
  7245. declare module "babylonjs/Culling/boundingInfo" {
  7246. import { DeepImmutable } from "babylonjs/types";
  7247. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7248. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7249. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7250. import { Plane } from "babylonjs/Maths/math.plane";
  7251. import { Collider } from "babylonjs/Collisions/collider";
  7252. /**
  7253. * Interface for cullable objects
  7254. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7255. */
  7256. export interface ICullable {
  7257. /**
  7258. * Checks if the object or part of the object is in the frustum
  7259. * @param frustumPlanes Camera near/planes
  7260. * @returns true if the object is in frustum otherwise false
  7261. */
  7262. isInFrustum(frustumPlanes: Plane[]): boolean;
  7263. /**
  7264. * Checks if a cullable object (mesh...) is in the camera frustum
  7265. * Unlike isInFrustum this cheks the full bounding box
  7266. * @param frustumPlanes Camera near/planes
  7267. * @returns true if the object is in frustum otherwise false
  7268. */
  7269. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7270. }
  7271. /**
  7272. * Info for a bounding data of a mesh
  7273. */
  7274. export class BoundingInfo implements ICullable {
  7275. /**
  7276. * Bounding box for the mesh
  7277. */
  7278. readonly boundingBox: BoundingBox;
  7279. /**
  7280. * Bounding sphere for the mesh
  7281. */
  7282. readonly boundingSphere: BoundingSphere;
  7283. private _isLocked;
  7284. private static readonly TmpVector3;
  7285. /**
  7286. * Constructs bounding info
  7287. * @param minimum min vector of the bounding box/sphere
  7288. * @param maximum max vector of the bounding box/sphere
  7289. * @param worldMatrix defines the new world matrix
  7290. */
  7291. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7292. /**
  7293. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7294. * @param min defines the new minimum vector (in local space)
  7295. * @param max defines the new maximum vector (in local space)
  7296. * @param worldMatrix defines the new world matrix
  7297. */
  7298. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7299. /**
  7300. * min vector of the bounding box/sphere
  7301. */
  7302. get minimum(): Vector3;
  7303. /**
  7304. * max vector of the bounding box/sphere
  7305. */
  7306. get maximum(): Vector3;
  7307. /**
  7308. * If the info is locked and won't be updated to avoid perf overhead
  7309. */
  7310. get isLocked(): boolean;
  7311. set isLocked(value: boolean);
  7312. /**
  7313. * Updates the bounding sphere and box
  7314. * @param world world matrix to be used to update
  7315. */
  7316. update(world: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7319. * @param center New center of the bounding info
  7320. * @param extend New extend of the bounding info
  7321. * @returns the current bounding info
  7322. */
  7323. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7324. /**
  7325. * Scale the current bounding info by applying a scale factor
  7326. * @param factor defines the scale factor to apply
  7327. * @returns the current bounding info
  7328. */
  7329. scale(factor: number): BoundingInfo;
  7330. /**
  7331. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7332. * @param frustumPlanes defines the frustum to test
  7333. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7334. * @returns true if the bounding info is in the frustum planes
  7335. */
  7336. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7337. /**
  7338. * Gets the world distance between the min and max points of the bounding box
  7339. */
  7340. get diagonalLength(): number;
  7341. /**
  7342. * Checks if a cullable object (mesh...) is in the camera frustum
  7343. * Unlike isInFrustum this cheks the full bounding box
  7344. * @param frustumPlanes Camera near/planes
  7345. * @returns true if the object is in frustum otherwise false
  7346. */
  7347. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7348. /** @hidden */
  7349. _checkCollision(collider: Collider): boolean;
  7350. /**
  7351. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7352. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7353. * @param point the point to check intersection with
  7354. * @returns if the point intersects
  7355. */
  7356. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7357. /**
  7358. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7359. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7360. * @param boundingInfo the bounding info to check intersection with
  7361. * @param precise if the intersection should be done using OBB
  7362. * @returns if the bounding info intersects
  7363. */
  7364. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7365. }
  7366. }
  7367. declare module "babylonjs/Maths/math.functions" {
  7368. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7369. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7370. /**
  7371. * Extracts minimum and maximum values from a list of indexed positions
  7372. * @param positions defines the positions to use
  7373. * @param indices defines the indices to the positions
  7374. * @param indexStart defines the start index
  7375. * @param indexCount defines the end index
  7376. * @param bias defines bias value to add to the result
  7377. * @return minimum and maximum values
  7378. */
  7379. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7380. minimum: Vector3;
  7381. maximum: Vector3;
  7382. };
  7383. /**
  7384. * Extracts minimum and maximum values from a list of positions
  7385. * @param positions defines the positions to use
  7386. * @param start defines the start index in the positions array
  7387. * @param count defines the number of positions to handle
  7388. * @param bias defines bias value to add to the result
  7389. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7390. * @return minimum and maximum values
  7391. */
  7392. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7393. minimum: Vector3;
  7394. maximum: Vector3;
  7395. };
  7396. }
  7397. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7398. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7399. /** @hidden */
  7400. export class WebGLDataBuffer extends DataBuffer {
  7401. private _buffer;
  7402. constructor(resource: WebGLBuffer);
  7403. get underlyingResource(): any;
  7404. }
  7405. }
  7406. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7407. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7408. import { Nullable } from "babylonjs/types";
  7409. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7410. /** @hidden */
  7411. export class WebGLPipelineContext implements IPipelineContext {
  7412. engine: ThinEngine;
  7413. program: Nullable<WebGLProgram>;
  7414. context?: WebGLRenderingContext;
  7415. vertexShader?: WebGLShader;
  7416. fragmentShader?: WebGLShader;
  7417. isParallelCompiled: boolean;
  7418. onCompiled?: () => void;
  7419. transformFeedback?: WebGLTransformFeedback | null;
  7420. vertexCompilationError: Nullable<string>;
  7421. fragmentCompilationError: Nullable<string>;
  7422. programLinkError: Nullable<string>;
  7423. programValidationError: Nullable<string>;
  7424. get isAsync(): boolean;
  7425. get isReady(): boolean;
  7426. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7427. _getVertexShaderCode(): string | null;
  7428. _getFragmentShaderCode(): string | null;
  7429. }
  7430. }
  7431. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7432. import { FloatArray, Nullable } from "babylonjs/types";
  7433. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7435. module "babylonjs/Engines/thinEngine" {
  7436. interface ThinEngine {
  7437. /**
  7438. * Create an uniform buffer
  7439. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7440. * @param elements defines the content of the uniform buffer
  7441. * @returns the webGL uniform buffer
  7442. */
  7443. createUniformBuffer(elements: FloatArray): DataBuffer;
  7444. /**
  7445. * Create a dynamic uniform buffer
  7446. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7447. * @param elements defines the content of the uniform buffer
  7448. * @returns the webGL uniform buffer
  7449. */
  7450. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7451. /**
  7452. * Update an existing uniform buffer
  7453. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7454. * @param uniformBuffer defines the target uniform buffer
  7455. * @param elements defines the content to update
  7456. * @param offset defines the offset in the uniform buffer where update should start
  7457. * @param count defines the size of the data to update
  7458. */
  7459. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7460. /**
  7461. * Bind an uniform buffer to the current webGL context
  7462. * @param buffer defines the buffer to bind
  7463. */
  7464. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7465. /**
  7466. * Bind a buffer to the current webGL context at a given location
  7467. * @param buffer defines the buffer to bind
  7468. * @param location defines the index where to bind the buffer
  7469. */
  7470. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7471. /**
  7472. * Bind a specific block at a given index in a specific shader program
  7473. * @param pipelineContext defines the pipeline context to use
  7474. * @param blockName defines the block name
  7475. * @param index defines the index where to bind the block
  7476. */
  7477. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7478. }
  7479. }
  7480. }
  7481. declare module "babylonjs/Materials/uniformBuffer" {
  7482. import { Nullable, FloatArray } from "babylonjs/types";
  7483. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7484. import { Engine } from "babylonjs/Engines/engine";
  7485. import { Effect } from "babylonjs/Materials/effect";
  7486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7487. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7488. import { Color3 } from "babylonjs/Maths/math.color";
  7489. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7490. /**
  7491. * Uniform buffer objects.
  7492. *
  7493. * Handles blocks of uniform on the GPU.
  7494. *
  7495. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7496. *
  7497. * For more information, please refer to :
  7498. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7499. */
  7500. export class UniformBuffer {
  7501. private _engine;
  7502. private _buffer;
  7503. private _data;
  7504. private _bufferData;
  7505. private _dynamic?;
  7506. private _uniformLocations;
  7507. private _uniformSizes;
  7508. private _uniformLocationPointer;
  7509. private _needSync;
  7510. private _noUBO;
  7511. private _currentEffect;
  7512. /** @hidden */
  7513. _alreadyBound: boolean;
  7514. private static _MAX_UNIFORM_SIZE;
  7515. private static _tempBuffer;
  7516. /**
  7517. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7518. * This is dynamic to allow compat with webgl 1 and 2.
  7519. * You will need to pass the name of the uniform as well as the value.
  7520. */
  7521. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7522. /**
  7523. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7524. * This is dynamic to allow compat with webgl 1 and 2.
  7525. * You will need to pass the name of the uniform as well as the value.
  7526. */
  7527. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7528. /**
  7529. * Lambda to Update a single float in a uniform buffer.
  7530. * This is dynamic to allow compat with webgl 1 and 2.
  7531. * You will need to pass the name of the uniform as well as the value.
  7532. */
  7533. updateFloat: (name: string, x: number) => void;
  7534. /**
  7535. * Lambda to Update a vec2 of float in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7540. /**
  7541. * Lambda to Update a vec3 of float in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7546. /**
  7547. * Lambda to Update a vec4 of float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7552. /**
  7553. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateMatrix: (name: string, mat: Matrix) => void;
  7558. /**
  7559. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateVector3: (name: string, vector: Vector3) => void;
  7564. /**
  7565. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateVector4: (name: string, vector: Vector4) => void;
  7570. /**
  7571. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7576. /**
  7577. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7582. /**
  7583. * Instantiates a new Uniform buffer objects.
  7584. *
  7585. * Handles blocks of uniform on the GPU.
  7586. *
  7587. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7588. *
  7589. * For more information, please refer to :
  7590. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7591. * @param engine Define the engine the buffer is associated with
  7592. * @param data Define the data contained in the buffer
  7593. * @param dynamic Define if the buffer is updatable
  7594. */
  7595. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7596. /**
  7597. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7598. * or just falling back on setUniformXXX calls.
  7599. */
  7600. get useUbo(): boolean;
  7601. /**
  7602. * Indicates if the WebGL underlying uniform buffer is in sync
  7603. * with the javascript cache data.
  7604. */
  7605. get isSync(): boolean;
  7606. /**
  7607. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7608. * Also, a dynamic UniformBuffer will disable cache verification and always
  7609. * update the underlying WebGL uniform buffer to the GPU.
  7610. * @returns if Dynamic, otherwise false
  7611. */
  7612. isDynamic(): boolean;
  7613. /**
  7614. * The data cache on JS side.
  7615. * @returns the underlying data as a float array
  7616. */
  7617. getData(): Float32Array;
  7618. /**
  7619. * The underlying WebGL Uniform buffer.
  7620. * @returns the webgl buffer
  7621. */
  7622. getBuffer(): Nullable<DataBuffer>;
  7623. /**
  7624. * std140 layout specifies how to align data within an UBO structure.
  7625. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7626. * for specs.
  7627. */
  7628. private _fillAlignment;
  7629. /**
  7630. * Adds an uniform in the buffer.
  7631. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7632. * for the layout to be correct !
  7633. * @param name Name of the uniform, as used in the uniform block in the shader.
  7634. * @param size Data size, or data directly.
  7635. */
  7636. addUniform(name: string, size: number | number[]): void;
  7637. /**
  7638. * Adds a Matrix 4x4 to the uniform buffer.
  7639. * @param name Name of the uniform, as used in the uniform block in the shader.
  7640. * @param mat A 4x4 matrix.
  7641. */
  7642. addMatrix(name: string, mat: Matrix): void;
  7643. /**
  7644. * Adds a vec2 to the uniform buffer.
  7645. * @param name Name of the uniform, as used in the uniform block in the shader.
  7646. * @param x Define the x component value of the vec2
  7647. * @param y Define the y component value of the vec2
  7648. */
  7649. addFloat2(name: string, x: number, y: number): void;
  7650. /**
  7651. * Adds a vec3 to the uniform buffer.
  7652. * @param name Name of the uniform, as used in the uniform block in the shader.
  7653. * @param x Define the x component value of the vec3
  7654. * @param y Define the y component value of the vec3
  7655. * @param z Define the z component value of the vec3
  7656. */
  7657. addFloat3(name: string, x: number, y: number, z: number): void;
  7658. /**
  7659. * Adds a vec3 to the uniform buffer.
  7660. * @param name Name of the uniform, as used in the uniform block in the shader.
  7661. * @param color Define the vec3 from a Color
  7662. */
  7663. addColor3(name: string, color: Color3): void;
  7664. /**
  7665. * Adds a vec4 to the uniform buffer.
  7666. * @param name Name of the uniform, as used in the uniform block in the shader.
  7667. * @param color Define the rgb components from a Color
  7668. * @param alpha Define the a component of the vec4
  7669. */
  7670. addColor4(name: string, color: Color3, alpha: number): void;
  7671. /**
  7672. * Adds a vec3 to the uniform buffer.
  7673. * @param name Name of the uniform, as used in the uniform block in the shader.
  7674. * @param vector Define the vec3 components from a Vector
  7675. */
  7676. addVector3(name: string, vector: Vector3): void;
  7677. /**
  7678. * Adds a Matrix 3x3 to the uniform buffer.
  7679. * @param name Name of the uniform, as used in the uniform block in the shader.
  7680. */
  7681. addMatrix3x3(name: string): void;
  7682. /**
  7683. * Adds a Matrix 2x2 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. */
  7686. addMatrix2x2(name: string): void;
  7687. /**
  7688. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7689. */
  7690. create(): void;
  7691. /** @hidden */
  7692. _rebuild(): void;
  7693. /**
  7694. * Updates the WebGL Uniform Buffer on the GPU.
  7695. * If the `dynamic` flag is set to true, no cache comparison is done.
  7696. * Otherwise, the buffer will be updated only if the cache differs.
  7697. */
  7698. update(): void;
  7699. /**
  7700. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7701. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7702. * @param data Define the flattened data
  7703. * @param size Define the size of the data.
  7704. */
  7705. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7706. private _valueCache;
  7707. private _cacheMatrix;
  7708. private _updateMatrix3x3ForUniform;
  7709. private _updateMatrix3x3ForEffect;
  7710. private _updateMatrix2x2ForEffect;
  7711. private _updateMatrix2x2ForUniform;
  7712. private _updateFloatForEffect;
  7713. private _updateFloatForUniform;
  7714. private _updateFloat2ForEffect;
  7715. private _updateFloat2ForUniform;
  7716. private _updateFloat3ForEffect;
  7717. private _updateFloat3ForUniform;
  7718. private _updateFloat4ForEffect;
  7719. private _updateFloat4ForUniform;
  7720. private _updateMatrixForEffect;
  7721. private _updateMatrixForUniform;
  7722. private _updateVector3ForEffect;
  7723. private _updateVector3ForUniform;
  7724. private _updateVector4ForEffect;
  7725. private _updateVector4ForUniform;
  7726. private _updateColor3ForEffect;
  7727. private _updateColor3ForUniform;
  7728. private _updateColor4ForEffect;
  7729. private _updateColor4ForUniform;
  7730. /**
  7731. * Sets a sampler uniform on the effect.
  7732. * @param name Define the name of the sampler.
  7733. * @param texture Define the texture to set in the sampler
  7734. */
  7735. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7736. /**
  7737. * Directly updates the value of the uniform in the cache AND on the GPU.
  7738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7739. * @param data Define the flattened data
  7740. */
  7741. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7742. /**
  7743. * Binds this uniform buffer to an effect.
  7744. * @param effect Define the effect to bind the buffer to
  7745. * @param name Name of the uniform block in the shader.
  7746. */
  7747. bindToEffect(effect: Effect, name: string): void;
  7748. /**
  7749. * Disposes the uniform buffer.
  7750. */
  7751. dispose(): void;
  7752. }
  7753. }
  7754. declare module "babylonjs/Misc/iInspectable" {
  7755. /**
  7756. * Enum that determines the text-wrapping mode to use.
  7757. */
  7758. export enum InspectableType {
  7759. /**
  7760. * Checkbox for booleans
  7761. */
  7762. Checkbox = 0,
  7763. /**
  7764. * Sliders for numbers
  7765. */
  7766. Slider = 1,
  7767. /**
  7768. * Vector3
  7769. */
  7770. Vector3 = 2,
  7771. /**
  7772. * Quaternions
  7773. */
  7774. Quaternion = 3,
  7775. /**
  7776. * Color3
  7777. */
  7778. Color3 = 4,
  7779. /**
  7780. * String
  7781. */
  7782. String = 5
  7783. }
  7784. /**
  7785. * Interface used to define custom inspectable properties.
  7786. * This interface is used by the inspector to display custom property grids
  7787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7788. */
  7789. export interface IInspectable {
  7790. /**
  7791. * Gets the label to display
  7792. */
  7793. label: string;
  7794. /**
  7795. * Gets the name of the property to edit
  7796. */
  7797. propertyName: string;
  7798. /**
  7799. * Gets the type of the editor to use
  7800. */
  7801. type: InspectableType;
  7802. /**
  7803. * Gets the minimum value of the property when using in "slider" mode
  7804. */
  7805. min?: number;
  7806. /**
  7807. * Gets the maximum value of the property when using in "slider" mode
  7808. */
  7809. max?: number;
  7810. /**
  7811. * Gets the setp to use when using in "slider" mode
  7812. */
  7813. step?: number;
  7814. }
  7815. }
  7816. declare module "babylonjs/Misc/timingTools" {
  7817. /**
  7818. * Class used to provide helper for timing
  7819. */
  7820. export class TimingTools {
  7821. /**
  7822. * Polyfill for setImmediate
  7823. * @param action defines the action to execute after the current execution block
  7824. */
  7825. static SetImmediate(action: () => void): void;
  7826. }
  7827. }
  7828. declare module "babylonjs/Misc/instantiationTools" {
  7829. /**
  7830. * Class used to enable instatition of objects by class name
  7831. */
  7832. export class InstantiationTools {
  7833. /**
  7834. * Use this object to register external classes like custom textures or material
  7835. * to allow the laoders to instantiate them
  7836. */
  7837. static RegisteredExternalClasses: {
  7838. [key: string]: Object;
  7839. };
  7840. /**
  7841. * Tries to instantiate a new object from a given class name
  7842. * @param className defines the class name to instantiate
  7843. * @returns the new object or null if the system was not able to do the instantiation
  7844. */
  7845. static Instantiate(className: string): any;
  7846. }
  7847. }
  7848. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7849. /**
  7850. * Define options used to create a depth texture
  7851. */
  7852. export class DepthTextureCreationOptions {
  7853. /** Specifies whether or not a stencil should be allocated in the texture */
  7854. generateStencil?: boolean;
  7855. /** Specifies whether or not bilinear filtering is enable on the texture */
  7856. bilinearFiltering?: boolean;
  7857. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7858. comparisonFunction?: number;
  7859. /** Specifies if the created texture is a cube texture */
  7860. isCube?: boolean;
  7861. }
  7862. }
  7863. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7865. import { Nullable } from "babylonjs/types";
  7866. import { Scene } from "babylonjs/scene";
  7867. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7868. module "babylonjs/Engines/thinEngine" {
  7869. interface ThinEngine {
  7870. /**
  7871. * Creates a depth stencil cube texture.
  7872. * This is only available in WebGL 2.
  7873. * @param size The size of face edge in the cube texture.
  7874. * @param options The options defining the cube texture.
  7875. * @returns The cube texture
  7876. */
  7877. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7878. /**
  7879. * Creates a cube texture
  7880. * @param rootUrl defines the url where the files to load is located
  7881. * @param scene defines the current scene
  7882. * @param files defines the list of files to load (1 per face)
  7883. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7884. * @param onLoad defines an optional callback raised when the texture is loaded
  7885. * @param onError defines an optional callback raised if there is an issue to load the texture
  7886. * @param format defines the format of the data
  7887. * @param forcedExtension defines the extension to use to pick the right loader
  7888. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7889. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7890. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7891. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7892. * @returns the cube texture as an InternalTexture
  7893. */
  7894. 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;
  7895. /**
  7896. * Creates a cube texture
  7897. * @param rootUrl defines the url where the files to load is located
  7898. * @param scene defines the current scene
  7899. * @param files defines the list of files to load (1 per face)
  7900. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7901. * @param onLoad defines an optional callback raised when the texture is loaded
  7902. * @param onError defines an optional callback raised if there is an issue to load the texture
  7903. * @param format defines the format of the data
  7904. * @param forcedExtension defines the extension to use to pick the right loader
  7905. * @returns the cube texture as an InternalTexture
  7906. */
  7907. 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;
  7908. /**
  7909. * Creates a cube texture
  7910. * @param rootUrl defines the url where the files to load is located
  7911. * @param scene defines the current scene
  7912. * @param files defines the list of files to load (1 per face)
  7913. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7914. * @param onLoad defines an optional callback raised when the texture is loaded
  7915. * @param onError defines an optional callback raised if there is an issue to load the texture
  7916. * @param format defines the format of the data
  7917. * @param forcedExtension defines the extension to use to pick the right loader
  7918. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7921. * @returns the cube texture as an InternalTexture
  7922. */
  7923. 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;
  7924. /** @hidden */
  7925. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7926. /** @hidden */
  7927. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7928. /** @hidden */
  7929. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7930. /** @hidden */
  7931. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7932. /**
  7933. * @hidden
  7934. */
  7935. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7936. }
  7937. }
  7938. }
  7939. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7940. import { Nullable } from "babylonjs/types";
  7941. import { Scene } from "babylonjs/scene";
  7942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7944. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7945. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7946. import { Observable } from "babylonjs/Misc/observable";
  7947. /**
  7948. * Class for creating a cube texture
  7949. */
  7950. export class CubeTexture extends BaseTexture {
  7951. private _delayedOnLoad;
  7952. /**
  7953. * Observable triggered once the texture has been loaded.
  7954. */
  7955. onLoadObservable: Observable<CubeTexture>;
  7956. /**
  7957. * The url of the texture
  7958. */
  7959. url: string;
  7960. /**
  7961. * Gets or sets the center of the bounding box associated with the cube texture.
  7962. * It must define where the camera used to render the texture was set
  7963. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7964. */
  7965. boundingBoxPosition: Vector3;
  7966. private _boundingBoxSize;
  7967. /**
  7968. * Gets or sets the size of the bounding box associated with the cube texture
  7969. * When defined, the cubemap will switch to local mode
  7970. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7971. * @example https://www.babylonjs-playground.com/#RNASML
  7972. */
  7973. set boundingBoxSize(value: Vector3);
  7974. /**
  7975. * Returns the bounding box size
  7976. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7977. */
  7978. get boundingBoxSize(): Vector3;
  7979. protected _rotationY: number;
  7980. /**
  7981. * Sets texture matrix rotation angle around Y axis in radians.
  7982. */
  7983. set rotationY(value: number);
  7984. /**
  7985. * Gets texture matrix rotation angle around Y axis radians.
  7986. */
  7987. get rotationY(): number;
  7988. /**
  7989. * Are mip maps generated for this texture or not.
  7990. */
  7991. get noMipmap(): boolean;
  7992. private _noMipmap;
  7993. private _files;
  7994. protected _forcedExtension: Nullable<string>;
  7995. private _extensions;
  7996. private _textureMatrix;
  7997. private _format;
  7998. private _createPolynomials;
  7999. /**
  8000. * Creates a cube texture from an array of image urls
  8001. * @param files defines an array of image urls
  8002. * @param scene defines the hosting scene
  8003. * @param noMipmap specifies if mip maps are not used
  8004. * @returns a cube texture
  8005. */
  8006. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8007. /**
  8008. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8009. * @param url defines the url of the prefiltered texture
  8010. * @param scene defines the scene the texture is attached to
  8011. * @param forcedExtension defines the extension of the file if different from the url
  8012. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8013. * @return the prefiltered texture
  8014. */
  8015. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8016. /**
  8017. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8018. * as prefiltered data.
  8019. * @param rootUrl defines the url of the texture or the root name of the six images
  8020. * @param null defines the scene or engine the texture is attached to
  8021. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8022. * @param noMipmap defines if mipmaps should be created or not
  8023. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8024. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8025. * @param onError defines a callback triggered in case of error during load
  8026. * @param format defines the internal format to use for the texture once loaded
  8027. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8028. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8029. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8030. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8031. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8032. * @return the cube texture
  8033. */
  8034. 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);
  8035. /**
  8036. * Get the current class name of the texture useful for serialization or dynamic coding.
  8037. * @returns "CubeTexture"
  8038. */
  8039. getClassName(): string;
  8040. /**
  8041. * Update the url (and optional buffer) of this texture if url was null during construction.
  8042. * @param url the url of the texture
  8043. * @param forcedExtension defines the extension to use
  8044. * @param onLoad callback called when the texture is loaded (defaults to null)
  8045. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8046. */
  8047. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8048. /**
  8049. * Delays loading of the cube texture
  8050. * @param forcedExtension defines the extension to use
  8051. */
  8052. delayLoad(forcedExtension?: string): void;
  8053. /**
  8054. * Returns the reflection texture matrix
  8055. * @returns the reflection texture matrix
  8056. */
  8057. getReflectionTextureMatrix(): Matrix;
  8058. /**
  8059. * Sets the reflection texture matrix
  8060. * @param value Reflection texture matrix
  8061. */
  8062. setReflectionTextureMatrix(value: Matrix): void;
  8063. /**
  8064. * Parses text to create a cube texture
  8065. * @param parsedTexture define the serialized text to read from
  8066. * @param scene defines the hosting scene
  8067. * @param rootUrl defines the root url of the cube texture
  8068. * @returns a cube texture
  8069. */
  8070. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8071. /**
  8072. * Makes a clone, or deep copy, of the cube texture
  8073. * @returns a new cube texture
  8074. */
  8075. clone(): CubeTexture;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/materialDefines" {
  8079. /**
  8080. * Manages the defines for the Material
  8081. */
  8082. export class MaterialDefines {
  8083. /** @hidden */
  8084. protected _keys: string[];
  8085. private _isDirty;
  8086. /** @hidden */
  8087. _renderId: number;
  8088. /** @hidden */
  8089. _areLightsDirty: boolean;
  8090. /** @hidden */
  8091. _areLightsDisposed: boolean;
  8092. /** @hidden */
  8093. _areAttributesDirty: boolean;
  8094. /** @hidden */
  8095. _areTexturesDirty: boolean;
  8096. /** @hidden */
  8097. _areFresnelDirty: boolean;
  8098. /** @hidden */
  8099. _areMiscDirty: boolean;
  8100. /** @hidden */
  8101. _arePrePassDirty: boolean;
  8102. /** @hidden */
  8103. _areImageProcessingDirty: boolean;
  8104. /** @hidden */
  8105. _normals: boolean;
  8106. /** @hidden */
  8107. _uvs: boolean;
  8108. /** @hidden */
  8109. _needNormals: boolean;
  8110. /** @hidden */
  8111. _needUVs: boolean;
  8112. [id: string]: any;
  8113. /**
  8114. * Specifies if the material needs to be re-calculated
  8115. */
  8116. get isDirty(): boolean;
  8117. /**
  8118. * Marks the material to indicate that it has been re-calculated
  8119. */
  8120. markAsProcessed(): void;
  8121. /**
  8122. * Marks the material to indicate that it needs to be re-calculated
  8123. */
  8124. markAsUnprocessed(): void;
  8125. /**
  8126. * Marks the material to indicate all of its defines need to be re-calculated
  8127. */
  8128. markAllAsDirty(): void;
  8129. /**
  8130. * Marks the material to indicate that image processing needs to be re-calculated
  8131. */
  8132. markAsImageProcessingDirty(): void;
  8133. /**
  8134. * Marks the material to indicate the lights need to be re-calculated
  8135. * @param disposed Defines whether the light is dirty due to dispose or not
  8136. */
  8137. markAsLightDirty(disposed?: boolean): void;
  8138. /**
  8139. * Marks the attribute state as changed
  8140. */
  8141. markAsAttributesDirty(): void;
  8142. /**
  8143. * Marks the texture state as changed
  8144. */
  8145. markAsTexturesDirty(): void;
  8146. /**
  8147. * Marks the fresnel state as changed
  8148. */
  8149. markAsFresnelDirty(): void;
  8150. /**
  8151. * Marks the misc state as changed
  8152. */
  8153. markAsMiscDirty(): void;
  8154. /**
  8155. * Marks the prepass state as changed
  8156. */
  8157. markAsPrePassDirty(): void;
  8158. /**
  8159. * Rebuilds the material defines
  8160. */
  8161. rebuild(): void;
  8162. /**
  8163. * Specifies if two material defines are equal
  8164. * @param other - A material define instance to compare to
  8165. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8166. */
  8167. isEqual(other: MaterialDefines): boolean;
  8168. /**
  8169. * Clones this instance's defines to another instance
  8170. * @param other - material defines to clone values to
  8171. */
  8172. cloneTo(other: MaterialDefines): void;
  8173. /**
  8174. * Resets the material define values
  8175. */
  8176. reset(): void;
  8177. /**
  8178. * Converts the material define values to a string
  8179. * @returns - String of material define information
  8180. */
  8181. toString(): string;
  8182. }
  8183. }
  8184. declare module "babylonjs/Materials/colorCurves" {
  8185. import { Effect } from "babylonjs/Materials/effect";
  8186. /**
  8187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8189. * 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;
  8190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8191. */
  8192. export class ColorCurves {
  8193. private _dirty;
  8194. private _tempColor;
  8195. private _globalCurve;
  8196. private _highlightsCurve;
  8197. private _midtonesCurve;
  8198. private _shadowsCurve;
  8199. private _positiveCurve;
  8200. private _negativeCurve;
  8201. private _globalHue;
  8202. private _globalDensity;
  8203. private _globalSaturation;
  8204. private _globalExposure;
  8205. /**
  8206. * Gets the global Hue value.
  8207. * 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).
  8208. */
  8209. get globalHue(): number;
  8210. /**
  8211. * Sets the global Hue value.
  8212. * 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).
  8213. */
  8214. set globalHue(value: number);
  8215. /**
  8216. * Gets the global Density value.
  8217. * 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.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. get globalDensity(): number;
  8221. /**
  8222. * Sets the global Density value.
  8223. * 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.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. set globalDensity(value: number);
  8227. /**
  8228. * Gets the global Saturation value.
  8229. * 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.
  8230. */
  8231. get globalSaturation(): number;
  8232. /**
  8233. * Sets the global Saturation value.
  8234. * 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.
  8235. */
  8236. set globalSaturation(value: number);
  8237. /**
  8238. * Gets the global Exposure value.
  8239. * 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.
  8240. */
  8241. get globalExposure(): number;
  8242. /**
  8243. * Sets the global Exposure value.
  8244. * 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.
  8245. */
  8246. set globalExposure(value: number);
  8247. private _highlightsHue;
  8248. private _highlightsDensity;
  8249. private _highlightsSaturation;
  8250. private _highlightsExposure;
  8251. /**
  8252. * Gets the highlights Hue value.
  8253. * 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).
  8254. */
  8255. get highlightsHue(): number;
  8256. /**
  8257. * Sets the highlights Hue value.
  8258. * 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).
  8259. */
  8260. set highlightsHue(value: number);
  8261. /**
  8262. * Gets the highlights Density value.
  8263. * 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.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. get highlightsDensity(): number;
  8267. /**
  8268. * Sets the highlights Density value.
  8269. * 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.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. set highlightsDensity(value: number);
  8273. /**
  8274. * Gets the highlights Saturation value.
  8275. * 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.
  8276. */
  8277. get highlightsSaturation(): number;
  8278. /**
  8279. * Sets the highlights Saturation value.
  8280. * 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.
  8281. */
  8282. set highlightsSaturation(value: number);
  8283. /**
  8284. * Gets the highlights Exposure value.
  8285. * 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.
  8286. */
  8287. get highlightsExposure(): number;
  8288. /**
  8289. * Sets the highlights Exposure value.
  8290. * 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.
  8291. */
  8292. set highlightsExposure(value: number);
  8293. private _midtonesHue;
  8294. private _midtonesDensity;
  8295. private _midtonesSaturation;
  8296. private _midtonesExposure;
  8297. /**
  8298. * Gets the midtones Hue value.
  8299. * 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).
  8300. */
  8301. get midtonesHue(): number;
  8302. /**
  8303. * Sets the midtones Hue value.
  8304. * 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).
  8305. */
  8306. set midtonesHue(value: number);
  8307. /**
  8308. * Gets the midtones Density value.
  8309. * 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.
  8310. * Values less than zero provide a filter of opposite hue.
  8311. */
  8312. get midtonesDensity(): number;
  8313. /**
  8314. * Sets the midtones Density value.
  8315. * 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.
  8316. * Values less than zero provide a filter of opposite hue.
  8317. */
  8318. set midtonesDensity(value: number);
  8319. /**
  8320. * Gets the midtones Saturation value.
  8321. * 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.
  8322. */
  8323. get midtonesSaturation(): number;
  8324. /**
  8325. * Sets the midtones Saturation value.
  8326. * 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.
  8327. */
  8328. set midtonesSaturation(value: number);
  8329. /**
  8330. * Gets the midtones Exposure value.
  8331. * 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.
  8332. */
  8333. get midtonesExposure(): number;
  8334. /**
  8335. * Sets the midtones Exposure value.
  8336. * 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.
  8337. */
  8338. set midtonesExposure(value: number);
  8339. private _shadowsHue;
  8340. private _shadowsDensity;
  8341. private _shadowsSaturation;
  8342. private _shadowsExposure;
  8343. /**
  8344. * Gets the shadows Hue value.
  8345. * 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).
  8346. */
  8347. get shadowsHue(): number;
  8348. /**
  8349. * Sets the shadows Hue value.
  8350. * 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).
  8351. */
  8352. set shadowsHue(value: number);
  8353. /**
  8354. * Gets the shadows Density value.
  8355. * 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.
  8356. * Values less than zero provide a filter of opposite hue.
  8357. */
  8358. get shadowsDensity(): number;
  8359. /**
  8360. * Sets the shadows Density value.
  8361. * 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.
  8362. * Values less than zero provide a filter of opposite hue.
  8363. */
  8364. set shadowsDensity(value: number);
  8365. /**
  8366. * Gets the shadows Saturation value.
  8367. * 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.
  8368. */
  8369. get shadowsSaturation(): number;
  8370. /**
  8371. * Sets the shadows Saturation value.
  8372. * 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.
  8373. */
  8374. set shadowsSaturation(value: number);
  8375. /**
  8376. * Gets the shadows Exposure value.
  8377. * 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.
  8378. */
  8379. get shadowsExposure(): number;
  8380. /**
  8381. * Sets the shadows Exposure value.
  8382. * 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.
  8383. */
  8384. set shadowsExposure(value: number);
  8385. /**
  8386. * Returns the class name
  8387. * @returns The class name
  8388. */
  8389. getClassName(): string;
  8390. /**
  8391. * Binds the color curves to the shader.
  8392. * @param colorCurves The color curve to bind
  8393. * @param effect The effect to bind to
  8394. * @param positiveUniform The positive uniform shader parameter
  8395. * @param neutralUniform The neutral uniform shader parameter
  8396. * @param negativeUniform The negative uniform shader parameter
  8397. */
  8398. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8399. /**
  8400. * Prepare the list of uniforms associated with the ColorCurves effects.
  8401. * @param uniformsList The list of uniforms used in the effect
  8402. */
  8403. static PrepareUniforms(uniformsList: string[]): void;
  8404. /**
  8405. * Returns color grading data based on a hue, density, saturation and exposure value.
  8406. * @param filterHue The hue of the color filter.
  8407. * @param filterDensity The density of the color filter.
  8408. * @param saturation The saturation.
  8409. * @param exposure The exposure.
  8410. * @param result The result data container.
  8411. */
  8412. private getColorGradingDataToRef;
  8413. /**
  8414. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8415. * @param value The input slider value in range [-100,100].
  8416. * @returns Adjusted value.
  8417. */
  8418. private static applyColorGradingSliderNonlinear;
  8419. /**
  8420. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8421. * @param hue The hue (H) input.
  8422. * @param saturation The saturation (S) input.
  8423. * @param brightness The brightness (B) input.
  8424. * @result An RGBA color represented as Vector4.
  8425. */
  8426. private static fromHSBToRef;
  8427. /**
  8428. * Returns a value clamped between min and max
  8429. * @param value The value to clamp
  8430. * @param min The minimum of value
  8431. * @param max The maximum of value
  8432. * @returns The clamped value.
  8433. */
  8434. private static clamp;
  8435. /**
  8436. * Clones the current color curve instance.
  8437. * @return The cloned curves
  8438. */
  8439. clone(): ColorCurves;
  8440. /**
  8441. * Serializes the current color curve instance to a json representation.
  8442. * @return a JSON representation
  8443. */
  8444. serialize(): any;
  8445. /**
  8446. * Parses the color curve from a json representation.
  8447. * @param source the JSON source to parse
  8448. * @return The parsed curves
  8449. */
  8450. static Parse(source: any): ColorCurves;
  8451. }
  8452. }
  8453. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8454. import { Observable } from "babylonjs/Misc/observable";
  8455. import { Nullable } from "babylonjs/types";
  8456. import { Color4 } from "babylonjs/Maths/math.color";
  8457. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8458. import { Effect } from "babylonjs/Materials/effect";
  8459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8460. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8461. /**
  8462. * Interface to follow in your material defines to integrate easily the
  8463. * Image proccessing functions.
  8464. * @hidden
  8465. */
  8466. export interface IImageProcessingConfigurationDefines {
  8467. IMAGEPROCESSING: boolean;
  8468. VIGNETTE: boolean;
  8469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8470. VIGNETTEBLENDMODEOPAQUE: boolean;
  8471. TONEMAPPING: boolean;
  8472. TONEMAPPING_ACES: boolean;
  8473. CONTRAST: boolean;
  8474. EXPOSURE: boolean;
  8475. COLORCURVES: boolean;
  8476. COLORGRADING: boolean;
  8477. COLORGRADING3D: boolean;
  8478. SAMPLER3DGREENDEPTH: boolean;
  8479. SAMPLER3DBGRMAP: boolean;
  8480. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8481. }
  8482. /**
  8483. * @hidden
  8484. */
  8485. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8486. IMAGEPROCESSING: boolean;
  8487. VIGNETTE: boolean;
  8488. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8489. VIGNETTEBLENDMODEOPAQUE: boolean;
  8490. TONEMAPPING: boolean;
  8491. TONEMAPPING_ACES: boolean;
  8492. CONTRAST: boolean;
  8493. COLORCURVES: boolean;
  8494. COLORGRADING: boolean;
  8495. COLORGRADING3D: boolean;
  8496. SAMPLER3DGREENDEPTH: boolean;
  8497. SAMPLER3DBGRMAP: boolean;
  8498. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8499. EXPOSURE: boolean;
  8500. constructor();
  8501. }
  8502. /**
  8503. * This groups together the common properties used for image processing either in direct forward pass
  8504. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8505. * or not.
  8506. */
  8507. export class ImageProcessingConfiguration {
  8508. /**
  8509. * Default tone mapping applied in BabylonJS.
  8510. */
  8511. static readonly TONEMAPPING_STANDARD: number;
  8512. /**
  8513. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8514. * to other engines rendering to increase portability.
  8515. */
  8516. static readonly TONEMAPPING_ACES: number;
  8517. /**
  8518. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8519. */
  8520. colorCurves: Nullable<ColorCurves>;
  8521. private _colorCurvesEnabled;
  8522. /**
  8523. * Gets wether the color curves effect is enabled.
  8524. */
  8525. get colorCurvesEnabled(): boolean;
  8526. /**
  8527. * Sets wether the color curves effect is enabled.
  8528. */
  8529. set colorCurvesEnabled(value: boolean);
  8530. private _colorGradingTexture;
  8531. /**
  8532. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8533. */
  8534. get colorGradingTexture(): Nullable<BaseTexture>;
  8535. /**
  8536. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8537. */
  8538. set colorGradingTexture(value: Nullable<BaseTexture>);
  8539. private _colorGradingEnabled;
  8540. /**
  8541. * Gets wether the color grading effect is enabled.
  8542. */
  8543. get colorGradingEnabled(): boolean;
  8544. /**
  8545. * Sets wether the color grading effect is enabled.
  8546. */
  8547. set colorGradingEnabled(value: boolean);
  8548. private _colorGradingWithGreenDepth;
  8549. /**
  8550. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8551. */
  8552. get colorGradingWithGreenDepth(): boolean;
  8553. /**
  8554. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8555. */
  8556. set colorGradingWithGreenDepth(value: boolean);
  8557. private _colorGradingBGR;
  8558. /**
  8559. * Gets wether the color grading texture contains BGR values.
  8560. */
  8561. get colorGradingBGR(): boolean;
  8562. /**
  8563. * Sets wether the color grading texture contains BGR values.
  8564. */
  8565. set colorGradingBGR(value: boolean);
  8566. /** @hidden */
  8567. _exposure: number;
  8568. /**
  8569. * Gets the Exposure used in the effect.
  8570. */
  8571. get exposure(): number;
  8572. /**
  8573. * Sets the Exposure used in the effect.
  8574. */
  8575. set exposure(value: number);
  8576. private _toneMappingEnabled;
  8577. /**
  8578. * Gets wether the tone mapping effect is enabled.
  8579. */
  8580. get toneMappingEnabled(): boolean;
  8581. /**
  8582. * Sets wether the tone mapping effect is enabled.
  8583. */
  8584. set toneMappingEnabled(value: boolean);
  8585. private _toneMappingType;
  8586. /**
  8587. * Gets the type of tone mapping effect.
  8588. */
  8589. get toneMappingType(): number;
  8590. /**
  8591. * Sets the type of tone mapping effect used in BabylonJS.
  8592. */
  8593. set toneMappingType(value: number);
  8594. protected _contrast: number;
  8595. /**
  8596. * Gets the contrast used in the effect.
  8597. */
  8598. get contrast(): number;
  8599. /**
  8600. * Sets the contrast used in the effect.
  8601. */
  8602. set contrast(value: number);
  8603. /**
  8604. * Vignette stretch size.
  8605. */
  8606. vignetteStretch: number;
  8607. /**
  8608. * Vignette centre X Offset.
  8609. */
  8610. vignetteCentreX: number;
  8611. /**
  8612. * Vignette centre Y Offset.
  8613. */
  8614. vignetteCentreY: number;
  8615. /**
  8616. * Vignette weight or intensity of the vignette effect.
  8617. */
  8618. vignetteWeight: number;
  8619. /**
  8620. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8621. * if vignetteEnabled is set to true.
  8622. */
  8623. vignetteColor: Color4;
  8624. /**
  8625. * Camera field of view used by the Vignette effect.
  8626. */
  8627. vignetteCameraFov: number;
  8628. private _vignetteBlendMode;
  8629. /**
  8630. * Gets the vignette blend mode allowing different kind of effect.
  8631. */
  8632. get vignetteBlendMode(): number;
  8633. /**
  8634. * Sets the vignette blend mode allowing different kind of effect.
  8635. */
  8636. set vignetteBlendMode(value: number);
  8637. private _vignetteEnabled;
  8638. /**
  8639. * Gets wether the vignette effect is enabled.
  8640. */
  8641. get vignetteEnabled(): boolean;
  8642. /**
  8643. * Sets wether the vignette effect is enabled.
  8644. */
  8645. set vignetteEnabled(value: boolean);
  8646. private _applyByPostProcess;
  8647. /**
  8648. * Gets wether the image processing is applied through a post process or not.
  8649. */
  8650. get applyByPostProcess(): boolean;
  8651. /**
  8652. * Sets wether the image processing is applied through a post process or not.
  8653. */
  8654. set applyByPostProcess(value: boolean);
  8655. private _isEnabled;
  8656. /**
  8657. * Gets wether the image processing is enabled or not.
  8658. */
  8659. get isEnabled(): boolean;
  8660. /**
  8661. * Sets wether the image processing is enabled or not.
  8662. */
  8663. set isEnabled(value: boolean);
  8664. /**
  8665. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8666. */
  8667. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8668. /**
  8669. * Method called each time the image processing information changes requires to recompile the effect.
  8670. */
  8671. protected _updateParameters(): void;
  8672. /**
  8673. * Gets the current class name.
  8674. * @return "ImageProcessingConfiguration"
  8675. */
  8676. getClassName(): string;
  8677. /**
  8678. * Prepare the list of uniforms associated with the Image Processing effects.
  8679. * @param uniforms The list of uniforms used in the effect
  8680. * @param defines the list of defines currently in use
  8681. */
  8682. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8683. /**
  8684. * Prepare the list of samplers associated with the Image Processing effects.
  8685. * @param samplersList The list of uniforms used in the effect
  8686. * @param defines the list of defines currently in use
  8687. */
  8688. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8689. /**
  8690. * Prepare the list of defines associated to the shader.
  8691. * @param defines the list of defines to complete
  8692. * @param forPostProcess Define if we are currently in post process mode or not
  8693. */
  8694. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8695. /**
  8696. * Returns true if all the image processing information are ready.
  8697. * @returns True if ready, otherwise, false
  8698. */
  8699. isReady(): boolean;
  8700. /**
  8701. * Binds the image processing to the shader.
  8702. * @param effect The effect to bind to
  8703. * @param overrideAspectRatio Override the aspect ratio of the effect
  8704. */
  8705. bind(effect: Effect, overrideAspectRatio?: number): void;
  8706. /**
  8707. * Clones the current image processing instance.
  8708. * @return The cloned image processing
  8709. */
  8710. clone(): ImageProcessingConfiguration;
  8711. /**
  8712. * Serializes the current image processing instance to a json representation.
  8713. * @return a JSON representation
  8714. */
  8715. serialize(): any;
  8716. /**
  8717. * Parses the image processing from a json representation.
  8718. * @param source the JSON source to parse
  8719. * @return The parsed image processing
  8720. */
  8721. static Parse(source: any): ImageProcessingConfiguration;
  8722. private static _VIGNETTEMODE_MULTIPLY;
  8723. private static _VIGNETTEMODE_OPAQUE;
  8724. /**
  8725. * Used to apply the vignette as a mix with the pixel color.
  8726. */
  8727. static get VIGNETTEMODE_MULTIPLY(): number;
  8728. /**
  8729. * Used to apply the vignette as a replacement of the pixel color.
  8730. */
  8731. static get VIGNETTEMODE_OPAQUE(): number;
  8732. }
  8733. }
  8734. declare module "babylonjs/Shaders/postprocess.vertex" {
  8735. /** @hidden */
  8736. export var postprocessVertexShader: {
  8737. name: string;
  8738. shader: string;
  8739. };
  8740. }
  8741. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8743. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8744. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8745. /**
  8746. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8747. */
  8748. export type RenderTargetTextureSize = number | {
  8749. width: number;
  8750. height: number;
  8751. layers?: number;
  8752. };
  8753. module "babylonjs/Engines/thinEngine" {
  8754. interface ThinEngine {
  8755. /**
  8756. * Creates a new render target texture
  8757. * @param size defines the size of the texture
  8758. * @param options defines the options used to create the texture
  8759. * @returns a new render target texture stored in an InternalTexture
  8760. */
  8761. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8762. /**
  8763. * Creates a depth stencil texture.
  8764. * This is only available in WebGL 2 or with the depth texture extension available.
  8765. * @param size The size of face edge in the texture.
  8766. * @param options The options defining the texture.
  8767. * @returns The texture
  8768. */
  8769. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8770. /** @hidden */
  8771. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8772. }
  8773. }
  8774. }
  8775. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8776. /**
  8777. * Defines the kind of connection point for node based material
  8778. */
  8779. export enum NodeMaterialBlockConnectionPointTypes {
  8780. /** Float */
  8781. Float = 1,
  8782. /** Int */
  8783. Int = 2,
  8784. /** Vector2 */
  8785. Vector2 = 4,
  8786. /** Vector3 */
  8787. Vector3 = 8,
  8788. /** Vector4 */
  8789. Vector4 = 16,
  8790. /** Color3 */
  8791. Color3 = 32,
  8792. /** Color4 */
  8793. Color4 = 64,
  8794. /** Matrix */
  8795. Matrix = 128,
  8796. /** Custom object */
  8797. Object = 256,
  8798. /** Detect type based on connection */
  8799. AutoDetect = 1024,
  8800. /** Output type that will be defined by input type */
  8801. BasedOnInput = 2048
  8802. }
  8803. }
  8804. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8805. /**
  8806. * Enum used to define the target of a block
  8807. */
  8808. export enum NodeMaterialBlockTargets {
  8809. /** Vertex shader */
  8810. Vertex = 1,
  8811. /** Fragment shader */
  8812. Fragment = 2,
  8813. /** Neutral */
  8814. Neutral = 4,
  8815. /** Vertex and Fragment */
  8816. VertexAndFragment = 3
  8817. }
  8818. }
  8819. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8820. /**
  8821. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8822. */
  8823. export enum NodeMaterialBlockConnectionPointMode {
  8824. /** Value is an uniform */
  8825. Uniform = 0,
  8826. /** Value is a mesh attribute */
  8827. Attribute = 1,
  8828. /** Value is a varying between vertex and fragment shaders */
  8829. Varying = 2,
  8830. /** Mode is undefined */
  8831. Undefined = 3
  8832. }
  8833. }
  8834. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8835. /**
  8836. * Enum used to define system values e.g. values automatically provided by the system
  8837. */
  8838. export enum NodeMaterialSystemValues {
  8839. /** World */
  8840. World = 1,
  8841. /** View */
  8842. View = 2,
  8843. /** Projection */
  8844. Projection = 3,
  8845. /** ViewProjection */
  8846. ViewProjection = 4,
  8847. /** WorldView */
  8848. WorldView = 5,
  8849. /** WorldViewProjection */
  8850. WorldViewProjection = 6,
  8851. /** CameraPosition */
  8852. CameraPosition = 7,
  8853. /** Fog Color */
  8854. FogColor = 8,
  8855. /** Delta time */
  8856. DeltaTime = 9
  8857. }
  8858. }
  8859. declare module "babylonjs/Maths/math.axis" {
  8860. import { Vector3 } from "babylonjs/Maths/math.vector";
  8861. /** Defines supported spaces */
  8862. export enum Space {
  8863. /** Local (object) space */
  8864. LOCAL = 0,
  8865. /** World space */
  8866. WORLD = 1,
  8867. /** Bone space */
  8868. BONE = 2
  8869. }
  8870. /** Defines the 3 main axes */
  8871. export class Axis {
  8872. /** X axis */
  8873. static X: Vector3;
  8874. /** Y axis */
  8875. static Y: Vector3;
  8876. /** Z axis */
  8877. static Z: Vector3;
  8878. }
  8879. }
  8880. declare module "babylonjs/Maths/math.frustum" {
  8881. import { Matrix } from "babylonjs/Maths/math.vector";
  8882. import { DeepImmutable } from "babylonjs/types";
  8883. import { Plane } from "babylonjs/Maths/math.plane";
  8884. /**
  8885. * Represents a camera frustum
  8886. */
  8887. export class Frustum {
  8888. /**
  8889. * Gets the planes representing the frustum
  8890. * @param transform matrix to be applied to the returned planes
  8891. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8892. */
  8893. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8894. /**
  8895. * Gets the near frustum plane transformed by the transform matrix
  8896. * @param transform transformation matrix to be applied to the resulting frustum plane
  8897. * @param frustumPlane the resuling frustum plane
  8898. */
  8899. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8900. /**
  8901. * Gets the far frustum plane transformed by the transform matrix
  8902. * @param transform transformation matrix to be applied to the resulting frustum plane
  8903. * @param frustumPlane the resuling frustum plane
  8904. */
  8905. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Gets the left frustum plane transformed by the transform matrix
  8908. * @param transform transformation matrix to be applied to the resulting frustum plane
  8909. * @param frustumPlane the resuling frustum plane
  8910. */
  8911. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8912. /**
  8913. * Gets the right frustum plane transformed by the transform matrix
  8914. * @param transform transformation matrix to be applied to the resulting frustum plane
  8915. * @param frustumPlane the resuling frustum plane
  8916. */
  8917. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8918. /**
  8919. * Gets the top frustum plane transformed by the transform matrix
  8920. * @param transform transformation matrix to be applied to the resulting frustum plane
  8921. * @param frustumPlane the resuling frustum plane
  8922. */
  8923. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8924. /**
  8925. * Gets the bottom frustum plane transformed by the transform matrix
  8926. * @param transform transformation matrix to be applied to the resulting frustum plane
  8927. * @param frustumPlane the resuling frustum plane
  8928. */
  8929. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8930. /**
  8931. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8932. * @param transform transformation matrix to be applied to the resulting frustum planes
  8933. * @param frustumPlanes the resuling frustum planes
  8934. */
  8935. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8936. }
  8937. }
  8938. declare module "babylonjs/Maths/math.size" {
  8939. /**
  8940. * Interface for the size containing width and height
  8941. */
  8942. export interface ISize {
  8943. /**
  8944. * Width
  8945. */
  8946. width: number;
  8947. /**
  8948. * Heighht
  8949. */
  8950. height: number;
  8951. }
  8952. /**
  8953. * Size containing widht and height
  8954. */
  8955. export class Size implements ISize {
  8956. /**
  8957. * Width
  8958. */
  8959. width: number;
  8960. /**
  8961. * Height
  8962. */
  8963. height: number;
  8964. /**
  8965. * Creates a Size object from the given width and height (floats).
  8966. * @param width width of the new size
  8967. * @param height height of the new size
  8968. */
  8969. constructor(width: number, height: number);
  8970. /**
  8971. * Returns a string with the Size width and height
  8972. * @returns a string with the Size width and height
  8973. */
  8974. toString(): string;
  8975. /**
  8976. * "Size"
  8977. * @returns the string "Size"
  8978. */
  8979. getClassName(): string;
  8980. /**
  8981. * Returns the Size hash code.
  8982. * @returns a hash code for a unique width and height
  8983. */
  8984. getHashCode(): number;
  8985. /**
  8986. * Updates the current size from the given one.
  8987. * @param src the given size
  8988. */
  8989. copyFrom(src: Size): void;
  8990. /**
  8991. * Updates in place the current Size from the given floats.
  8992. * @param width width of the new size
  8993. * @param height height of the new size
  8994. * @returns the updated Size.
  8995. */
  8996. copyFromFloats(width: number, height: number): Size;
  8997. /**
  8998. * Updates in place the current Size from the given floats.
  8999. * @param width width to set
  9000. * @param height height to set
  9001. * @returns the updated Size.
  9002. */
  9003. set(width: number, height: number): Size;
  9004. /**
  9005. * Multiplies the width and height by numbers
  9006. * @param w factor to multiple the width by
  9007. * @param h factor to multiple the height by
  9008. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9009. */
  9010. multiplyByFloats(w: number, h: number): Size;
  9011. /**
  9012. * Clones the size
  9013. * @returns a new Size copied from the given one.
  9014. */
  9015. clone(): Size;
  9016. /**
  9017. * True if the current Size and the given one width and height are strictly equal.
  9018. * @param other the other size to compare against
  9019. * @returns True if the current Size and the given one width and height are strictly equal.
  9020. */
  9021. equals(other: Size): boolean;
  9022. /**
  9023. * The surface of the Size : width * height (float).
  9024. */
  9025. get surface(): number;
  9026. /**
  9027. * Create a new size of zero
  9028. * @returns a new Size set to (0.0, 0.0)
  9029. */
  9030. static Zero(): Size;
  9031. /**
  9032. * Sums the width and height of two sizes
  9033. * @param otherSize size to add to this size
  9034. * @returns a new Size set as the addition result of the current Size and the given one.
  9035. */
  9036. add(otherSize: Size): Size;
  9037. /**
  9038. * Subtracts the width and height of two
  9039. * @param otherSize size to subtract to this size
  9040. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9041. */
  9042. subtract(otherSize: Size): Size;
  9043. /**
  9044. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9045. * @param start starting size to lerp between
  9046. * @param end end size to lerp between
  9047. * @param amount amount to lerp between the start and end values
  9048. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9049. */
  9050. static Lerp(start: Size, end: Size, amount: number): Size;
  9051. }
  9052. }
  9053. declare module "babylonjs/Maths/math.vertexFormat" {
  9054. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9055. /**
  9056. * Contains position and normal vectors for a vertex
  9057. */
  9058. export class PositionNormalVertex {
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position: Vector3;
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal: Vector3;
  9063. /**
  9064. * Creates a PositionNormalVertex
  9065. * @param position the position of the vertex (defaut: 0,0,0)
  9066. * @param normal the normal of the vertex (defaut: 0,1,0)
  9067. */
  9068. constructor(
  9069. /** the position of the vertex (defaut: 0,0,0) */
  9070. position?: Vector3,
  9071. /** the normal of the vertex (defaut: 0,1,0) */
  9072. normal?: Vector3);
  9073. /**
  9074. * Clones the PositionNormalVertex
  9075. * @returns the cloned PositionNormalVertex
  9076. */
  9077. clone(): PositionNormalVertex;
  9078. }
  9079. /**
  9080. * Contains position, normal and uv vectors for a vertex
  9081. */
  9082. export class PositionNormalTextureVertex {
  9083. /** the position of the vertex (defaut: 0,0,0) */
  9084. position: Vector3;
  9085. /** the normal of the vertex (defaut: 0,1,0) */
  9086. normal: Vector3;
  9087. /** the uv of the vertex (default: 0,0) */
  9088. uv: Vector2;
  9089. /**
  9090. * Creates a PositionNormalTextureVertex
  9091. * @param position the position of the vertex (defaut: 0,0,0)
  9092. * @param normal the normal of the vertex (defaut: 0,1,0)
  9093. * @param uv the uv of the vertex (default: 0,0)
  9094. */
  9095. constructor(
  9096. /** the position of the vertex (defaut: 0,0,0) */
  9097. position?: Vector3,
  9098. /** the normal of the vertex (defaut: 0,1,0) */
  9099. normal?: Vector3,
  9100. /** the uv of the vertex (default: 0,0) */
  9101. uv?: Vector2);
  9102. /**
  9103. * Clones the PositionNormalTextureVertex
  9104. * @returns the cloned PositionNormalTextureVertex
  9105. */
  9106. clone(): PositionNormalTextureVertex;
  9107. }
  9108. }
  9109. declare module "babylonjs/Maths/math" {
  9110. export * from "babylonjs/Maths/math.axis";
  9111. export * from "babylonjs/Maths/math.color";
  9112. export * from "babylonjs/Maths/math.constants";
  9113. export * from "babylonjs/Maths/math.frustum";
  9114. export * from "babylonjs/Maths/math.path";
  9115. export * from "babylonjs/Maths/math.plane";
  9116. export * from "babylonjs/Maths/math.size";
  9117. export * from "babylonjs/Maths/math.vector";
  9118. export * from "babylonjs/Maths/math.vertexFormat";
  9119. export * from "babylonjs/Maths/math.viewport";
  9120. }
  9121. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9122. /**
  9123. * Enum defining the type of animations supported by InputBlock
  9124. */
  9125. export enum AnimatedInputBlockTypes {
  9126. /** No animation */
  9127. None = 0,
  9128. /** Time based animation. Will only work for floats */
  9129. Time = 1
  9130. }
  9131. }
  9132. declare module "babylonjs/Lights/shadowLight" {
  9133. import { Camera } from "babylonjs/Cameras/camera";
  9134. import { Scene } from "babylonjs/scene";
  9135. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. import { Light } from "babylonjs/Lights/light";
  9138. /**
  9139. * Interface describing all the common properties and methods a shadow light needs to implement.
  9140. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9141. * as well as binding the different shadow properties to the effects.
  9142. */
  9143. export interface IShadowLight extends Light {
  9144. /**
  9145. * The light id in the scene (used in scene.findLighById for instance)
  9146. */
  9147. id: string;
  9148. /**
  9149. * The position the shdow will be casted from.
  9150. */
  9151. position: Vector3;
  9152. /**
  9153. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9154. */
  9155. direction: Vector3;
  9156. /**
  9157. * The transformed position. Position of the light in world space taking parenting in account.
  9158. */
  9159. transformedPosition: Vector3;
  9160. /**
  9161. * The transformed direction. Direction of the light in world space taking parenting in account.
  9162. */
  9163. transformedDirection: Vector3;
  9164. /**
  9165. * The friendly name of the light in the scene.
  9166. */
  9167. name: string;
  9168. /**
  9169. * Defines the shadow projection clipping minimum z value.
  9170. */
  9171. shadowMinZ: number;
  9172. /**
  9173. * Defines the shadow projection clipping maximum z value.
  9174. */
  9175. shadowMaxZ: number;
  9176. /**
  9177. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9178. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9179. */
  9180. computeTransformedInformation(): boolean;
  9181. /**
  9182. * Gets the scene the light belongs to.
  9183. * @returns The scene
  9184. */
  9185. getScene(): Scene;
  9186. /**
  9187. * Callback defining a custom Projection Matrix Builder.
  9188. * This can be used to override the default projection matrix computation.
  9189. */
  9190. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9191. /**
  9192. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9193. * @param matrix The materix to updated with the projection information
  9194. * @param viewMatrix The transform matrix of the light
  9195. * @param renderList The list of mesh to render in the map
  9196. * @returns The current light
  9197. */
  9198. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9199. /**
  9200. * Gets the current depth scale used in ESM.
  9201. * @returns The scale
  9202. */
  9203. getDepthScale(): number;
  9204. /**
  9205. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9206. * @returns true if a cube texture needs to be use
  9207. */
  9208. needCube(): boolean;
  9209. /**
  9210. * Detects if the projection matrix requires to be recomputed this frame.
  9211. * @returns true if it requires to be recomputed otherwise, false.
  9212. */
  9213. needProjectionMatrixCompute(): boolean;
  9214. /**
  9215. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9216. */
  9217. forceProjectionMatrixCompute(): void;
  9218. /**
  9219. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9220. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9221. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9222. */
  9223. getShadowDirection(faceIndex?: number): Vector3;
  9224. /**
  9225. * Gets the minZ used for shadow according to both the scene and the light.
  9226. * @param activeCamera The camera we are returning the min for
  9227. * @returns the depth min z
  9228. */
  9229. getDepthMinZ(activeCamera: Camera): number;
  9230. /**
  9231. * Gets the maxZ used for shadow according to both the scene and the light.
  9232. * @param activeCamera The camera we are returning the max for
  9233. * @returns the depth max z
  9234. */
  9235. getDepthMaxZ(activeCamera: Camera): number;
  9236. }
  9237. /**
  9238. * Base implementation IShadowLight
  9239. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9240. */
  9241. export abstract class ShadowLight extends Light implements IShadowLight {
  9242. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9243. protected _position: Vector3;
  9244. protected _setPosition(value: Vector3): void;
  9245. /**
  9246. * Sets the position the shadow will be casted from. Also use as the light position for both
  9247. * point and spot lights.
  9248. */
  9249. get position(): Vector3;
  9250. /**
  9251. * Sets the position the shadow will be casted from. Also use as the light position for both
  9252. * point and spot lights.
  9253. */
  9254. set position(value: Vector3);
  9255. protected _direction: Vector3;
  9256. protected _setDirection(value: Vector3): void;
  9257. /**
  9258. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9259. * Also use as the light direction on spot and directional lights.
  9260. */
  9261. get direction(): Vector3;
  9262. /**
  9263. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9264. * Also use as the light direction on spot and directional lights.
  9265. */
  9266. set direction(value: Vector3);
  9267. protected _shadowMinZ: number;
  9268. /**
  9269. * Gets the shadow projection clipping minimum z value.
  9270. */
  9271. get shadowMinZ(): number;
  9272. /**
  9273. * Sets the shadow projection clipping minimum z value.
  9274. */
  9275. set shadowMinZ(value: number);
  9276. protected _shadowMaxZ: number;
  9277. /**
  9278. * Sets the shadow projection clipping maximum z value.
  9279. */
  9280. get shadowMaxZ(): number;
  9281. /**
  9282. * Gets the shadow projection clipping maximum z value.
  9283. */
  9284. set shadowMaxZ(value: number);
  9285. /**
  9286. * Callback defining a custom Projection Matrix Builder.
  9287. * This can be used to override the default projection matrix computation.
  9288. */
  9289. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9290. /**
  9291. * The transformed position. Position of the light in world space taking parenting in account.
  9292. */
  9293. transformedPosition: Vector3;
  9294. /**
  9295. * The transformed direction. Direction of the light in world space taking parenting in account.
  9296. */
  9297. transformedDirection: Vector3;
  9298. private _needProjectionMatrixCompute;
  9299. /**
  9300. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9301. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9302. */
  9303. computeTransformedInformation(): boolean;
  9304. /**
  9305. * Return the depth scale used for the shadow map.
  9306. * @returns the depth scale.
  9307. */
  9308. getDepthScale(): number;
  9309. /**
  9310. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9311. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9312. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9313. */
  9314. getShadowDirection(faceIndex?: number): Vector3;
  9315. /**
  9316. * Returns the ShadowLight absolute position in the World.
  9317. * @returns the position vector in world space
  9318. */
  9319. getAbsolutePosition(): Vector3;
  9320. /**
  9321. * Sets the ShadowLight direction toward the passed target.
  9322. * @param target The point to target in local space
  9323. * @returns the updated ShadowLight direction
  9324. */
  9325. setDirectionToTarget(target: Vector3): Vector3;
  9326. /**
  9327. * Returns the light rotation in euler definition.
  9328. * @returns the x y z rotation in local space.
  9329. */
  9330. getRotation(): Vector3;
  9331. /**
  9332. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9333. * @returns true if a cube texture needs to be use
  9334. */
  9335. needCube(): boolean;
  9336. /**
  9337. * Detects if the projection matrix requires to be recomputed this frame.
  9338. * @returns true if it requires to be recomputed otherwise, false.
  9339. */
  9340. needProjectionMatrixCompute(): boolean;
  9341. /**
  9342. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9343. */
  9344. forceProjectionMatrixCompute(): void;
  9345. /** @hidden */
  9346. _initCache(): void;
  9347. /** @hidden */
  9348. _isSynchronized(): boolean;
  9349. /**
  9350. * Computes the world matrix of the node
  9351. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9352. * @returns the world matrix
  9353. */
  9354. computeWorldMatrix(force?: boolean): Matrix;
  9355. /**
  9356. * Gets the minZ used for shadow according to both the scene and the light.
  9357. * @param activeCamera The camera we are returning the min for
  9358. * @returns the depth min z
  9359. */
  9360. getDepthMinZ(activeCamera: Camera): number;
  9361. /**
  9362. * Gets the maxZ used for shadow according to both the scene and the light.
  9363. * @param activeCamera The camera we are returning the max for
  9364. * @returns the depth max z
  9365. */
  9366. getDepthMaxZ(activeCamera: Camera): number;
  9367. /**
  9368. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9369. * @param matrix The materix to updated with the projection information
  9370. * @param viewMatrix The transform matrix of the light
  9371. * @param renderList The list of mesh to render in the map
  9372. * @returns The current light
  9373. */
  9374. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9375. }
  9376. }
  9377. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9378. /** @hidden */
  9379. export var packingFunctions: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9385. /** @hidden */
  9386. export var bayerDitherFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9392. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9393. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9394. /** @hidden */
  9395. export var shadowMapFragmentDeclaration: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9401. /** @hidden */
  9402. export var clipPlaneFragmentDeclaration: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9408. /** @hidden */
  9409. export var clipPlaneFragment: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9415. /** @hidden */
  9416. export var shadowMapFragment: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9422. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9424. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9425. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9426. /** @hidden */
  9427. export var shadowMapPixelShader: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9433. /** @hidden */
  9434. export var bonesDeclaration: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9440. /** @hidden */
  9441. export var morphTargetsVertexGlobalDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9447. /** @hidden */
  9448. export var morphTargetsVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9454. /** @hidden */
  9455. export var instancesDeclaration: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9461. /** @hidden */
  9462. export var helperFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9468. /** @hidden */
  9469. export var shadowMapVertexDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9475. /** @hidden */
  9476. export var clipPlaneVertexDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9482. /** @hidden */
  9483. export var morphTargetsVertex: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9489. /** @hidden */
  9490. export var instancesVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9496. /** @hidden */
  9497. export var bonesVertex: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9503. /** @hidden */
  9504. export var shadowMapVertexNormalBias: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9510. /** @hidden */
  9511. export var shadowMapVertexMetric: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9517. /** @hidden */
  9518. export var clipPlaneVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9524. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9529. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9537. /** @hidden */
  9538. export var shadowMapVertexShader: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9544. /** @hidden */
  9545. export var depthBoxBlurPixelShader: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9551. /** @hidden */
  9552. export var shadowMapFragmentSoftTransparentShadow: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Materials/effectFallbacks" {
  9558. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9559. import { Effect } from "babylonjs/Materials/effect";
  9560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9561. /**
  9562. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9563. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9564. */
  9565. export class EffectFallbacks implements IEffectFallbacks {
  9566. private _defines;
  9567. private _currentRank;
  9568. private _maxRank;
  9569. private _mesh;
  9570. /**
  9571. * Removes the fallback from the bound mesh.
  9572. */
  9573. unBindMesh(): void;
  9574. /**
  9575. * Adds a fallback on the specified property.
  9576. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9577. * @param define The name of the define in the shader
  9578. */
  9579. addFallback(rank: number, define: string): void;
  9580. /**
  9581. * Sets the mesh to use CPU skinning when needing to fallback.
  9582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9583. * @param mesh The mesh to use the fallbacks.
  9584. */
  9585. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9586. /**
  9587. * Checks to see if more fallbacks are still availible.
  9588. */
  9589. get hasMoreFallbacks(): boolean;
  9590. /**
  9591. * Removes the defines that should be removed when falling back.
  9592. * @param currentDefines defines the current define statements for the shader.
  9593. * @param effect defines the current effect we try to compile
  9594. * @returns The resulting defines with defines of the current rank removed.
  9595. */
  9596. reduce(currentDefines: string, effect: Effect): string;
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/action" {
  9600. import { Observable } from "babylonjs/Misc/observable";
  9601. import { Condition } from "babylonjs/Actions/condition";
  9602. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9603. import { Nullable } from "babylonjs/types";
  9604. import { Scene } from "babylonjs/scene";
  9605. import { ActionManager } from "babylonjs/Actions/actionManager";
  9606. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9607. import { Node } from "babylonjs/node";
  9608. /**
  9609. * Interface used to define Action
  9610. */
  9611. export interface IAction {
  9612. /**
  9613. * Trigger for the action
  9614. */
  9615. trigger: number;
  9616. /** Options of the trigger */
  9617. triggerOptions: any;
  9618. /**
  9619. * Gets the trigger parameters
  9620. * @returns the trigger parameters
  9621. */
  9622. getTriggerParameter(): any;
  9623. /**
  9624. * Internal only - executes current action event
  9625. * @hidden
  9626. */
  9627. _executeCurrent(evt?: ActionEvent): void;
  9628. /**
  9629. * Serialize placeholder for child classes
  9630. * @param parent of child
  9631. * @returns the serialized object
  9632. */
  9633. serialize(parent: any): any;
  9634. /**
  9635. * Internal only
  9636. * @hidden
  9637. */
  9638. _prepare(): void;
  9639. /**
  9640. * Internal only - manager for action
  9641. * @hidden
  9642. */
  9643. _actionManager: Nullable<AbstractActionManager>;
  9644. /**
  9645. * Adds action to chain of actions, may be a DoNothingAction
  9646. * @param action defines the next action to execute
  9647. * @returns The action passed in
  9648. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9649. */
  9650. then(action: IAction): IAction;
  9651. }
  9652. /**
  9653. * The action to be carried out following a trigger
  9654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9655. */
  9656. export class Action implements IAction {
  9657. /** the trigger, with or without parameters, for the action */
  9658. triggerOptions: any;
  9659. /**
  9660. * Trigger for the action
  9661. */
  9662. trigger: number;
  9663. /**
  9664. * Internal only - manager for action
  9665. * @hidden
  9666. */
  9667. _actionManager: ActionManager;
  9668. private _nextActiveAction;
  9669. private _child;
  9670. private _condition?;
  9671. private _triggerParameter;
  9672. /**
  9673. * An event triggered prior to action being executed.
  9674. */
  9675. onBeforeExecuteObservable: Observable<Action>;
  9676. /**
  9677. * Creates a new Action
  9678. * @param triggerOptions the trigger, with or without parameters, for the action
  9679. * @param condition an optional determinant of action
  9680. */
  9681. constructor(
  9682. /** the trigger, with or without parameters, for the action */
  9683. triggerOptions: any, condition?: Condition);
  9684. /**
  9685. * Internal only
  9686. * @hidden
  9687. */
  9688. _prepare(): void;
  9689. /**
  9690. * Gets the trigger parameters
  9691. * @returns the trigger parameters
  9692. */
  9693. getTriggerParameter(): any;
  9694. /**
  9695. * Internal only - executes current action event
  9696. * @hidden
  9697. */
  9698. _executeCurrent(evt?: ActionEvent): void;
  9699. /**
  9700. * Execute placeholder for child classes
  9701. * @param evt optional action event
  9702. */
  9703. execute(evt?: ActionEvent): void;
  9704. /**
  9705. * Skips to next active action
  9706. */
  9707. skipToNextActiveAction(): void;
  9708. /**
  9709. * Adds action to chain of actions, may be a DoNothingAction
  9710. * @param action defines the next action to execute
  9711. * @returns The action passed in
  9712. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9713. */
  9714. then(action: Action): Action;
  9715. /**
  9716. * Internal only
  9717. * @hidden
  9718. */
  9719. _getProperty(propertyPath: string): string;
  9720. /**
  9721. * Internal only
  9722. * @hidden
  9723. */
  9724. _getEffectiveTarget(target: any, propertyPath: string): any;
  9725. /**
  9726. * Serialize placeholder for child classes
  9727. * @param parent of child
  9728. * @returns the serialized object
  9729. */
  9730. serialize(parent: any): any;
  9731. /**
  9732. * Internal only called by serialize
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedAction: any, parent?: any): any;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. static _SerializeValueAsString: (value: any) => string;
  9741. /**
  9742. * Internal only
  9743. * @hidden
  9744. */
  9745. static _GetTargetProperty: (target: Scene | Node) => {
  9746. name: string;
  9747. targetType: string;
  9748. value: string;
  9749. };
  9750. }
  9751. }
  9752. declare module "babylonjs/Actions/condition" {
  9753. import { ActionManager } from "babylonjs/Actions/actionManager";
  9754. /**
  9755. * A Condition applied to an Action
  9756. */
  9757. export class Condition {
  9758. /**
  9759. * Internal only - manager for action
  9760. * @hidden
  9761. */
  9762. _actionManager: ActionManager;
  9763. /**
  9764. * Internal only
  9765. * @hidden
  9766. */
  9767. _evaluationId: number;
  9768. /**
  9769. * Internal only
  9770. * @hidden
  9771. */
  9772. _currentResult: boolean;
  9773. /**
  9774. * Creates a new Condition
  9775. * @param actionManager the manager of the action the condition is applied to
  9776. */
  9777. constructor(actionManager: ActionManager);
  9778. /**
  9779. * Check if the current condition is valid
  9780. * @returns a boolean
  9781. */
  9782. isValid(): boolean;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. _getProperty(propertyPath: string): string;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. _getEffectiveTarget(target: any, propertyPath: string): any;
  9793. /**
  9794. * Serialize placeholder for child classes
  9795. * @returns the serialized object
  9796. */
  9797. serialize(): any;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. protected _serialize(serializedCondition: any): any;
  9803. }
  9804. /**
  9805. * Defines specific conditional operators as extensions of Condition
  9806. */
  9807. export class ValueCondition extends Condition {
  9808. /** path to specify the property of the target the conditional operator uses */
  9809. propertyPath: string;
  9810. /** the value compared by the conditional operator against the current value of the property */
  9811. value: any;
  9812. /** the conditional operator, default ValueCondition.IsEqual */
  9813. operator: number;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsEqual;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsDifferent;
  9824. /**
  9825. * Internal only
  9826. * @hidden
  9827. */
  9828. private static _IsGreater;
  9829. /**
  9830. * Internal only
  9831. * @hidden
  9832. */
  9833. private static _IsLesser;
  9834. /**
  9835. * returns the number for IsEqual
  9836. */
  9837. static get IsEqual(): number;
  9838. /**
  9839. * Returns the number for IsDifferent
  9840. */
  9841. static get IsDifferent(): number;
  9842. /**
  9843. * Returns the number for IsGreater
  9844. */
  9845. static get IsGreater(): number;
  9846. /**
  9847. * Returns the number for IsLesser
  9848. */
  9849. static get IsLesser(): number;
  9850. /**
  9851. * Internal only The action manager for the condition
  9852. * @hidden
  9853. */
  9854. _actionManager: ActionManager;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _target;
  9860. /**
  9861. * Internal only
  9862. * @hidden
  9863. */
  9864. private _effectiveTarget;
  9865. /**
  9866. * Internal only
  9867. * @hidden
  9868. */
  9869. private _property;
  9870. /**
  9871. * Creates a new ValueCondition
  9872. * @param actionManager manager for the action the condition applies to
  9873. * @param target for the action
  9874. * @param propertyPath path to specify the property of the target the conditional operator uses
  9875. * @param value the value compared by the conditional operator against the current value of the property
  9876. * @param operator the conditional operator, default ValueCondition.IsEqual
  9877. */
  9878. constructor(actionManager: ActionManager, target: any,
  9879. /** path to specify the property of the target the conditional operator uses */
  9880. propertyPath: string,
  9881. /** the value compared by the conditional operator against the current value of the property */
  9882. value: any,
  9883. /** the conditional operator, default ValueCondition.IsEqual */
  9884. operator?: number);
  9885. /**
  9886. * Compares the given value with the property value for the specified conditional operator
  9887. * @returns the result of the comparison
  9888. */
  9889. isValid(): boolean;
  9890. /**
  9891. * Serialize the ValueCondition into a JSON compatible object
  9892. * @returns serialization object
  9893. */
  9894. serialize(): any;
  9895. /**
  9896. * Gets the name of the conditional operator for the ValueCondition
  9897. * @param operator the conditional operator
  9898. * @returns the name
  9899. */
  9900. static GetOperatorName(operator: number): string;
  9901. }
  9902. /**
  9903. * Defines a predicate condition as an extension of Condition
  9904. */
  9905. export class PredicateCondition extends Condition {
  9906. /** defines the predicate function used to validate the condition */
  9907. predicate: () => boolean;
  9908. /**
  9909. * Internal only - manager for action
  9910. * @hidden
  9911. */
  9912. _actionManager: ActionManager;
  9913. /**
  9914. * Creates a new PredicateCondition
  9915. * @param actionManager manager for the action the condition applies to
  9916. * @param predicate defines the predicate function used to validate the condition
  9917. */
  9918. constructor(actionManager: ActionManager,
  9919. /** defines the predicate function used to validate the condition */
  9920. predicate: () => boolean);
  9921. /**
  9922. * @returns the validity of the predicate condition
  9923. */
  9924. isValid(): boolean;
  9925. }
  9926. /**
  9927. * Defines a state condition as an extension of Condition
  9928. */
  9929. export class StateCondition extends Condition {
  9930. /** Value to compare with target state */
  9931. value: string;
  9932. /**
  9933. * Internal only - manager for action
  9934. * @hidden
  9935. */
  9936. _actionManager: ActionManager;
  9937. /**
  9938. * Internal only
  9939. * @hidden
  9940. */
  9941. private _target;
  9942. /**
  9943. * Creates a new StateCondition
  9944. * @param actionManager manager for the action the condition applies to
  9945. * @param target of the condition
  9946. * @param value to compare with target state
  9947. */
  9948. constructor(actionManager: ActionManager, target: any,
  9949. /** Value to compare with target state */
  9950. value: string);
  9951. /**
  9952. * Gets a boolean indicating if the current condition is met
  9953. * @returns the validity of the state
  9954. */
  9955. isValid(): boolean;
  9956. /**
  9957. * Serialize the StateCondition into a JSON compatible object
  9958. * @returns serialization object
  9959. */
  9960. serialize(): any;
  9961. }
  9962. }
  9963. declare module "babylonjs/Actions/directActions" {
  9964. import { Action } from "babylonjs/Actions/action";
  9965. import { Condition } from "babylonjs/Actions/condition";
  9966. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9967. /**
  9968. * This defines an action responsible to toggle a boolean once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class SwitchBooleanAction extends Action {
  9972. /**
  9973. * The path to the boolean property in the target object
  9974. */
  9975. propertyPath: string;
  9976. private _target;
  9977. private _effectiveTarget;
  9978. private _property;
  9979. /**
  9980. * Instantiate the action
  9981. * @param triggerOptions defines the trigger options
  9982. * @param target defines the object containing the boolean
  9983. * @param propertyPath defines the path to the boolean property in the target object
  9984. * @param condition defines the trigger related conditions
  9985. */
  9986. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9987. /** @hidden */
  9988. _prepare(): void;
  9989. /**
  9990. * Execute the action toggle the boolean value.
  9991. */
  9992. execute(): void;
  9993. /**
  9994. * Serializes the actions and its related information.
  9995. * @param parent defines the object to serialize in
  9996. * @returns the serialized object
  9997. */
  9998. serialize(parent: any): any;
  9999. }
  10000. /**
  10001. * This defines an action responsible to set a the state field of the target
  10002. * to a desired value once triggered.
  10003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10004. */
  10005. export class SetStateAction extends Action {
  10006. /**
  10007. * The value to store in the state field.
  10008. */
  10009. value: string;
  10010. private _target;
  10011. /**
  10012. * Instantiate the action
  10013. * @param triggerOptions defines the trigger options
  10014. * @param target defines the object containing the state property
  10015. * @param value defines the value to store in the state field
  10016. * @param condition defines the trigger related conditions
  10017. */
  10018. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10019. /**
  10020. * Execute the action and store the value on the target state property.
  10021. */
  10022. execute(): void;
  10023. /**
  10024. * Serializes the actions and its related information.
  10025. * @param parent defines the object to serialize in
  10026. * @returns the serialized object
  10027. */
  10028. serialize(parent: any): any;
  10029. }
  10030. /**
  10031. * This defines an action responsible to set a property of the target
  10032. * to a desired value once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class SetValueAction extends Action {
  10036. /**
  10037. * The path of the property to set in the target.
  10038. */
  10039. propertyPath: string;
  10040. /**
  10041. * The value to set in the property
  10042. */
  10043. value: any;
  10044. private _target;
  10045. private _effectiveTarget;
  10046. private _property;
  10047. /**
  10048. * Instantiate the action
  10049. * @param triggerOptions defines the trigger options
  10050. * @param target defines the object containing the property
  10051. * @param propertyPath defines the path of the property to set in the target
  10052. * @param value defines the value to set in the property
  10053. * @param condition defines the trigger related conditions
  10054. */
  10055. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10056. /** @hidden */
  10057. _prepare(): void;
  10058. /**
  10059. * Execute the action and set the targetted property to the desired value.
  10060. */
  10061. execute(): void;
  10062. /**
  10063. * Serializes the actions and its related information.
  10064. * @param parent defines the object to serialize in
  10065. * @returns the serialized object
  10066. */
  10067. serialize(parent: any): any;
  10068. }
  10069. /**
  10070. * This defines an action responsible to increment the target value
  10071. * to a desired value once triggered.
  10072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10073. */
  10074. export class IncrementValueAction extends Action {
  10075. /**
  10076. * The path of the property to increment in the target.
  10077. */
  10078. propertyPath: string;
  10079. /**
  10080. * The value we should increment the property by.
  10081. */
  10082. value: any;
  10083. private _target;
  10084. private _effectiveTarget;
  10085. private _property;
  10086. /**
  10087. * Instantiate the action
  10088. * @param triggerOptions defines the trigger options
  10089. * @param target defines the object containing the property
  10090. * @param propertyPath defines the path of the property to increment in the target
  10091. * @param value defines the value value we should increment the property by
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and increment the target of the value amount.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible to start an animation once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class PlayAnimationAction extends Action {
  10113. /**
  10114. * Where the animation should start (animation frame)
  10115. */
  10116. from: number;
  10117. /**
  10118. * Where the animation should stop (animation frame)
  10119. */
  10120. to: number;
  10121. /**
  10122. * Define if the animation should loop or stop after the first play.
  10123. */
  10124. loop?: boolean;
  10125. private _target;
  10126. /**
  10127. * Instantiate the action
  10128. * @param triggerOptions defines the trigger options
  10129. * @param target defines the target animation or animation name
  10130. * @param from defines from where the animation should start (animation frame)
  10131. * @param end defines where the animation should stop (animation frame)
  10132. * @param loop defines if the animation should loop or stop after the first play
  10133. * @param condition defines the trigger related conditions
  10134. */
  10135. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10136. /** @hidden */
  10137. _prepare(): void;
  10138. /**
  10139. * Execute the action and play the animation.
  10140. */
  10141. execute(): void;
  10142. /**
  10143. * Serializes the actions and its related information.
  10144. * @param parent defines the object to serialize in
  10145. * @returns the serialized object
  10146. */
  10147. serialize(parent: any): any;
  10148. }
  10149. /**
  10150. * This defines an action responsible to stop an animation once triggered.
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10152. */
  10153. export class StopAnimationAction extends Action {
  10154. private _target;
  10155. /**
  10156. * Instantiate the action
  10157. * @param triggerOptions defines the trigger options
  10158. * @param target defines the target animation or animation name
  10159. * @param condition defines the trigger related conditions
  10160. */
  10161. constructor(triggerOptions: any, target: any, condition?: Condition);
  10162. /** @hidden */
  10163. _prepare(): void;
  10164. /**
  10165. * Execute the action and stop the animation.
  10166. */
  10167. execute(): void;
  10168. /**
  10169. * Serializes the actions and its related information.
  10170. * @param parent defines the object to serialize in
  10171. * @returns the serialized object
  10172. */
  10173. serialize(parent: any): any;
  10174. }
  10175. /**
  10176. * This defines an action responsible that does nothing once triggered.
  10177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10178. */
  10179. export class DoNothingAction extends Action {
  10180. /**
  10181. * Instantiate the action
  10182. * @param triggerOptions defines the trigger options
  10183. * @param condition defines the trigger related conditions
  10184. */
  10185. constructor(triggerOptions?: any, condition?: Condition);
  10186. /**
  10187. * Execute the action and do nothing.
  10188. */
  10189. execute(): void;
  10190. /**
  10191. * Serializes the actions and its related information.
  10192. * @param parent defines the object to serialize in
  10193. * @returns the serialized object
  10194. */
  10195. serialize(parent: any): any;
  10196. }
  10197. /**
  10198. * This defines an action responsible to trigger several actions once triggered.
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10200. */
  10201. export class CombineAction extends Action {
  10202. /**
  10203. * The list of aggregated animations to run.
  10204. */
  10205. children: Action[];
  10206. /**
  10207. * Instantiate the action
  10208. * @param triggerOptions defines the trigger options
  10209. * @param children defines the list of aggregated animations to run
  10210. * @param condition defines the trigger related conditions
  10211. */
  10212. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10213. /** @hidden */
  10214. _prepare(): void;
  10215. /**
  10216. * Execute the action and executes all the aggregated actions.
  10217. */
  10218. execute(evt: ActionEvent): void;
  10219. /**
  10220. * Serializes the actions and its related information.
  10221. * @param parent defines the object to serialize in
  10222. * @returns the serialized object
  10223. */
  10224. serialize(parent: any): any;
  10225. }
  10226. /**
  10227. * This defines an action responsible to run code (external event) once triggered.
  10228. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10229. */
  10230. export class ExecuteCodeAction extends Action {
  10231. /**
  10232. * The callback function to run.
  10233. */
  10234. func: (evt: ActionEvent) => void;
  10235. /**
  10236. * Instantiate the action
  10237. * @param triggerOptions defines the trigger options
  10238. * @param func defines the callback function to run
  10239. * @param condition defines the trigger related conditions
  10240. */
  10241. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10242. /**
  10243. * Execute the action and run the attached code.
  10244. */
  10245. execute(evt: ActionEvent): void;
  10246. }
  10247. /**
  10248. * This defines an action responsible to set the parent property of the target once triggered.
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10250. */
  10251. export class SetParentAction extends Action {
  10252. private _parent;
  10253. private _target;
  10254. /**
  10255. * Instantiate the action
  10256. * @param triggerOptions defines the trigger options
  10257. * @param target defines the target containing the parent property
  10258. * @param parent defines from where the animation should start (animation frame)
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10262. /** @hidden */
  10263. _prepare(): void;
  10264. /**
  10265. * Execute the action and set the parent property.
  10266. */
  10267. execute(): void;
  10268. /**
  10269. * Serializes the actions and its related information.
  10270. * @param parent defines the object to serialize in
  10271. * @returns the serialized object
  10272. */
  10273. serialize(parent: any): any;
  10274. }
  10275. }
  10276. declare module "babylonjs/Actions/actionManager" {
  10277. import { Nullable } from "babylonjs/types";
  10278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10279. import { Scene } from "babylonjs/scene";
  10280. import { IAction } from "babylonjs/Actions/action";
  10281. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10282. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10283. /**
  10284. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10285. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10287. */
  10288. export class ActionManager extends AbstractActionManager {
  10289. /**
  10290. * Nothing
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly NothingTrigger: number;
  10294. /**
  10295. * On pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnPickTrigger: number;
  10299. /**
  10300. * On left pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnLeftPickTrigger: number;
  10304. /**
  10305. * On right pick
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnRightPickTrigger: number;
  10309. /**
  10310. * On center pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnCenterPickTrigger: number;
  10314. /**
  10315. * On pick down
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickDownTrigger: number;
  10319. /**
  10320. * On double pick
  10321. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10322. */
  10323. static readonly OnDoublePickTrigger: number;
  10324. /**
  10325. * On pick up
  10326. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10327. */
  10328. static readonly OnPickUpTrigger: number;
  10329. /**
  10330. * On pick out.
  10331. * This trigger will only be raised if you also declared a OnPickDown
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickOutTrigger: number;
  10335. /**
  10336. * On long press
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnLongPressTrigger: number;
  10340. /**
  10341. * On pointer over
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnPointerOverTrigger: number;
  10345. /**
  10346. * On pointer out
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnPointerOutTrigger: number;
  10350. /**
  10351. * On every frame
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnEveryFrameTrigger: number;
  10355. /**
  10356. * On intersection enter
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnIntersectionEnterTrigger: number;
  10360. /**
  10361. * On intersection exit
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnIntersectionExitTrigger: number;
  10365. /**
  10366. * On key down
  10367. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10368. */
  10369. static readonly OnKeyDownTrigger: number;
  10370. /**
  10371. * On key up
  10372. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10373. */
  10374. static readonly OnKeyUpTrigger: number;
  10375. private _scene;
  10376. /**
  10377. * Creates a new action manager
  10378. * @param scene defines the hosting scene
  10379. */
  10380. constructor(scene: Scene);
  10381. /**
  10382. * Releases all associated resources
  10383. */
  10384. dispose(): void;
  10385. /**
  10386. * Gets hosting scene
  10387. * @returns the hosting scene
  10388. */
  10389. getScene(): Scene;
  10390. /**
  10391. * Does this action manager handles actions of any of the given triggers
  10392. * @param triggers defines the triggers to be tested
  10393. * @return a boolean indicating whether one (or more) of the triggers is handled
  10394. */
  10395. hasSpecificTriggers(triggers: number[]): boolean;
  10396. /**
  10397. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10398. * speed.
  10399. * @param triggerA defines the trigger to be tested
  10400. * @param triggerB defines the trigger to be tested
  10401. * @return a boolean indicating whether one (or more) of the triggers is handled
  10402. */
  10403. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10404. /**
  10405. * Does this action manager handles actions of a given trigger
  10406. * @param trigger defines the trigger to be tested
  10407. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10408. * @return whether the trigger is handled
  10409. */
  10410. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10411. /**
  10412. * Does this action manager has pointer triggers
  10413. */
  10414. get hasPointerTriggers(): boolean;
  10415. /**
  10416. * Does this action manager has pick triggers
  10417. */
  10418. get hasPickTriggers(): boolean;
  10419. /**
  10420. * Registers an action to this action manager
  10421. * @param action defines the action to be registered
  10422. * @return the action amended (prepared) after registration
  10423. */
  10424. registerAction(action: IAction): Nullable<IAction>;
  10425. /**
  10426. * Unregisters an action to this action manager
  10427. * @param action defines the action to be unregistered
  10428. * @return a boolean indicating whether the action has been unregistered
  10429. */
  10430. unregisterAction(action: IAction): Boolean;
  10431. /**
  10432. * Process a specific trigger
  10433. * @param trigger defines the trigger to process
  10434. * @param evt defines the event details to be processed
  10435. */
  10436. processTrigger(trigger: number, evt?: IActionEvent): void;
  10437. /** @hidden */
  10438. _getEffectiveTarget(target: any, propertyPath: string): any;
  10439. /** @hidden */
  10440. _getProperty(propertyPath: string): string;
  10441. /**
  10442. * Serialize this manager to a JSON object
  10443. * @param name defines the property name to store this manager
  10444. * @returns a JSON representation of this manager
  10445. */
  10446. serialize(name: string): any;
  10447. /**
  10448. * Creates a new ActionManager from a JSON data
  10449. * @param parsedActions defines the JSON data to read from
  10450. * @param object defines the hosting mesh
  10451. * @param scene defines the hosting scene
  10452. */
  10453. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10454. /**
  10455. * Get a trigger name by index
  10456. * @param trigger defines the trigger index
  10457. * @returns a trigger name
  10458. */
  10459. static GetTriggerName(trigger: number): string;
  10460. }
  10461. }
  10462. declare module "babylonjs/Sprites/sprite" {
  10463. import { Vector3 } from "babylonjs/Maths/math.vector";
  10464. import { Nullable } from "babylonjs/types";
  10465. import { ActionManager } from "babylonjs/Actions/actionManager";
  10466. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10467. import { Color4 } from "babylonjs/Maths/math.color";
  10468. import { Observable } from "babylonjs/Misc/observable";
  10469. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10470. import { Animation } from "babylonjs/Animations/animation";
  10471. /**
  10472. * Class used to represent a sprite
  10473. * @see https://doc.babylonjs.com/babylon101/sprites
  10474. */
  10475. export class Sprite implements IAnimatable {
  10476. /** defines the name */
  10477. name: string;
  10478. /** Gets or sets the current world position */
  10479. position: Vector3;
  10480. /** Gets or sets the main color */
  10481. color: Color4;
  10482. /** Gets or sets the width */
  10483. width: number;
  10484. /** Gets or sets the height */
  10485. height: number;
  10486. /** Gets or sets rotation angle */
  10487. angle: number;
  10488. /** Gets or sets the cell index in the sprite sheet */
  10489. cellIndex: number;
  10490. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10491. cellRef: string;
  10492. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10493. invertU: boolean;
  10494. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10495. invertV: boolean;
  10496. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10497. disposeWhenFinishedAnimating: boolean;
  10498. /** Gets the list of attached animations */
  10499. animations: Nullable<Array<Animation>>;
  10500. /** Gets or sets a boolean indicating if the sprite can be picked */
  10501. isPickable: boolean;
  10502. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10503. useAlphaForPicking: boolean;
  10504. /** @hidden */
  10505. _xOffset: number;
  10506. /** @hidden */
  10507. _yOffset: number;
  10508. /** @hidden */
  10509. _xSize: number;
  10510. /** @hidden */
  10511. _ySize: number;
  10512. /**
  10513. * Gets or sets the associated action manager
  10514. */
  10515. actionManager: Nullable<ActionManager>;
  10516. /**
  10517. * An event triggered when the control has been disposed
  10518. */
  10519. onDisposeObservable: Observable<Sprite>;
  10520. private _animationStarted;
  10521. private _loopAnimation;
  10522. private _fromIndex;
  10523. private _toIndex;
  10524. private _delay;
  10525. private _direction;
  10526. private _manager;
  10527. private _time;
  10528. private _onAnimationEnd;
  10529. /**
  10530. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10531. */
  10532. isVisible: boolean;
  10533. /**
  10534. * Gets or sets the sprite size
  10535. */
  10536. get size(): number;
  10537. set size(value: number);
  10538. /**
  10539. * Returns a boolean indicating if the animation is started
  10540. */
  10541. get animationStarted(): boolean;
  10542. /**
  10543. * Gets or sets the unique id of the sprite
  10544. */
  10545. uniqueId: number;
  10546. /**
  10547. * Gets the manager of this sprite
  10548. */
  10549. get manager(): ISpriteManager;
  10550. /**
  10551. * Creates a new Sprite
  10552. * @param name defines the name
  10553. * @param manager defines the manager
  10554. */
  10555. constructor(
  10556. /** defines the name */
  10557. name: string, manager: ISpriteManager);
  10558. /**
  10559. * Returns the string "Sprite"
  10560. * @returns "Sprite"
  10561. */
  10562. getClassName(): string;
  10563. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10564. get fromIndex(): number;
  10565. set fromIndex(value: number);
  10566. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10567. get toIndex(): number;
  10568. set toIndex(value: number);
  10569. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10570. get loopAnimation(): boolean;
  10571. set loopAnimation(value: boolean);
  10572. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10573. get delay(): number;
  10574. set delay(value: number);
  10575. /**
  10576. * Starts an animation
  10577. * @param from defines the initial key
  10578. * @param to defines the end key
  10579. * @param loop defines if the animation must loop
  10580. * @param delay defines the start delay (in ms)
  10581. * @param onAnimationEnd defines a callback to call when animation ends
  10582. */
  10583. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10584. /** Stops current animation (if any) */
  10585. stopAnimation(): void;
  10586. /** @hidden */
  10587. _animate(deltaTime: number): void;
  10588. /** Release associated resources */
  10589. dispose(): void;
  10590. /**
  10591. * Serializes the sprite to a JSON object
  10592. * @returns the JSON object
  10593. */
  10594. serialize(): any;
  10595. /**
  10596. * Parses a JSON object to create a new sprite
  10597. * @param parsedSprite The JSON object to parse
  10598. * @param manager defines the hosting manager
  10599. * @returns the new sprite
  10600. */
  10601. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10602. }
  10603. }
  10604. declare module "babylonjs/Collisions/pickingInfo" {
  10605. import { Nullable } from "babylonjs/types";
  10606. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10608. import { Sprite } from "babylonjs/Sprites/sprite";
  10609. import { Ray } from "babylonjs/Culling/ray";
  10610. /**
  10611. * Information about the result of picking within a scene
  10612. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10613. */
  10614. export class PickingInfo {
  10615. /** @hidden */
  10616. _pickingUnavailable: boolean;
  10617. /**
  10618. * If the pick collided with an object
  10619. */
  10620. hit: boolean;
  10621. /**
  10622. * Distance away where the pick collided
  10623. */
  10624. distance: number;
  10625. /**
  10626. * The location of pick collision
  10627. */
  10628. pickedPoint: Nullable<Vector3>;
  10629. /**
  10630. * The mesh corresponding the the pick collision
  10631. */
  10632. pickedMesh: Nullable<AbstractMesh>;
  10633. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10634. bu: number;
  10635. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10636. bv: number;
  10637. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10638. faceId: number;
  10639. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10640. subMeshFaceId: number;
  10641. /** Id of the the submesh that was picked */
  10642. subMeshId: number;
  10643. /** If a sprite was picked, this will be the sprite the pick collided with */
  10644. pickedSprite: Nullable<Sprite>;
  10645. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10646. thinInstanceIndex: number;
  10647. /**
  10648. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10649. */
  10650. originMesh: Nullable<AbstractMesh>;
  10651. /**
  10652. * The ray that was used to perform the picking.
  10653. */
  10654. ray: Nullable<Ray>;
  10655. /**
  10656. * Gets the normal correspodning to the face the pick collided with
  10657. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10658. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10659. * @returns The normal correspodning to the face the pick collided with
  10660. */
  10661. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10662. /**
  10663. * Gets the texture coordinates of where the pick occured
  10664. * @returns the vector containing the coordnates of the texture
  10665. */
  10666. getTextureCoordinates(): Nullable<Vector2>;
  10667. }
  10668. }
  10669. declare module "babylonjs/Culling/ray" {
  10670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10677. import { Plane } from "babylonjs/Maths/math.plane";
  10678. /**
  10679. * Class representing a ray with position and direction
  10680. */
  10681. export class Ray {
  10682. /** origin point */
  10683. origin: Vector3;
  10684. /** direction */
  10685. direction: Vector3;
  10686. /** length of the ray */
  10687. length: number;
  10688. private static readonly _TmpVector3;
  10689. private _tmpRay;
  10690. /**
  10691. * Creates a new ray
  10692. * @param origin origin point
  10693. * @param direction direction
  10694. * @param length length of the ray
  10695. */
  10696. constructor(
  10697. /** origin point */
  10698. origin: Vector3,
  10699. /** direction */
  10700. direction: Vector3,
  10701. /** length of the ray */
  10702. length?: number);
  10703. /**
  10704. * Checks if the ray intersects a box
  10705. * This does not account for the ray lenght by design to improve perfs.
  10706. * @param minimum bound of the box
  10707. * @param maximum bound of the box
  10708. * @param intersectionTreshold extra extend to be added to the box in all direction
  10709. * @returns if the box was hit
  10710. */
  10711. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10712. /**
  10713. * Checks if the ray intersects a box
  10714. * This does not account for the ray lenght by design to improve perfs.
  10715. * @param box the bounding box to check
  10716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10717. * @returns if the box was hit
  10718. */
  10719. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10720. /**
  10721. * If the ray hits a sphere
  10722. * @param sphere the bounding sphere to check
  10723. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10724. * @returns true if it hits the sphere
  10725. */
  10726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10727. /**
  10728. * If the ray hits a triange
  10729. * @param vertex0 triangle vertex
  10730. * @param vertex1 triangle vertex
  10731. * @param vertex2 triangle vertex
  10732. * @returns intersection information if hit
  10733. */
  10734. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10735. /**
  10736. * Checks if ray intersects a plane
  10737. * @param plane the plane to check
  10738. * @returns the distance away it was hit
  10739. */
  10740. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10741. /**
  10742. * Calculate the intercept of a ray on a given axis
  10743. * @param axis to check 'x' | 'y' | 'z'
  10744. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10745. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10746. */
  10747. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10748. /**
  10749. * Checks if ray intersects a mesh
  10750. * @param mesh the mesh to check
  10751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10752. * @returns picking info of the intersecton
  10753. */
  10754. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10755. /**
  10756. * Checks if ray intersects a mesh
  10757. * @param meshes the meshes to check
  10758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10759. * @param results array to store result in
  10760. * @returns Array of picking infos
  10761. */
  10762. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10763. private _comparePickingInfo;
  10764. private static smallnum;
  10765. private static rayl;
  10766. /**
  10767. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10768. * @param sega the first point of the segment to test the intersection against
  10769. * @param segb the second point of the segment to test the intersection against
  10770. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10771. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10772. */
  10773. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10774. /**
  10775. * Update the ray from viewport position
  10776. * @param x position
  10777. * @param y y position
  10778. * @param viewportWidth viewport width
  10779. * @param viewportHeight viewport height
  10780. * @param world world matrix
  10781. * @param view view matrix
  10782. * @param projection projection matrix
  10783. * @returns this ray updated
  10784. */
  10785. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10786. /**
  10787. * Creates a ray with origin and direction of 0,0,0
  10788. * @returns the new ray
  10789. */
  10790. static Zero(): Ray;
  10791. /**
  10792. * Creates a new ray from screen space and viewport
  10793. * @param x position
  10794. * @param y y position
  10795. * @param viewportWidth viewport width
  10796. * @param viewportHeight viewport height
  10797. * @param world world matrix
  10798. * @param view view matrix
  10799. * @param projection projection matrix
  10800. * @returns new ray
  10801. */
  10802. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10803. /**
  10804. * 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
  10805. * transformed to the given world matrix.
  10806. * @param origin The origin point
  10807. * @param end The end point
  10808. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10809. * @returns the new ray
  10810. */
  10811. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10812. /**
  10813. * Transforms a ray by a matrix
  10814. * @param ray ray to transform
  10815. * @param matrix matrix to apply
  10816. * @returns the resulting new ray
  10817. */
  10818. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10819. /**
  10820. * Transforms a ray by a matrix
  10821. * @param ray ray to transform
  10822. * @param matrix matrix to apply
  10823. * @param result ray to store result in
  10824. */
  10825. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10826. /**
  10827. * Unproject a ray from screen space to object space
  10828. * @param sourceX defines the screen space x coordinate to use
  10829. * @param sourceY defines the screen space y coordinate to use
  10830. * @param viewportWidth defines the current width of the viewport
  10831. * @param viewportHeight defines the current height of the viewport
  10832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10833. * @param view defines the view matrix to use
  10834. * @param projection defines the projection matrix to use
  10835. */
  10836. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10837. }
  10838. /**
  10839. * Type used to define predicate used to select faces when a mesh intersection is detected
  10840. */
  10841. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10842. module "babylonjs/scene" {
  10843. interface Scene {
  10844. /** @hidden */
  10845. _tempPickingRay: Nullable<Ray>;
  10846. /** @hidden */
  10847. _cachedRayForTransform: Ray;
  10848. /** @hidden */
  10849. _pickWithRayInverseMatrix: Matrix;
  10850. /** @hidden */
  10851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10852. /** @hidden */
  10853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10854. /** @hidden */
  10855. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10856. }
  10857. }
  10858. }
  10859. declare module "babylonjs/sceneComponent" {
  10860. import { Scene } from "babylonjs/scene";
  10861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10863. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10864. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10865. import { Nullable } from "babylonjs/types";
  10866. import { Camera } from "babylonjs/Cameras/camera";
  10867. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10868. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10869. import { AbstractScene } from "babylonjs/abstractScene";
  10870. import { Mesh } from "babylonjs/Meshes/mesh";
  10871. /**
  10872. * Groups all the scene component constants in one place to ease maintenance.
  10873. * @hidden
  10874. */
  10875. export class SceneComponentConstants {
  10876. static readonly NAME_EFFECTLAYER: string;
  10877. static readonly NAME_LAYER: string;
  10878. static readonly NAME_LENSFLARESYSTEM: string;
  10879. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10880. static readonly NAME_PARTICLESYSTEM: string;
  10881. static readonly NAME_GAMEPAD: string;
  10882. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10883. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10884. static readonly NAME_PREPASSRENDERER: string;
  10885. static readonly NAME_DEPTHRENDERER: string;
  10886. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10887. static readonly NAME_SPRITE: string;
  10888. static readonly NAME_SUBSURFACE: string;
  10889. static readonly NAME_OUTLINERENDERER: string;
  10890. static readonly NAME_PROCEDURALTEXTURE: string;
  10891. static readonly NAME_SHADOWGENERATOR: string;
  10892. static readonly NAME_OCTREE: string;
  10893. static readonly NAME_PHYSICSENGINE: string;
  10894. static readonly NAME_AUDIO: string;
  10895. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10896. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10897. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10899. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10900. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10901. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10902. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10903. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10904. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10905. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10906. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10907. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10908. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10909. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10910. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10911. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10912. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10913. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10914. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10915. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10916. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10917. static readonly STEP_AFTERRENDER_AUDIO: number;
  10918. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10919. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10920. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10921. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10922. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10923. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10924. static readonly STEP_POINTERMOVE_SPRITE: number;
  10925. static readonly STEP_POINTERDOWN_SPRITE: number;
  10926. static readonly STEP_POINTERUP_SPRITE: number;
  10927. }
  10928. /**
  10929. * This represents a scene component.
  10930. *
  10931. * This is used to decouple the dependency the scene is having on the different workloads like
  10932. * layers, post processes...
  10933. */
  10934. export interface ISceneComponent {
  10935. /**
  10936. * The name of the component. Each component must have a unique name.
  10937. */
  10938. name: string;
  10939. /**
  10940. * The scene the component belongs to.
  10941. */
  10942. scene: Scene;
  10943. /**
  10944. * Register the component to one instance of a scene.
  10945. */
  10946. register(): void;
  10947. /**
  10948. * Rebuilds the elements related to this component in case of
  10949. * context lost for instance.
  10950. */
  10951. rebuild(): void;
  10952. /**
  10953. * Disposes the component and the associated ressources.
  10954. */
  10955. dispose(): void;
  10956. }
  10957. /**
  10958. * This represents a SERIALIZABLE scene component.
  10959. *
  10960. * This extends Scene Component to add Serialization methods on top.
  10961. */
  10962. export interface ISceneSerializableComponent extends ISceneComponent {
  10963. /**
  10964. * Adds all the elements from the container to the scene
  10965. * @param container the container holding the elements
  10966. */
  10967. addFromContainer(container: AbstractScene): void;
  10968. /**
  10969. * Removes all the elements in the container from the scene
  10970. * @param container contains the elements to remove
  10971. * @param dispose if the removed element should be disposed (default: false)
  10972. */
  10973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10974. /**
  10975. * Serializes the component data to the specified json object
  10976. * @param serializationObject The object to serialize to
  10977. */
  10978. serialize(serializationObject: any): void;
  10979. }
  10980. /**
  10981. * Strong typing of a Mesh related stage step action
  10982. */
  10983. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10984. /**
  10985. * Strong typing of a Evaluate Sub Mesh related stage step action
  10986. */
  10987. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10988. /**
  10989. * Strong typing of a Active Mesh related stage step action
  10990. */
  10991. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10992. /**
  10993. * Strong typing of a Camera related stage step action
  10994. */
  10995. export type CameraStageAction = (camera: Camera) => void;
  10996. /**
  10997. * Strong typing of a Camera Frame buffer related stage step action
  10998. */
  10999. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11000. /**
  11001. * Strong typing of a Render Target related stage step action
  11002. */
  11003. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11004. /**
  11005. * Strong typing of a RenderingGroup related stage step action
  11006. */
  11007. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11008. /**
  11009. * Strong typing of a Mesh Render related stage step action
  11010. */
  11011. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11012. /**
  11013. * Strong typing of a simple stage step action
  11014. */
  11015. export type SimpleStageAction = () => void;
  11016. /**
  11017. * Strong typing of a render target action.
  11018. */
  11019. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11020. /**
  11021. * Strong typing of a pointer move action.
  11022. */
  11023. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11024. /**
  11025. * Strong typing of a pointer up/down action.
  11026. */
  11027. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11028. /**
  11029. * Representation of a stage in the scene (Basically a list of ordered steps)
  11030. * @hidden
  11031. */
  11032. export class Stage<T extends Function> extends Array<{
  11033. index: number;
  11034. component: ISceneComponent;
  11035. action: T;
  11036. }> {
  11037. /**
  11038. * Hide ctor from the rest of the world.
  11039. * @param items The items to add.
  11040. */
  11041. private constructor();
  11042. /**
  11043. * Creates a new Stage.
  11044. * @returns A new instance of a Stage
  11045. */
  11046. static Create<T extends Function>(): Stage<T>;
  11047. /**
  11048. * Registers a step in an ordered way in the targeted stage.
  11049. * @param index Defines the position to register the step in
  11050. * @param component Defines the component attached to the step
  11051. * @param action Defines the action to launch during the step
  11052. */
  11053. registerStep(index: number, component: ISceneComponent, action: T): void;
  11054. /**
  11055. * Clears all the steps from the stage.
  11056. */
  11057. clear(): void;
  11058. }
  11059. }
  11060. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11061. import { Nullable } from "babylonjs/types";
  11062. import { Observable } from "babylonjs/Misc/observable";
  11063. import { Scene } from "babylonjs/scene";
  11064. import { Sprite } from "babylonjs/Sprites/sprite";
  11065. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11066. import { Ray } from "babylonjs/Culling/ray";
  11067. import { Camera } from "babylonjs/Cameras/camera";
  11068. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11069. import { ISceneComponent } from "babylonjs/sceneComponent";
  11070. module "babylonjs/scene" {
  11071. interface Scene {
  11072. /** @hidden */
  11073. _pointerOverSprite: Nullable<Sprite>;
  11074. /** @hidden */
  11075. _pickedDownSprite: Nullable<Sprite>;
  11076. /** @hidden */
  11077. _tempSpritePickingRay: Nullable<Ray>;
  11078. /**
  11079. * All of the sprite managers added to this scene
  11080. * @see https://doc.babylonjs.com/babylon101/sprites
  11081. */
  11082. spriteManagers: Array<ISpriteManager>;
  11083. /**
  11084. * An event triggered when sprites rendering is about to start
  11085. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11086. */
  11087. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11088. /**
  11089. * An event triggered when sprites rendering is done
  11090. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11091. */
  11092. onAfterSpritesRenderingObservable: Observable<Scene>;
  11093. /** @hidden */
  11094. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11095. /** Launch a ray to try to pick a sprite in the scene
  11096. * @param x position on screen
  11097. * @param y position on screen
  11098. * @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
  11099. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11100. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11101. * @returns a PickingInfo
  11102. */
  11103. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11104. /** Use the given ray to pick a sprite in the scene
  11105. * @param ray The ray (in world space) to use to pick meshes
  11106. * @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
  11107. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11108. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo
  11110. */
  11111. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11112. /** @hidden */
  11113. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11114. /** Launch a ray to try to pick sprites in the scene
  11115. * @param x position on screen
  11116. * @param y position on screen
  11117. * @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
  11118. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11119. * @returns a PickingInfo array
  11120. */
  11121. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11122. /** Use the given ray to pick sprites in the scene
  11123. * @param ray The ray (in world space) to use to pick meshes
  11124. * @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
  11125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11126. * @returns a PickingInfo array
  11127. */
  11128. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11129. /**
  11130. * Force the sprite under the pointer
  11131. * @param sprite defines the sprite to use
  11132. */
  11133. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11134. /**
  11135. * Gets the sprite under the pointer
  11136. * @returns a Sprite or null if no sprite is under the pointer
  11137. */
  11138. getPointerOverSprite(): Nullable<Sprite>;
  11139. }
  11140. }
  11141. /**
  11142. * Defines the sprite scene component responsible to manage sprites
  11143. * in a given scene.
  11144. */
  11145. export class SpriteSceneComponent implements ISceneComponent {
  11146. /**
  11147. * The component name helpfull to identify the component in the list of scene components.
  11148. */
  11149. readonly name: string;
  11150. /**
  11151. * The scene the component belongs to.
  11152. */
  11153. scene: Scene;
  11154. /** @hidden */
  11155. private _spritePredicate;
  11156. /**
  11157. * Creates a new instance of the component for the given scene
  11158. * @param scene Defines the scene to register the component in
  11159. */
  11160. constructor(scene: Scene);
  11161. /**
  11162. * Registers the component in a given scene
  11163. */
  11164. register(): void;
  11165. /**
  11166. * Rebuilds the elements related to this component in case of
  11167. * context lost for instance.
  11168. */
  11169. rebuild(): void;
  11170. /**
  11171. * Disposes the component and the associated ressources.
  11172. */
  11173. dispose(): void;
  11174. private _pickSpriteButKeepRay;
  11175. private _pointerMove;
  11176. private _pointerDown;
  11177. private _pointerUp;
  11178. }
  11179. }
  11180. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11181. /** @hidden */
  11182. export var fogFragmentDeclaration: {
  11183. name: string;
  11184. shader: string;
  11185. };
  11186. }
  11187. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11188. /** @hidden */
  11189. export var fogFragment: {
  11190. name: string;
  11191. shader: string;
  11192. };
  11193. }
  11194. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11195. /** @hidden */
  11196. export var imageProcessingCompatibility: {
  11197. name: string;
  11198. shader: string;
  11199. };
  11200. }
  11201. declare module "babylonjs/Shaders/sprites.fragment" {
  11202. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11203. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11204. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11205. /** @hidden */
  11206. export var spritesPixelShader: {
  11207. name: string;
  11208. shader: string;
  11209. };
  11210. }
  11211. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11212. /** @hidden */
  11213. export var fogVertexDeclaration: {
  11214. name: string;
  11215. shader: string;
  11216. };
  11217. }
  11218. declare module "babylonjs/Shaders/sprites.vertex" {
  11219. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11220. /** @hidden */
  11221. export var spritesVertexShader: {
  11222. name: string;
  11223. shader: string;
  11224. };
  11225. }
  11226. declare module "babylonjs/Sprites/spriteManager" {
  11227. import { IDisposable, Scene } from "babylonjs/scene";
  11228. import { Nullable } from "babylonjs/types";
  11229. import { Observable } from "babylonjs/Misc/observable";
  11230. import { Sprite } from "babylonjs/Sprites/sprite";
  11231. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11232. import { Camera } from "babylonjs/Cameras/camera";
  11233. import { Texture } from "babylonjs/Materials/Textures/texture";
  11234. import "babylonjs/Shaders/sprites.fragment";
  11235. import "babylonjs/Shaders/sprites.vertex";
  11236. import { Ray } from "babylonjs/Culling/ray";
  11237. /**
  11238. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11239. */
  11240. export interface ISpriteManager extends IDisposable {
  11241. /**
  11242. * Gets manager's name
  11243. */
  11244. name: string;
  11245. /**
  11246. * Restricts the camera to viewing objects with the same layerMask.
  11247. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11248. */
  11249. layerMask: number;
  11250. /**
  11251. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11252. */
  11253. isPickable: boolean;
  11254. /**
  11255. * Gets the hosting scene
  11256. */
  11257. scene: Scene;
  11258. /**
  11259. * Specifies the rendering group id for this mesh (0 by default)
  11260. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11261. */
  11262. renderingGroupId: number;
  11263. /**
  11264. * Defines the list of sprites managed by the manager.
  11265. */
  11266. sprites: Array<Sprite>;
  11267. /**
  11268. * Gets or sets the spritesheet texture
  11269. */
  11270. texture: Texture;
  11271. /** Defines the default width of a cell in the spritesheet */
  11272. cellWidth: number;
  11273. /** Defines the default height of a cell in the spritesheet */
  11274. cellHeight: number;
  11275. /**
  11276. * Tests the intersection of a sprite with a specific ray.
  11277. * @param ray The ray we are sending to test the collision
  11278. * @param camera The camera space we are sending rays in
  11279. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11280. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11281. * @returns picking info or null.
  11282. */
  11283. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11284. /**
  11285. * Intersects the sprites with a ray
  11286. * @param ray defines the ray to intersect with
  11287. * @param camera defines the current active camera
  11288. * @param predicate defines a predicate used to select candidate sprites
  11289. * @returns null if no hit or a PickingInfo array
  11290. */
  11291. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11292. /**
  11293. * Renders the list of sprites on screen.
  11294. */
  11295. render(): void;
  11296. }
  11297. /**
  11298. * Class used to manage multiple sprites on the same spritesheet
  11299. * @see https://doc.babylonjs.com/babylon101/sprites
  11300. */
  11301. export class SpriteManager implements ISpriteManager {
  11302. /** defines the manager's name */
  11303. name: string;
  11304. /** Define the Url to load snippets */
  11305. static SnippetUrl: string;
  11306. /** Snippet ID if the manager was created from the snippet server */
  11307. snippetId: string;
  11308. /** Gets the list of sprites */
  11309. sprites: Sprite[];
  11310. /** Gets or sets the rendering group id (0 by default) */
  11311. renderingGroupId: number;
  11312. /** Gets or sets camera layer mask */
  11313. layerMask: number;
  11314. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11315. fogEnabled: boolean;
  11316. /** Gets or sets a boolean indicating if the sprites are pickable */
  11317. isPickable: boolean;
  11318. /** Defines the default width of a cell in the spritesheet */
  11319. cellWidth: number;
  11320. /** Defines the default height of a cell in the spritesheet */
  11321. cellHeight: number;
  11322. /** Associative array from JSON sprite data file */
  11323. private _cellData;
  11324. /** Array of sprite names from JSON sprite data file */
  11325. private _spriteMap;
  11326. /** True when packed cell data from JSON file is ready*/
  11327. private _packedAndReady;
  11328. private _textureContent;
  11329. private _useInstancing;
  11330. /**
  11331. * An event triggered when the manager is disposed.
  11332. */
  11333. onDisposeObservable: Observable<SpriteManager>;
  11334. private _onDisposeObserver;
  11335. /**
  11336. * Callback called when the manager is disposed
  11337. */
  11338. set onDispose(callback: () => void);
  11339. private _capacity;
  11340. private _fromPacked;
  11341. private _spriteTexture;
  11342. private _epsilon;
  11343. private _scene;
  11344. private _vertexData;
  11345. private _buffer;
  11346. private _vertexBuffers;
  11347. private _spriteBuffer;
  11348. private _indexBuffer;
  11349. private _effectBase;
  11350. private _effectFog;
  11351. private _vertexBufferSize;
  11352. /**
  11353. * Gets or sets the unique id of the sprite
  11354. */
  11355. uniqueId: number;
  11356. /**
  11357. * Gets the array of sprites
  11358. */
  11359. get children(): Sprite[];
  11360. /**
  11361. * Gets the hosting scene
  11362. */
  11363. get scene(): Scene;
  11364. /**
  11365. * Gets the capacity of the manager
  11366. */
  11367. get capacity(): number;
  11368. /**
  11369. * Gets or sets the spritesheet texture
  11370. */
  11371. get texture(): Texture;
  11372. set texture(value: Texture);
  11373. private _blendMode;
  11374. /**
  11375. * Blend mode use to render the particle, it can be any of
  11376. * the static Constants.ALPHA_x properties provided in this class.
  11377. * Default value is Constants.ALPHA_COMBINE
  11378. */
  11379. get blendMode(): number;
  11380. set blendMode(blendMode: number);
  11381. /** Disables writing to the depth buffer when rendering the sprites.
  11382. * It can be handy to disable depth writing when using textures without alpha channel
  11383. * and setting some specific blend modes.
  11384. */
  11385. disableDepthWrite: boolean;
  11386. /**
  11387. * Creates a new sprite manager
  11388. * @param name defines the manager's name
  11389. * @param imgUrl defines the sprite sheet url
  11390. * @param capacity defines the maximum allowed number of sprites
  11391. * @param cellSize defines the size of a sprite cell
  11392. * @param scene defines the hosting scene
  11393. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11394. * @param samplingMode defines the smapling mode to use with spritesheet
  11395. * @param fromPacked set to false; do not alter
  11396. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11397. */
  11398. constructor(
  11399. /** defines the manager's name */
  11400. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11401. /**
  11402. * Returns the string "SpriteManager"
  11403. * @returns "SpriteManager"
  11404. */
  11405. getClassName(): string;
  11406. private _makePacked;
  11407. private _appendSpriteVertex;
  11408. private _checkTextureAlpha;
  11409. /**
  11410. * Intersects the sprites with a ray
  11411. * @param ray defines the ray to intersect with
  11412. * @param camera defines the current active camera
  11413. * @param predicate defines a predicate used to select candidate sprites
  11414. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11415. * @returns null if no hit or a PickingInfo
  11416. */
  11417. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11418. /**
  11419. * Intersects the sprites with a ray
  11420. * @param ray defines the ray to intersect with
  11421. * @param camera defines the current active camera
  11422. * @param predicate defines a predicate used to select candidate sprites
  11423. * @returns null if no hit or a PickingInfo array
  11424. */
  11425. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11426. /**
  11427. * Render all child sprites
  11428. */
  11429. render(): void;
  11430. /**
  11431. * Release associated resources
  11432. */
  11433. dispose(): void;
  11434. /**
  11435. * Serializes the sprite manager to a JSON object
  11436. * @param serializeTexture defines if the texture must be serialized as well
  11437. * @returns the JSON object
  11438. */
  11439. serialize(serializeTexture?: boolean): any;
  11440. /**
  11441. * Parses a JSON object to create a new sprite manager.
  11442. * @param parsedManager The JSON object to parse
  11443. * @param scene The scene to create the sprite managerin
  11444. * @param rootUrl The root url to use to load external dependencies like texture
  11445. * @returns the new sprite manager
  11446. */
  11447. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11448. /**
  11449. * Creates a sprite manager from a snippet saved in a remote file
  11450. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11451. * @param url defines the url to load from
  11452. * @param scene defines the hosting scene
  11453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11454. * @returns a promise that will resolve to the new sprite manager
  11455. */
  11456. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11457. /**
  11458. * Creates a sprite manager from a snippet saved by the sprite editor
  11459. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11460. * @param scene defines the hosting scene
  11461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11462. * @returns a promise that will resolve to the new sprite manager
  11463. */
  11464. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11465. }
  11466. }
  11467. declare module "babylonjs/Misc/gradients" {
  11468. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11469. /** Interface used by value gradients (color, factor, ...) */
  11470. export interface IValueGradient {
  11471. /**
  11472. * Gets or sets the gradient value (between 0 and 1)
  11473. */
  11474. gradient: number;
  11475. }
  11476. /** Class used to store color4 gradient */
  11477. export class ColorGradient implements IValueGradient {
  11478. /**
  11479. * Gets or sets the gradient value (between 0 and 1)
  11480. */
  11481. gradient: number;
  11482. /**
  11483. * Gets or sets first associated color
  11484. */
  11485. color1: Color4;
  11486. /**
  11487. * Gets or sets second associated color
  11488. */
  11489. color2?: Color4 | undefined;
  11490. /**
  11491. * Creates a new color4 gradient
  11492. * @param gradient gets or sets the gradient value (between 0 and 1)
  11493. * @param color1 gets or sets first associated color
  11494. * @param color2 gets or sets first second color
  11495. */
  11496. constructor(
  11497. /**
  11498. * Gets or sets the gradient value (between 0 and 1)
  11499. */
  11500. gradient: number,
  11501. /**
  11502. * Gets or sets first associated color
  11503. */
  11504. color1: Color4,
  11505. /**
  11506. * Gets or sets second associated color
  11507. */
  11508. color2?: Color4 | undefined);
  11509. /**
  11510. * Will get a color picked randomly between color1 and color2.
  11511. * If color2 is undefined then color1 will be used
  11512. * @param result defines the target Color4 to store the result in
  11513. */
  11514. getColorToRef(result: Color4): void;
  11515. }
  11516. /** Class used to store color 3 gradient */
  11517. export class Color3Gradient implements IValueGradient {
  11518. /**
  11519. * Gets or sets the gradient value (between 0 and 1)
  11520. */
  11521. gradient: number;
  11522. /**
  11523. * Gets or sets the associated color
  11524. */
  11525. color: Color3;
  11526. /**
  11527. * Creates a new color3 gradient
  11528. * @param gradient gets or sets the gradient value (between 0 and 1)
  11529. * @param color gets or sets associated color
  11530. */
  11531. constructor(
  11532. /**
  11533. * Gets or sets the gradient value (between 0 and 1)
  11534. */
  11535. gradient: number,
  11536. /**
  11537. * Gets or sets the associated color
  11538. */
  11539. color: Color3);
  11540. }
  11541. /** Class used to store factor gradient */
  11542. export class FactorGradient implements IValueGradient {
  11543. /**
  11544. * Gets or sets the gradient value (between 0 and 1)
  11545. */
  11546. gradient: number;
  11547. /**
  11548. * Gets or sets first associated factor
  11549. */
  11550. factor1: number;
  11551. /**
  11552. * Gets or sets second associated factor
  11553. */
  11554. factor2?: number | undefined;
  11555. /**
  11556. * Creates a new factor gradient
  11557. * @param gradient gets or sets the gradient value (between 0 and 1)
  11558. * @param factor1 gets or sets first associated factor
  11559. * @param factor2 gets or sets second associated factor
  11560. */
  11561. constructor(
  11562. /**
  11563. * Gets or sets the gradient value (between 0 and 1)
  11564. */
  11565. gradient: number,
  11566. /**
  11567. * Gets or sets first associated factor
  11568. */
  11569. factor1: number,
  11570. /**
  11571. * Gets or sets second associated factor
  11572. */
  11573. factor2?: number | undefined);
  11574. /**
  11575. * Will get a number picked randomly between factor1 and factor2.
  11576. * If factor2 is undefined then factor1 will be used
  11577. * @returns the picked number
  11578. */
  11579. getFactor(): number;
  11580. }
  11581. /**
  11582. * Helper used to simplify some generic gradient tasks
  11583. */
  11584. export class GradientHelper {
  11585. /**
  11586. * Gets the current gradient from an array of IValueGradient
  11587. * @param ratio defines the current ratio to get
  11588. * @param gradients defines the array of IValueGradient
  11589. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11590. */
  11591. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11592. }
  11593. }
  11594. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11595. import { Nullable } from "babylonjs/types";
  11596. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11597. import { Scene } from "babylonjs/scene";
  11598. module "babylonjs/Engines/thinEngine" {
  11599. interface ThinEngine {
  11600. /**
  11601. * Creates a raw texture
  11602. * @param data defines the data to store in the texture
  11603. * @param width defines the width of the texture
  11604. * @param height defines the height of the texture
  11605. * @param format defines the format of the data
  11606. * @param generateMipMaps defines if the engine should generate the mip levels
  11607. * @param invertY defines if data must be stored with Y axis inverted
  11608. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11609. * @param compression defines the compression used (null by default)
  11610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11611. * @returns the raw texture inside an InternalTexture
  11612. */
  11613. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11614. /**
  11615. * Update a raw texture
  11616. * @param texture defines the texture to update
  11617. * @param data defines the data to store in the texture
  11618. * @param format defines the format of the data
  11619. * @param invertY defines if data must be stored with Y axis inverted
  11620. */
  11621. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11622. /**
  11623. * Update a raw texture
  11624. * @param texture defines the texture to update
  11625. * @param data defines the data to store in the texture
  11626. * @param format defines the format of the data
  11627. * @param invertY defines if data must be stored with Y axis inverted
  11628. * @param compression defines the compression used (null by default)
  11629. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11630. */
  11631. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11632. /**
  11633. * Creates a new raw cube texture
  11634. * @param data defines the array of data to use to create each face
  11635. * @param size defines the size of the textures
  11636. * @param format defines the format of the data
  11637. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11638. * @param generateMipMaps defines if the engine should generate the mip levels
  11639. * @param invertY defines if data must be stored with Y axis inverted
  11640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11641. * @param compression defines the compression used (null by default)
  11642. * @returns the cube texture as an InternalTexture
  11643. */
  11644. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11645. /**
  11646. * Update a raw cube texture
  11647. * @param texture defines the texture to udpdate
  11648. * @param data defines the data to store
  11649. * @param format defines the data format
  11650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11651. * @param invertY defines if data must be stored with Y axis inverted
  11652. */
  11653. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11654. /**
  11655. * Update a raw cube texture
  11656. * @param texture defines the texture to udpdate
  11657. * @param data defines the data to store
  11658. * @param format defines the data format
  11659. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11660. * @param invertY defines if data must be stored with Y axis inverted
  11661. * @param compression defines the compression used (null by default)
  11662. */
  11663. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11664. /**
  11665. * Update a raw cube texture
  11666. * @param texture defines the texture to udpdate
  11667. * @param data defines the data to store
  11668. * @param format defines the data format
  11669. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11670. * @param invertY defines if data must be stored with Y axis inverted
  11671. * @param compression defines the compression used (null by default)
  11672. * @param level defines which level of the texture to update
  11673. */
  11674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11675. /**
  11676. * Creates a new raw cube texture from a specified url
  11677. * @param url defines the url where the data is located
  11678. * @param scene defines the current scene
  11679. * @param size defines the size of the textures
  11680. * @param format defines the format of the data
  11681. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11682. * @param noMipmap defines if the engine should avoid generating the mip levels
  11683. * @param callback defines a callback used to extract texture data from loaded data
  11684. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11685. * @param onLoad defines a callback called when texture is loaded
  11686. * @param onError defines a callback called if there is an error
  11687. * @returns the cube texture as an InternalTexture
  11688. */
  11689. 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;
  11690. /**
  11691. * Creates a new raw cube texture from a specified url
  11692. * @param url defines the url where the data is located
  11693. * @param scene defines the current scene
  11694. * @param size defines the size of the textures
  11695. * @param format defines the format of the data
  11696. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11697. * @param noMipmap defines if the engine should avoid generating the mip levels
  11698. * @param callback defines a callback used to extract texture data from loaded data
  11699. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11700. * @param onLoad defines a callback called when texture is loaded
  11701. * @param onError defines a callback called if there is an error
  11702. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11703. * @param invertY defines if data must be stored with Y axis inverted
  11704. * @returns the cube texture as an InternalTexture
  11705. */
  11706. 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;
  11707. /**
  11708. * Creates a new raw 3D texture
  11709. * @param data defines the data used to create the texture
  11710. * @param width defines the width of the texture
  11711. * @param height defines the height of the texture
  11712. * @param depth defines the depth of the texture
  11713. * @param format defines the format of the texture
  11714. * @param generateMipMaps defines if the engine must generate mip levels
  11715. * @param invertY defines if data must be stored with Y axis inverted
  11716. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11717. * @param compression defines the compressed used (can be null)
  11718. * @param textureType defines the compressed used (can be null)
  11719. * @returns a new raw 3D texture (stored in an InternalTexture)
  11720. */
  11721. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11722. /**
  11723. * Update a raw 3D texture
  11724. * @param texture defines the texture to update
  11725. * @param data defines the data to store
  11726. * @param format defines the data format
  11727. * @param invertY defines if data must be stored with Y axis inverted
  11728. */
  11729. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11730. /**
  11731. * Update a raw 3D texture
  11732. * @param texture defines the texture to update
  11733. * @param data defines the data to store
  11734. * @param format defines the data format
  11735. * @param invertY defines if data must be stored with Y axis inverted
  11736. * @param compression defines the used compression (can be null)
  11737. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11738. */
  11739. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11740. /**
  11741. * Creates a new raw 2D array texture
  11742. * @param data defines the data used to create the texture
  11743. * @param width defines the width of the texture
  11744. * @param height defines the height of the texture
  11745. * @param depth defines the number of layers of the texture
  11746. * @param format defines the format of the texture
  11747. * @param generateMipMaps defines if the engine must generate mip levels
  11748. * @param invertY defines if data must be stored with Y axis inverted
  11749. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11750. * @param compression defines the compressed used (can be null)
  11751. * @param textureType defines the compressed used (can be null)
  11752. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11753. */
  11754. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11755. /**
  11756. * Update a raw 2D array texture
  11757. * @param texture defines the texture to update
  11758. * @param data defines the data to store
  11759. * @param format defines the data format
  11760. * @param invertY defines if data must be stored with Y axis inverted
  11761. */
  11762. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11763. /**
  11764. * Update a raw 2D array texture
  11765. * @param texture defines the texture to update
  11766. * @param data defines the data to store
  11767. * @param format defines the data format
  11768. * @param invertY defines if data must be stored with Y axis inverted
  11769. * @param compression defines the used compression (can be null)
  11770. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11771. */
  11772. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11773. }
  11774. }
  11775. }
  11776. declare module "babylonjs/Materials/Textures/rawTexture" {
  11777. import { Texture } from "babylonjs/Materials/Textures/texture";
  11778. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11779. import { Nullable } from "babylonjs/types";
  11780. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11781. import { Scene } from "babylonjs/scene";
  11782. /**
  11783. * Raw texture can help creating a texture directly from an array of data.
  11784. * This can be super useful if you either get the data from an uncompressed source or
  11785. * if you wish to create your texture pixel by pixel.
  11786. */
  11787. export class RawTexture extends Texture {
  11788. /**
  11789. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11790. */
  11791. format: number;
  11792. /**
  11793. * Instantiates a new RawTexture.
  11794. * Raw texture can help creating a texture directly from an array of data.
  11795. * This can be super useful if you either get the data from an uncompressed source or
  11796. * if you wish to create your texture pixel by pixel.
  11797. * @param data define the array of data to use to create the texture
  11798. * @param width define the width of the texture
  11799. * @param height define the height of the texture
  11800. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11801. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11802. * @param generateMipMaps define whether mip maps should be generated or not
  11803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11805. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11806. */
  11807. constructor(data: ArrayBufferView, width: number, height: number,
  11808. /**
  11809. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11810. */
  11811. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11812. /**
  11813. * Updates the texture underlying data.
  11814. * @param data Define the new data of the texture
  11815. */
  11816. update(data: ArrayBufferView): void;
  11817. /**
  11818. * Creates a luminance texture from some data.
  11819. * @param data Define the texture data
  11820. * @param width Define the width of the texture
  11821. * @param height Define the height of the texture
  11822. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11823. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11824. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11825. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11826. * @returns the luminance texture
  11827. */
  11828. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11829. /**
  11830. * Creates a luminance alpha texture from some data.
  11831. * @param data Define the texture data
  11832. * @param width Define the width of the texture
  11833. * @param height Define the height of the texture
  11834. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11838. * @returns the luminance alpha texture
  11839. */
  11840. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11841. /**
  11842. * Creates an alpha texture from some data.
  11843. * @param data Define the texture data
  11844. * @param width Define the width of the texture
  11845. * @param height Define the height of the texture
  11846. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11847. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11848. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11849. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11850. * @returns the alpha texture
  11851. */
  11852. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11853. /**
  11854. * Creates a RGB texture from some data.
  11855. * @param data Define the texture data
  11856. * @param width Define the width of the texture
  11857. * @param height Define the height of the texture
  11858. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11862. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11863. * @returns the RGB alpha texture
  11864. */
  11865. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11866. /**
  11867. * Creates a RGBA texture from some data.
  11868. * @param data Define the texture data
  11869. * @param width Define the width of the texture
  11870. * @param height Define the height of the texture
  11871. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11872. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11873. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11874. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11875. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11876. * @returns the RGBA texture
  11877. */
  11878. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11879. /**
  11880. * Creates a R texture from some data.
  11881. * @param data Define the texture data
  11882. * @param width Define the width of the texture
  11883. * @param height Define the height of the texture
  11884. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11885. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11886. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11887. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11888. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11889. * @returns the R texture
  11890. */
  11891. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11892. }
  11893. }
  11894. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11895. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11896. import { IndicesArray, DataArray } from "babylonjs/types";
  11897. module "babylonjs/Engines/thinEngine" {
  11898. interface ThinEngine {
  11899. /**
  11900. * Update a dynamic index buffer
  11901. * @param indexBuffer defines the target index buffer
  11902. * @param indices defines the data to update
  11903. * @param offset defines the offset in the target index buffer where update should start
  11904. */
  11905. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11906. /**
  11907. * Updates a dynamic vertex buffer.
  11908. * @param vertexBuffer the vertex buffer to update
  11909. * @param data the data used to update the vertex buffer
  11910. * @param byteOffset the byte offset of the data
  11911. * @param byteLength the byte length of the data
  11912. */
  11913. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11914. }
  11915. }
  11916. }
  11917. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11918. import { Scene } from "babylonjs/scene";
  11919. import { ISceneComponent } from "babylonjs/sceneComponent";
  11920. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11921. module "babylonjs/abstractScene" {
  11922. interface AbstractScene {
  11923. /**
  11924. * The list of procedural textures added to the scene
  11925. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11926. */
  11927. proceduralTextures: Array<ProceduralTexture>;
  11928. }
  11929. }
  11930. /**
  11931. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11932. * in a given scene.
  11933. */
  11934. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11935. /**
  11936. * The component name helpfull to identify the component in the list of scene components.
  11937. */
  11938. readonly name: string;
  11939. /**
  11940. * The scene the component belongs to.
  11941. */
  11942. scene: Scene;
  11943. /**
  11944. * Creates a new instance of the component for the given scene
  11945. * @param scene Defines the scene to register the component in
  11946. */
  11947. constructor(scene: Scene);
  11948. /**
  11949. * Registers the component in a given scene
  11950. */
  11951. register(): void;
  11952. /**
  11953. * Rebuilds the elements related to this component in case of
  11954. * context lost for instance.
  11955. */
  11956. rebuild(): void;
  11957. /**
  11958. * Disposes the component and the associated ressources.
  11959. */
  11960. dispose(): void;
  11961. private _beforeClear;
  11962. }
  11963. }
  11964. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11965. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11966. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11967. module "babylonjs/Engines/thinEngine" {
  11968. interface ThinEngine {
  11969. /**
  11970. * Creates a new render target cube texture
  11971. * @param size defines the size of the texture
  11972. * @param options defines the options used to create the texture
  11973. * @returns a new render target cube texture stored in an InternalTexture
  11974. */
  11975. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11976. }
  11977. }
  11978. }
  11979. declare module "babylonjs/Shaders/procedural.vertex" {
  11980. /** @hidden */
  11981. export var proceduralVertexShader: {
  11982. name: string;
  11983. shader: string;
  11984. };
  11985. }
  11986. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11987. import { Observable } from "babylonjs/Misc/observable";
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Scene } from "babylonjs/scene";
  11990. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11991. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11992. import { Effect } from "babylonjs/Materials/effect";
  11993. import { Texture } from "babylonjs/Materials/Textures/texture";
  11994. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11995. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11996. import "babylonjs/Shaders/procedural.vertex";
  11997. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11998. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11999. /**
  12000. * 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.
  12001. * This is the base class of any Procedural texture and contains most of the shareable code.
  12002. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12003. */
  12004. export class ProceduralTexture extends Texture {
  12005. /**
  12006. * Define if the texture is enabled or not (disabled texture will not render)
  12007. */
  12008. isEnabled: boolean;
  12009. /**
  12010. * Define if the texture must be cleared before rendering (default is true)
  12011. */
  12012. autoClear: boolean;
  12013. /**
  12014. * Callback called when the texture is generated
  12015. */
  12016. onGenerated: () => void;
  12017. /**
  12018. * Event raised when the texture is generated
  12019. */
  12020. onGeneratedObservable: Observable<ProceduralTexture>;
  12021. /**
  12022. * Event raised before the texture is generated
  12023. */
  12024. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12025. /**
  12026. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12027. */
  12028. nodeMaterialSource: Nullable<NodeMaterial>;
  12029. /** @hidden */
  12030. _generateMipMaps: boolean;
  12031. /** @hidden **/
  12032. _effect: Effect;
  12033. /** @hidden */
  12034. _textures: {
  12035. [key: string]: Texture;
  12036. };
  12037. /** @hidden */
  12038. protected _fallbackTexture: Nullable<Texture>;
  12039. private _size;
  12040. private _currentRefreshId;
  12041. private _frameId;
  12042. private _refreshRate;
  12043. private _vertexBuffers;
  12044. private _indexBuffer;
  12045. private _uniforms;
  12046. private _samplers;
  12047. private _fragment;
  12048. private _floats;
  12049. private _ints;
  12050. private _floatsArrays;
  12051. private _colors3;
  12052. private _colors4;
  12053. private _vectors2;
  12054. private _vectors3;
  12055. private _matrices;
  12056. private _fallbackTextureUsed;
  12057. private _fullEngine;
  12058. private _cachedDefines;
  12059. private _contentUpdateId;
  12060. private _contentData;
  12061. /**
  12062. * Instantiates a new procedural texture.
  12063. * 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.
  12064. * This is the base class of any Procedural texture and contains most of the shareable code.
  12065. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12066. * @param name Define the name of the texture
  12067. * @param size Define the size of the texture to create
  12068. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12069. * @param scene Define the scene the texture belongs to
  12070. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12071. * @param generateMipMaps Define if the texture should creates mip maps or not
  12072. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12073. * @param textureType The FBO internal texture type
  12074. */
  12075. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12076. /**
  12077. * The effect that is created when initializing the post process.
  12078. * @returns The created effect corresponding the the postprocess.
  12079. */
  12080. getEffect(): Effect;
  12081. /**
  12082. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12083. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12084. */
  12085. getContent(): Nullable<ArrayBufferView>;
  12086. private _createIndexBuffer;
  12087. /** @hidden */
  12088. _rebuild(): void;
  12089. /**
  12090. * Resets the texture in order to recreate its associated resources.
  12091. * This can be called in case of context loss
  12092. */
  12093. reset(): void;
  12094. protected _getDefines(): string;
  12095. /**
  12096. * Is the texture ready to be used ? (rendered at least once)
  12097. * @returns true if ready, otherwise, false.
  12098. */
  12099. isReady(): boolean;
  12100. /**
  12101. * Resets the refresh counter of the texture and start bak from scratch.
  12102. * Could be useful to regenerate the texture if it is setup to render only once.
  12103. */
  12104. resetRefreshCounter(): void;
  12105. /**
  12106. * Set the fragment shader to use in order to render the texture.
  12107. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12108. */
  12109. setFragment(fragment: any): void;
  12110. /**
  12111. * Define the refresh rate of the texture or the rendering frequency.
  12112. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12113. */
  12114. get refreshRate(): number;
  12115. set refreshRate(value: number);
  12116. /** @hidden */
  12117. _shouldRender(): boolean;
  12118. /**
  12119. * Get the size the texture is rendering at.
  12120. * @returns the size (on cube texture it is always squared)
  12121. */
  12122. getRenderSize(): RenderTargetTextureSize;
  12123. /**
  12124. * Resize the texture to new value.
  12125. * @param size Define the new size the texture should have
  12126. * @param generateMipMaps Define whether the new texture should create mip maps
  12127. */
  12128. resize(size: number, generateMipMaps: boolean): void;
  12129. private _checkUniform;
  12130. /**
  12131. * Set a texture in the shader program used to render.
  12132. * @param name Define the name of the uniform samplers as defined in the shader
  12133. * @param texture Define the texture to bind to this sampler
  12134. * @return the texture itself allowing "fluent" like uniform updates
  12135. */
  12136. setTexture(name: string, texture: Texture): ProceduralTexture;
  12137. /**
  12138. * Set a float in the shader.
  12139. * @param name Define the name of the uniform as defined in the shader
  12140. * @param value Define the value to give to the uniform
  12141. * @return the texture itself allowing "fluent" like uniform updates
  12142. */
  12143. setFloat(name: string, value: number): ProceduralTexture;
  12144. /**
  12145. * Set a int in the shader.
  12146. * @param name Define the name of the uniform as defined in the shader
  12147. * @param value Define the value to give to the uniform
  12148. * @return the texture itself allowing "fluent" like uniform updates
  12149. */
  12150. setInt(name: string, value: number): ProceduralTexture;
  12151. /**
  12152. * Set an array of floats in the shader.
  12153. * @param name Define the name of the uniform as defined in the shader
  12154. * @param value Define the value to give to the uniform
  12155. * @return the texture itself allowing "fluent" like uniform updates
  12156. */
  12157. setFloats(name: string, value: number[]): ProceduralTexture;
  12158. /**
  12159. * Set a vec3 in the shader from a Color3.
  12160. * @param name Define the name of the uniform as defined in the shader
  12161. * @param value Define the value to give to the uniform
  12162. * @return the texture itself allowing "fluent" like uniform updates
  12163. */
  12164. setColor3(name: string, value: Color3): ProceduralTexture;
  12165. /**
  12166. * Set a vec4 in the shader from a Color4.
  12167. * @param name Define the name of the uniform as defined in the shader
  12168. * @param value Define the value to give to the uniform
  12169. * @return the texture itself allowing "fluent" like uniform updates
  12170. */
  12171. setColor4(name: string, value: Color4): ProceduralTexture;
  12172. /**
  12173. * Set a vec2 in the shader from a Vector2.
  12174. * @param name Define the name of the uniform as defined in the shader
  12175. * @param value Define the value to give to the uniform
  12176. * @return the texture itself allowing "fluent" like uniform updates
  12177. */
  12178. setVector2(name: string, value: Vector2): ProceduralTexture;
  12179. /**
  12180. * Set a vec3 in the shader from a Vector3.
  12181. * @param name Define the name of the uniform as defined in the shader
  12182. * @param value Define the value to give to the uniform
  12183. * @return the texture itself allowing "fluent" like uniform updates
  12184. */
  12185. setVector3(name: string, value: Vector3): ProceduralTexture;
  12186. /**
  12187. * Set a mat4 in the shader from a MAtrix.
  12188. * @param name Define the name of the uniform as defined in the shader
  12189. * @param value Define the value to give to the uniform
  12190. * @return the texture itself allowing "fluent" like uniform updates
  12191. */
  12192. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12193. /**
  12194. * Render the texture to its associated render target.
  12195. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12196. */
  12197. render(useCameraPostProcess?: boolean): void;
  12198. /**
  12199. * Clone the texture.
  12200. * @returns the cloned texture
  12201. */
  12202. clone(): ProceduralTexture;
  12203. /**
  12204. * Dispose the texture and release its asoociated resources.
  12205. */
  12206. dispose(): void;
  12207. }
  12208. }
  12209. declare module "babylonjs/Particles/baseParticleSystem" {
  12210. import { Nullable } from "babylonjs/types";
  12211. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12213. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12214. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12215. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12217. import { Color4 } from "babylonjs/Maths/math.color";
  12218. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12219. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12220. import { Animation } from "babylonjs/Animations/animation";
  12221. import { Scene } from "babylonjs/scene";
  12222. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12223. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12224. /**
  12225. * This represents the base class for particle system in Babylon.
  12226. * 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.
  12227. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12228. * @example https://doc.babylonjs.com/babylon101/particles
  12229. */
  12230. export class BaseParticleSystem {
  12231. /**
  12232. * Source color is added to the destination color without alpha affecting the result
  12233. */
  12234. static BLENDMODE_ONEONE: number;
  12235. /**
  12236. * Blend current color and particle color using particle’s alpha
  12237. */
  12238. static BLENDMODE_STANDARD: number;
  12239. /**
  12240. * Add current color and particle color multiplied by particle’s alpha
  12241. */
  12242. static BLENDMODE_ADD: number;
  12243. /**
  12244. * Multiply current color with particle color
  12245. */
  12246. static BLENDMODE_MULTIPLY: number;
  12247. /**
  12248. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12249. */
  12250. static BLENDMODE_MULTIPLYADD: number;
  12251. /**
  12252. * List of animations used by the particle system.
  12253. */
  12254. animations: Animation[];
  12255. /**
  12256. * Gets or sets the unique id of the particle system
  12257. */
  12258. uniqueId: number;
  12259. /**
  12260. * The id of the Particle system.
  12261. */
  12262. id: string;
  12263. /**
  12264. * The friendly name of the Particle system.
  12265. */
  12266. name: string;
  12267. /**
  12268. * Snippet ID if the particle system was created from the snippet server
  12269. */
  12270. snippetId: string;
  12271. /**
  12272. * The rendering group used by the Particle system to chose when to render.
  12273. */
  12274. renderingGroupId: number;
  12275. /**
  12276. * The emitter represents the Mesh or position we are attaching the particle system to.
  12277. */
  12278. emitter: Nullable<AbstractMesh | Vector3>;
  12279. /**
  12280. * The maximum number of particles to emit per frame
  12281. */
  12282. emitRate: number;
  12283. /**
  12284. * If you want to launch only a few particles at once, that can be done, as well.
  12285. */
  12286. manualEmitCount: number;
  12287. /**
  12288. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12289. */
  12290. updateSpeed: number;
  12291. /**
  12292. * The amount of time the particle system is running (depends of the overall update speed).
  12293. */
  12294. targetStopDuration: number;
  12295. /**
  12296. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12297. */
  12298. disposeOnStop: boolean;
  12299. /**
  12300. * Minimum power of emitting particles.
  12301. */
  12302. minEmitPower: number;
  12303. /**
  12304. * Maximum power of emitting particles.
  12305. */
  12306. maxEmitPower: number;
  12307. /**
  12308. * Minimum life time of emitting particles.
  12309. */
  12310. minLifeTime: number;
  12311. /**
  12312. * Maximum life time of emitting particles.
  12313. */
  12314. maxLifeTime: number;
  12315. /**
  12316. * Minimum Size of emitting particles.
  12317. */
  12318. minSize: number;
  12319. /**
  12320. * Maximum Size of emitting particles.
  12321. */
  12322. maxSize: number;
  12323. /**
  12324. * Minimum scale of emitting particles on X axis.
  12325. */
  12326. minScaleX: number;
  12327. /**
  12328. * Maximum scale of emitting particles on X axis.
  12329. */
  12330. maxScaleX: number;
  12331. /**
  12332. * Minimum scale of emitting particles on Y axis.
  12333. */
  12334. minScaleY: number;
  12335. /**
  12336. * Maximum scale of emitting particles on Y axis.
  12337. */
  12338. maxScaleY: number;
  12339. /**
  12340. * Gets or sets the minimal initial rotation in radians.
  12341. */
  12342. minInitialRotation: number;
  12343. /**
  12344. * Gets or sets the maximal initial rotation in radians.
  12345. */
  12346. maxInitialRotation: number;
  12347. /**
  12348. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12349. */
  12350. minAngularSpeed: number;
  12351. /**
  12352. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12353. */
  12354. maxAngularSpeed: number;
  12355. /**
  12356. * The texture used to render each particle. (this can be a spritesheet)
  12357. */
  12358. particleTexture: Nullable<BaseTexture>;
  12359. /**
  12360. * The layer mask we are rendering the particles through.
  12361. */
  12362. layerMask: number;
  12363. /**
  12364. * This can help using your own shader to render the particle system.
  12365. * The according effect will be created
  12366. */
  12367. customShader: any;
  12368. /**
  12369. * By default particle system starts as soon as they are created. This prevents the
  12370. * automatic start to happen and let you decide when to start emitting particles.
  12371. */
  12372. preventAutoStart: boolean;
  12373. private _noiseTexture;
  12374. /**
  12375. * Gets or sets a texture used to add random noise to particle positions
  12376. */
  12377. get noiseTexture(): Nullable<ProceduralTexture>;
  12378. set noiseTexture(value: Nullable<ProceduralTexture>);
  12379. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12380. noiseStrength: Vector3;
  12381. /**
  12382. * Callback triggered when the particle animation is ending.
  12383. */
  12384. onAnimationEnd: Nullable<() => void>;
  12385. /**
  12386. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12387. */
  12388. blendMode: number;
  12389. /**
  12390. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12391. * to override the particles.
  12392. */
  12393. forceDepthWrite: boolean;
  12394. /** 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 */
  12395. preWarmCycles: number;
  12396. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12397. preWarmStepOffset: number;
  12398. /**
  12399. * 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)
  12400. */
  12401. spriteCellChangeSpeed: number;
  12402. /**
  12403. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12404. */
  12405. startSpriteCellID: number;
  12406. /**
  12407. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12408. */
  12409. endSpriteCellID: number;
  12410. /**
  12411. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12412. */
  12413. spriteCellWidth: number;
  12414. /**
  12415. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12416. */
  12417. spriteCellHeight: number;
  12418. /**
  12419. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12420. */
  12421. spriteRandomStartCell: boolean;
  12422. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12423. translationPivot: Vector2;
  12424. /** @hidden */
  12425. protected _isAnimationSheetEnabled: boolean;
  12426. /**
  12427. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12428. */
  12429. beginAnimationOnStart: boolean;
  12430. /**
  12431. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12432. */
  12433. beginAnimationFrom: number;
  12434. /**
  12435. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12436. */
  12437. beginAnimationTo: number;
  12438. /**
  12439. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12440. */
  12441. beginAnimationLoop: boolean;
  12442. /**
  12443. * Gets or sets a world offset applied to all particles
  12444. */
  12445. worldOffset: Vector3;
  12446. /**
  12447. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12448. */
  12449. get isAnimationSheetEnabled(): boolean;
  12450. set isAnimationSheetEnabled(value: boolean);
  12451. /**
  12452. * Get hosting scene
  12453. * @returns the scene
  12454. */
  12455. getScene(): Nullable<Scene>;
  12456. /**
  12457. * You can use gravity if you want to give an orientation to your particles.
  12458. */
  12459. gravity: Vector3;
  12460. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12461. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12462. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12463. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12464. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12465. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12466. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12467. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12468. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12469. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12470. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12471. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12472. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12473. /**
  12474. * Defines the delay in milliseconds before starting the system (0 by default)
  12475. */
  12476. startDelay: number;
  12477. /**
  12478. * Gets the current list of drag gradients.
  12479. * You must use addDragGradient and removeDragGradient to udpate this list
  12480. * @returns the list of drag gradients
  12481. */
  12482. getDragGradients(): Nullable<Array<FactorGradient>>;
  12483. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12484. limitVelocityDamping: number;
  12485. /**
  12486. * Gets the current list of limit velocity gradients.
  12487. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12488. * @returns the list of limit velocity gradients
  12489. */
  12490. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12491. /**
  12492. * Gets the current list of color gradients.
  12493. * You must use addColorGradient and removeColorGradient to udpate this list
  12494. * @returns the list of color gradients
  12495. */
  12496. getColorGradients(): Nullable<Array<ColorGradient>>;
  12497. /**
  12498. * Gets the current list of size gradients.
  12499. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12500. * @returns the list of size gradients
  12501. */
  12502. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12503. /**
  12504. * Gets the current list of color remap gradients.
  12505. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12506. * @returns the list of color remap gradients
  12507. */
  12508. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12509. /**
  12510. * Gets the current list of alpha remap gradients.
  12511. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12512. * @returns the list of alpha remap gradients
  12513. */
  12514. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12515. /**
  12516. * Gets the current list of life time gradients.
  12517. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12518. * @returns the list of life time gradients
  12519. */
  12520. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12521. /**
  12522. * Gets the current list of angular speed gradients.
  12523. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12524. * @returns the list of angular speed gradients
  12525. */
  12526. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12527. /**
  12528. * Gets the current list of velocity gradients.
  12529. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12530. * @returns the list of velocity gradients
  12531. */
  12532. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12533. /**
  12534. * Gets the current list of start size gradients.
  12535. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12536. * @returns the list of start size gradients
  12537. */
  12538. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12539. /**
  12540. * Gets the current list of emit rate gradients.
  12541. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12542. * @returns the list of emit rate gradients
  12543. */
  12544. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12545. /**
  12546. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12547. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12548. */
  12549. get direction1(): Vector3;
  12550. set direction1(value: Vector3);
  12551. /**
  12552. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12553. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12554. */
  12555. get direction2(): Vector3;
  12556. set direction2(value: Vector3);
  12557. /**
  12558. * 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.
  12559. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12560. */
  12561. get minEmitBox(): Vector3;
  12562. set minEmitBox(value: Vector3);
  12563. /**
  12564. * 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.
  12565. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12566. */
  12567. get maxEmitBox(): Vector3;
  12568. set maxEmitBox(value: Vector3);
  12569. /**
  12570. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12571. */
  12572. color1: Color4;
  12573. /**
  12574. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12575. */
  12576. color2: Color4;
  12577. /**
  12578. * Color the particle will have at the end of its lifetime
  12579. */
  12580. colorDead: Color4;
  12581. /**
  12582. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12583. */
  12584. textureMask: Color4;
  12585. /**
  12586. * The particle emitter type defines the emitter used by the particle system.
  12587. * It can be for example box, sphere, or cone...
  12588. */
  12589. particleEmitterType: IParticleEmitterType;
  12590. /** @hidden */
  12591. _isSubEmitter: boolean;
  12592. /**
  12593. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12594. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12595. */
  12596. billboardMode: number;
  12597. protected _isBillboardBased: boolean;
  12598. /**
  12599. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12600. */
  12601. get isBillboardBased(): boolean;
  12602. set isBillboardBased(value: boolean);
  12603. /**
  12604. * The scene the particle system belongs to.
  12605. */
  12606. protected _scene: Nullable<Scene>;
  12607. /**
  12608. * The engine the particle system belongs to.
  12609. */
  12610. protected _engine: ThinEngine;
  12611. /**
  12612. * Local cache of defines for image processing.
  12613. */
  12614. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12615. /**
  12616. * Default configuration related to image processing available in the standard Material.
  12617. */
  12618. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12619. /**
  12620. * Gets the image processing configuration used either in this material.
  12621. */
  12622. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12623. /**
  12624. * Sets the Default image processing configuration used either in the this material.
  12625. *
  12626. * If sets to null, the scene one is in use.
  12627. */
  12628. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12629. /**
  12630. * Attaches a new image processing configuration to the Standard Material.
  12631. * @param configuration
  12632. */
  12633. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12634. /** @hidden */
  12635. protected _reset(): void;
  12636. /** @hidden */
  12637. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12638. /**
  12639. * Instantiates a particle system.
  12640. * 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.
  12641. * @param name The name of the particle system
  12642. */
  12643. constructor(name: string);
  12644. /**
  12645. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12648. * @returns the emitter
  12649. */
  12650. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12651. /**
  12652. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12653. * @param radius The radius of the hemisphere to emit from
  12654. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12655. * @returns the emitter
  12656. */
  12657. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12658. /**
  12659. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12660. * @param radius The radius of the sphere to emit from
  12661. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12662. * @returns the emitter
  12663. */
  12664. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12665. /**
  12666. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12667. * @param radius The radius of the sphere to emit from
  12668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12670. * @returns the emitter
  12671. */
  12672. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12673. /**
  12674. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12675. * @param radius The radius of the emission cylinder
  12676. * @param height The height of the emission cylinder
  12677. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12678. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12679. * @returns the emitter
  12680. */
  12681. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12682. /**
  12683. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12684. * @param radius The radius of the cylinder to emit from
  12685. * @param height The height of the emission cylinder
  12686. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12689. * @returns the emitter
  12690. */
  12691. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12692. /**
  12693. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12694. * @param radius The radius of the cone to emit from
  12695. * @param angle The base angle of the cone
  12696. * @returns the emitter
  12697. */
  12698. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12699. /**
  12700. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12703. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12704. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12705. * @returns the emitter
  12706. */
  12707. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12708. }
  12709. }
  12710. declare module "babylonjs/Particles/subEmitter" {
  12711. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12712. import { Scene } from "babylonjs/scene";
  12713. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12714. /**
  12715. * Type of sub emitter
  12716. */
  12717. export enum SubEmitterType {
  12718. /**
  12719. * Attached to the particle over it's lifetime
  12720. */
  12721. ATTACHED = 0,
  12722. /**
  12723. * Created when the particle dies
  12724. */
  12725. END = 1
  12726. }
  12727. /**
  12728. * Sub emitter class used to emit particles from an existing particle
  12729. */
  12730. export class SubEmitter {
  12731. /**
  12732. * the particle system to be used by the sub emitter
  12733. */
  12734. particleSystem: ParticleSystem;
  12735. /**
  12736. * Type of the submitter (Default: END)
  12737. */
  12738. type: SubEmitterType;
  12739. /**
  12740. * 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)
  12741. * Note: This only is supported when using an emitter of type Mesh
  12742. */
  12743. inheritDirection: boolean;
  12744. /**
  12745. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12746. */
  12747. inheritedVelocityAmount: number;
  12748. /**
  12749. * Creates a sub emitter
  12750. * @param particleSystem the particle system to be used by the sub emitter
  12751. */
  12752. constructor(
  12753. /**
  12754. * the particle system to be used by the sub emitter
  12755. */
  12756. particleSystem: ParticleSystem);
  12757. /**
  12758. * Clones the sub emitter
  12759. * @returns the cloned sub emitter
  12760. */
  12761. clone(): SubEmitter;
  12762. /**
  12763. * Serialize current object to a JSON object
  12764. * @returns the serialized object
  12765. */
  12766. serialize(): any;
  12767. /** @hidden */
  12768. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12769. /**
  12770. * Creates a new SubEmitter from a serialized JSON version
  12771. * @param serializationObject defines the JSON object to read from
  12772. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12773. * @param rootUrl defines the rootUrl for data loading
  12774. * @returns a new SubEmitter
  12775. */
  12776. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12777. /** Release associated resources */
  12778. dispose(): void;
  12779. }
  12780. }
  12781. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12782. /** @hidden */
  12783. export var imageProcessingDeclaration: {
  12784. name: string;
  12785. shader: string;
  12786. };
  12787. }
  12788. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12789. /** @hidden */
  12790. export var imageProcessingFunctions: {
  12791. name: string;
  12792. shader: string;
  12793. };
  12794. }
  12795. declare module "babylonjs/Shaders/particles.fragment" {
  12796. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12797. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12798. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12799. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12800. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12801. /** @hidden */
  12802. export var particlesPixelShader: {
  12803. name: string;
  12804. shader: string;
  12805. };
  12806. }
  12807. declare module "babylonjs/Shaders/particles.vertex" {
  12808. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12809. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12810. /** @hidden */
  12811. export var particlesVertexShader: {
  12812. name: string;
  12813. shader: string;
  12814. };
  12815. }
  12816. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12817. import { Nullable } from "babylonjs/types";
  12818. import { Plane } from "babylonjs/Maths/math";
  12819. /**
  12820. * Interface used to define entities containing multiple clip planes
  12821. */
  12822. export interface IClipPlanesHolder {
  12823. /**
  12824. * Gets or sets the active clipplane 1
  12825. */
  12826. clipPlane: Nullable<Plane>;
  12827. /**
  12828. * Gets or sets the active clipplane 2
  12829. */
  12830. clipPlane2: Nullable<Plane>;
  12831. /**
  12832. * Gets or sets the active clipplane 3
  12833. */
  12834. clipPlane3: Nullable<Plane>;
  12835. /**
  12836. * Gets or sets the active clipplane 4
  12837. */
  12838. clipPlane4: Nullable<Plane>;
  12839. /**
  12840. * Gets or sets the active clipplane 5
  12841. */
  12842. clipPlane5: Nullable<Plane>;
  12843. /**
  12844. * Gets or sets the active clipplane 6
  12845. */
  12846. clipPlane6: Nullable<Plane>;
  12847. }
  12848. }
  12849. declare module "babylonjs/Materials/thinMaterialHelper" {
  12850. import { Effect } from "babylonjs/Materials/effect";
  12851. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12852. /**
  12853. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12854. *
  12855. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12856. *
  12857. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12858. */
  12859. export class ThinMaterialHelper {
  12860. /**
  12861. * Binds the clip plane information from the holder to the effect.
  12862. * @param effect The effect we are binding the data to
  12863. * @param holder The entity containing the clip plane information
  12864. */
  12865. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12866. }
  12867. }
  12868. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12869. module "babylonjs/Engines/thinEngine" {
  12870. interface ThinEngine {
  12871. /**
  12872. * Sets alpha constants used by some alpha blending modes
  12873. * @param r defines the red component
  12874. * @param g defines the green component
  12875. * @param b defines the blue component
  12876. * @param a defines the alpha component
  12877. */
  12878. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12879. /**
  12880. * Sets the current alpha mode
  12881. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12882. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12883. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12884. */
  12885. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12886. /**
  12887. * Gets the current alpha mode
  12888. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12889. * @returns the current alpha mode
  12890. */
  12891. getAlphaMode(): number;
  12892. /**
  12893. * Sets the current alpha equation
  12894. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12895. */
  12896. setAlphaEquation(equation: number): void;
  12897. /**
  12898. * Gets the current alpha equation.
  12899. * @returns the current alpha equation
  12900. */
  12901. getAlphaEquation(): number;
  12902. }
  12903. }
  12904. }
  12905. declare module "babylonjs/Particles/particleSystem" {
  12906. import { Nullable } from "babylonjs/types";
  12907. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12908. import { Observable } from "babylonjs/Misc/observable";
  12909. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12910. import { Effect } from "babylonjs/Materials/effect";
  12911. import { IDisposable } from "babylonjs/scene";
  12912. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12913. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12914. import { Particle } from "babylonjs/Particles/particle";
  12915. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12916. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12917. import "babylonjs/Shaders/particles.fragment";
  12918. import "babylonjs/Shaders/particles.vertex";
  12919. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12920. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12921. import "babylonjs/Engines/Extensions/engine.alpha";
  12922. import { Scene } from "babylonjs/scene";
  12923. /**
  12924. * This represents a particle system in Babylon.
  12925. * 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.
  12926. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12927. * @example https://doc.babylonjs.com/babylon101/particles
  12928. */
  12929. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12930. /**
  12931. * Billboard mode will only apply to Y axis
  12932. */
  12933. static readonly BILLBOARDMODE_Y: number;
  12934. /**
  12935. * Billboard mode will apply to all axes
  12936. */
  12937. static readonly BILLBOARDMODE_ALL: number;
  12938. /**
  12939. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12940. */
  12941. static readonly BILLBOARDMODE_STRETCHED: number;
  12942. /**
  12943. * This function can be defined to provide custom update for active particles.
  12944. * This function will be called instead of regular update (age, position, color, etc.).
  12945. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12946. */
  12947. updateFunction: (particles: Particle[]) => void;
  12948. private _emitterWorldMatrix;
  12949. /**
  12950. * This function can be defined to specify initial direction for every new particle.
  12951. * It by default use the emitterType defined function
  12952. */
  12953. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12954. /**
  12955. * This function can be defined to specify initial position for every new particle.
  12956. * It by default use the emitterType defined function
  12957. */
  12958. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12959. /**
  12960. * @hidden
  12961. */
  12962. _inheritedVelocityOffset: Vector3;
  12963. /**
  12964. * An event triggered when the system is disposed
  12965. */
  12966. onDisposeObservable: Observable<IParticleSystem>;
  12967. /**
  12968. * An event triggered when the system is stopped
  12969. */
  12970. onStoppedObservable: Observable<IParticleSystem>;
  12971. private _onDisposeObserver;
  12972. /**
  12973. * Sets a callback that will be triggered when the system is disposed
  12974. */
  12975. set onDispose(callback: () => void);
  12976. private _particles;
  12977. private _epsilon;
  12978. private _capacity;
  12979. private _stockParticles;
  12980. private _newPartsExcess;
  12981. private _vertexData;
  12982. private _vertexBuffer;
  12983. private _vertexBuffers;
  12984. private _spriteBuffer;
  12985. private _indexBuffer;
  12986. private _effect;
  12987. private _customEffect;
  12988. private _cachedDefines;
  12989. private _scaledColorStep;
  12990. private _colorDiff;
  12991. private _scaledDirection;
  12992. private _scaledGravity;
  12993. private _currentRenderId;
  12994. private _alive;
  12995. private _useInstancing;
  12996. private _started;
  12997. private _stopped;
  12998. private _actualFrame;
  12999. private _scaledUpdateSpeed;
  13000. private _vertexBufferSize;
  13001. /** @hidden */
  13002. _currentEmitRateGradient: Nullable<FactorGradient>;
  13003. /** @hidden */
  13004. _currentEmitRate1: number;
  13005. /** @hidden */
  13006. _currentEmitRate2: number;
  13007. /** @hidden */
  13008. _currentStartSizeGradient: Nullable<FactorGradient>;
  13009. /** @hidden */
  13010. _currentStartSize1: number;
  13011. /** @hidden */
  13012. _currentStartSize2: number;
  13013. private readonly _rawTextureWidth;
  13014. private _rampGradientsTexture;
  13015. private _useRampGradients;
  13016. /** Gets or sets a matrix to use to compute projection */
  13017. defaultProjectionMatrix: Matrix;
  13018. /** Gets or sets a matrix to use to compute view */
  13019. defaultViewMatrix: Matrix;
  13020. /** Gets or sets a boolean indicating that ramp gradients must be used
  13021. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13022. */
  13023. get useRampGradients(): boolean;
  13024. set useRampGradients(value: boolean);
  13025. /**
  13026. * 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.
  13027. * 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: [])
  13028. */
  13029. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13030. private _subEmitters;
  13031. /**
  13032. * @hidden
  13033. * If the particle systems emitter should be disposed when the particle system is disposed
  13034. */
  13035. _disposeEmitterOnDispose: boolean;
  13036. /**
  13037. * The current active Sub-systems, this property is used by the root particle system only.
  13038. */
  13039. activeSubSystems: Array<ParticleSystem>;
  13040. /**
  13041. * Specifies if the particles are updated in emitter local space or world space
  13042. */
  13043. isLocal: boolean;
  13044. private _rootParticleSystem;
  13045. /**
  13046. * Gets the current list of active particles
  13047. */
  13048. get particles(): Particle[];
  13049. /**
  13050. * Gets the number of particles active at the same time.
  13051. * @returns The number of active particles.
  13052. */
  13053. getActiveCount(): number;
  13054. /**
  13055. * Returns the string "ParticleSystem"
  13056. * @returns a string containing the class name
  13057. */
  13058. getClassName(): string;
  13059. /**
  13060. * Gets a boolean indicating that the system is stopping
  13061. * @returns true if the system is currently stopping
  13062. */
  13063. isStopping(): boolean;
  13064. /**
  13065. * Gets the custom effect used to render the particles
  13066. * @param blendMode Blend mode for which the effect should be retrieved
  13067. * @returns The effect
  13068. */
  13069. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13070. /**
  13071. * Sets the custom effect used to render the particles
  13072. * @param effect The effect to set
  13073. * @param blendMode Blend mode for which the effect should be set
  13074. */
  13075. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13076. /** @hidden */
  13077. private _onBeforeDrawParticlesObservable;
  13078. /**
  13079. * Observable that will be called just before the particles are drawn
  13080. */
  13081. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13082. /**
  13083. * Gets the name of the particle vertex shader
  13084. */
  13085. get vertexShaderName(): string;
  13086. /**
  13087. * Instantiates a particle system.
  13088. * 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.
  13089. * @param name The name of the particle system
  13090. * @param capacity The max number of particles alive at the same time
  13091. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13092. * @param customEffect a custom effect used to change the way particles are rendered by default
  13093. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13094. * @param epsilon Offset used to render the particles
  13095. */
  13096. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13097. private _addFactorGradient;
  13098. private _removeFactorGradient;
  13099. /**
  13100. * Adds a new life time gradient
  13101. * @param gradient defines the gradient to use (between 0 and 1)
  13102. * @param factor defines the life time factor to affect to the specified gradient
  13103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13104. * @returns the current particle system
  13105. */
  13106. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13107. /**
  13108. * Remove a specific life time gradient
  13109. * @param gradient defines the gradient to remove
  13110. * @returns the current particle system
  13111. */
  13112. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13113. /**
  13114. * Adds a new size gradient
  13115. * @param gradient defines the gradient to use (between 0 and 1)
  13116. * @param factor defines the size factor to affect to the specified gradient
  13117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13118. * @returns the current particle system
  13119. */
  13120. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13121. /**
  13122. * Remove a specific size gradient
  13123. * @param gradient defines the gradient to remove
  13124. * @returns the current particle system
  13125. */
  13126. removeSizeGradient(gradient: number): IParticleSystem;
  13127. /**
  13128. * Adds a new color remap gradient
  13129. * @param gradient defines the gradient to use (between 0 and 1)
  13130. * @param min defines the color remap minimal range
  13131. * @param max defines the color remap maximal range
  13132. * @returns the current particle system
  13133. */
  13134. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13135. /**
  13136. * Remove a specific color remap gradient
  13137. * @param gradient defines the gradient to remove
  13138. * @returns the current particle system
  13139. */
  13140. removeColorRemapGradient(gradient: number): IParticleSystem;
  13141. /**
  13142. * Adds a new alpha remap gradient
  13143. * @param gradient defines the gradient to use (between 0 and 1)
  13144. * @param min defines the alpha remap minimal range
  13145. * @param max defines the alpha remap maximal range
  13146. * @returns the current particle system
  13147. */
  13148. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13149. /**
  13150. * Remove a specific alpha remap gradient
  13151. * @param gradient defines the gradient to remove
  13152. * @returns the current particle system
  13153. */
  13154. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13155. /**
  13156. * Adds a new angular speed gradient
  13157. * @param gradient defines the gradient to use (between 0 and 1)
  13158. * @param factor defines the angular speed to affect to the specified gradient
  13159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13160. * @returns the current particle system
  13161. */
  13162. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13163. /**
  13164. * Remove a specific angular speed gradient
  13165. * @param gradient defines the gradient to remove
  13166. * @returns the current particle system
  13167. */
  13168. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13169. /**
  13170. * Adds a new velocity gradient
  13171. * @param gradient defines the gradient to use (between 0 and 1)
  13172. * @param factor defines the velocity to affect to the specified gradient
  13173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13174. * @returns the current particle system
  13175. */
  13176. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13177. /**
  13178. * Remove a specific velocity gradient
  13179. * @param gradient defines the gradient to remove
  13180. * @returns the current particle system
  13181. */
  13182. removeVelocityGradient(gradient: number): IParticleSystem;
  13183. /**
  13184. * Adds a new limit velocity gradient
  13185. * @param gradient defines the gradient to use (between 0 and 1)
  13186. * @param factor defines the limit velocity value to affect to the specified gradient
  13187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13188. * @returns the current particle system
  13189. */
  13190. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13191. /**
  13192. * Remove a specific limit velocity gradient
  13193. * @param gradient defines the gradient to remove
  13194. * @returns the current particle system
  13195. */
  13196. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13197. /**
  13198. * Adds a new drag gradient
  13199. * @param gradient defines the gradient to use (between 0 and 1)
  13200. * @param factor defines the drag value to affect to the specified gradient
  13201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13202. * @returns the current particle system
  13203. */
  13204. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13205. /**
  13206. * Remove a specific drag gradient
  13207. * @param gradient defines the gradient to remove
  13208. * @returns the current particle system
  13209. */
  13210. removeDragGradient(gradient: number): IParticleSystem;
  13211. /**
  13212. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13213. * @param gradient defines the gradient to use (between 0 and 1)
  13214. * @param factor defines the emit rate value to affect to the specified gradient
  13215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13216. * @returns the current particle system
  13217. */
  13218. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13219. /**
  13220. * Remove a specific emit rate gradient
  13221. * @param gradient defines the gradient to remove
  13222. * @returns the current particle system
  13223. */
  13224. removeEmitRateGradient(gradient: number): IParticleSystem;
  13225. /**
  13226. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13227. * @param gradient defines the gradient to use (between 0 and 1)
  13228. * @param factor defines the start size value to affect to the specified gradient
  13229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13230. * @returns the current particle system
  13231. */
  13232. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13233. /**
  13234. * Remove a specific start size gradient
  13235. * @param gradient defines the gradient to remove
  13236. * @returns the current particle system
  13237. */
  13238. removeStartSizeGradient(gradient: number): IParticleSystem;
  13239. private _createRampGradientTexture;
  13240. /**
  13241. * Gets the current list of ramp gradients.
  13242. * You must use addRampGradient and removeRampGradient to udpate this list
  13243. * @returns the list of ramp gradients
  13244. */
  13245. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13246. /** Force the system to rebuild all gradients that need to be resync */
  13247. forceRefreshGradients(): void;
  13248. private _syncRampGradientTexture;
  13249. /**
  13250. * Adds a new ramp gradient used to remap particle colors
  13251. * @param gradient defines the gradient to use (between 0 and 1)
  13252. * @param color defines the color to affect to the specified gradient
  13253. * @returns the current particle system
  13254. */
  13255. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13256. /**
  13257. * Remove a specific ramp gradient
  13258. * @param gradient defines the gradient to remove
  13259. * @returns the current particle system
  13260. */
  13261. removeRampGradient(gradient: number): ParticleSystem;
  13262. /**
  13263. * Adds a new color gradient
  13264. * @param gradient defines the gradient to use (between 0 and 1)
  13265. * @param color1 defines the color to affect to the specified gradient
  13266. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13267. * @returns this particle system
  13268. */
  13269. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13270. /**
  13271. * Remove a specific color gradient
  13272. * @param gradient defines the gradient to remove
  13273. * @returns this particle system
  13274. */
  13275. removeColorGradient(gradient: number): IParticleSystem;
  13276. private _fetchR;
  13277. protected _reset(): void;
  13278. private _resetEffect;
  13279. private _createVertexBuffers;
  13280. private _createIndexBuffer;
  13281. /**
  13282. * Gets the maximum number of particles active at the same time.
  13283. * @returns The max number of active particles.
  13284. */
  13285. getCapacity(): number;
  13286. /**
  13287. * Gets whether there are still active particles in the system.
  13288. * @returns True if it is alive, otherwise false.
  13289. */
  13290. isAlive(): boolean;
  13291. /**
  13292. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13293. * @returns True if it has been started, otherwise false.
  13294. */
  13295. isStarted(): boolean;
  13296. private _prepareSubEmitterInternalArray;
  13297. /**
  13298. * Starts the particle system and begins to emit
  13299. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13300. */
  13301. start(delay?: number): void;
  13302. /**
  13303. * Stops the particle system.
  13304. * @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.
  13305. */
  13306. stop(stopSubEmitters?: boolean): void;
  13307. /**
  13308. * Remove all active particles
  13309. */
  13310. reset(): void;
  13311. /**
  13312. * @hidden (for internal use only)
  13313. */
  13314. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13315. /**
  13316. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13317. * Its lifetime will start back at 0.
  13318. */
  13319. recycleParticle: (particle: Particle) => void;
  13320. private _stopSubEmitters;
  13321. private _createParticle;
  13322. private _removeFromRoot;
  13323. private _emitFromParticle;
  13324. private _update;
  13325. /** @hidden */
  13326. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13327. /** @hidden */
  13328. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13329. /**
  13330. * Fill the defines array according to the current settings of the particle system
  13331. * @param defines Array to be updated
  13332. * @param blendMode blend mode to take into account when updating the array
  13333. */
  13334. fillDefines(defines: Array<string>, blendMode: number): void;
  13335. /**
  13336. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13337. * @param uniforms Uniforms array to fill
  13338. * @param attributes Attributes array to fill
  13339. * @param samplers Samplers array to fill
  13340. */
  13341. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13342. /** @hidden */
  13343. private _getEffect;
  13344. /**
  13345. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13346. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13347. */
  13348. animate(preWarmOnly?: boolean): void;
  13349. private _appendParticleVertices;
  13350. /**
  13351. * Rebuilds the particle system.
  13352. */
  13353. rebuild(): void;
  13354. /**
  13355. * Is this system ready to be used/rendered
  13356. * @return true if the system is ready
  13357. */
  13358. isReady(): boolean;
  13359. private _render;
  13360. /**
  13361. * Renders the particle system in its current state.
  13362. * @returns the current number of particles
  13363. */
  13364. render(): number;
  13365. /**
  13366. * Disposes the particle system and free the associated resources
  13367. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13368. */
  13369. dispose(disposeTexture?: boolean): void;
  13370. /**
  13371. * Clones the particle system.
  13372. * @param name The name of the cloned object
  13373. * @param newEmitter The new emitter to use
  13374. * @returns the cloned particle system
  13375. */
  13376. clone(name: string, newEmitter: any): ParticleSystem;
  13377. /**
  13378. * Serializes the particle system to a JSON object
  13379. * @param serializeTexture defines if the texture must be serialized as well
  13380. * @returns the JSON object
  13381. */
  13382. serialize(serializeTexture?: boolean): any;
  13383. /** @hidden */
  13384. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13385. /** @hidden */
  13386. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13387. /**
  13388. * Parses a JSON object to create a particle system.
  13389. * @param parsedParticleSystem The JSON object to parse
  13390. * @param sceneOrEngine The scene or the engine to create the particle system in
  13391. * @param rootUrl The root url to use to load external dependencies like texture
  13392. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13393. * @returns the Parsed particle system
  13394. */
  13395. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13396. }
  13397. }
  13398. declare module "babylonjs/Particles/particle" {
  13399. import { Nullable } from "babylonjs/types";
  13400. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13401. import { Color4 } from "babylonjs/Maths/math.color";
  13402. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13403. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13404. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13405. /**
  13406. * A particle represents one of the element emitted by a particle system.
  13407. * This is mainly define by its coordinates, direction, velocity and age.
  13408. */
  13409. export class Particle {
  13410. /**
  13411. * The particle system the particle belongs to.
  13412. */
  13413. particleSystem: ParticleSystem;
  13414. private static _Count;
  13415. /**
  13416. * Unique ID of the particle
  13417. */
  13418. id: number;
  13419. /**
  13420. * The world position of the particle in the scene.
  13421. */
  13422. position: Vector3;
  13423. /**
  13424. * The world direction of the particle in the scene.
  13425. */
  13426. direction: Vector3;
  13427. /**
  13428. * The color of the particle.
  13429. */
  13430. color: Color4;
  13431. /**
  13432. * The color change of the particle per step.
  13433. */
  13434. colorStep: Color4;
  13435. /**
  13436. * Defines how long will the life of the particle be.
  13437. */
  13438. lifeTime: number;
  13439. /**
  13440. * The current age of the particle.
  13441. */
  13442. age: number;
  13443. /**
  13444. * The current size of the particle.
  13445. */
  13446. size: number;
  13447. /**
  13448. * The current scale of the particle.
  13449. */
  13450. scale: Vector2;
  13451. /**
  13452. * The current angle of the particle.
  13453. */
  13454. angle: number;
  13455. /**
  13456. * Defines how fast is the angle changing.
  13457. */
  13458. angularSpeed: number;
  13459. /**
  13460. * Defines the cell index used by the particle to be rendered from a sprite.
  13461. */
  13462. cellIndex: number;
  13463. /**
  13464. * The information required to support color remapping
  13465. */
  13466. remapData: Vector4;
  13467. /** @hidden */
  13468. _randomCellOffset?: number;
  13469. /** @hidden */
  13470. _initialDirection: Nullable<Vector3>;
  13471. /** @hidden */
  13472. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13473. /** @hidden */
  13474. _initialStartSpriteCellID: number;
  13475. /** @hidden */
  13476. _initialEndSpriteCellID: number;
  13477. /** @hidden */
  13478. _currentColorGradient: Nullable<ColorGradient>;
  13479. /** @hidden */
  13480. _currentColor1: Color4;
  13481. /** @hidden */
  13482. _currentColor2: Color4;
  13483. /** @hidden */
  13484. _currentSizeGradient: Nullable<FactorGradient>;
  13485. /** @hidden */
  13486. _currentSize1: number;
  13487. /** @hidden */
  13488. _currentSize2: number;
  13489. /** @hidden */
  13490. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13491. /** @hidden */
  13492. _currentAngularSpeed1: number;
  13493. /** @hidden */
  13494. _currentAngularSpeed2: number;
  13495. /** @hidden */
  13496. _currentVelocityGradient: Nullable<FactorGradient>;
  13497. /** @hidden */
  13498. _currentVelocity1: number;
  13499. /** @hidden */
  13500. _currentVelocity2: number;
  13501. /** @hidden */
  13502. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13503. /** @hidden */
  13504. _currentLimitVelocity1: number;
  13505. /** @hidden */
  13506. _currentLimitVelocity2: number;
  13507. /** @hidden */
  13508. _currentDragGradient: Nullable<FactorGradient>;
  13509. /** @hidden */
  13510. _currentDrag1: number;
  13511. /** @hidden */
  13512. _currentDrag2: number;
  13513. /** @hidden */
  13514. _randomNoiseCoordinates1: Vector3;
  13515. /** @hidden */
  13516. _randomNoiseCoordinates2: Vector3;
  13517. /** @hidden */
  13518. _localPosition?: Vector3;
  13519. /**
  13520. * Creates a new instance Particle
  13521. * @param particleSystem the particle system the particle belongs to
  13522. */
  13523. constructor(
  13524. /**
  13525. * The particle system the particle belongs to.
  13526. */
  13527. particleSystem: ParticleSystem);
  13528. private updateCellInfoFromSystem;
  13529. /**
  13530. * Defines how the sprite cell index is updated for the particle
  13531. */
  13532. updateCellIndex(): void;
  13533. /** @hidden */
  13534. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13535. /** @hidden */
  13536. _inheritParticleInfoToSubEmitters(): void;
  13537. /** @hidden */
  13538. _reset(): void;
  13539. /**
  13540. * Copy the properties of particle to another one.
  13541. * @param other the particle to copy the information to.
  13542. */
  13543. copyTo(other: Particle): void;
  13544. }
  13545. }
  13546. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13547. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13548. import { Effect } from "babylonjs/Materials/effect";
  13549. import { Particle } from "babylonjs/Particles/particle";
  13550. import { Nullable } from "babylonjs/types";
  13551. import { Scene } from "babylonjs/scene";
  13552. /**
  13553. * Particle emitter represents a volume emitting particles.
  13554. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13555. */
  13556. export interface IParticleEmitterType {
  13557. /**
  13558. * Called by the particle System when the direction is computed for the created particle.
  13559. * @param worldMatrix is the world matrix of the particle system
  13560. * @param directionToUpdate is the direction vector to update with the result
  13561. * @param particle is the particle we are computed the direction for
  13562. * @param isLocal defines if the direction should be set in local space
  13563. */
  13564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13565. /**
  13566. * Called by the particle System when the position is computed for the created particle.
  13567. * @param worldMatrix is the world matrix of the particle system
  13568. * @param positionToUpdate is the position vector to update with the result
  13569. * @param particle is the particle we are computed the position for
  13570. * @param isLocal defines if the position should be set in local space
  13571. */
  13572. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13573. /**
  13574. * Clones the current emitter and returns a copy of it
  13575. * @returns the new emitter
  13576. */
  13577. clone(): IParticleEmitterType;
  13578. /**
  13579. * Called by the GPUParticleSystem to setup the update shader
  13580. * @param effect defines the update shader
  13581. */
  13582. applyToShader(effect: Effect): void;
  13583. /**
  13584. * Returns a string to use to update the GPU particles update shader
  13585. * @returns the effect defines string
  13586. */
  13587. getEffectDefines(): string;
  13588. /**
  13589. * Returns a string representing the class name
  13590. * @returns a string containing the class name
  13591. */
  13592. getClassName(): string;
  13593. /**
  13594. * Serializes the particle system to a JSON object.
  13595. * @returns the JSON object
  13596. */
  13597. serialize(): any;
  13598. /**
  13599. * Parse properties from a JSON object
  13600. * @param serializationObject defines the JSON object
  13601. * @param scene defines the hosting scene
  13602. */
  13603. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13604. }
  13605. }
  13606. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13607. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13608. import { Effect } from "babylonjs/Materials/effect";
  13609. import { Particle } from "babylonjs/Particles/particle";
  13610. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13611. /**
  13612. * Particle emitter emitting particles from the inside of a box.
  13613. * It emits the particles randomly between 2 given directions.
  13614. */
  13615. export class BoxParticleEmitter implements IParticleEmitterType {
  13616. /**
  13617. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13618. */
  13619. direction1: Vector3;
  13620. /**
  13621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13622. */
  13623. direction2: Vector3;
  13624. /**
  13625. * 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.
  13626. */
  13627. minEmitBox: Vector3;
  13628. /**
  13629. * 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.
  13630. */
  13631. maxEmitBox: Vector3;
  13632. /**
  13633. * Creates a new instance BoxParticleEmitter
  13634. */
  13635. constructor();
  13636. /**
  13637. * Called by the particle System when the direction is computed for the created particle.
  13638. * @param worldMatrix is the world matrix of the particle system
  13639. * @param directionToUpdate is the direction vector to update with the result
  13640. * @param particle is the particle we are computed the direction for
  13641. * @param isLocal defines if the direction should be set in local space
  13642. */
  13643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13644. /**
  13645. * Called by the particle System when the position is computed for the created particle.
  13646. * @param worldMatrix is the world matrix of the particle system
  13647. * @param positionToUpdate is the position vector to update with the result
  13648. * @param particle is the particle we are computed the position for
  13649. * @param isLocal defines if the position should be set in local space
  13650. */
  13651. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13652. /**
  13653. * Clones the current emitter and returns a copy of it
  13654. * @returns the new emitter
  13655. */
  13656. clone(): BoxParticleEmitter;
  13657. /**
  13658. * Called by the GPUParticleSystem to setup the update shader
  13659. * @param effect defines the update shader
  13660. */
  13661. applyToShader(effect: Effect): void;
  13662. /**
  13663. * Returns a string to use to update the GPU particles update shader
  13664. * @returns a string containng the defines string
  13665. */
  13666. getEffectDefines(): string;
  13667. /**
  13668. * Returns the string "BoxParticleEmitter"
  13669. * @returns a string containing the class name
  13670. */
  13671. getClassName(): string;
  13672. /**
  13673. * Serializes the particle system to a JSON object.
  13674. * @returns the JSON object
  13675. */
  13676. serialize(): any;
  13677. /**
  13678. * Parse properties from a JSON object
  13679. * @param serializationObject defines the JSON object
  13680. */
  13681. parse(serializationObject: any): void;
  13682. }
  13683. }
  13684. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13685. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13686. import { Effect } from "babylonjs/Materials/effect";
  13687. import { Particle } from "babylonjs/Particles/particle";
  13688. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13689. /**
  13690. * Particle emitter emitting particles from the inside of a cone.
  13691. * It emits the particles alongside the cone volume from the base to the particle.
  13692. * The emission direction might be randomized.
  13693. */
  13694. export class ConeParticleEmitter implements IParticleEmitterType {
  13695. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13696. directionRandomizer: number;
  13697. private _radius;
  13698. private _angle;
  13699. private _height;
  13700. /**
  13701. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13702. */
  13703. radiusRange: number;
  13704. /**
  13705. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13706. */
  13707. heightRange: number;
  13708. /**
  13709. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13710. */
  13711. emitFromSpawnPointOnly: boolean;
  13712. /**
  13713. * Gets or sets the radius of the emission cone
  13714. */
  13715. get radius(): number;
  13716. set radius(value: number);
  13717. /**
  13718. * Gets or sets the angle of the emission cone
  13719. */
  13720. get angle(): number;
  13721. set angle(value: number);
  13722. private _buildHeight;
  13723. /**
  13724. * Creates a new instance ConeParticleEmitter
  13725. * @param radius the radius of the emission cone (1 by default)
  13726. * @param angle the cone base angle (PI by default)
  13727. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13728. */
  13729. constructor(radius?: number, angle?: number,
  13730. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13731. directionRandomizer?: number);
  13732. /**
  13733. * Called by the particle System when the direction is computed for the created particle.
  13734. * @param worldMatrix is the world matrix of the particle system
  13735. * @param directionToUpdate is the direction vector to update with the result
  13736. * @param particle is the particle we are computed the direction for
  13737. * @param isLocal defines if the direction should be set in local space
  13738. */
  13739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13740. /**
  13741. * Called by the particle System when the position is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param positionToUpdate is the position vector to update with the result
  13744. * @param particle is the particle we are computed the position for
  13745. * @param isLocal defines if the position should be set in local space
  13746. */
  13747. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Clones the current emitter and returns a copy of it
  13750. * @returns the new emitter
  13751. */
  13752. clone(): ConeParticleEmitter;
  13753. /**
  13754. * Called by the GPUParticleSystem to setup the update shader
  13755. * @param effect defines the update shader
  13756. */
  13757. applyToShader(effect: Effect): void;
  13758. /**
  13759. * Returns a string to use to update the GPU particles update shader
  13760. * @returns a string containng the defines string
  13761. */
  13762. getEffectDefines(): string;
  13763. /**
  13764. * Returns the string "ConeParticleEmitter"
  13765. * @returns a string containing the class name
  13766. */
  13767. getClassName(): string;
  13768. /**
  13769. * Serializes the particle system to a JSON object.
  13770. * @returns the JSON object
  13771. */
  13772. serialize(): any;
  13773. /**
  13774. * Parse properties from a JSON object
  13775. * @param serializationObject defines the JSON object
  13776. */
  13777. parse(serializationObject: any): void;
  13778. }
  13779. }
  13780. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13781. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13782. import { Effect } from "babylonjs/Materials/effect";
  13783. import { Particle } from "babylonjs/Particles/particle";
  13784. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13785. /**
  13786. * Particle emitter emitting particles from the inside of a cylinder.
  13787. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13788. */
  13789. export class CylinderParticleEmitter implements IParticleEmitterType {
  13790. /**
  13791. * The radius of the emission cylinder.
  13792. */
  13793. radius: number;
  13794. /**
  13795. * The height of the emission cylinder.
  13796. */
  13797. height: number;
  13798. /**
  13799. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13800. */
  13801. radiusRange: number;
  13802. /**
  13803. * How much to randomize the particle direction [0-1].
  13804. */
  13805. directionRandomizer: number;
  13806. /**
  13807. * Creates a new instance CylinderParticleEmitter
  13808. * @param radius the radius of the emission cylinder (1 by default)
  13809. * @param height the height of the emission cylinder (1 by default)
  13810. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13811. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13812. */
  13813. constructor(
  13814. /**
  13815. * The radius of the emission cylinder.
  13816. */
  13817. radius?: number,
  13818. /**
  13819. * The height of the emission cylinder.
  13820. */
  13821. height?: number,
  13822. /**
  13823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13824. */
  13825. radiusRange?: number,
  13826. /**
  13827. * How much to randomize the particle direction [0-1].
  13828. */
  13829. directionRandomizer?: number);
  13830. /**
  13831. * Called by the particle System when the direction is computed for the created particle.
  13832. * @param worldMatrix is the world matrix of the particle system
  13833. * @param directionToUpdate is the direction vector to update with the result
  13834. * @param particle is the particle we are computed the direction for
  13835. * @param isLocal defines if the direction should be set in local space
  13836. */
  13837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13838. /**
  13839. * Called by the particle System when the position is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param positionToUpdate is the position vector to update with the result
  13842. * @param particle is the particle we are computed the position for
  13843. * @param isLocal defines if the position should be set in local space
  13844. */
  13845. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Clones the current emitter and returns a copy of it
  13848. * @returns the new emitter
  13849. */
  13850. clone(): CylinderParticleEmitter;
  13851. /**
  13852. * Called by the GPUParticleSystem to setup the update shader
  13853. * @param effect defines the update shader
  13854. */
  13855. applyToShader(effect: Effect): void;
  13856. /**
  13857. * Returns a string to use to update the GPU particles update shader
  13858. * @returns a string containng the defines string
  13859. */
  13860. getEffectDefines(): string;
  13861. /**
  13862. * Returns the string "CylinderParticleEmitter"
  13863. * @returns a string containing the class name
  13864. */
  13865. getClassName(): string;
  13866. /**
  13867. * Serializes the particle system to a JSON object.
  13868. * @returns the JSON object
  13869. */
  13870. serialize(): any;
  13871. /**
  13872. * Parse properties from a JSON object
  13873. * @param serializationObject defines the JSON object
  13874. */
  13875. parse(serializationObject: any): void;
  13876. }
  13877. /**
  13878. * Particle emitter emitting particles from the inside of a cylinder.
  13879. * It emits the particles randomly between two vectors.
  13880. */
  13881. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13882. /**
  13883. * The min limit of the emission direction.
  13884. */
  13885. direction1: Vector3;
  13886. /**
  13887. * The max limit of the emission direction.
  13888. */
  13889. direction2: Vector3;
  13890. /**
  13891. * Creates a new instance CylinderDirectedParticleEmitter
  13892. * @param radius the radius of the emission cylinder (1 by default)
  13893. * @param height the height of the emission cylinder (1 by default)
  13894. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13895. * @param direction1 the min limit of the emission direction (up vector by default)
  13896. * @param direction2 the max limit of the emission direction (up vector by default)
  13897. */
  13898. constructor(radius?: number, height?: number, radiusRange?: number,
  13899. /**
  13900. * The min limit of the emission direction.
  13901. */
  13902. direction1?: Vector3,
  13903. /**
  13904. * The max limit of the emission direction.
  13905. */
  13906. direction2?: Vector3);
  13907. /**
  13908. * Called by the particle System when the direction is computed for the created particle.
  13909. * @param worldMatrix is the world matrix of the particle system
  13910. * @param directionToUpdate is the direction vector to update with the result
  13911. * @param particle is the particle we are computed the direction for
  13912. */
  13913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13914. /**
  13915. * Clones the current emitter and returns a copy of it
  13916. * @returns the new emitter
  13917. */
  13918. clone(): CylinderDirectedParticleEmitter;
  13919. /**
  13920. * Called by the GPUParticleSystem to setup the update shader
  13921. * @param effect defines the update shader
  13922. */
  13923. applyToShader(effect: Effect): void;
  13924. /**
  13925. * Returns a string to use to update the GPU particles update shader
  13926. * @returns a string containng the defines string
  13927. */
  13928. getEffectDefines(): string;
  13929. /**
  13930. * Returns the string "CylinderDirectedParticleEmitter"
  13931. * @returns a string containing the class name
  13932. */
  13933. getClassName(): string;
  13934. /**
  13935. * Serializes the particle system to a JSON object.
  13936. * @returns the JSON object
  13937. */
  13938. serialize(): any;
  13939. /**
  13940. * Parse properties from a JSON object
  13941. * @param serializationObject defines the JSON object
  13942. */
  13943. parse(serializationObject: any): void;
  13944. }
  13945. }
  13946. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13947. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13948. import { Effect } from "babylonjs/Materials/effect";
  13949. import { Particle } from "babylonjs/Particles/particle";
  13950. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13951. /**
  13952. * Particle emitter emitting particles from the inside of a hemisphere.
  13953. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13954. */
  13955. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13956. /**
  13957. * The radius of the emission hemisphere.
  13958. */
  13959. radius: number;
  13960. /**
  13961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13962. */
  13963. radiusRange: number;
  13964. /**
  13965. * How much to randomize the particle direction [0-1].
  13966. */
  13967. directionRandomizer: number;
  13968. /**
  13969. * Creates a new instance HemisphericParticleEmitter
  13970. * @param radius the radius of the emission hemisphere (1 by default)
  13971. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13972. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13973. */
  13974. constructor(
  13975. /**
  13976. * The radius of the emission hemisphere.
  13977. */
  13978. radius?: number,
  13979. /**
  13980. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13981. */
  13982. radiusRange?: number,
  13983. /**
  13984. * How much to randomize the particle direction [0-1].
  13985. */
  13986. directionRandomizer?: number);
  13987. /**
  13988. * Called by the particle System when the direction is computed for the created particle.
  13989. * @param worldMatrix is the world matrix of the particle system
  13990. * @param directionToUpdate is the direction vector to update with the result
  13991. * @param particle is the particle we are computed the direction for
  13992. * @param isLocal defines if the direction should be set in local space
  13993. */
  13994. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13995. /**
  13996. * Called by the particle System when the position is computed for the created particle.
  13997. * @param worldMatrix is the world matrix of the particle system
  13998. * @param positionToUpdate is the position vector to update with the result
  13999. * @param particle is the particle we are computed the position for
  14000. * @param isLocal defines if the position should be set in local space
  14001. */
  14002. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14003. /**
  14004. * Clones the current emitter and returns a copy of it
  14005. * @returns the new emitter
  14006. */
  14007. clone(): HemisphericParticleEmitter;
  14008. /**
  14009. * Called by the GPUParticleSystem to setup the update shader
  14010. * @param effect defines the update shader
  14011. */
  14012. applyToShader(effect: Effect): void;
  14013. /**
  14014. * Returns a string to use to update the GPU particles update shader
  14015. * @returns a string containng the defines string
  14016. */
  14017. getEffectDefines(): string;
  14018. /**
  14019. * Returns the string "HemisphericParticleEmitter"
  14020. * @returns a string containing the class name
  14021. */
  14022. getClassName(): string;
  14023. /**
  14024. * Serializes the particle system to a JSON object.
  14025. * @returns the JSON object
  14026. */
  14027. serialize(): any;
  14028. /**
  14029. * Parse properties from a JSON object
  14030. * @param serializationObject defines the JSON object
  14031. */
  14032. parse(serializationObject: any): void;
  14033. }
  14034. }
  14035. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14036. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14037. import { Effect } from "babylonjs/Materials/effect";
  14038. import { Particle } from "babylonjs/Particles/particle";
  14039. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14040. /**
  14041. * Particle emitter emitting particles from a point.
  14042. * It emits the particles randomly between 2 given directions.
  14043. */
  14044. export class PointParticleEmitter implements IParticleEmitterType {
  14045. /**
  14046. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14047. */
  14048. direction1: Vector3;
  14049. /**
  14050. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14051. */
  14052. direction2: Vector3;
  14053. /**
  14054. * Creates a new instance PointParticleEmitter
  14055. */
  14056. constructor();
  14057. /**
  14058. * Called by the particle System when the direction is computed for the created particle.
  14059. * @param worldMatrix is the world matrix of the particle system
  14060. * @param directionToUpdate is the direction vector to update with the result
  14061. * @param particle is the particle we are computed the direction for
  14062. * @param isLocal defines if the direction should be set in local space
  14063. */
  14064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14065. /**
  14066. * Called by the particle System when the position is computed for the created particle.
  14067. * @param worldMatrix is the world matrix of the particle system
  14068. * @param positionToUpdate is the position vector to update with the result
  14069. * @param particle is the particle we are computed the position for
  14070. * @param isLocal defines if the position should be set in local space
  14071. */
  14072. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14073. /**
  14074. * Clones the current emitter and returns a copy of it
  14075. * @returns the new emitter
  14076. */
  14077. clone(): PointParticleEmitter;
  14078. /**
  14079. * Called by the GPUParticleSystem to setup the update shader
  14080. * @param effect defines the update shader
  14081. */
  14082. applyToShader(effect: Effect): void;
  14083. /**
  14084. * Returns a string to use to update the GPU particles update shader
  14085. * @returns a string containng the defines string
  14086. */
  14087. getEffectDefines(): string;
  14088. /**
  14089. * Returns the string "PointParticleEmitter"
  14090. * @returns a string containing the class name
  14091. */
  14092. getClassName(): string;
  14093. /**
  14094. * Serializes the particle system to a JSON object.
  14095. * @returns the JSON object
  14096. */
  14097. serialize(): any;
  14098. /**
  14099. * Parse properties from a JSON object
  14100. * @param serializationObject defines the JSON object
  14101. */
  14102. parse(serializationObject: any): void;
  14103. }
  14104. }
  14105. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14106. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14107. import { Effect } from "babylonjs/Materials/effect";
  14108. import { Particle } from "babylonjs/Particles/particle";
  14109. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14110. /**
  14111. * Particle emitter emitting particles from the inside of a sphere.
  14112. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14113. */
  14114. export class SphereParticleEmitter implements IParticleEmitterType {
  14115. /**
  14116. * The radius of the emission sphere.
  14117. */
  14118. radius: number;
  14119. /**
  14120. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14121. */
  14122. radiusRange: number;
  14123. /**
  14124. * How much to randomize the particle direction [0-1].
  14125. */
  14126. directionRandomizer: number;
  14127. /**
  14128. * Creates a new instance SphereParticleEmitter
  14129. * @param radius the radius of the emission sphere (1 by default)
  14130. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14131. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14132. */
  14133. constructor(
  14134. /**
  14135. * The radius of the emission sphere.
  14136. */
  14137. radius?: number,
  14138. /**
  14139. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14140. */
  14141. radiusRange?: number,
  14142. /**
  14143. * How much to randomize the particle direction [0-1].
  14144. */
  14145. directionRandomizer?: number);
  14146. /**
  14147. * Called by the particle System when the direction is computed for the created particle.
  14148. * @param worldMatrix is the world matrix of the particle system
  14149. * @param directionToUpdate is the direction vector to update with the result
  14150. * @param particle is the particle we are computed the direction for
  14151. * @param isLocal defines if the direction should be set in local space
  14152. */
  14153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14154. /**
  14155. * Called by the particle System when the position is computed for the created particle.
  14156. * @param worldMatrix is the world matrix of the particle system
  14157. * @param positionToUpdate is the position vector to update with the result
  14158. * @param particle is the particle we are computed the position for
  14159. * @param isLocal defines if the position should be set in local space
  14160. */
  14161. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14162. /**
  14163. * Clones the current emitter and returns a copy of it
  14164. * @returns the new emitter
  14165. */
  14166. clone(): SphereParticleEmitter;
  14167. /**
  14168. * Called by the GPUParticleSystem to setup the update shader
  14169. * @param effect defines the update shader
  14170. */
  14171. applyToShader(effect: Effect): void;
  14172. /**
  14173. * Returns a string to use to update the GPU particles update shader
  14174. * @returns a string containng the defines string
  14175. */
  14176. getEffectDefines(): string;
  14177. /**
  14178. * Returns the string "SphereParticleEmitter"
  14179. * @returns a string containing the class name
  14180. */
  14181. getClassName(): string;
  14182. /**
  14183. * Serializes the particle system to a JSON object.
  14184. * @returns the JSON object
  14185. */
  14186. serialize(): any;
  14187. /**
  14188. * Parse properties from a JSON object
  14189. * @param serializationObject defines the JSON object
  14190. */
  14191. parse(serializationObject: any): void;
  14192. }
  14193. /**
  14194. * Particle emitter emitting particles from the inside of a sphere.
  14195. * It emits the particles randomly between two vectors.
  14196. */
  14197. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14198. /**
  14199. * The min limit of the emission direction.
  14200. */
  14201. direction1: Vector3;
  14202. /**
  14203. * The max limit of the emission direction.
  14204. */
  14205. direction2: Vector3;
  14206. /**
  14207. * Creates a new instance SphereDirectedParticleEmitter
  14208. * @param radius the radius of the emission sphere (1 by default)
  14209. * @param direction1 the min limit of the emission direction (up vector by default)
  14210. * @param direction2 the max limit of the emission direction (up vector by default)
  14211. */
  14212. constructor(radius?: number,
  14213. /**
  14214. * The min limit of the emission direction.
  14215. */
  14216. direction1?: Vector3,
  14217. /**
  14218. * The max limit of the emission direction.
  14219. */
  14220. direction2?: Vector3);
  14221. /**
  14222. * Called by the particle System when the direction is computed for the created particle.
  14223. * @param worldMatrix is the world matrix of the particle system
  14224. * @param directionToUpdate is the direction vector to update with the result
  14225. * @param particle is the particle we are computed the direction for
  14226. */
  14227. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14228. /**
  14229. * Clones the current emitter and returns a copy of it
  14230. * @returns the new emitter
  14231. */
  14232. clone(): SphereDirectedParticleEmitter;
  14233. /**
  14234. * Called by the GPUParticleSystem to setup the update shader
  14235. * @param effect defines the update shader
  14236. */
  14237. applyToShader(effect: Effect): void;
  14238. /**
  14239. * Returns a string to use to update the GPU particles update shader
  14240. * @returns a string containng the defines string
  14241. */
  14242. getEffectDefines(): string;
  14243. /**
  14244. * Returns the string "SphereDirectedParticleEmitter"
  14245. * @returns a string containing the class name
  14246. */
  14247. getClassName(): string;
  14248. /**
  14249. * Serializes the particle system to a JSON object.
  14250. * @returns the JSON object
  14251. */
  14252. serialize(): any;
  14253. /**
  14254. * Parse properties from a JSON object
  14255. * @param serializationObject defines the JSON object
  14256. */
  14257. parse(serializationObject: any): void;
  14258. }
  14259. }
  14260. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14261. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14262. import { Effect } from "babylonjs/Materials/effect";
  14263. import { Particle } from "babylonjs/Particles/particle";
  14264. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14265. import { Nullable } from "babylonjs/types";
  14266. /**
  14267. * Particle emitter emitting particles from a custom list of positions.
  14268. */
  14269. export class CustomParticleEmitter implements IParticleEmitterType {
  14270. /**
  14271. * Gets or sets the position generator that will create the inital position of each particle.
  14272. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14273. */
  14274. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14275. /**
  14276. * Gets or sets the destination generator that will create the final destination of each particle.
  14277. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14278. */
  14279. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14280. /**
  14281. * Creates a new instance CustomParticleEmitter
  14282. */
  14283. constructor();
  14284. /**
  14285. * Called by the particle System when the direction is computed for the created particle.
  14286. * @param worldMatrix is the world matrix of the particle system
  14287. * @param directionToUpdate is the direction vector to update with the result
  14288. * @param particle is the particle we are computed the direction for
  14289. * @param isLocal defines if the direction should be set in local space
  14290. */
  14291. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14292. /**
  14293. * Called by the particle System when the position is computed for the created particle.
  14294. * @param worldMatrix is the world matrix of the particle system
  14295. * @param positionToUpdate is the position vector to update with the result
  14296. * @param particle is the particle we are computed the position for
  14297. * @param isLocal defines if the position should be set in local space
  14298. */
  14299. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14300. /**
  14301. * Clones the current emitter and returns a copy of it
  14302. * @returns the new emitter
  14303. */
  14304. clone(): CustomParticleEmitter;
  14305. /**
  14306. * Called by the GPUParticleSystem to setup the update shader
  14307. * @param effect defines the update shader
  14308. */
  14309. applyToShader(effect: Effect): void;
  14310. /**
  14311. * Returns a string to use to update the GPU particles update shader
  14312. * @returns a string containng the defines string
  14313. */
  14314. getEffectDefines(): string;
  14315. /**
  14316. * Returns the string "PointParticleEmitter"
  14317. * @returns a string containing the class name
  14318. */
  14319. getClassName(): string;
  14320. /**
  14321. * Serializes the particle system to a JSON object.
  14322. * @returns the JSON object
  14323. */
  14324. serialize(): any;
  14325. /**
  14326. * Parse properties from a JSON object
  14327. * @param serializationObject defines the JSON object
  14328. */
  14329. parse(serializationObject: any): void;
  14330. }
  14331. }
  14332. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14333. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14334. import { Effect } from "babylonjs/Materials/effect";
  14335. import { Particle } from "babylonjs/Particles/particle";
  14336. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14337. import { Nullable } from "babylonjs/types";
  14338. import { Scene } from "babylonjs/scene";
  14339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14340. /**
  14341. * Particle emitter emitting particles from the inside of a box.
  14342. * It emits the particles randomly between 2 given directions.
  14343. */
  14344. export class MeshParticleEmitter implements IParticleEmitterType {
  14345. private _indices;
  14346. private _positions;
  14347. private _normals;
  14348. private _storedNormal;
  14349. private _mesh;
  14350. /**
  14351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14352. */
  14353. direction1: Vector3;
  14354. /**
  14355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14356. */
  14357. direction2: Vector3;
  14358. /**
  14359. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14360. */
  14361. useMeshNormalsForDirection: boolean;
  14362. /** Defines the mesh to use as source */
  14363. get mesh(): Nullable<AbstractMesh>;
  14364. set mesh(value: Nullable<AbstractMesh>);
  14365. /**
  14366. * Creates a new instance MeshParticleEmitter
  14367. * @param mesh defines the mesh to use as source
  14368. */
  14369. constructor(mesh?: Nullable<AbstractMesh>);
  14370. /**
  14371. * Called by the particle System when the direction is computed for the created particle.
  14372. * @param worldMatrix is the world matrix of the particle system
  14373. * @param directionToUpdate is the direction vector to update with the result
  14374. * @param particle is the particle we are computed the direction for
  14375. * @param isLocal defines if the direction should be set in local space
  14376. */
  14377. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14378. /**
  14379. * Called by the particle System when the position is computed for the created particle.
  14380. * @param worldMatrix is the world matrix of the particle system
  14381. * @param positionToUpdate is the position vector to update with the result
  14382. * @param particle is the particle we are computed the position for
  14383. * @param isLocal defines if the position should be set in local space
  14384. */
  14385. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14386. /**
  14387. * Clones the current emitter and returns a copy of it
  14388. * @returns the new emitter
  14389. */
  14390. clone(): MeshParticleEmitter;
  14391. /**
  14392. * Called by the GPUParticleSystem to setup the update shader
  14393. * @param effect defines the update shader
  14394. */
  14395. applyToShader(effect: Effect): void;
  14396. /**
  14397. * Returns a string to use to update the GPU particles update shader
  14398. * @returns a string containng the defines string
  14399. */
  14400. getEffectDefines(): string;
  14401. /**
  14402. * Returns the string "BoxParticleEmitter"
  14403. * @returns a string containing the class name
  14404. */
  14405. getClassName(): string;
  14406. /**
  14407. * Serializes the particle system to a JSON object.
  14408. * @returns the JSON object
  14409. */
  14410. serialize(): any;
  14411. /**
  14412. * Parse properties from a JSON object
  14413. * @param serializationObject defines the JSON object
  14414. * @param scene defines the hosting scene
  14415. */
  14416. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14417. }
  14418. }
  14419. declare module "babylonjs/Particles/EmitterTypes/index" {
  14420. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14421. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14422. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14423. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14424. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14425. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14426. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14427. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14428. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14429. }
  14430. declare module "babylonjs/Particles/IParticleSystem" {
  14431. import { Nullable } from "babylonjs/types";
  14432. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14433. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14435. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14436. import { Scene } from "babylonjs/scene";
  14437. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14438. import { Effect } from "babylonjs/Materials/effect";
  14439. import { Observable } from "babylonjs/Misc/observable";
  14440. import { Animation } from "babylonjs/Animations/animation";
  14441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14442. /**
  14443. * Interface representing a particle system in Babylon.js.
  14444. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14445. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14446. */
  14447. export interface IParticleSystem {
  14448. /**
  14449. * List of animations used by the particle system.
  14450. */
  14451. animations: Animation[];
  14452. /**
  14453. * The id of the Particle system.
  14454. */
  14455. id: string;
  14456. /**
  14457. * The name of the Particle system.
  14458. */
  14459. name: string;
  14460. /**
  14461. * The emitter represents the Mesh or position we are attaching the particle system to.
  14462. */
  14463. emitter: Nullable<AbstractMesh | Vector3>;
  14464. /**
  14465. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14466. */
  14467. isBillboardBased: boolean;
  14468. /**
  14469. * The rendering group used by the Particle system to chose when to render.
  14470. */
  14471. renderingGroupId: number;
  14472. /**
  14473. * The layer mask we are rendering the particles through.
  14474. */
  14475. layerMask: number;
  14476. /**
  14477. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14478. */
  14479. updateSpeed: number;
  14480. /**
  14481. * The amount of time the particle system is running (depends of the overall update speed).
  14482. */
  14483. targetStopDuration: number;
  14484. /**
  14485. * The texture used to render each particle. (this can be a spritesheet)
  14486. */
  14487. particleTexture: Nullable<BaseTexture>;
  14488. /**
  14489. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14490. */
  14491. blendMode: number;
  14492. /**
  14493. * Minimum life time of emitting particles.
  14494. */
  14495. minLifeTime: number;
  14496. /**
  14497. * Maximum life time of emitting particles.
  14498. */
  14499. maxLifeTime: number;
  14500. /**
  14501. * Minimum Size of emitting particles.
  14502. */
  14503. minSize: number;
  14504. /**
  14505. * Maximum Size of emitting particles.
  14506. */
  14507. maxSize: number;
  14508. /**
  14509. * Minimum scale of emitting particles on X axis.
  14510. */
  14511. minScaleX: number;
  14512. /**
  14513. * Maximum scale of emitting particles on X axis.
  14514. */
  14515. maxScaleX: number;
  14516. /**
  14517. * Minimum scale of emitting particles on Y axis.
  14518. */
  14519. minScaleY: number;
  14520. /**
  14521. * Maximum scale of emitting particles on Y axis.
  14522. */
  14523. maxScaleY: number;
  14524. /**
  14525. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14526. */
  14527. color1: Color4;
  14528. /**
  14529. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14530. */
  14531. color2: Color4;
  14532. /**
  14533. * Color the particle will have at the end of its lifetime.
  14534. */
  14535. colorDead: Color4;
  14536. /**
  14537. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14538. */
  14539. emitRate: number;
  14540. /**
  14541. * You can use gravity if you want to give an orientation to your particles.
  14542. */
  14543. gravity: Vector3;
  14544. /**
  14545. * Minimum power of emitting particles.
  14546. */
  14547. minEmitPower: number;
  14548. /**
  14549. * Maximum power of emitting particles.
  14550. */
  14551. maxEmitPower: number;
  14552. /**
  14553. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14554. */
  14555. minAngularSpeed: number;
  14556. /**
  14557. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14558. */
  14559. maxAngularSpeed: number;
  14560. /**
  14561. * Gets or sets the minimal initial rotation in radians.
  14562. */
  14563. minInitialRotation: number;
  14564. /**
  14565. * Gets or sets the maximal initial rotation in radians.
  14566. */
  14567. maxInitialRotation: number;
  14568. /**
  14569. * The particle emitter type defines the emitter used by the particle system.
  14570. * It can be for example box, sphere, or cone...
  14571. */
  14572. particleEmitterType: Nullable<IParticleEmitterType>;
  14573. /**
  14574. * Defines the delay in milliseconds before starting the system (0 by default)
  14575. */
  14576. startDelay: number;
  14577. /**
  14578. * 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
  14579. */
  14580. preWarmCycles: number;
  14581. /**
  14582. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14583. */
  14584. preWarmStepOffset: number;
  14585. /**
  14586. * 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)
  14587. */
  14588. spriteCellChangeSpeed: number;
  14589. /**
  14590. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14591. */
  14592. startSpriteCellID: number;
  14593. /**
  14594. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14595. */
  14596. endSpriteCellID: number;
  14597. /**
  14598. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14599. */
  14600. spriteCellWidth: number;
  14601. /**
  14602. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14603. */
  14604. spriteCellHeight: number;
  14605. /**
  14606. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14607. */
  14608. spriteRandomStartCell: boolean;
  14609. /**
  14610. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14611. */
  14612. isAnimationSheetEnabled: boolean;
  14613. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14614. translationPivot: Vector2;
  14615. /**
  14616. * Gets or sets a texture used to add random noise to particle positions
  14617. */
  14618. noiseTexture: Nullable<BaseTexture>;
  14619. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14620. noiseStrength: Vector3;
  14621. /**
  14622. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14623. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14624. */
  14625. billboardMode: number;
  14626. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14627. limitVelocityDamping: number;
  14628. /**
  14629. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14630. */
  14631. beginAnimationOnStart: boolean;
  14632. /**
  14633. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14634. */
  14635. beginAnimationFrom: number;
  14636. /**
  14637. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14638. */
  14639. beginAnimationTo: number;
  14640. /**
  14641. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14642. */
  14643. beginAnimationLoop: boolean;
  14644. /**
  14645. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14646. */
  14647. disposeOnStop: boolean;
  14648. /**
  14649. * Specifies if the particles are updated in emitter local space or world space
  14650. */
  14651. isLocal: boolean;
  14652. /** Snippet ID if the particle system was created from the snippet server */
  14653. snippetId: string;
  14654. /** Gets or sets a matrix to use to compute projection */
  14655. defaultProjectionMatrix: Matrix;
  14656. /**
  14657. * Gets the maximum number of particles active at the same time.
  14658. * @returns The max number of active particles.
  14659. */
  14660. getCapacity(): number;
  14661. /**
  14662. * Gets the number of particles active at the same time.
  14663. * @returns The number of active particles.
  14664. */
  14665. getActiveCount(): number;
  14666. /**
  14667. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14668. * @returns True if it has been started, otherwise false.
  14669. */
  14670. isStarted(): boolean;
  14671. /**
  14672. * Animates the particle system for this frame.
  14673. */
  14674. animate(): void;
  14675. /**
  14676. * Renders the particle system in its current state.
  14677. * @returns the current number of particles
  14678. */
  14679. render(): number;
  14680. /**
  14681. * Dispose the particle system and frees its associated resources.
  14682. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14683. */
  14684. dispose(disposeTexture?: boolean): void;
  14685. /**
  14686. * An event triggered when the system is disposed
  14687. */
  14688. onDisposeObservable: Observable<IParticleSystem>;
  14689. /**
  14690. * An event triggered when the system is stopped
  14691. */
  14692. onStoppedObservable: Observable<IParticleSystem>;
  14693. /**
  14694. * Clones the particle system.
  14695. * @param name The name of the cloned object
  14696. * @param newEmitter The new emitter to use
  14697. * @returns the cloned particle system
  14698. */
  14699. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14700. /**
  14701. * Serializes the particle system to a JSON object
  14702. * @param serializeTexture defines if the texture must be serialized as well
  14703. * @returns the JSON object
  14704. */
  14705. serialize(serializeTexture: boolean): any;
  14706. /**
  14707. * Rebuild the particle system
  14708. */
  14709. rebuild(): void;
  14710. /** Force the system to rebuild all gradients that need to be resync */
  14711. forceRefreshGradients(): void;
  14712. /**
  14713. * Starts the particle system and begins to emit
  14714. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14715. */
  14716. start(delay?: number): void;
  14717. /**
  14718. * Stops the particle system.
  14719. */
  14720. stop(): void;
  14721. /**
  14722. * Remove all active particles
  14723. */
  14724. reset(): void;
  14725. /**
  14726. * Gets a boolean indicating that the system is stopping
  14727. * @returns true if the system is currently stopping
  14728. */
  14729. isStopping(): boolean;
  14730. /**
  14731. * Is this system ready to be used/rendered
  14732. * @return true if the system is ready
  14733. */
  14734. isReady(): boolean;
  14735. /**
  14736. * Returns the string "ParticleSystem"
  14737. * @returns a string containing the class name
  14738. */
  14739. getClassName(): string;
  14740. /**
  14741. * Gets the custom effect used to render the particles
  14742. * @param blendMode Blend mode for which the effect should be retrieved
  14743. * @returns The effect
  14744. */
  14745. getCustomEffect(blendMode: number): Nullable<Effect>;
  14746. /**
  14747. * Sets the custom effect used to render the particles
  14748. * @param effect The effect to set
  14749. * @param blendMode Blend mode for which the effect should be set
  14750. */
  14751. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14752. /**
  14753. * Fill the defines array according to the current settings of the particle system
  14754. * @param defines Array to be updated
  14755. * @param blendMode blend mode to take into account when updating the array
  14756. */
  14757. fillDefines(defines: Array<string>, blendMode: number): void;
  14758. /**
  14759. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14760. * @param uniforms Uniforms array to fill
  14761. * @param attributes Attributes array to fill
  14762. * @param samplers Samplers array to fill
  14763. */
  14764. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14765. /**
  14766. * Observable that will be called just before the particles are drawn
  14767. */
  14768. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14769. /**
  14770. * Gets the name of the particle vertex shader
  14771. */
  14772. vertexShaderName: string;
  14773. /**
  14774. * Adds a new color gradient
  14775. * @param gradient defines the gradient to use (between 0 and 1)
  14776. * @param color1 defines the color to affect to the specified gradient
  14777. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14778. * @returns the current particle system
  14779. */
  14780. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14781. /**
  14782. * Remove a specific color gradient
  14783. * @param gradient defines the gradient to remove
  14784. * @returns the current particle system
  14785. */
  14786. removeColorGradient(gradient: number): IParticleSystem;
  14787. /**
  14788. * Adds a new size gradient
  14789. * @param gradient defines the gradient to use (between 0 and 1)
  14790. * @param factor defines the size factor to affect to the specified gradient
  14791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14792. * @returns the current particle system
  14793. */
  14794. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14795. /**
  14796. * Remove a specific size gradient
  14797. * @param gradient defines the gradient to remove
  14798. * @returns the current particle system
  14799. */
  14800. removeSizeGradient(gradient: number): IParticleSystem;
  14801. /**
  14802. * Gets the current list of color gradients.
  14803. * You must use addColorGradient and removeColorGradient to udpate this list
  14804. * @returns the list of color gradients
  14805. */
  14806. getColorGradients(): Nullable<Array<ColorGradient>>;
  14807. /**
  14808. * Gets the current list of size gradients.
  14809. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14810. * @returns the list of size gradients
  14811. */
  14812. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14813. /**
  14814. * Gets the current list of angular speed gradients.
  14815. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14816. * @returns the list of angular speed gradients
  14817. */
  14818. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Adds a new angular speed gradient
  14821. * @param gradient defines the gradient to use (between 0 and 1)
  14822. * @param factor defines the angular speed to affect to the specified gradient
  14823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14824. * @returns the current particle system
  14825. */
  14826. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14827. /**
  14828. * Remove a specific angular speed gradient
  14829. * @param gradient defines the gradient to remove
  14830. * @returns the current particle system
  14831. */
  14832. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14833. /**
  14834. * Gets the current list of velocity gradients.
  14835. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14836. * @returns the list of velocity gradients
  14837. */
  14838. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14839. /**
  14840. * Adds a new velocity gradient
  14841. * @param gradient defines the gradient to use (between 0 and 1)
  14842. * @param factor defines the velocity to affect to the specified gradient
  14843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14844. * @returns the current particle system
  14845. */
  14846. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14847. /**
  14848. * Remove a specific velocity gradient
  14849. * @param gradient defines the gradient to remove
  14850. * @returns the current particle system
  14851. */
  14852. removeVelocityGradient(gradient: number): IParticleSystem;
  14853. /**
  14854. * Gets the current list of limit velocity gradients.
  14855. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14856. * @returns the list of limit velocity gradients
  14857. */
  14858. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14859. /**
  14860. * Adds a new limit velocity gradient
  14861. * @param gradient defines the gradient to use (between 0 and 1)
  14862. * @param factor defines the limit velocity to affect to the specified gradient
  14863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14864. * @returns the current particle system
  14865. */
  14866. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14867. /**
  14868. * Remove a specific limit velocity gradient
  14869. * @param gradient defines the gradient to remove
  14870. * @returns the current particle system
  14871. */
  14872. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14873. /**
  14874. * Adds a new drag gradient
  14875. * @param gradient defines the gradient to use (between 0 and 1)
  14876. * @param factor defines the drag to affect to the specified gradient
  14877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14878. * @returns the current particle system
  14879. */
  14880. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14881. /**
  14882. * Remove a specific drag gradient
  14883. * @param gradient defines the gradient to remove
  14884. * @returns the current particle system
  14885. */
  14886. removeDragGradient(gradient: number): IParticleSystem;
  14887. /**
  14888. * Gets the current list of drag gradients.
  14889. * You must use addDragGradient and removeDragGradient to udpate this list
  14890. * @returns the list of drag gradients
  14891. */
  14892. getDragGradients(): Nullable<Array<FactorGradient>>;
  14893. /**
  14894. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14895. * @param gradient defines the gradient to use (between 0 and 1)
  14896. * @param factor defines the emit rate to affect to the specified gradient
  14897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14898. * @returns the current particle system
  14899. */
  14900. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14901. /**
  14902. * Remove a specific emit rate gradient
  14903. * @param gradient defines the gradient to remove
  14904. * @returns the current particle system
  14905. */
  14906. removeEmitRateGradient(gradient: number): IParticleSystem;
  14907. /**
  14908. * Gets the current list of emit rate gradients.
  14909. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14910. * @returns the list of emit rate gradients
  14911. */
  14912. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14913. /**
  14914. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14915. * @param gradient defines the gradient to use (between 0 and 1)
  14916. * @param factor defines the start size to affect to the specified gradient
  14917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14918. * @returns the current particle system
  14919. */
  14920. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14921. /**
  14922. * Remove a specific start size gradient
  14923. * @param gradient defines the gradient to remove
  14924. * @returns the current particle system
  14925. */
  14926. removeStartSizeGradient(gradient: number): IParticleSystem;
  14927. /**
  14928. * Gets the current list of start size gradients.
  14929. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14930. * @returns the list of start size gradients
  14931. */
  14932. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14933. /**
  14934. * Adds a new life time gradient
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param factor defines the life time factor to affect to the specified gradient
  14937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14938. * @returns the current particle system
  14939. */
  14940. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14941. /**
  14942. * Remove a specific life time gradient
  14943. * @param gradient defines the gradient to remove
  14944. * @returns the current particle system
  14945. */
  14946. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14947. /**
  14948. * Gets the current list of life time gradients.
  14949. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14950. * @returns the list of life time gradients
  14951. */
  14952. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14953. /**
  14954. * Gets the current list of color gradients.
  14955. * You must use addColorGradient and removeColorGradient to udpate this list
  14956. * @returns the list of color gradients
  14957. */
  14958. getColorGradients(): Nullable<Array<ColorGradient>>;
  14959. /**
  14960. * Adds a new ramp gradient used to remap particle colors
  14961. * @param gradient defines the gradient to use (between 0 and 1)
  14962. * @param color defines the color to affect to the specified gradient
  14963. * @returns the current particle system
  14964. */
  14965. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14966. /**
  14967. * Gets the current list of ramp gradients.
  14968. * You must use addRampGradient and removeRampGradient to udpate this list
  14969. * @returns the list of ramp gradients
  14970. */
  14971. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14972. /** Gets or sets a boolean indicating that ramp gradients must be used
  14973. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14974. */
  14975. useRampGradients: boolean;
  14976. /**
  14977. * Adds a new color remap gradient
  14978. * @param gradient defines the gradient to use (between 0 and 1)
  14979. * @param min defines the color remap minimal range
  14980. * @param max defines the color remap maximal range
  14981. * @returns the current particle system
  14982. */
  14983. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14984. /**
  14985. * Gets the current list of color remap gradients.
  14986. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14987. * @returns the list of color remap gradients
  14988. */
  14989. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14990. /**
  14991. * Adds a new alpha remap gradient
  14992. * @param gradient defines the gradient to use (between 0 and 1)
  14993. * @param min defines the alpha remap minimal range
  14994. * @param max defines the alpha remap maximal range
  14995. * @returns the current particle system
  14996. */
  14997. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14998. /**
  14999. * Gets the current list of alpha remap gradients.
  15000. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15001. * @returns the list of alpha remap gradients
  15002. */
  15003. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15004. /**
  15005. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15006. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15007. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15008. * @returns the emitter
  15009. */
  15010. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15011. /**
  15012. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15013. * @param radius The radius of the hemisphere to emit from
  15014. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15015. * @returns the emitter
  15016. */
  15017. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15018. /**
  15019. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15020. * @param radius The radius of the sphere to emit from
  15021. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15022. * @returns the emitter
  15023. */
  15024. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15025. /**
  15026. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15027. * @param radius The radius of the sphere to emit from
  15028. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15029. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15030. * @returns the emitter
  15031. */
  15032. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15033. /**
  15034. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15035. * @param radius The radius of the emission cylinder
  15036. * @param height The height of the emission cylinder
  15037. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15038. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15039. * @returns the emitter
  15040. */
  15041. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15042. /**
  15043. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15044. * @param radius The radius of the cylinder to emit from
  15045. * @param height The height of the emission cylinder
  15046. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15047. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15048. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15049. * @returns the emitter
  15050. */
  15051. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15052. /**
  15053. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15054. * @param radius The radius of the cone to emit from
  15055. * @param angle The base angle of the cone
  15056. * @returns the emitter
  15057. */
  15058. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15059. /**
  15060. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15061. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15062. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15063. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15064. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15065. * @returns the emitter
  15066. */
  15067. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15068. /**
  15069. * Get hosting scene
  15070. * @returns the scene
  15071. */
  15072. getScene(): Nullable<Scene>;
  15073. }
  15074. }
  15075. declare module "babylonjs/Meshes/transformNode" {
  15076. import { DeepImmutable } from "babylonjs/types";
  15077. import { Observable } from "babylonjs/Misc/observable";
  15078. import { Nullable } from "babylonjs/types";
  15079. import { Camera } from "babylonjs/Cameras/camera";
  15080. import { Scene } from "babylonjs/scene";
  15081. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15082. import { Node } from "babylonjs/node";
  15083. import { Bone } from "babylonjs/Bones/bone";
  15084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15085. import { Space } from "babylonjs/Maths/math.axis";
  15086. /**
  15087. * 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.
  15088. * @see https://doc.babylonjs.com/how_to/transformnode
  15089. */
  15090. export class TransformNode extends Node {
  15091. /**
  15092. * Object will not rotate to face the camera
  15093. */
  15094. static BILLBOARDMODE_NONE: number;
  15095. /**
  15096. * Object will rotate to face the camera but only on the x axis
  15097. */
  15098. static BILLBOARDMODE_X: number;
  15099. /**
  15100. * Object will rotate to face the camera but only on the y axis
  15101. */
  15102. static BILLBOARDMODE_Y: number;
  15103. /**
  15104. * Object will rotate to face the camera but only on the z axis
  15105. */
  15106. static BILLBOARDMODE_Z: number;
  15107. /**
  15108. * Object will rotate to face the camera
  15109. */
  15110. static BILLBOARDMODE_ALL: number;
  15111. /**
  15112. * Object will rotate to face the camera's position instead of orientation
  15113. */
  15114. static BILLBOARDMODE_USE_POSITION: number;
  15115. private static _TmpRotation;
  15116. private static _TmpScaling;
  15117. private static _TmpTranslation;
  15118. private _forward;
  15119. private _forwardInverted;
  15120. private _up;
  15121. private _right;
  15122. private _rightInverted;
  15123. private _position;
  15124. private _rotation;
  15125. private _rotationQuaternion;
  15126. protected _scaling: Vector3;
  15127. protected _isDirty: boolean;
  15128. private _transformToBoneReferal;
  15129. private _isAbsoluteSynced;
  15130. private _billboardMode;
  15131. /**
  15132. * Gets or sets the billboard mode. Default is 0.
  15133. *
  15134. * | Value | Type | Description |
  15135. * | --- | --- | --- |
  15136. * | 0 | BILLBOARDMODE_NONE | |
  15137. * | 1 | BILLBOARDMODE_X | |
  15138. * | 2 | BILLBOARDMODE_Y | |
  15139. * | 4 | BILLBOARDMODE_Z | |
  15140. * | 7 | BILLBOARDMODE_ALL | |
  15141. *
  15142. */
  15143. get billboardMode(): number;
  15144. set billboardMode(value: number);
  15145. private _preserveParentRotationForBillboard;
  15146. /**
  15147. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15148. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15149. */
  15150. get preserveParentRotationForBillboard(): boolean;
  15151. set preserveParentRotationForBillboard(value: boolean);
  15152. /**
  15153. * 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
  15154. */
  15155. scalingDeterminant: number;
  15156. private _infiniteDistance;
  15157. /**
  15158. * Gets or sets the distance of the object to max, often used by skybox
  15159. */
  15160. get infiniteDistance(): boolean;
  15161. set infiniteDistance(value: boolean);
  15162. /**
  15163. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15164. * By default the system will update normals to compensate
  15165. */
  15166. ignoreNonUniformScaling: boolean;
  15167. /**
  15168. * 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
  15169. */
  15170. reIntegrateRotationIntoRotationQuaternion: boolean;
  15171. /** @hidden */
  15172. _poseMatrix: Nullable<Matrix>;
  15173. /** @hidden */
  15174. _localMatrix: Matrix;
  15175. private _usePivotMatrix;
  15176. private _absolutePosition;
  15177. private _absoluteScaling;
  15178. private _absoluteRotationQuaternion;
  15179. private _pivotMatrix;
  15180. private _pivotMatrixInverse;
  15181. /** @hidden */
  15182. _postMultiplyPivotMatrix: boolean;
  15183. protected _isWorldMatrixFrozen: boolean;
  15184. /** @hidden */
  15185. _indexInSceneTransformNodesArray: number;
  15186. /**
  15187. * An event triggered after the world matrix is updated
  15188. */
  15189. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15190. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15191. /**
  15192. * Gets a string identifying the name of the class
  15193. * @returns "TransformNode" string
  15194. */
  15195. getClassName(): string;
  15196. /**
  15197. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15198. */
  15199. get position(): Vector3;
  15200. set position(newPosition: Vector3);
  15201. /**
  15202. * 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)).
  15203. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15204. */
  15205. get rotation(): Vector3;
  15206. set rotation(newRotation: Vector3);
  15207. /**
  15208. * 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)).
  15209. */
  15210. get scaling(): Vector3;
  15211. set scaling(newScaling: Vector3);
  15212. /**
  15213. * 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).
  15214. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15215. */
  15216. get rotationQuaternion(): Nullable<Quaternion>;
  15217. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15218. /**
  15219. * The forward direction of that transform in world space.
  15220. */
  15221. get forward(): Vector3;
  15222. /**
  15223. * The up direction of that transform in world space.
  15224. */
  15225. get up(): Vector3;
  15226. /**
  15227. * The right direction of that transform in world space.
  15228. */
  15229. get right(): Vector3;
  15230. /**
  15231. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15232. * @param matrix the matrix to copy the pose from
  15233. * @returns this TransformNode.
  15234. */
  15235. updatePoseMatrix(matrix: Matrix): TransformNode;
  15236. /**
  15237. * Returns the mesh Pose matrix.
  15238. * @returns the pose matrix
  15239. */
  15240. getPoseMatrix(): Matrix;
  15241. /** @hidden */
  15242. _isSynchronized(): boolean;
  15243. /** @hidden */
  15244. _initCache(): void;
  15245. /**
  15246. * Flag the transform node as dirty (Forcing it to update everything)
  15247. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15248. * @returns this transform node
  15249. */
  15250. markAsDirty(property: string): TransformNode;
  15251. /**
  15252. * Returns the current mesh absolute position.
  15253. * Returns a Vector3.
  15254. */
  15255. get absolutePosition(): Vector3;
  15256. /**
  15257. * Returns the current mesh absolute scaling.
  15258. * Returns a Vector3.
  15259. */
  15260. get absoluteScaling(): Vector3;
  15261. /**
  15262. * Returns the current mesh absolute rotation.
  15263. * Returns a Quaternion.
  15264. */
  15265. get absoluteRotationQuaternion(): Quaternion;
  15266. /**
  15267. * Sets a new matrix to apply before all other transformation
  15268. * @param matrix defines the transform matrix
  15269. * @returns the current TransformNode
  15270. */
  15271. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15272. /**
  15273. * Sets a new pivot matrix to the current node
  15274. * @param matrix defines the new pivot matrix to use
  15275. * @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
  15276. * @returns the current TransformNode
  15277. */
  15278. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15279. /**
  15280. * Returns the mesh pivot matrix.
  15281. * Default : Identity.
  15282. * @returns the matrix
  15283. */
  15284. getPivotMatrix(): Matrix;
  15285. /**
  15286. * Instantiate (when possible) or clone that node with its hierarchy
  15287. * @param newParent defines the new parent to use for the instance (or clone)
  15288. * @param options defines options to configure how copy is done
  15289. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15290. * @returns an instance (or a clone) of the current node with its hiearchy
  15291. */
  15292. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15293. doNotInstantiate: boolean;
  15294. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15295. /**
  15296. * Prevents the World matrix to be computed any longer
  15297. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15298. * @returns the TransformNode.
  15299. */
  15300. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15301. /**
  15302. * Allows back the World matrix computation.
  15303. * @returns the TransformNode.
  15304. */
  15305. unfreezeWorldMatrix(): this;
  15306. /**
  15307. * True if the World matrix has been frozen.
  15308. */
  15309. get isWorldMatrixFrozen(): boolean;
  15310. /**
  15311. * Retuns the mesh absolute position in the World.
  15312. * @returns a Vector3.
  15313. */
  15314. getAbsolutePosition(): Vector3;
  15315. /**
  15316. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15317. * @param absolutePosition the absolute position to set
  15318. * @returns the TransformNode.
  15319. */
  15320. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15321. /**
  15322. * Sets the mesh position in its local space.
  15323. * @param vector3 the position to set in localspace
  15324. * @returns the TransformNode.
  15325. */
  15326. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15327. /**
  15328. * Returns the mesh position in the local space from the current World matrix values.
  15329. * @returns a new Vector3.
  15330. */
  15331. getPositionExpressedInLocalSpace(): Vector3;
  15332. /**
  15333. * Translates the mesh along the passed Vector3 in its local space.
  15334. * @param vector3 the distance to translate in localspace
  15335. * @returns the TransformNode.
  15336. */
  15337. locallyTranslate(vector3: Vector3): TransformNode;
  15338. private static _lookAtVectorCache;
  15339. /**
  15340. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15341. * @param targetPoint the position (must be in same space as current mesh) to look at
  15342. * @param yawCor optional yaw (y-axis) correction in radians
  15343. * @param pitchCor optional pitch (x-axis) correction in radians
  15344. * @param rollCor optional roll (z-axis) correction in radians
  15345. * @param space the choosen space of the target
  15346. * @returns the TransformNode.
  15347. */
  15348. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15349. /**
  15350. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15351. * This Vector3 is expressed in the World space.
  15352. * @param localAxis axis to rotate
  15353. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15354. */
  15355. getDirection(localAxis: Vector3): Vector3;
  15356. /**
  15357. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15358. * localAxis is expressed in the mesh local space.
  15359. * result is computed in the Wordl space from the mesh World matrix.
  15360. * @param localAxis axis to rotate
  15361. * @param result the resulting transformnode
  15362. * @returns this TransformNode.
  15363. */
  15364. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15365. /**
  15366. * Sets this transform node rotation to the given local axis.
  15367. * @param localAxis the axis in local space
  15368. * @param yawCor optional yaw (y-axis) correction in radians
  15369. * @param pitchCor optional pitch (x-axis) correction in radians
  15370. * @param rollCor optional roll (z-axis) correction in radians
  15371. * @returns this TransformNode
  15372. */
  15373. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15374. /**
  15375. * Sets a new pivot point to the current node
  15376. * @param point defines the new pivot point to use
  15377. * @param space defines if the point is in world or local space (local by default)
  15378. * @returns the current TransformNode
  15379. */
  15380. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15381. /**
  15382. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15383. * @returns the pivot point
  15384. */
  15385. getPivotPoint(): Vector3;
  15386. /**
  15387. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15388. * @param result the vector3 to store the result
  15389. * @returns this TransformNode.
  15390. */
  15391. getPivotPointToRef(result: Vector3): TransformNode;
  15392. /**
  15393. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15394. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15395. */
  15396. getAbsolutePivotPoint(): Vector3;
  15397. /**
  15398. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15399. * @param result vector3 to store the result
  15400. * @returns this TransformNode.
  15401. */
  15402. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15403. /**
  15404. * Defines the passed node as the parent of the current node.
  15405. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15406. * @see https://doc.babylonjs.com/how_to/parenting
  15407. * @param node the node ot set as the parent
  15408. * @returns this TransformNode.
  15409. */
  15410. setParent(node: Nullable<Node>): TransformNode;
  15411. private _nonUniformScaling;
  15412. /**
  15413. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15414. */
  15415. get nonUniformScaling(): boolean;
  15416. /** @hidden */
  15417. _updateNonUniformScalingState(value: boolean): boolean;
  15418. /**
  15419. * Attach the current TransformNode to another TransformNode associated with a bone
  15420. * @param bone Bone affecting the TransformNode
  15421. * @param affectedTransformNode TransformNode associated with the bone
  15422. * @returns this object
  15423. */
  15424. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15425. /**
  15426. * Detach the transform node if its associated with a bone
  15427. * @returns this object
  15428. */
  15429. detachFromBone(): TransformNode;
  15430. private static _rotationAxisCache;
  15431. /**
  15432. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15433. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15434. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15435. * The passed axis is also normalized.
  15436. * @param axis the axis to rotate around
  15437. * @param amount the amount to rotate in radians
  15438. * @param space Space to rotate in (Default: local)
  15439. * @returns the TransformNode.
  15440. */
  15441. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15442. /**
  15443. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15444. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15445. * The passed axis is also normalized. .
  15446. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15447. * @param point the point to rotate around
  15448. * @param axis the axis to rotate around
  15449. * @param amount the amount to rotate in radians
  15450. * @returns the TransformNode
  15451. */
  15452. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15453. /**
  15454. * Translates the mesh along the axis vector for the passed distance in the given space.
  15455. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15456. * @param axis the axis to translate in
  15457. * @param distance the distance to translate
  15458. * @param space Space to rotate in (Default: local)
  15459. * @returns the TransformNode.
  15460. */
  15461. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15462. /**
  15463. * Adds a rotation step to the mesh current rotation.
  15464. * x, y, z are Euler angles expressed in radians.
  15465. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15466. * This means this rotation is made in the mesh local space only.
  15467. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15468. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15469. * ```javascript
  15470. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15471. * ```
  15472. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15473. * 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.
  15474. * @param x Rotation to add
  15475. * @param y Rotation to add
  15476. * @param z Rotation to add
  15477. * @returns the TransformNode.
  15478. */
  15479. addRotation(x: number, y: number, z: number): TransformNode;
  15480. /**
  15481. * @hidden
  15482. */
  15483. protected _getEffectiveParent(): Nullable<Node>;
  15484. /**
  15485. * Computes the world matrix of the node
  15486. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15487. * @returns the world matrix
  15488. */
  15489. computeWorldMatrix(force?: boolean): Matrix;
  15490. /**
  15491. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15492. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15493. */
  15494. resetLocalMatrix(independentOfChildren?: boolean): void;
  15495. protected _afterComputeWorldMatrix(): void;
  15496. /**
  15497. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15498. * @param func callback function to add
  15499. *
  15500. * @returns the TransformNode.
  15501. */
  15502. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15503. /**
  15504. * Removes a registered callback function.
  15505. * @param func callback function to remove
  15506. * @returns the TransformNode.
  15507. */
  15508. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15509. /**
  15510. * Gets the position of the current mesh in camera space
  15511. * @param camera defines the camera to use
  15512. * @returns a position
  15513. */
  15514. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15515. /**
  15516. * Returns the distance from the mesh to the active camera
  15517. * @param camera defines the camera to use
  15518. * @returns the distance
  15519. */
  15520. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15521. /**
  15522. * Clone the current transform node
  15523. * @param name Name of the new clone
  15524. * @param newParent New parent for the clone
  15525. * @param doNotCloneChildren Do not clone children hierarchy
  15526. * @returns the new transform node
  15527. */
  15528. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15529. /**
  15530. * Serializes the objects information.
  15531. * @param currentSerializationObject defines the object to serialize in
  15532. * @returns the serialized object
  15533. */
  15534. serialize(currentSerializationObject?: any): any;
  15535. /**
  15536. * Returns a new TransformNode object parsed from the source provided.
  15537. * @param parsedTransformNode is the source.
  15538. * @param scene the scne the object belongs to
  15539. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15540. * @returns a new TransformNode object parsed from the source provided.
  15541. */
  15542. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15543. /**
  15544. * Get all child-transformNodes of this node
  15545. * @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
  15546. * @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
  15547. * @returns an array of TransformNode
  15548. */
  15549. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15550. /**
  15551. * Releases resources associated with this transform node.
  15552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15554. */
  15555. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15556. /**
  15557. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15558. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15559. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15560. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15561. * @returns the current mesh
  15562. */
  15563. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15564. private _syncAbsoluteScalingAndRotation;
  15565. }
  15566. }
  15567. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15568. /**
  15569. * Class used to override all child animations of a given target
  15570. */
  15571. export class AnimationPropertiesOverride {
  15572. /**
  15573. * Gets or sets a value indicating if animation blending must be used
  15574. */
  15575. enableBlending: boolean;
  15576. /**
  15577. * Gets or sets the blending speed to use when enableBlending is true
  15578. */
  15579. blendingSpeed: number;
  15580. /**
  15581. * Gets or sets the default loop mode to use
  15582. */
  15583. loopMode: number;
  15584. }
  15585. }
  15586. declare module "babylonjs/Bones/bone" {
  15587. import { Skeleton } from "babylonjs/Bones/skeleton";
  15588. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15589. import { Nullable } from "babylonjs/types";
  15590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15592. import { Node } from "babylonjs/node";
  15593. import { Space } from "babylonjs/Maths/math.axis";
  15594. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15595. /**
  15596. * Class used to store bone information
  15597. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15598. */
  15599. export class Bone extends Node {
  15600. /**
  15601. * defines the bone name
  15602. */
  15603. name: string;
  15604. private static _tmpVecs;
  15605. private static _tmpQuat;
  15606. private static _tmpMats;
  15607. /**
  15608. * Gets the list of child bones
  15609. */
  15610. children: Bone[];
  15611. /** Gets the animations associated with this bone */
  15612. animations: import("babylonjs/Animations/animation").Animation[];
  15613. /**
  15614. * Gets or sets bone length
  15615. */
  15616. length: number;
  15617. /**
  15618. * @hidden Internal only
  15619. * Set this value to map this bone to a different index in the transform matrices
  15620. * Set this value to -1 to exclude the bone from the transform matrices
  15621. */
  15622. _index: Nullable<number>;
  15623. private _skeleton;
  15624. private _localMatrix;
  15625. private _restPose;
  15626. private _bindPose;
  15627. private _baseMatrix;
  15628. private _absoluteTransform;
  15629. private _invertedAbsoluteTransform;
  15630. private _parent;
  15631. private _scalingDeterminant;
  15632. private _worldTransform;
  15633. private _localScaling;
  15634. private _localRotation;
  15635. private _localPosition;
  15636. private _needToDecompose;
  15637. private _needToCompose;
  15638. /** @hidden */
  15639. _linkedTransformNode: Nullable<TransformNode>;
  15640. /** @hidden */
  15641. _waitingTransformNodeId: Nullable<string>;
  15642. /** @hidden */
  15643. get _matrix(): Matrix;
  15644. /** @hidden */
  15645. set _matrix(value: Matrix);
  15646. /**
  15647. * Create a new bone
  15648. * @param name defines the bone name
  15649. * @param skeleton defines the parent skeleton
  15650. * @param parentBone defines the parent (can be null if the bone is the root)
  15651. * @param localMatrix defines the local matrix
  15652. * @param restPose defines the rest pose matrix
  15653. * @param baseMatrix defines the base matrix
  15654. * @param index defines index of the bone in the hiearchy
  15655. */
  15656. constructor(
  15657. /**
  15658. * defines the bone name
  15659. */
  15660. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15661. /**
  15662. * Gets the current object class name.
  15663. * @return the class name
  15664. */
  15665. getClassName(): string;
  15666. /**
  15667. * Gets the parent skeleton
  15668. * @returns a skeleton
  15669. */
  15670. getSkeleton(): Skeleton;
  15671. /**
  15672. * Gets parent bone
  15673. * @returns a bone or null if the bone is the root of the bone hierarchy
  15674. */
  15675. getParent(): Nullable<Bone>;
  15676. /**
  15677. * Returns an array containing the root bones
  15678. * @returns an array containing the root bones
  15679. */
  15680. getChildren(): Array<Bone>;
  15681. /**
  15682. * Gets the node index in matrix array generated for rendering
  15683. * @returns the node index
  15684. */
  15685. getIndex(): number;
  15686. /**
  15687. * Sets the parent bone
  15688. * @param parent defines the parent (can be null if the bone is the root)
  15689. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15690. */
  15691. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15692. /**
  15693. * Gets the local matrix
  15694. * @returns a matrix
  15695. */
  15696. getLocalMatrix(): Matrix;
  15697. /**
  15698. * Gets the base matrix (initial matrix which remains unchanged)
  15699. * @returns a matrix
  15700. */
  15701. getBaseMatrix(): Matrix;
  15702. /**
  15703. * Gets the rest pose matrix
  15704. * @returns a matrix
  15705. */
  15706. getRestPose(): Matrix;
  15707. /**
  15708. * Sets the rest pose matrix
  15709. * @param matrix the local-space rest pose to set for this bone
  15710. */
  15711. setRestPose(matrix: Matrix): void;
  15712. /**
  15713. * Gets the bind pose matrix
  15714. * @returns the bind pose matrix
  15715. */
  15716. getBindPose(): Matrix;
  15717. /**
  15718. * Sets the bind pose matrix
  15719. * @param matrix the local-space bind pose to set for this bone
  15720. */
  15721. setBindPose(matrix: Matrix): void;
  15722. /**
  15723. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15724. */
  15725. getWorldMatrix(): Matrix;
  15726. /**
  15727. * Sets the local matrix to rest pose matrix
  15728. */
  15729. returnToRest(): void;
  15730. /**
  15731. * Gets the inverse of the absolute transform matrix.
  15732. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15733. * @returns a matrix
  15734. */
  15735. getInvertedAbsoluteTransform(): Matrix;
  15736. /**
  15737. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15738. * @returns a matrix
  15739. */
  15740. getAbsoluteTransform(): Matrix;
  15741. /**
  15742. * Links with the given transform node.
  15743. * The local matrix of this bone is copied from the transform node every frame.
  15744. * @param transformNode defines the transform node to link to
  15745. */
  15746. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15747. /**
  15748. * Gets the node used to drive the bone's transformation
  15749. * @returns a transform node or null
  15750. */
  15751. getTransformNode(): Nullable<TransformNode>;
  15752. /** Gets or sets current position (in local space) */
  15753. get position(): Vector3;
  15754. set position(newPosition: Vector3);
  15755. /** Gets or sets current rotation (in local space) */
  15756. get rotation(): Vector3;
  15757. set rotation(newRotation: Vector3);
  15758. /** Gets or sets current rotation quaternion (in local space) */
  15759. get rotationQuaternion(): Quaternion;
  15760. set rotationQuaternion(newRotation: Quaternion);
  15761. /** Gets or sets current scaling (in local space) */
  15762. get scaling(): Vector3;
  15763. set scaling(newScaling: Vector3);
  15764. /**
  15765. * Gets the animation properties override
  15766. */
  15767. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15768. private _decompose;
  15769. private _compose;
  15770. /**
  15771. * Update the base and local matrices
  15772. * @param matrix defines the new base or local matrix
  15773. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15774. * @param updateLocalMatrix defines if the local matrix should be updated
  15775. */
  15776. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15777. /** @hidden */
  15778. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15779. /**
  15780. * Flag the bone as dirty (Forcing it to update everything)
  15781. */
  15782. markAsDirty(): void;
  15783. /** @hidden */
  15784. _markAsDirtyAndCompose(): void;
  15785. private _markAsDirtyAndDecompose;
  15786. /**
  15787. * Translate the bone in local or world space
  15788. * @param vec The amount to translate the bone
  15789. * @param space The space that the translation is in
  15790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15791. */
  15792. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15793. /**
  15794. * Set the postion of the bone in local or world space
  15795. * @param position The position to set the bone
  15796. * @param space The space that the position is in
  15797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15798. */
  15799. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15800. /**
  15801. * Set the absolute position of the bone (world space)
  15802. * @param position The position to set the bone
  15803. * @param mesh The mesh that this bone is attached to
  15804. */
  15805. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15806. /**
  15807. * Scale the bone on the x, y and z axes (in local space)
  15808. * @param x The amount to scale the bone on the x axis
  15809. * @param y The amount to scale the bone on the y axis
  15810. * @param z The amount to scale the bone on the z axis
  15811. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15812. */
  15813. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15814. /**
  15815. * Set the bone scaling in local space
  15816. * @param scale defines the scaling vector
  15817. */
  15818. setScale(scale: Vector3): void;
  15819. /**
  15820. * Gets the current scaling in local space
  15821. * @returns the current scaling vector
  15822. */
  15823. getScale(): Vector3;
  15824. /**
  15825. * Gets the current scaling in local space and stores it in a target vector
  15826. * @param result defines the target vector
  15827. */
  15828. getScaleToRef(result: Vector3): void;
  15829. /**
  15830. * Set the yaw, pitch, and roll of the bone in local or world space
  15831. * @param yaw The rotation of the bone on the y axis
  15832. * @param pitch The rotation of the bone on the x axis
  15833. * @param roll The rotation of the bone on the z axis
  15834. * @param space The space that the axes of rotation are in
  15835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15836. */
  15837. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15838. /**
  15839. * Add a rotation to the bone on an axis in local or world space
  15840. * @param axis The axis to rotate the bone on
  15841. * @param amount The amount to rotate the bone
  15842. * @param space The space that the axis is in
  15843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15844. */
  15845. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15846. /**
  15847. * Set the rotation of the bone to a particular axis angle in local or world space
  15848. * @param axis The axis to rotate the bone on
  15849. * @param angle The angle that the bone should be rotated to
  15850. * @param space The space that the axis is in
  15851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15852. */
  15853. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15854. /**
  15855. * Set the euler rotation of the bone in local or world space
  15856. * @param rotation The euler rotation that the bone should be set to
  15857. * @param space The space that the rotation is in
  15858. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15859. */
  15860. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15861. /**
  15862. * Set the quaternion rotation of the bone in local or world space
  15863. * @param quat The quaternion rotation that the bone should be set to
  15864. * @param space The space that the rotation is in
  15865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15866. */
  15867. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15868. /**
  15869. * Set the rotation matrix of the bone in local or world space
  15870. * @param rotMat The rotation matrix that the bone should be set to
  15871. * @param space The space that the rotation is in
  15872. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15873. */
  15874. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15875. private _rotateWithMatrix;
  15876. private _getNegativeRotationToRef;
  15877. /**
  15878. * Get the position of the bone in local or world space
  15879. * @param space The space that the returned position is in
  15880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15881. * @returns The position of the bone
  15882. */
  15883. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15884. /**
  15885. * Copy the position of the bone to a vector3 in local or world space
  15886. * @param space The space that the returned position is in
  15887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15888. * @param result The vector3 to copy the position to
  15889. */
  15890. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15891. /**
  15892. * Get the absolute position of the bone (world space)
  15893. * @param mesh The mesh that this bone is attached to
  15894. * @returns The absolute position of the bone
  15895. */
  15896. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15897. /**
  15898. * Copy the absolute position of the bone (world space) to the result param
  15899. * @param mesh The mesh that this bone is attached to
  15900. * @param result The vector3 to copy the absolute position to
  15901. */
  15902. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15903. /**
  15904. * Compute the absolute transforms of this bone and its children
  15905. */
  15906. computeAbsoluteTransforms(): void;
  15907. /**
  15908. * Get the world direction from an axis that is in the local space of the bone
  15909. * @param localAxis The local direction that is used to compute the world direction
  15910. * @param mesh The mesh that this bone is attached to
  15911. * @returns The world direction
  15912. */
  15913. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15914. /**
  15915. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15916. * @param localAxis The local direction that is used to compute the world direction
  15917. * @param mesh The mesh that this bone is attached to
  15918. * @param result The vector3 that the world direction will be copied to
  15919. */
  15920. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15921. /**
  15922. * Get the euler rotation of the bone in local or world space
  15923. * @param space The space that the rotation should be in
  15924. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15925. * @returns The euler rotation
  15926. */
  15927. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15928. /**
  15929. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15930. * @param space The space that the rotation should be in
  15931. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15932. * @param result The vector3 that the rotation should be copied to
  15933. */
  15934. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15935. /**
  15936. * Get the quaternion rotation of the bone in either local or world space
  15937. * @param space The space that the rotation should be in
  15938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15939. * @returns The quaternion rotation
  15940. */
  15941. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15942. /**
  15943. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15944. * @param space The space that the rotation should be in
  15945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15946. * @param result The quaternion that the rotation should be copied to
  15947. */
  15948. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15949. /**
  15950. * Get the rotation matrix of the bone in local or world space
  15951. * @param space The space that the rotation should be in
  15952. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15953. * @returns The rotation matrix
  15954. */
  15955. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15956. /**
  15957. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15958. * @param space The space that the rotation should be in
  15959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15960. * @param result The quaternion that the rotation should be copied to
  15961. */
  15962. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15963. /**
  15964. * Get the world position of a point that is in the local space of the bone
  15965. * @param position The local position
  15966. * @param mesh The mesh that this bone is attached to
  15967. * @returns The world position
  15968. */
  15969. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15970. /**
  15971. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15972. * @param position The local position
  15973. * @param mesh The mesh that this bone is attached to
  15974. * @param result The vector3 that the world position should be copied to
  15975. */
  15976. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15977. /**
  15978. * Get the local position of a point that is in world space
  15979. * @param position The world position
  15980. * @param mesh The mesh that this bone is attached to
  15981. * @returns The local position
  15982. */
  15983. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15984. /**
  15985. * Get the local position of a point that is in world space and copy it to the result param
  15986. * @param position The world position
  15987. * @param mesh The mesh that this bone is attached to
  15988. * @param result The vector3 that the local position should be copied to
  15989. */
  15990. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15991. /**
  15992. * Set the current local matrix as the restPose for this bone.
  15993. */
  15994. setCurrentPoseAsRest(): void;
  15995. }
  15996. }
  15997. declare module "babylonjs/Animations/runtimeAnimation" {
  15998. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15999. import { Animatable } from "babylonjs/Animations/animatable";
  16000. import { Scene } from "babylonjs/scene";
  16001. /**
  16002. * Defines a runtime animation
  16003. */
  16004. export class RuntimeAnimation {
  16005. private _events;
  16006. /**
  16007. * The current frame of the runtime animation
  16008. */
  16009. private _currentFrame;
  16010. /**
  16011. * The animation used by the runtime animation
  16012. */
  16013. private _animation;
  16014. /**
  16015. * The target of the runtime animation
  16016. */
  16017. private _target;
  16018. /**
  16019. * The initiating animatable
  16020. */
  16021. private _host;
  16022. /**
  16023. * The original value of the runtime animation
  16024. */
  16025. private _originalValue;
  16026. /**
  16027. * The original blend value of the runtime animation
  16028. */
  16029. private _originalBlendValue;
  16030. /**
  16031. * The offsets cache of the runtime animation
  16032. */
  16033. private _offsetsCache;
  16034. /**
  16035. * The high limits cache of the runtime animation
  16036. */
  16037. private _highLimitsCache;
  16038. /**
  16039. * Specifies if the runtime animation has been stopped
  16040. */
  16041. private _stopped;
  16042. /**
  16043. * The blending factor of the runtime animation
  16044. */
  16045. private _blendingFactor;
  16046. /**
  16047. * The BabylonJS scene
  16048. */
  16049. private _scene;
  16050. /**
  16051. * The current value of the runtime animation
  16052. */
  16053. private _currentValue;
  16054. /** @hidden */
  16055. _animationState: _IAnimationState;
  16056. /**
  16057. * The active target of the runtime animation
  16058. */
  16059. private _activeTargets;
  16060. private _currentActiveTarget;
  16061. private _directTarget;
  16062. /**
  16063. * The target path of the runtime animation
  16064. */
  16065. private _targetPath;
  16066. /**
  16067. * The weight of the runtime animation
  16068. */
  16069. private _weight;
  16070. /**
  16071. * The ratio offset of the runtime animation
  16072. */
  16073. private _ratioOffset;
  16074. /**
  16075. * The previous delay of the runtime animation
  16076. */
  16077. private _previousDelay;
  16078. /**
  16079. * The previous ratio of the runtime animation
  16080. */
  16081. private _previousRatio;
  16082. private _enableBlending;
  16083. private _keys;
  16084. private _minFrame;
  16085. private _maxFrame;
  16086. private _minValue;
  16087. private _maxValue;
  16088. private _targetIsArray;
  16089. /**
  16090. * Gets the current frame of the runtime animation
  16091. */
  16092. get currentFrame(): number;
  16093. /**
  16094. * Gets the weight of the runtime animation
  16095. */
  16096. get weight(): number;
  16097. /**
  16098. * Gets the current value of the runtime animation
  16099. */
  16100. get currentValue(): any;
  16101. /**
  16102. * Gets the target path of the runtime animation
  16103. */
  16104. get targetPath(): string;
  16105. /**
  16106. * Gets the actual target of the runtime animation
  16107. */
  16108. get target(): any;
  16109. /**
  16110. * Gets the additive state of the runtime animation
  16111. */
  16112. get isAdditive(): boolean;
  16113. /** @hidden */
  16114. _onLoop: () => void;
  16115. /**
  16116. * Create a new RuntimeAnimation object
  16117. * @param target defines the target of the animation
  16118. * @param animation defines the source animation object
  16119. * @param scene defines the hosting scene
  16120. * @param host defines the initiating Animatable
  16121. */
  16122. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16123. private _preparePath;
  16124. /**
  16125. * Gets the animation from the runtime animation
  16126. */
  16127. get animation(): Animation;
  16128. /**
  16129. * Resets the runtime animation to the beginning
  16130. * @param restoreOriginal defines whether to restore the target property to the original value
  16131. */
  16132. reset(restoreOriginal?: boolean): void;
  16133. /**
  16134. * Specifies if the runtime animation is stopped
  16135. * @returns Boolean specifying if the runtime animation is stopped
  16136. */
  16137. isStopped(): boolean;
  16138. /**
  16139. * Disposes of the runtime animation
  16140. */
  16141. dispose(): void;
  16142. /**
  16143. * Apply the interpolated value to the target
  16144. * @param currentValue defines the value computed by the animation
  16145. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16146. */
  16147. setValue(currentValue: any, weight: number): void;
  16148. private _getOriginalValues;
  16149. private _setValue;
  16150. /**
  16151. * Gets the loop pmode of the runtime animation
  16152. * @returns Loop Mode
  16153. */
  16154. private _getCorrectLoopMode;
  16155. /**
  16156. * Move the current animation to a given frame
  16157. * @param frame defines the frame to move to
  16158. */
  16159. goToFrame(frame: number): void;
  16160. /**
  16161. * @hidden Internal use only
  16162. */
  16163. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16164. /**
  16165. * Execute the current animation
  16166. * @param delay defines the delay to add to the current frame
  16167. * @param from defines the lower bound of the animation range
  16168. * @param to defines the upper bound of the animation range
  16169. * @param loop defines if the current animation must loop
  16170. * @param speedRatio defines the current speed ratio
  16171. * @param weight defines the weight of the animation (default is -1 so no weight)
  16172. * @param onLoop optional callback called when animation loops
  16173. * @returns a boolean indicating if the animation is running
  16174. */
  16175. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16176. }
  16177. }
  16178. declare module "babylonjs/Animations/animatable" {
  16179. import { Animation } from "babylonjs/Animations/animation";
  16180. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16181. import { Nullable } from "babylonjs/types";
  16182. import { Observable } from "babylonjs/Misc/observable";
  16183. import { Scene } from "babylonjs/scene";
  16184. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16185. import { Node } from "babylonjs/node";
  16186. /**
  16187. * Class used to store an actual running animation
  16188. */
  16189. export class Animatable {
  16190. /** defines the target object */
  16191. target: any;
  16192. /** defines the starting frame number (default is 0) */
  16193. fromFrame: number;
  16194. /** defines the ending frame number (default is 100) */
  16195. toFrame: number;
  16196. /** defines if the animation must loop (default is false) */
  16197. loopAnimation: boolean;
  16198. /** defines a callback to call when animation ends if it is not looping */
  16199. onAnimationEnd?: (() => void) | null | undefined;
  16200. /** defines a callback to call when animation loops */
  16201. onAnimationLoop?: (() => void) | null | undefined;
  16202. /** defines whether the animation should be evaluated additively */
  16203. isAdditive: boolean;
  16204. private _localDelayOffset;
  16205. private _pausedDelay;
  16206. private _runtimeAnimations;
  16207. private _paused;
  16208. private _scene;
  16209. private _speedRatio;
  16210. private _weight;
  16211. private _syncRoot;
  16212. /**
  16213. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16214. * This will only apply for non looping animation (default is true)
  16215. */
  16216. disposeOnEnd: boolean;
  16217. /**
  16218. * Gets a boolean indicating if the animation has started
  16219. */
  16220. animationStarted: boolean;
  16221. /**
  16222. * Observer raised when the animation ends
  16223. */
  16224. onAnimationEndObservable: Observable<Animatable>;
  16225. /**
  16226. * Observer raised when the animation loops
  16227. */
  16228. onAnimationLoopObservable: Observable<Animatable>;
  16229. /**
  16230. * Gets the root Animatable used to synchronize and normalize animations
  16231. */
  16232. get syncRoot(): Nullable<Animatable>;
  16233. /**
  16234. * Gets the current frame of the first RuntimeAnimation
  16235. * Used to synchronize Animatables
  16236. */
  16237. get masterFrame(): number;
  16238. /**
  16239. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16240. */
  16241. get weight(): number;
  16242. set weight(value: number);
  16243. /**
  16244. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16245. */
  16246. get speedRatio(): number;
  16247. set speedRatio(value: number);
  16248. /**
  16249. * Creates a new Animatable
  16250. * @param scene defines the hosting scene
  16251. * @param target defines the target object
  16252. * @param fromFrame defines the starting frame number (default is 0)
  16253. * @param toFrame defines the ending frame number (default is 100)
  16254. * @param loopAnimation defines if the animation must loop (default is false)
  16255. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16256. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16257. * @param animations defines a group of animation to add to the new Animatable
  16258. * @param onAnimationLoop defines a callback to call when animation loops
  16259. * @param isAdditive defines whether the animation should be evaluated additively
  16260. */
  16261. constructor(scene: Scene,
  16262. /** defines the target object */
  16263. target: any,
  16264. /** defines the starting frame number (default is 0) */
  16265. fromFrame?: number,
  16266. /** defines the ending frame number (default is 100) */
  16267. toFrame?: number,
  16268. /** defines if the animation must loop (default is false) */
  16269. loopAnimation?: boolean, speedRatio?: number,
  16270. /** defines a callback to call when animation ends if it is not looping */
  16271. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16272. /** defines a callback to call when animation loops */
  16273. onAnimationLoop?: (() => void) | null | undefined,
  16274. /** defines whether the animation should be evaluated additively */
  16275. isAdditive?: boolean);
  16276. /**
  16277. * Synchronize and normalize current Animatable with a source Animatable
  16278. * This is useful when using animation weights and when animations are not of the same length
  16279. * @param root defines the root Animatable to synchronize with
  16280. * @returns the current Animatable
  16281. */
  16282. syncWith(root: Animatable): Animatable;
  16283. /**
  16284. * Gets the list of runtime animations
  16285. * @returns an array of RuntimeAnimation
  16286. */
  16287. getAnimations(): RuntimeAnimation[];
  16288. /**
  16289. * Adds more animations to the current animatable
  16290. * @param target defines the target of the animations
  16291. * @param animations defines the new animations to add
  16292. */
  16293. appendAnimations(target: any, animations: Animation[]): void;
  16294. /**
  16295. * Gets the source animation for a specific property
  16296. * @param property defines the propertyu to look for
  16297. * @returns null or the source animation for the given property
  16298. */
  16299. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16300. /**
  16301. * Gets the runtime animation for a specific property
  16302. * @param property defines the propertyu to look for
  16303. * @returns null or the runtime animation for the given property
  16304. */
  16305. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16306. /**
  16307. * Resets the animatable to its original state
  16308. */
  16309. reset(): void;
  16310. /**
  16311. * Allows the animatable to blend with current running animations
  16312. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16313. * @param blendingSpeed defines the blending speed to use
  16314. */
  16315. enableBlending(blendingSpeed: number): void;
  16316. /**
  16317. * Disable animation blending
  16318. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16319. */
  16320. disableBlending(): void;
  16321. /**
  16322. * Jump directly to a given frame
  16323. * @param frame defines the frame to jump to
  16324. */
  16325. goToFrame(frame: number): void;
  16326. /**
  16327. * Pause the animation
  16328. */
  16329. pause(): void;
  16330. /**
  16331. * Restart the animation
  16332. */
  16333. restart(): void;
  16334. private _raiseOnAnimationEnd;
  16335. /**
  16336. * Stop and delete the current animation
  16337. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16338. * @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)
  16339. */
  16340. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16341. /**
  16342. * Wait asynchronously for the animation to end
  16343. * @returns a promise which will be fullfilled when the animation ends
  16344. */
  16345. waitAsync(): Promise<Animatable>;
  16346. /** @hidden */
  16347. _animate(delay: number): boolean;
  16348. }
  16349. module "babylonjs/scene" {
  16350. interface Scene {
  16351. /** @hidden */
  16352. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16353. /** @hidden */
  16354. _processLateAnimationBindingsForMatrices(holder: {
  16355. totalWeight: number;
  16356. totalAdditiveWeight: number;
  16357. animations: RuntimeAnimation[];
  16358. additiveAnimations: RuntimeAnimation[];
  16359. originalValue: Matrix;
  16360. }): any;
  16361. /** @hidden */
  16362. _processLateAnimationBindingsForQuaternions(holder: {
  16363. totalWeight: number;
  16364. totalAdditiveWeight: number;
  16365. animations: RuntimeAnimation[];
  16366. additiveAnimations: RuntimeAnimation[];
  16367. originalValue: Quaternion;
  16368. }, refQuaternion: Quaternion): Quaternion;
  16369. /** @hidden */
  16370. _processLateAnimationBindings(): void;
  16371. /**
  16372. * Will start the animation sequence of a given target
  16373. * @param target defines the target
  16374. * @param from defines from which frame should animation start
  16375. * @param to defines until which frame should animation run.
  16376. * @param weight defines the weight to apply to the animation (1.0 by default)
  16377. * @param loop defines if the animation loops
  16378. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16379. * @param onAnimationEnd defines the function to be executed when the animation ends
  16380. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16381. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16382. * @param onAnimationLoop defines the callback to call when an animation loops
  16383. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16384. * @returns the animatable object created for this animation
  16385. */
  16386. 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;
  16387. /**
  16388. * Will start the animation sequence of a given target
  16389. * @param target defines the target
  16390. * @param from defines from which frame should animation start
  16391. * @param to defines until which frame should animation run.
  16392. * @param loop defines if the animation loops
  16393. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16394. * @param onAnimationEnd defines the function to be executed when the animation ends
  16395. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16396. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16397. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16398. * @param onAnimationLoop defines the callback to call when an animation loops
  16399. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16400. * @returns the animatable object created for this animation
  16401. */
  16402. 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;
  16403. /**
  16404. * Will start the animation sequence of a given target and its hierarchy
  16405. * @param target defines the target
  16406. * @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.
  16407. * @param from defines from which frame should animation start
  16408. * @param to defines until which frame should animation run.
  16409. * @param loop defines if the animation loops
  16410. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16411. * @param onAnimationEnd defines the function to be executed when the animation ends
  16412. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16413. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16414. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16415. * @param onAnimationLoop defines the callback to call when an animation loops
  16416. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16417. * @returns the list of created animatables
  16418. */
  16419. 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[];
  16420. /**
  16421. * Begin a new animation on a given node
  16422. * @param target defines the target where the animation will take place
  16423. * @param animations defines the list of animations to start
  16424. * @param from defines the initial value
  16425. * @param to defines the final value
  16426. * @param loop defines if you want animation to loop (off by default)
  16427. * @param speedRatio defines the speed ratio to apply to all animations
  16428. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16429. * @param onAnimationLoop defines the callback to call when an animation loops
  16430. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16431. * @returns the list of created animatables
  16432. */
  16433. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16434. /**
  16435. * Begin a new animation on a given node and its hierarchy
  16436. * @param target defines the root node where the animation will take place
  16437. * @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.
  16438. * @param animations defines the list of animations to start
  16439. * @param from defines the initial value
  16440. * @param to defines the final value
  16441. * @param loop defines if you want animation to loop (off by default)
  16442. * @param speedRatio defines the speed ratio to apply to all animations
  16443. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16444. * @param onAnimationLoop defines the callback to call when an animation loops
  16445. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16446. * @returns the list of animatables created for all nodes
  16447. */
  16448. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16449. /**
  16450. * Gets the animatable associated with a specific target
  16451. * @param target defines the target of the animatable
  16452. * @returns the required animatable if found
  16453. */
  16454. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16455. /**
  16456. * Gets all animatables associated with a given target
  16457. * @param target defines the target to look animatables for
  16458. * @returns an array of Animatables
  16459. */
  16460. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16461. /**
  16462. * Stops and removes all animations that have been applied to the scene
  16463. */
  16464. stopAllAnimations(): void;
  16465. /**
  16466. * Gets the current delta time used by animation engine
  16467. */
  16468. deltaTime: number;
  16469. }
  16470. }
  16471. module "babylonjs/Bones/bone" {
  16472. interface Bone {
  16473. /**
  16474. * Copy an animation range from another bone
  16475. * @param source defines the source bone
  16476. * @param rangeName defines the range name to copy
  16477. * @param frameOffset defines the frame offset
  16478. * @param rescaleAsRequired defines if rescaling must be applied if required
  16479. * @param skelDimensionsRatio defines the scaling ratio
  16480. * @returns true if operation was successful
  16481. */
  16482. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16483. }
  16484. }
  16485. }
  16486. declare module "babylonjs/Bones/skeleton" {
  16487. import { Bone } from "babylonjs/Bones/bone";
  16488. import { Observable } from "babylonjs/Misc/observable";
  16489. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16490. import { Scene } from "babylonjs/scene";
  16491. import { Nullable } from "babylonjs/types";
  16492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16493. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16494. import { Animatable } from "babylonjs/Animations/animatable";
  16495. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16496. import { Animation } from "babylonjs/Animations/animation";
  16497. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16498. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16499. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16500. /**
  16501. * Class used to handle skinning animations
  16502. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16503. */
  16504. export class Skeleton implements IAnimatable {
  16505. /** defines the skeleton name */
  16506. name: string;
  16507. /** defines the skeleton Id */
  16508. id: string;
  16509. /**
  16510. * Defines the list of child bones
  16511. */
  16512. bones: Bone[];
  16513. /**
  16514. * Defines an estimate of the dimension of the skeleton at rest
  16515. */
  16516. dimensionsAtRest: Vector3;
  16517. /**
  16518. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16519. */
  16520. needInitialSkinMatrix: boolean;
  16521. /**
  16522. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16523. */
  16524. overrideMesh: Nullable<AbstractMesh>;
  16525. /**
  16526. * Gets the list of animations attached to this skeleton
  16527. */
  16528. animations: Array<Animation>;
  16529. private _scene;
  16530. private _isDirty;
  16531. private _transformMatrices;
  16532. private _transformMatrixTexture;
  16533. private _meshesWithPoseMatrix;
  16534. private _animatables;
  16535. private _identity;
  16536. private _synchronizedWithMesh;
  16537. private _ranges;
  16538. private _lastAbsoluteTransformsUpdateId;
  16539. private _canUseTextureForBones;
  16540. private _uniqueId;
  16541. /** @hidden */
  16542. _numBonesWithLinkedTransformNode: number;
  16543. /** @hidden */
  16544. _hasWaitingData: Nullable<boolean>;
  16545. /** @hidden */
  16546. _waitingOverrideMeshId: Nullable<string>;
  16547. /**
  16548. * Specifies if the skeleton should be serialized
  16549. */
  16550. doNotSerialize: boolean;
  16551. private _useTextureToStoreBoneMatrices;
  16552. /**
  16553. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16554. * Please note that this option is not available if the hardware does not support it
  16555. */
  16556. get useTextureToStoreBoneMatrices(): boolean;
  16557. set useTextureToStoreBoneMatrices(value: boolean);
  16558. private _animationPropertiesOverride;
  16559. /**
  16560. * Gets or sets the animation properties override
  16561. */
  16562. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16563. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16564. /**
  16565. * List of inspectable custom properties (used by the Inspector)
  16566. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16567. */
  16568. inspectableCustomProperties: IInspectable[];
  16569. /**
  16570. * An observable triggered before computing the skeleton's matrices
  16571. */
  16572. onBeforeComputeObservable: Observable<Skeleton>;
  16573. /**
  16574. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16575. */
  16576. get isUsingTextureForMatrices(): boolean;
  16577. /**
  16578. * Gets the unique ID of this skeleton
  16579. */
  16580. get uniqueId(): number;
  16581. /**
  16582. * Creates a new skeleton
  16583. * @param name defines the skeleton name
  16584. * @param id defines the skeleton Id
  16585. * @param scene defines the hosting scene
  16586. */
  16587. constructor(
  16588. /** defines the skeleton name */
  16589. name: string,
  16590. /** defines the skeleton Id */
  16591. id: string, scene: Scene);
  16592. /**
  16593. * Gets the current object class name.
  16594. * @return the class name
  16595. */
  16596. getClassName(): string;
  16597. /**
  16598. * Returns an array containing the root bones
  16599. * @returns an array containing the root bones
  16600. */
  16601. getChildren(): Array<Bone>;
  16602. /**
  16603. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16604. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16605. * @returns a Float32Array containing matrices data
  16606. */
  16607. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16608. /**
  16609. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16610. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16611. * @returns a raw texture containing the data
  16612. */
  16613. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16614. /**
  16615. * Gets the current hosting scene
  16616. * @returns a scene object
  16617. */
  16618. getScene(): Scene;
  16619. /**
  16620. * Gets a string representing the current skeleton data
  16621. * @param fullDetails defines a boolean indicating if we want a verbose version
  16622. * @returns a string representing the current skeleton data
  16623. */
  16624. toString(fullDetails?: boolean): string;
  16625. /**
  16626. * Get bone's index searching by name
  16627. * @param name defines bone's name to search for
  16628. * @return the indice of the bone. Returns -1 if not found
  16629. */
  16630. getBoneIndexByName(name: string): number;
  16631. /**
  16632. * Creater a new animation range
  16633. * @param name defines the name of the range
  16634. * @param from defines the start key
  16635. * @param to defines the end key
  16636. */
  16637. createAnimationRange(name: string, from: number, to: number): void;
  16638. /**
  16639. * Delete a specific animation range
  16640. * @param name defines the name of the range
  16641. * @param deleteFrames defines if frames must be removed as well
  16642. */
  16643. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16644. /**
  16645. * Gets a specific animation range
  16646. * @param name defines the name of the range to look for
  16647. * @returns the requested animation range or null if not found
  16648. */
  16649. getAnimationRange(name: string): Nullable<AnimationRange>;
  16650. /**
  16651. * Gets the list of all animation ranges defined on this skeleton
  16652. * @returns an array
  16653. */
  16654. getAnimationRanges(): Nullable<AnimationRange>[];
  16655. /**
  16656. * Copy animation range from a source skeleton.
  16657. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16658. * @param source defines the source skeleton
  16659. * @param name defines the name of the range to copy
  16660. * @param rescaleAsRequired defines if rescaling must be applied if required
  16661. * @returns true if operation was successful
  16662. */
  16663. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16664. /**
  16665. * Forces the skeleton to go to rest pose
  16666. */
  16667. returnToRest(): void;
  16668. private _getHighestAnimationFrame;
  16669. /**
  16670. * Begin a specific animation range
  16671. * @param name defines the name of the range to start
  16672. * @param loop defines if looping must be turned on (false by default)
  16673. * @param speedRatio defines the speed ratio to apply (1 by default)
  16674. * @param onAnimationEnd defines a callback which will be called when animation will end
  16675. * @returns a new animatable
  16676. */
  16677. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16678. /**
  16679. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16680. * @param skeleton defines the Skeleton containing the animation range to convert
  16681. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16682. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16683. * @returns the original skeleton
  16684. */
  16685. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16686. /** @hidden */
  16687. _markAsDirty(): void;
  16688. /** @hidden */
  16689. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16690. /** @hidden */
  16691. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16692. private _computeTransformMatrices;
  16693. /**
  16694. * Build all resources required to render a skeleton
  16695. */
  16696. prepare(): void;
  16697. /**
  16698. * Gets the list of animatables currently running for this skeleton
  16699. * @returns an array of animatables
  16700. */
  16701. getAnimatables(): IAnimatable[];
  16702. /**
  16703. * Clone the current skeleton
  16704. * @param name defines the name of the new skeleton
  16705. * @param id defines the id of the new skeleton
  16706. * @returns the new skeleton
  16707. */
  16708. clone(name: string, id?: string): Skeleton;
  16709. /**
  16710. * Enable animation blending for this skeleton
  16711. * @param blendingSpeed defines the blending speed to apply
  16712. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16713. */
  16714. enableBlending(blendingSpeed?: number): void;
  16715. /**
  16716. * Releases all resources associated with the current skeleton
  16717. */
  16718. dispose(): void;
  16719. /**
  16720. * Serialize the skeleton in a JSON object
  16721. * @returns a JSON object
  16722. */
  16723. serialize(): any;
  16724. /**
  16725. * Creates a new skeleton from serialized data
  16726. * @param parsedSkeleton defines the serialized data
  16727. * @param scene defines the hosting scene
  16728. * @returns a new skeleton
  16729. */
  16730. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16731. /**
  16732. * Compute all node absolute transforms
  16733. * @param forceUpdate defines if computation must be done even if cache is up to date
  16734. */
  16735. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16736. /**
  16737. * Gets the root pose matrix
  16738. * @returns a matrix
  16739. */
  16740. getPoseMatrix(): Nullable<Matrix>;
  16741. /**
  16742. * Sorts bones per internal index
  16743. */
  16744. sortBones(): void;
  16745. private _sortBones;
  16746. /**
  16747. * Set the current local matrix as the restPose for all bones in the skeleton.
  16748. */
  16749. setCurrentPoseAsRest(): void;
  16750. }
  16751. }
  16752. declare module "babylonjs/Meshes/instancedMesh" {
  16753. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16755. import { Camera } from "babylonjs/Cameras/camera";
  16756. import { Node } from "babylonjs/node";
  16757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16758. import { Mesh } from "babylonjs/Meshes/mesh";
  16759. import { Material } from "babylonjs/Materials/material";
  16760. import { Skeleton } from "babylonjs/Bones/skeleton";
  16761. import { Light } from "babylonjs/Lights/light";
  16762. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16763. /**
  16764. * Creates an instance based on a source mesh.
  16765. */
  16766. export class InstancedMesh extends AbstractMesh {
  16767. private _sourceMesh;
  16768. private _currentLOD;
  16769. /** @hidden */
  16770. _indexInSourceMeshInstanceArray: number;
  16771. constructor(name: string, source: Mesh);
  16772. /**
  16773. * Returns the string "InstancedMesh".
  16774. */
  16775. getClassName(): string;
  16776. /** Gets the list of lights affecting that mesh */
  16777. get lightSources(): Light[];
  16778. _resyncLightSources(): void;
  16779. _resyncLightSource(light: Light): void;
  16780. _removeLightSource(light: Light, dispose: boolean): void;
  16781. /**
  16782. * If the source mesh receives shadows
  16783. */
  16784. get receiveShadows(): boolean;
  16785. /**
  16786. * The material of the source mesh
  16787. */
  16788. get material(): Nullable<Material>;
  16789. /**
  16790. * Visibility of the source mesh
  16791. */
  16792. get visibility(): number;
  16793. /**
  16794. * Skeleton of the source mesh
  16795. */
  16796. get skeleton(): Nullable<Skeleton>;
  16797. /**
  16798. * Rendering ground id of the source mesh
  16799. */
  16800. get renderingGroupId(): number;
  16801. set renderingGroupId(value: number);
  16802. /**
  16803. * Returns the total number of vertices (integer).
  16804. */
  16805. getTotalVertices(): number;
  16806. /**
  16807. * Returns a positive integer : the total number of indices in this mesh geometry.
  16808. * @returns the numner of indices or zero if the mesh has no geometry.
  16809. */
  16810. getTotalIndices(): number;
  16811. /**
  16812. * The source mesh of the instance
  16813. */
  16814. get sourceMesh(): Mesh;
  16815. /**
  16816. * Creates a new InstancedMesh object from the mesh model.
  16817. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16818. * @param name defines the name of the new instance
  16819. * @returns a new InstancedMesh
  16820. */
  16821. createInstance(name: string): InstancedMesh;
  16822. /**
  16823. * Is this node ready to be used/rendered
  16824. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16825. * @return {boolean} is it ready
  16826. */
  16827. isReady(completeCheck?: boolean): boolean;
  16828. /**
  16829. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16830. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16831. * @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.
  16832. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16833. */
  16834. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16835. /**
  16836. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16837. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16838. * The `data` are either a numeric array either a Float32Array.
  16839. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16840. * 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).
  16841. * Note that a new underlying VertexBuffer object is created each call.
  16842. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16843. *
  16844. * Possible `kind` values :
  16845. * - VertexBuffer.PositionKind
  16846. * - VertexBuffer.UVKind
  16847. * - VertexBuffer.UV2Kind
  16848. * - VertexBuffer.UV3Kind
  16849. * - VertexBuffer.UV4Kind
  16850. * - VertexBuffer.UV5Kind
  16851. * - VertexBuffer.UV6Kind
  16852. * - VertexBuffer.ColorKind
  16853. * - VertexBuffer.MatricesIndicesKind
  16854. * - VertexBuffer.MatricesIndicesExtraKind
  16855. * - VertexBuffer.MatricesWeightsKind
  16856. * - VertexBuffer.MatricesWeightsExtraKind
  16857. *
  16858. * Returns the Mesh.
  16859. */
  16860. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16861. /**
  16862. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16863. * If the mesh has no geometry, it is simply returned as it is.
  16864. * The `data` are either a numeric array either a Float32Array.
  16865. * No new underlying VertexBuffer object is created.
  16866. * 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.
  16867. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16868. *
  16869. * Possible `kind` values :
  16870. * - VertexBuffer.PositionKind
  16871. * - VertexBuffer.UVKind
  16872. * - VertexBuffer.UV2Kind
  16873. * - VertexBuffer.UV3Kind
  16874. * - VertexBuffer.UV4Kind
  16875. * - VertexBuffer.UV5Kind
  16876. * - VertexBuffer.UV6Kind
  16877. * - VertexBuffer.ColorKind
  16878. * - VertexBuffer.MatricesIndicesKind
  16879. * - VertexBuffer.MatricesIndicesExtraKind
  16880. * - VertexBuffer.MatricesWeightsKind
  16881. * - VertexBuffer.MatricesWeightsExtraKind
  16882. *
  16883. * Returns the Mesh.
  16884. */
  16885. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16886. /**
  16887. * Sets the mesh indices.
  16888. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16889. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16890. * This method creates a new index buffer each call.
  16891. * Returns the Mesh.
  16892. */
  16893. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16894. /**
  16895. * Boolean : True if the mesh owns the requested kind of data.
  16896. */
  16897. isVerticesDataPresent(kind: string): boolean;
  16898. /**
  16899. * Returns an array of indices (IndicesArray).
  16900. */
  16901. getIndices(): Nullable<IndicesArray>;
  16902. get _positions(): Nullable<Vector3[]>;
  16903. /**
  16904. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16905. * This means the mesh underlying bounding box and sphere are recomputed.
  16906. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16907. * @returns the current mesh
  16908. */
  16909. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16910. /** @hidden */
  16911. _preActivate(): InstancedMesh;
  16912. /** @hidden */
  16913. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16914. /** @hidden */
  16915. _postActivate(): void;
  16916. getWorldMatrix(): Matrix;
  16917. get isAnInstance(): boolean;
  16918. /**
  16919. * Returns the current associated LOD AbstractMesh.
  16920. */
  16921. getLOD(camera: Camera): AbstractMesh;
  16922. /** @hidden */
  16923. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16924. /** @hidden */
  16925. _syncSubMeshes(): InstancedMesh;
  16926. /** @hidden */
  16927. _generatePointsArray(): boolean;
  16928. /** @hidden */
  16929. _updateBoundingInfo(): AbstractMesh;
  16930. /**
  16931. * Creates a new InstancedMesh from the current mesh.
  16932. * - name (string) : the cloned mesh name
  16933. * - newParent (optional Node) : the optional Node to parent the clone to.
  16934. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16935. *
  16936. * Returns the clone.
  16937. */
  16938. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16939. /**
  16940. * Disposes the InstancedMesh.
  16941. * Returns nothing.
  16942. */
  16943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16944. }
  16945. module "babylonjs/Meshes/mesh" {
  16946. interface Mesh {
  16947. /**
  16948. * Register a custom buffer that will be instanced
  16949. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16950. * @param kind defines the buffer kind
  16951. * @param stride defines the stride in floats
  16952. */
  16953. registerInstancedBuffer(kind: string, stride: number): void;
  16954. /**
  16955. * true to use the edge renderer for all instances of this mesh
  16956. */
  16957. edgesShareWithInstances: boolean;
  16958. /** @hidden */
  16959. _userInstancedBuffersStorage: {
  16960. data: {
  16961. [key: string]: Float32Array;
  16962. };
  16963. sizes: {
  16964. [key: string]: number;
  16965. };
  16966. vertexBuffers: {
  16967. [key: string]: Nullable<VertexBuffer>;
  16968. };
  16969. strides: {
  16970. [key: string]: number;
  16971. };
  16972. };
  16973. }
  16974. }
  16975. module "babylonjs/Meshes/abstractMesh" {
  16976. interface AbstractMesh {
  16977. /**
  16978. * Object used to store instanced buffers defined by user
  16979. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16980. */
  16981. instancedBuffers: {
  16982. [key: string]: any;
  16983. };
  16984. }
  16985. }
  16986. }
  16987. declare module "babylonjs/Materials/shaderMaterial" {
  16988. import { Nullable } from "babylonjs/types";
  16989. import { Scene } from "babylonjs/scene";
  16990. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16992. import { Mesh } from "babylonjs/Meshes/mesh";
  16993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16995. import { Effect } from "babylonjs/Materials/effect";
  16996. import { Material } from "babylonjs/Materials/material";
  16997. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16998. /**
  16999. * Defines the options associated with the creation of a shader material.
  17000. */
  17001. export interface IShaderMaterialOptions {
  17002. /**
  17003. * Does the material work in alpha blend mode
  17004. */
  17005. needAlphaBlending: boolean;
  17006. /**
  17007. * Does the material work in alpha test mode
  17008. */
  17009. needAlphaTesting: boolean;
  17010. /**
  17011. * The list of attribute names used in the shader
  17012. */
  17013. attributes: string[];
  17014. /**
  17015. * The list of unifrom names used in the shader
  17016. */
  17017. uniforms: string[];
  17018. /**
  17019. * The list of UBO names used in the shader
  17020. */
  17021. uniformBuffers: string[];
  17022. /**
  17023. * The list of sampler names used in the shader
  17024. */
  17025. samplers: string[];
  17026. /**
  17027. * The list of defines used in the shader
  17028. */
  17029. defines: string[];
  17030. }
  17031. /**
  17032. * 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.
  17033. *
  17034. * This returned material effects how the mesh will look based on the code in the shaders.
  17035. *
  17036. * @see https://doc.babylonjs.com/how_to/shader_material
  17037. */
  17038. export class ShaderMaterial extends Material {
  17039. private _shaderPath;
  17040. private _options;
  17041. private _textures;
  17042. private _textureArrays;
  17043. private _floats;
  17044. private _ints;
  17045. private _floatsArrays;
  17046. private _colors3;
  17047. private _colors3Arrays;
  17048. private _colors4;
  17049. private _colors4Arrays;
  17050. private _vectors2;
  17051. private _vectors3;
  17052. private _vectors4;
  17053. private _matrices;
  17054. private _matrixArrays;
  17055. private _matrices3x3;
  17056. private _matrices2x2;
  17057. private _vectors2Arrays;
  17058. private _vectors3Arrays;
  17059. private _vectors4Arrays;
  17060. private _cachedWorldViewMatrix;
  17061. private _cachedWorldViewProjectionMatrix;
  17062. private _renderId;
  17063. private _multiview;
  17064. private _cachedDefines;
  17065. /** Define the Url to load snippets */
  17066. static SnippetUrl: string;
  17067. /** Snippet ID if the material was created from the snippet server */
  17068. snippetId: string;
  17069. /**
  17070. * Instantiate a new shader material.
  17071. * 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.
  17072. * This returned material effects how the mesh will look based on the code in the shaders.
  17073. * @see https://doc.babylonjs.com/how_to/shader_material
  17074. * @param name Define the name of the material in the scene
  17075. * @param scene Define the scene the material belongs to
  17076. * @param shaderPath Defines the route to the shader code in one of three ways:
  17077. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17078. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17079. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17080. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17081. * @param options Define the options used to create the shader
  17082. */
  17083. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17084. /**
  17085. * Gets the shader path used to define the shader code
  17086. * It can be modified to trigger a new compilation
  17087. */
  17088. get shaderPath(): any;
  17089. /**
  17090. * Sets the shader path used to define the shader code
  17091. * It can be modified to trigger a new compilation
  17092. */
  17093. set shaderPath(shaderPath: any);
  17094. /**
  17095. * Gets the options used to compile the shader.
  17096. * They can be modified to trigger a new compilation
  17097. */
  17098. get options(): IShaderMaterialOptions;
  17099. /**
  17100. * Gets the current class name of the material e.g. "ShaderMaterial"
  17101. * Mainly use in serialization.
  17102. * @returns the class name
  17103. */
  17104. getClassName(): string;
  17105. /**
  17106. * Specifies if the material will require alpha blending
  17107. * @returns a boolean specifying if alpha blending is needed
  17108. */
  17109. needAlphaBlending(): boolean;
  17110. /**
  17111. * Specifies if this material should be rendered in alpha test mode
  17112. * @returns a boolean specifying if an alpha test is needed.
  17113. */
  17114. needAlphaTesting(): boolean;
  17115. private _checkUniform;
  17116. /**
  17117. * Set a texture in the shader.
  17118. * @param name Define the name of the uniform samplers as defined in the shader
  17119. * @param texture Define the texture to bind to this sampler
  17120. * @return the material itself allowing "fluent" like uniform updates
  17121. */
  17122. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17123. /**
  17124. * Set a texture array in the shader.
  17125. * @param name Define the name of the uniform sampler array as defined in the shader
  17126. * @param textures Define the list of textures to bind to this sampler
  17127. * @return the material itself allowing "fluent" like uniform updates
  17128. */
  17129. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17130. /**
  17131. * Set a float in the shader.
  17132. * @param name Define the name of the uniform as defined in the shader
  17133. * @param value Define the value to give to the uniform
  17134. * @return the material itself allowing "fluent" like uniform updates
  17135. */
  17136. setFloat(name: string, value: number): ShaderMaterial;
  17137. /**
  17138. * Set a int in the shader.
  17139. * @param name Define the name of the uniform as defined in the shader
  17140. * @param value Define the value to give to the uniform
  17141. * @return the material itself allowing "fluent" like uniform updates
  17142. */
  17143. setInt(name: string, value: number): ShaderMaterial;
  17144. /**
  17145. * Set an array of floats in the shader.
  17146. * @param name Define the name of the uniform as defined in the shader
  17147. * @param value Define the value to give to the uniform
  17148. * @return the material itself allowing "fluent" like uniform updates
  17149. */
  17150. setFloats(name: string, value: number[]): ShaderMaterial;
  17151. /**
  17152. * Set a vec3 in the shader from a Color3.
  17153. * @param name Define the name of the uniform as defined in the shader
  17154. * @param value Define the value to give to the uniform
  17155. * @return the material itself allowing "fluent" like uniform updates
  17156. */
  17157. setColor3(name: string, value: Color3): ShaderMaterial;
  17158. /**
  17159. * Set a vec3 array in the shader from a Color3 array.
  17160. * @param name Define the name of the uniform as defined in the shader
  17161. * @param value Define the value to give to the uniform
  17162. * @return the material itself allowing "fluent" like uniform updates
  17163. */
  17164. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17165. /**
  17166. * Set a vec4 in the shader from a Color4.
  17167. * @param name Define the name of the uniform as defined in the shader
  17168. * @param value Define the value to give to the uniform
  17169. * @return the material itself allowing "fluent" like uniform updates
  17170. */
  17171. setColor4(name: string, value: Color4): ShaderMaterial;
  17172. /**
  17173. * Set a vec4 array in the shader from a Color4 array.
  17174. * @param name Define the name of the uniform as defined in the shader
  17175. * @param value Define the value to give to the uniform
  17176. * @return the material itself allowing "fluent" like uniform updates
  17177. */
  17178. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17179. /**
  17180. * Set a vec2 in the shader from a Vector2.
  17181. * @param name Define the name of the uniform as defined in the shader
  17182. * @param value Define the value to give to the uniform
  17183. * @return the material itself allowing "fluent" like uniform updates
  17184. */
  17185. setVector2(name: string, value: Vector2): ShaderMaterial;
  17186. /**
  17187. * Set a vec3 in the shader from a Vector3.
  17188. * @param name Define the name of the uniform as defined in the shader
  17189. * @param value Define the value to give to the uniform
  17190. * @return the material itself allowing "fluent" like uniform updates
  17191. */
  17192. setVector3(name: string, value: Vector3): ShaderMaterial;
  17193. /**
  17194. * Set a vec4 in the shader from a Vector4.
  17195. * @param name Define the name of the uniform as defined in the shader
  17196. * @param value Define the value to give to the uniform
  17197. * @return the material itself allowing "fluent" like uniform updates
  17198. */
  17199. setVector4(name: string, value: Vector4): ShaderMaterial;
  17200. /**
  17201. * Set a mat4 in the shader from a Matrix.
  17202. * @param name Define the name of the uniform as defined in the shader
  17203. * @param value Define the value to give to the uniform
  17204. * @return the material itself allowing "fluent" like uniform updates
  17205. */
  17206. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17207. /**
  17208. * Set a float32Array in the shader from a matrix array.
  17209. * @param name Define the name of the uniform as defined in the shader
  17210. * @param value Define the value to give to the uniform
  17211. * @return the material itself allowing "fluent" like uniform updates
  17212. */
  17213. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17214. /**
  17215. * Set a mat3 in the shader from a Float32Array.
  17216. * @param name Define the name of the uniform as defined in the shader
  17217. * @param value Define the value to give to the uniform
  17218. * @return the material itself allowing "fluent" like uniform updates
  17219. */
  17220. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17221. /**
  17222. * Set a mat2 in the shader from a Float32Array.
  17223. * @param name Define the name of the uniform as defined in the shader
  17224. * @param value Define the value to give to the uniform
  17225. * @return the material itself allowing "fluent" like uniform updates
  17226. */
  17227. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17228. /**
  17229. * Set a vec2 array in the shader from a number array.
  17230. * @param name Define the name of the uniform as defined in the shader
  17231. * @param value Define the value to give to the uniform
  17232. * @return the material itself allowing "fluent" like uniform updates
  17233. */
  17234. setArray2(name: string, value: number[]): ShaderMaterial;
  17235. /**
  17236. * Set a vec3 array in the shader from a number array.
  17237. * @param name Define the name of the uniform as defined in the shader
  17238. * @param value Define the value to give to the uniform
  17239. * @return the material itself allowing "fluent" like uniform updates
  17240. */
  17241. setArray3(name: string, value: number[]): ShaderMaterial;
  17242. /**
  17243. * Set a vec4 array in the shader from a number array.
  17244. * @param name Define the name of the uniform as defined in the shader
  17245. * @param value Define the value to give to the uniform
  17246. * @return the material itself allowing "fluent" like uniform updates
  17247. */
  17248. setArray4(name: string, value: number[]): ShaderMaterial;
  17249. private _checkCache;
  17250. /**
  17251. * Specifies that the submesh is ready to be used
  17252. * @param mesh defines the mesh to check
  17253. * @param subMesh defines which submesh to check
  17254. * @param useInstances specifies that instances should be used
  17255. * @returns a boolean indicating that the submesh is ready or not
  17256. */
  17257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17258. /**
  17259. * Checks if the material is ready to render the requested mesh
  17260. * @param mesh Define the mesh to render
  17261. * @param useInstances Define whether or not the material is used with instances
  17262. * @returns true if ready, otherwise false
  17263. */
  17264. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17265. /**
  17266. * Binds the world matrix to the material
  17267. * @param world defines the world transformation matrix
  17268. * @param effectOverride - If provided, use this effect instead of internal effect
  17269. */
  17270. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17271. /**
  17272. * Binds the submesh to this material by preparing the effect and shader to draw
  17273. * @param world defines the world transformation matrix
  17274. * @param mesh defines the mesh containing the submesh
  17275. * @param subMesh defines the submesh to bind the material to
  17276. */
  17277. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17278. /**
  17279. * Binds the material to the mesh
  17280. * @param world defines the world transformation matrix
  17281. * @param mesh defines the mesh to bind the material to
  17282. * @param effectOverride - If provided, use this effect instead of internal effect
  17283. */
  17284. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17285. protected _afterBind(mesh?: Mesh): void;
  17286. /**
  17287. * Gets the active textures from the material
  17288. * @returns an array of textures
  17289. */
  17290. getActiveTextures(): BaseTexture[];
  17291. /**
  17292. * Specifies if the material uses a texture
  17293. * @param texture defines the texture to check against the material
  17294. * @returns a boolean specifying if the material uses the texture
  17295. */
  17296. hasTexture(texture: BaseTexture): boolean;
  17297. /**
  17298. * Makes a duplicate of the material, and gives it a new name
  17299. * @param name defines the new name for the duplicated material
  17300. * @returns the cloned material
  17301. */
  17302. clone(name: string): ShaderMaterial;
  17303. /**
  17304. * Disposes the material
  17305. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17306. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17307. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17308. */
  17309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17310. /**
  17311. * Serializes this material in a JSON representation
  17312. * @returns the serialized material object
  17313. */
  17314. serialize(): any;
  17315. /**
  17316. * Creates a shader material from parsed shader material data
  17317. * @param source defines the JSON represnetation of the material
  17318. * @param scene defines the hosting scene
  17319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17320. * @returns a new material
  17321. */
  17322. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17323. /**
  17324. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17325. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17326. * @param url defines the url to load from
  17327. * @param scene defines the hosting scene
  17328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17329. * @returns a promise that will resolve to the new ShaderMaterial
  17330. */
  17331. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17332. /**
  17333. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17334. * @param snippetId defines the snippet to load
  17335. * @param scene defines the hosting scene
  17336. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17337. * @returns a promise that will resolve to the new ShaderMaterial
  17338. */
  17339. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17340. }
  17341. }
  17342. declare module "babylonjs/Shaders/color.fragment" {
  17343. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17344. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17345. /** @hidden */
  17346. export var colorPixelShader: {
  17347. name: string;
  17348. shader: string;
  17349. };
  17350. }
  17351. declare module "babylonjs/Shaders/color.vertex" {
  17352. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17353. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17354. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17355. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17356. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17358. /** @hidden */
  17359. export var colorVertexShader: {
  17360. name: string;
  17361. shader: string;
  17362. };
  17363. }
  17364. declare module "babylonjs/Meshes/linesMesh" {
  17365. import { Nullable } from "babylonjs/types";
  17366. import { Scene } from "babylonjs/scene";
  17367. import { Color3 } from "babylonjs/Maths/math.color";
  17368. import { Node } from "babylonjs/node";
  17369. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17370. import { Mesh } from "babylonjs/Meshes/mesh";
  17371. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17372. import { Effect } from "babylonjs/Materials/effect";
  17373. import { Material } from "babylonjs/Materials/material";
  17374. import "babylonjs/Shaders/color.fragment";
  17375. import "babylonjs/Shaders/color.vertex";
  17376. /**
  17377. * Line mesh
  17378. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17379. */
  17380. export class LinesMesh extends Mesh {
  17381. /**
  17382. * If vertex color should be applied to the mesh
  17383. */
  17384. readonly useVertexColor?: boolean | undefined;
  17385. /**
  17386. * If vertex alpha should be applied to the mesh
  17387. */
  17388. readonly useVertexAlpha?: boolean | undefined;
  17389. /**
  17390. * Color of the line (Default: White)
  17391. */
  17392. color: Color3;
  17393. /**
  17394. * Alpha of the line (Default: 1)
  17395. */
  17396. alpha: number;
  17397. /**
  17398. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17399. * This margin is expressed in world space coordinates, so its value may vary.
  17400. * Default value is 0.1
  17401. */
  17402. intersectionThreshold: number;
  17403. private _colorShader;
  17404. private color4;
  17405. /**
  17406. * Creates a new LinesMesh
  17407. * @param name defines the name
  17408. * @param scene defines the hosting scene
  17409. * @param parent defines the parent mesh if any
  17410. * @param source defines the optional source LinesMesh used to clone data from
  17411. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17412. * When false, achieved by calling a clone(), also passing False.
  17413. * This will make creation of children, recursive.
  17414. * @param useVertexColor defines if this LinesMesh supports vertex color
  17415. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17416. */
  17417. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17418. /**
  17419. * If vertex color should be applied to the mesh
  17420. */
  17421. useVertexColor?: boolean | undefined,
  17422. /**
  17423. * If vertex alpha should be applied to the mesh
  17424. */
  17425. useVertexAlpha?: boolean | undefined);
  17426. private _addClipPlaneDefine;
  17427. private _removeClipPlaneDefine;
  17428. isReady(): boolean;
  17429. /**
  17430. * Returns the string "LineMesh"
  17431. */
  17432. getClassName(): string;
  17433. /**
  17434. * @hidden
  17435. */
  17436. get material(): Material;
  17437. /**
  17438. * @hidden
  17439. */
  17440. set material(value: Material);
  17441. /**
  17442. * @hidden
  17443. */
  17444. get checkCollisions(): boolean;
  17445. /** @hidden */
  17446. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17447. /** @hidden */
  17448. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17449. /**
  17450. * Disposes of the line mesh
  17451. * @param doNotRecurse If children should be disposed
  17452. */
  17453. dispose(doNotRecurse?: boolean): void;
  17454. /**
  17455. * Returns a new LineMesh object cloned from the current one.
  17456. */
  17457. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17458. /**
  17459. * Creates a new InstancedLinesMesh object from the mesh model.
  17460. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17461. * @param name defines the name of the new instance
  17462. * @returns a new InstancedLinesMesh
  17463. */
  17464. createInstance(name: string): InstancedLinesMesh;
  17465. }
  17466. /**
  17467. * Creates an instance based on a source LinesMesh
  17468. */
  17469. export class InstancedLinesMesh extends InstancedMesh {
  17470. /**
  17471. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17472. * This margin is expressed in world space coordinates, so its value may vary.
  17473. * Initilized with the intersectionThreshold value of the source LinesMesh
  17474. */
  17475. intersectionThreshold: number;
  17476. constructor(name: string, source: LinesMesh);
  17477. /**
  17478. * Returns the string "InstancedLinesMesh".
  17479. */
  17480. getClassName(): string;
  17481. }
  17482. }
  17483. declare module "babylonjs/Shaders/line.fragment" {
  17484. /** @hidden */
  17485. export var linePixelShader: {
  17486. name: string;
  17487. shader: string;
  17488. };
  17489. }
  17490. declare module "babylonjs/Shaders/line.vertex" {
  17491. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17492. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17493. /** @hidden */
  17494. export var lineVertexShader: {
  17495. name: string;
  17496. shader: string;
  17497. };
  17498. }
  17499. declare module "babylonjs/Rendering/edgesRenderer" {
  17500. import { Nullable } from "babylonjs/types";
  17501. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17503. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17504. import { IDisposable } from "babylonjs/scene";
  17505. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17506. import "babylonjs/Shaders/line.fragment";
  17507. import "babylonjs/Shaders/line.vertex";
  17508. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17509. import { SmartArray } from "babylonjs/Misc/smartArray";
  17510. module "babylonjs/scene" {
  17511. interface Scene {
  17512. /** @hidden */
  17513. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17514. }
  17515. }
  17516. module "babylonjs/Meshes/abstractMesh" {
  17517. interface AbstractMesh {
  17518. /**
  17519. * Gets the edgesRenderer associated with the mesh
  17520. */
  17521. edgesRenderer: Nullable<EdgesRenderer>;
  17522. }
  17523. }
  17524. module "babylonjs/Meshes/linesMesh" {
  17525. interface LinesMesh {
  17526. /**
  17527. * Enables the edge rendering mode on the mesh.
  17528. * This mode makes the mesh edges visible
  17529. * @param epsilon defines the maximal distance between two angles to detect a face
  17530. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17531. * @returns the currentAbstractMesh
  17532. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17533. */
  17534. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17535. }
  17536. }
  17537. module "babylonjs/Meshes/linesMesh" {
  17538. interface InstancedLinesMesh {
  17539. /**
  17540. * Enables the edge rendering mode on the mesh.
  17541. * This mode makes the mesh edges visible
  17542. * @param epsilon defines the maximal distance between two angles to detect a face
  17543. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17544. * @returns the current InstancedLinesMesh
  17545. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17546. */
  17547. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17548. }
  17549. }
  17550. /**
  17551. * Defines the minimum contract an Edges renderer should follow.
  17552. */
  17553. export interface IEdgesRenderer extends IDisposable {
  17554. /**
  17555. * Gets or sets a boolean indicating if the edgesRenderer is active
  17556. */
  17557. isEnabled: boolean;
  17558. /**
  17559. * Renders the edges of the attached mesh,
  17560. */
  17561. render(): void;
  17562. /**
  17563. * Checks wether or not the edges renderer is ready to render.
  17564. * @return true if ready, otherwise false.
  17565. */
  17566. isReady(): boolean;
  17567. /**
  17568. * List of instances to render in case the source mesh has instances
  17569. */
  17570. customInstances: SmartArray<Matrix>;
  17571. }
  17572. /**
  17573. * Defines the additional options of the edges renderer
  17574. */
  17575. export interface IEdgesRendererOptions {
  17576. /**
  17577. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17578. * If not defined, the default value is true
  17579. */
  17580. useAlternateEdgeFinder?: boolean;
  17581. /**
  17582. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17583. * If not defined, the default value is true.
  17584. * 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)
  17585. * This option is used only if useAlternateEdgeFinder = true
  17586. */
  17587. useFastVertexMerger?: boolean;
  17588. /**
  17589. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17590. * The default value is 1e-6
  17591. * This option is used only if useAlternateEdgeFinder = true
  17592. */
  17593. epsilonVertexMerge?: number;
  17594. /**
  17595. * 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
  17596. * 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.
  17597. * This option is used only if useAlternateEdgeFinder = true
  17598. */
  17599. applyTessellation?: boolean;
  17600. /**
  17601. * 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
  17602. * The default value is 1e-6
  17603. * This option is used only if useAlternateEdgeFinder = true
  17604. */
  17605. epsilonVertexAligned?: number;
  17606. }
  17607. /**
  17608. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17609. */
  17610. export class EdgesRenderer implements IEdgesRenderer {
  17611. /**
  17612. * Define the size of the edges with an orthographic camera
  17613. */
  17614. edgesWidthScalerForOrthographic: number;
  17615. /**
  17616. * Define the size of the edges with a perspective camera
  17617. */
  17618. edgesWidthScalerForPerspective: number;
  17619. protected _source: AbstractMesh;
  17620. protected _linesPositions: number[];
  17621. protected _linesNormals: number[];
  17622. protected _linesIndices: number[];
  17623. protected _epsilon: number;
  17624. protected _indicesCount: number;
  17625. protected _lineShader: ShaderMaterial;
  17626. protected _ib: DataBuffer;
  17627. protected _buffers: {
  17628. [key: string]: Nullable<VertexBuffer>;
  17629. };
  17630. protected _buffersForInstances: {
  17631. [key: string]: Nullable<VertexBuffer>;
  17632. };
  17633. protected _checkVerticesInsteadOfIndices: boolean;
  17634. protected _options: Nullable<IEdgesRendererOptions>;
  17635. private _meshRebuildObserver;
  17636. private _meshDisposeObserver;
  17637. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17638. isEnabled: boolean;
  17639. /**
  17640. * List of instances to render in case the source mesh has instances
  17641. */
  17642. customInstances: SmartArray<Matrix>;
  17643. private static GetShader;
  17644. /**
  17645. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17646. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17647. * @param source Mesh used to create edges
  17648. * @param epsilon sum of angles in adjacency to check for edge
  17649. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17650. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17651. * @param options The options to apply when generating the edges
  17652. */
  17653. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17654. protected _prepareRessources(): void;
  17655. /** @hidden */
  17656. _rebuild(): void;
  17657. /**
  17658. * Releases the required resources for the edges renderer
  17659. */
  17660. dispose(): void;
  17661. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17662. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17663. /**
  17664. * Checks if the pair of p0 and p1 is en edge
  17665. * @param faceIndex
  17666. * @param edge
  17667. * @param faceNormals
  17668. * @param p0
  17669. * @param p1
  17670. * @private
  17671. */
  17672. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17673. /**
  17674. * push line into the position, normal and index buffer
  17675. * @protected
  17676. */
  17677. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17678. /**
  17679. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17680. */
  17681. private _tessellateTriangle;
  17682. private _generateEdgesLinesAlternate;
  17683. /**
  17684. * Generates lines edges from adjacencjes
  17685. * @private
  17686. */
  17687. _generateEdgesLines(): void;
  17688. /**
  17689. * Checks wether or not the edges renderer is ready to render.
  17690. * @return true if ready, otherwise false.
  17691. */
  17692. isReady(): boolean;
  17693. /**
  17694. * Renders the edges of the attached mesh,
  17695. */
  17696. render(): void;
  17697. }
  17698. /**
  17699. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17700. */
  17701. export class LineEdgesRenderer extends EdgesRenderer {
  17702. /**
  17703. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17704. * @param source LineMesh used to generate edges
  17705. * @param epsilon not important (specified angle for edge detection)
  17706. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17707. */
  17708. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17709. /**
  17710. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17711. */
  17712. _generateEdgesLines(): void;
  17713. }
  17714. }
  17715. declare module "babylonjs/Rendering/renderingGroup" {
  17716. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17719. import { Nullable } from "babylonjs/types";
  17720. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17721. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17722. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17723. import { Material } from "babylonjs/Materials/material";
  17724. import { Scene } from "babylonjs/scene";
  17725. /**
  17726. * This represents the object necessary to create a rendering group.
  17727. * This is exclusively used and created by the rendering manager.
  17728. * To modify the behavior, you use the available helpers in your scene or meshes.
  17729. * @hidden
  17730. */
  17731. export class RenderingGroup {
  17732. index: number;
  17733. private static _zeroVector;
  17734. private _scene;
  17735. private _opaqueSubMeshes;
  17736. private _transparentSubMeshes;
  17737. private _alphaTestSubMeshes;
  17738. private _depthOnlySubMeshes;
  17739. private _particleSystems;
  17740. private _spriteManagers;
  17741. private _opaqueSortCompareFn;
  17742. private _alphaTestSortCompareFn;
  17743. private _transparentSortCompareFn;
  17744. private _renderOpaque;
  17745. private _renderAlphaTest;
  17746. private _renderTransparent;
  17747. /** @hidden */
  17748. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17749. onBeforeTransparentRendering: () => void;
  17750. /**
  17751. * Set the opaque sort comparison function.
  17752. * If null the sub meshes will be render in the order they were created
  17753. */
  17754. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17755. /**
  17756. * Set the alpha test sort comparison function.
  17757. * If null the sub meshes will be render in the order they were created
  17758. */
  17759. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17760. /**
  17761. * Set the transparent sort comparison function.
  17762. * If null the sub meshes will be render in the order they were created
  17763. */
  17764. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17765. /**
  17766. * Creates a new rendering group.
  17767. * @param index The rendering group index
  17768. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17769. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17770. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17771. */
  17772. 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>);
  17773. /**
  17774. * Render all the sub meshes contained in the group.
  17775. * @param customRenderFunction Used to override the default render behaviour of the group.
  17776. * @returns true if rendered some submeshes.
  17777. */
  17778. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17779. /**
  17780. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17781. * @param subMeshes The submeshes to render
  17782. */
  17783. private renderOpaqueSorted;
  17784. /**
  17785. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17786. * @param subMeshes The submeshes to render
  17787. */
  17788. private renderAlphaTestSorted;
  17789. /**
  17790. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17791. * @param subMeshes The submeshes to render
  17792. */
  17793. private renderTransparentSorted;
  17794. /**
  17795. * Renders the submeshes in a specified order.
  17796. * @param subMeshes The submeshes to sort before render
  17797. * @param sortCompareFn The comparison function use to sort
  17798. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17799. * @param transparent Specifies to activate blending if true
  17800. */
  17801. private static renderSorted;
  17802. /**
  17803. * Renders the submeshes in the order they were dispatched (no sort applied).
  17804. * @param subMeshes The submeshes to render
  17805. */
  17806. private static renderUnsorted;
  17807. /**
  17808. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17809. * are rendered back to front if in the same alpha index.
  17810. *
  17811. * @param a The first submesh
  17812. * @param b The second submesh
  17813. * @returns The result of the comparison
  17814. */
  17815. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17816. /**
  17817. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17818. * are rendered back to front.
  17819. *
  17820. * @param a The first submesh
  17821. * @param b The second submesh
  17822. * @returns The result of the comparison
  17823. */
  17824. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17825. /**
  17826. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17827. * are rendered front to back (prevent overdraw).
  17828. *
  17829. * @param a The first submesh
  17830. * @param b The second submesh
  17831. * @returns The result of the comparison
  17832. */
  17833. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17834. /**
  17835. * Resets the different lists of submeshes to prepare a new frame.
  17836. */
  17837. prepare(): void;
  17838. dispose(): void;
  17839. /**
  17840. * Inserts the submesh in its correct queue depending on its material.
  17841. * @param subMesh The submesh to dispatch
  17842. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17843. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17844. */
  17845. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17846. dispatchSprites(spriteManager: ISpriteManager): void;
  17847. dispatchParticles(particleSystem: IParticleSystem): void;
  17848. private _renderParticles;
  17849. private _renderSprites;
  17850. }
  17851. }
  17852. declare module "babylonjs/Rendering/renderingManager" {
  17853. import { Nullable } from "babylonjs/types";
  17854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17856. import { SmartArray } from "babylonjs/Misc/smartArray";
  17857. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17858. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17859. import { Material } from "babylonjs/Materials/material";
  17860. import { Scene } from "babylonjs/scene";
  17861. import { Camera } from "babylonjs/Cameras/camera";
  17862. /**
  17863. * Interface describing the different options available in the rendering manager
  17864. * regarding Auto Clear between groups.
  17865. */
  17866. export interface IRenderingManagerAutoClearSetup {
  17867. /**
  17868. * Defines whether or not autoclear is enable.
  17869. */
  17870. autoClear: boolean;
  17871. /**
  17872. * Defines whether or not to autoclear the depth buffer.
  17873. */
  17874. depth: boolean;
  17875. /**
  17876. * Defines whether or not to autoclear the stencil buffer.
  17877. */
  17878. stencil: boolean;
  17879. }
  17880. /**
  17881. * This class is used by the onRenderingGroupObservable
  17882. */
  17883. export class RenderingGroupInfo {
  17884. /**
  17885. * The Scene that being rendered
  17886. */
  17887. scene: Scene;
  17888. /**
  17889. * The camera currently used for the rendering pass
  17890. */
  17891. camera: Nullable<Camera>;
  17892. /**
  17893. * The ID of the renderingGroup being processed
  17894. */
  17895. renderingGroupId: number;
  17896. }
  17897. /**
  17898. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17899. * It is enable to manage the different groups as well as the different necessary sort functions.
  17900. * This should not be used directly aside of the few static configurations
  17901. */
  17902. export class RenderingManager {
  17903. /**
  17904. * The max id used for rendering groups (not included)
  17905. */
  17906. static MAX_RENDERINGGROUPS: number;
  17907. /**
  17908. * The min id used for rendering groups (included)
  17909. */
  17910. static MIN_RENDERINGGROUPS: number;
  17911. /**
  17912. * Used to globally prevent autoclearing scenes.
  17913. */
  17914. static AUTOCLEAR: boolean;
  17915. /**
  17916. * @hidden
  17917. */
  17918. _useSceneAutoClearSetup: boolean;
  17919. private _scene;
  17920. private _renderingGroups;
  17921. private _depthStencilBufferAlreadyCleaned;
  17922. private _autoClearDepthStencil;
  17923. private _customOpaqueSortCompareFn;
  17924. private _customAlphaTestSortCompareFn;
  17925. private _customTransparentSortCompareFn;
  17926. private _renderingGroupInfo;
  17927. /**
  17928. * Instantiates a new rendering group for a particular scene
  17929. * @param scene Defines the scene the groups belongs to
  17930. */
  17931. constructor(scene: Scene);
  17932. private _clearDepthStencilBuffer;
  17933. /**
  17934. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17935. * @hidden
  17936. */
  17937. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17938. /**
  17939. * Resets the different information of the group to prepare a new frame
  17940. * @hidden
  17941. */
  17942. reset(): void;
  17943. /**
  17944. * Dispose and release the group and its associated resources.
  17945. * @hidden
  17946. */
  17947. dispose(): void;
  17948. /**
  17949. * Clear the info related to rendering groups preventing retention points during dispose.
  17950. */
  17951. freeRenderingGroups(): void;
  17952. private _prepareRenderingGroup;
  17953. /**
  17954. * Add a sprite manager to the rendering manager in order to render it this frame.
  17955. * @param spriteManager Define the sprite manager to render
  17956. */
  17957. dispatchSprites(spriteManager: ISpriteManager): void;
  17958. /**
  17959. * Add a particle system to the rendering manager in order to render it this frame.
  17960. * @param particleSystem Define the particle system to render
  17961. */
  17962. dispatchParticles(particleSystem: IParticleSystem): void;
  17963. /**
  17964. * Add a submesh to the manager in order to render it this frame
  17965. * @param subMesh The submesh to dispatch
  17966. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17967. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17968. */
  17969. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17970. /**
  17971. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17972. * This allowed control for front to back rendering or reversly depending of the special needs.
  17973. *
  17974. * @param renderingGroupId The rendering group id corresponding to its index
  17975. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17976. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17977. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17978. */
  17979. 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;
  17980. /**
  17981. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17982. *
  17983. * @param renderingGroupId The rendering group id corresponding to its index
  17984. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17985. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17986. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17987. */
  17988. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17989. /**
  17990. * Gets the current auto clear configuration for one rendering group of the rendering
  17991. * manager.
  17992. * @param index the rendering group index to get the information for
  17993. * @returns The auto clear setup for the requested rendering group
  17994. */
  17995. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17996. }
  17997. }
  17998. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17999. import { SmartArray } from "babylonjs/Misc/smartArray";
  18000. import { Nullable } from "babylonjs/types";
  18001. import { Scene } from "babylonjs/scene";
  18002. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18003. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18005. import { Mesh } from "babylonjs/Meshes/mesh";
  18006. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18007. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18008. import { Effect } from "babylonjs/Materials/effect";
  18009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18010. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18011. import "babylonjs/Shaders/shadowMap.fragment";
  18012. import "babylonjs/Shaders/shadowMap.vertex";
  18013. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18014. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18015. import { Observable } from "babylonjs/Misc/observable";
  18016. /**
  18017. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18018. */
  18019. export interface ICustomShaderOptions {
  18020. /**
  18021. * Gets or sets the custom shader name to use
  18022. */
  18023. shaderName: string;
  18024. /**
  18025. * The list of attribute names used in the shader
  18026. */
  18027. attributes?: string[];
  18028. /**
  18029. * The list of unifrom names used in the shader
  18030. */
  18031. uniforms?: string[];
  18032. /**
  18033. * The list of sampler names used in the shader
  18034. */
  18035. samplers?: string[];
  18036. /**
  18037. * The list of defines used in the shader
  18038. */
  18039. defines?: string[];
  18040. }
  18041. /**
  18042. * Interface to implement to create a shadow generator compatible with BJS.
  18043. */
  18044. export interface IShadowGenerator {
  18045. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18046. id: string;
  18047. /**
  18048. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18049. * @returns The render target texture if present otherwise, null
  18050. */
  18051. getShadowMap(): Nullable<RenderTargetTexture>;
  18052. /**
  18053. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18054. * @param subMesh The submesh we want to render in the shadow map
  18055. * @param useInstances Defines wether will draw in the map using instances
  18056. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18057. * @returns true if ready otherwise, false
  18058. */
  18059. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18060. /**
  18061. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18062. * @param defines Defines of the material we want to update
  18063. * @param lightIndex Index of the light in the enabled light list of the material
  18064. */
  18065. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18066. /**
  18067. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18068. * defined in the generator but impacting the effect).
  18069. * It implies the unifroms available on the materials are the standard BJS ones.
  18070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18071. * @param effect The effect we are binfing the information for
  18072. */
  18073. bindShadowLight(lightIndex: string, effect: Effect): void;
  18074. /**
  18075. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18076. * (eq to shadow prjection matrix * light transform matrix)
  18077. * @returns The transform matrix used to create the shadow map
  18078. */
  18079. getTransformMatrix(): Matrix;
  18080. /**
  18081. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18082. * Cube and 2D textures for instance.
  18083. */
  18084. recreateShadowMap(): void;
  18085. /**
  18086. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18087. * @param onCompiled Callback triggered at the and of the effects compilation
  18088. * @param options Sets of optional options forcing the compilation with different modes
  18089. */
  18090. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18091. useInstances: boolean;
  18092. }>): void;
  18093. /**
  18094. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18095. * @param options Sets of optional options forcing the compilation with different modes
  18096. * @returns A promise that resolves when the compilation completes
  18097. */
  18098. forceCompilationAsync(options?: Partial<{
  18099. useInstances: boolean;
  18100. }>): Promise<void>;
  18101. /**
  18102. * Serializes the shadow generator setup to a json object.
  18103. * @returns The serialized JSON object
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Disposes the Shadow map and related Textures and effects.
  18108. */
  18109. dispose(): void;
  18110. }
  18111. /**
  18112. * Default implementation IShadowGenerator.
  18113. * This is the main object responsible of generating shadows in the framework.
  18114. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18115. */
  18116. export class ShadowGenerator implements IShadowGenerator {
  18117. /**
  18118. * Name of the shadow generator class
  18119. */
  18120. static CLASSNAME: string;
  18121. /**
  18122. * Shadow generator mode None: no filtering applied.
  18123. */
  18124. static readonly FILTER_NONE: number;
  18125. /**
  18126. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18127. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18128. */
  18129. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18130. /**
  18131. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18132. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18133. */
  18134. static readonly FILTER_POISSONSAMPLING: number;
  18135. /**
  18136. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18137. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18138. */
  18139. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18140. /**
  18141. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18142. * edge artifacts on steep falloff.
  18143. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18144. */
  18145. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18146. /**
  18147. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18148. * edge artifacts on steep falloff.
  18149. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18150. */
  18151. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18152. /**
  18153. * Shadow generator mode PCF: Percentage Closer Filtering
  18154. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18155. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18156. */
  18157. static readonly FILTER_PCF: number;
  18158. /**
  18159. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18160. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18161. * Contact Hardening
  18162. */
  18163. static readonly FILTER_PCSS: number;
  18164. /**
  18165. * Reserved for PCF and PCSS
  18166. * Highest Quality.
  18167. *
  18168. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18169. *
  18170. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18171. */
  18172. static readonly QUALITY_HIGH: number;
  18173. /**
  18174. * Reserved for PCF and PCSS
  18175. * Good tradeoff for quality/perf cross devices
  18176. *
  18177. * Execute PCF on a 3*3 kernel.
  18178. *
  18179. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18180. */
  18181. static readonly QUALITY_MEDIUM: number;
  18182. /**
  18183. * Reserved for PCF and PCSS
  18184. * The lowest quality but the fastest.
  18185. *
  18186. * Execute PCF on a 1*1 kernel.
  18187. *
  18188. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18189. */
  18190. static readonly QUALITY_LOW: number;
  18191. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18192. id: string;
  18193. /** Gets or sets the custom shader name to use */
  18194. customShaderOptions: ICustomShaderOptions;
  18195. /**
  18196. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18197. */
  18198. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18199. /**
  18200. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18201. */
  18202. onAfterShadowMapRenderObservable: Observable<Effect>;
  18203. /**
  18204. * Observable triggered before a mesh is rendered in the shadow map.
  18205. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18206. */
  18207. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18208. /**
  18209. * Observable triggered after a mesh is rendered in the shadow map.
  18210. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18211. */
  18212. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18213. protected _bias: number;
  18214. /**
  18215. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18216. */
  18217. get bias(): number;
  18218. /**
  18219. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18220. */
  18221. set bias(bias: number);
  18222. protected _normalBias: number;
  18223. /**
  18224. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18225. */
  18226. get normalBias(): number;
  18227. /**
  18228. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18229. */
  18230. set normalBias(normalBias: number);
  18231. protected _blurBoxOffset: number;
  18232. /**
  18233. * Gets the blur box offset: offset applied during the blur pass.
  18234. * Only useful if useKernelBlur = false
  18235. */
  18236. get blurBoxOffset(): number;
  18237. /**
  18238. * Sets the blur box offset: offset applied during the blur pass.
  18239. * Only useful if useKernelBlur = false
  18240. */
  18241. set blurBoxOffset(value: number);
  18242. protected _blurScale: number;
  18243. /**
  18244. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18245. * 2 means half of the size.
  18246. */
  18247. get blurScale(): number;
  18248. /**
  18249. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18250. * 2 means half of the size.
  18251. */
  18252. set blurScale(value: number);
  18253. protected _blurKernel: number;
  18254. /**
  18255. * Gets the blur kernel: kernel size of the blur pass.
  18256. * Only useful if useKernelBlur = true
  18257. */
  18258. get blurKernel(): number;
  18259. /**
  18260. * Sets the blur kernel: kernel size of the blur pass.
  18261. * Only useful if useKernelBlur = true
  18262. */
  18263. set blurKernel(value: number);
  18264. protected _useKernelBlur: boolean;
  18265. /**
  18266. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18267. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18268. */
  18269. get useKernelBlur(): boolean;
  18270. /**
  18271. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18272. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18273. */
  18274. set useKernelBlur(value: boolean);
  18275. protected _depthScale: number;
  18276. /**
  18277. * Gets the depth scale used in ESM mode.
  18278. */
  18279. get depthScale(): number;
  18280. /**
  18281. * Sets the depth scale used in ESM mode.
  18282. * This can override the scale stored on the light.
  18283. */
  18284. set depthScale(value: number);
  18285. protected _validateFilter(filter: number): number;
  18286. protected _filter: number;
  18287. /**
  18288. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18289. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18290. */
  18291. get filter(): number;
  18292. /**
  18293. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18294. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18295. */
  18296. set filter(value: number);
  18297. /**
  18298. * Gets if the current filter is set to Poisson Sampling.
  18299. */
  18300. get usePoissonSampling(): boolean;
  18301. /**
  18302. * Sets the current filter to Poisson Sampling.
  18303. */
  18304. set usePoissonSampling(value: boolean);
  18305. /**
  18306. * Gets if the current filter is set to ESM.
  18307. */
  18308. get useExponentialShadowMap(): boolean;
  18309. /**
  18310. * Sets the current filter is to ESM.
  18311. */
  18312. set useExponentialShadowMap(value: boolean);
  18313. /**
  18314. * Gets if the current filter is set to filtered ESM.
  18315. */
  18316. get useBlurExponentialShadowMap(): boolean;
  18317. /**
  18318. * Gets if the current filter is set to filtered ESM.
  18319. */
  18320. set useBlurExponentialShadowMap(value: boolean);
  18321. /**
  18322. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18323. * exponential to prevent steep falloff artifacts).
  18324. */
  18325. get useCloseExponentialShadowMap(): boolean;
  18326. /**
  18327. * Sets the current filter to "close ESM" (using the inverse of the
  18328. * exponential to prevent steep falloff artifacts).
  18329. */
  18330. set useCloseExponentialShadowMap(value: boolean);
  18331. /**
  18332. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18333. * exponential to prevent steep falloff artifacts).
  18334. */
  18335. get useBlurCloseExponentialShadowMap(): boolean;
  18336. /**
  18337. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18338. * exponential to prevent steep falloff artifacts).
  18339. */
  18340. set useBlurCloseExponentialShadowMap(value: boolean);
  18341. /**
  18342. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18343. */
  18344. get usePercentageCloserFiltering(): boolean;
  18345. /**
  18346. * Sets the current filter to "PCF" (percentage closer filtering).
  18347. */
  18348. set usePercentageCloserFiltering(value: boolean);
  18349. protected _filteringQuality: number;
  18350. /**
  18351. * Gets the PCF or PCSS Quality.
  18352. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18353. */
  18354. get filteringQuality(): number;
  18355. /**
  18356. * Sets the PCF or PCSS Quality.
  18357. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18358. */
  18359. set filteringQuality(filteringQuality: number);
  18360. /**
  18361. * Gets if the current filter is set to "PCSS" (contact hardening).
  18362. */
  18363. get useContactHardeningShadow(): boolean;
  18364. /**
  18365. * Sets the current filter to "PCSS" (contact hardening).
  18366. */
  18367. set useContactHardeningShadow(value: boolean);
  18368. protected _contactHardeningLightSizeUVRatio: number;
  18369. /**
  18370. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18371. * Using a ratio helps keeping shape stability independently of the map size.
  18372. *
  18373. * It does not account for the light projection as it was having too much
  18374. * instability during the light setup or during light position changes.
  18375. *
  18376. * Only valid if useContactHardeningShadow is true.
  18377. */
  18378. get contactHardeningLightSizeUVRatio(): number;
  18379. /**
  18380. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18381. * Using a ratio helps keeping shape stability independently of the map size.
  18382. *
  18383. * It does not account for the light projection as it was having too much
  18384. * instability during the light setup or during light position changes.
  18385. *
  18386. * Only valid if useContactHardeningShadow is true.
  18387. */
  18388. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18389. protected _darkness: number;
  18390. /** Gets or sets the actual darkness of a shadow */
  18391. get darkness(): number;
  18392. set darkness(value: number);
  18393. /**
  18394. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18395. * 0 means strongest and 1 would means no shadow.
  18396. * @returns the darkness.
  18397. */
  18398. getDarkness(): number;
  18399. /**
  18400. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18401. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18402. * @returns the shadow generator allowing fluent coding.
  18403. */
  18404. setDarkness(darkness: number): ShadowGenerator;
  18405. protected _transparencyShadow: boolean;
  18406. /** Gets or sets the ability to have transparent shadow */
  18407. get transparencyShadow(): boolean;
  18408. set transparencyShadow(value: boolean);
  18409. /**
  18410. * Sets the ability to have transparent shadow (boolean).
  18411. * @param transparent True if transparent else False
  18412. * @returns the shadow generator allowing fluent coding
  18413. */
  18414. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18415. /**
  18416. * Enables or disables shadows with varying strength based on the transparency
  18417. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18418. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18419. * mesh.visibility * alphaTexture.a
  18420. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18421. */
  18422. enableSoftTransparentShadow: boolean;
  18423. protected _shadowMap: Nullable<RenderTargetTexture>;
  18424. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18425. /**
  18426. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18427. * @returns The render target texture if present otherwise, null
  18428. */
  18429. getShadowMap(): Nullable<RenderTargetTexture>;
  18430. /**
  18431. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18432. * @returns The render target texture if the shadow map is present otherwise, null
  18433. */
  18434. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18435. /**
  18436. * Gets the class name of that object
  18437. * @returns "ShadowGenerator"
  18438. */
  18439. getClassName(): string;
  18440. /**
  18441. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18442. * @param mesh Mesh to add
  18443. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18444. * @returns the Shadow Generator itself
  18445. */
  18446. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18447. /**
  18448. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18449. * @param mesh Mesh to remove
  18450. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18451. * @returns the Shadow Generator itself
  18452. */
  18453. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18454. /**
  18455. * Controls the extent to which the shadows fade out at the edge of the frustum
  18456. */
  18457. frustumEdgeFalloff: number;
  18458. protected _light: IShadowLight;
  18459. /**
  18460. * Returns the associated light object.
  18461. * @returns the light generating the shadow
  18462. */
  18463. getLight(): IShadowLight;
  18464. /**
  18465. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18466. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18467. * It might on the other hand introduce peter panning.
  18468. */
  18469. forceBackFacesOnly: boolean;
  18470. protected _scene: Scene;
  18471. protected _lightDirection: Vector3;
  18472. protected _effect: Effect;
  18473. protected _viewMatrix: Matrix;
  18474. protected _projectionMatrix: Matrix;
  18475. protected _transformMatrix: Matrix;
  18476. protected _cachedPosition: Vector3;
  18477. protected _cachedDirection: Vector3;
  18478. protected _cachedDefines: string;
  18479. protected _currentRenderID: number;
  18480. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18481. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18482. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18483. protected _blurPostProcesses: PostProcess[];
  18484. protected _mapSize: number;
  18485. protected _currentFaceIndex: number;
  18486. protected _currentFaceIndexCache: number;
  18487. protected _textureType: number;
  18488. protected _defaultTextureMatrix: Matrix;
  18489. protected _storedUniqueId: Nullable<number>;
  18490. /** @hidden */
  18491. static _SceneComponentInitialization: (scene: Scene) => void;
  18492. /**
  18493. * Creates a ShadowGenerator object.
  18494. * A ShadowGenerator is the required tool to use the shadows.
  18495. * Each light casting shadows needs to use its own ShadowGenerator.
  18496. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18497. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18498. * @param light The light object generating the shadows.
  18499. * @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.
  18500. */
  18501. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18502. protected _initializeGenerator(): void;
  18503. protected _createTargetRenderTexture(): void;
  18504. protected _initializeShadowMap(): void;
  18505. protected _initializeBlurRTTAndPostProcesses(): void;
  18506. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18507. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18508. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18509. protected _applyFilterValues(): void;
  18510. /**
  18511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18512. * @param onCompiled Callback triggered at the and of the effects compilation
  18513. * @param options Sets of optional options forcing the compilation with different modes
  18514. */
  18515. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18516. useInstances: boolean;
  18517. }>): void;
  18518. /**
  18519. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18520. * @param options Sets of optional options forcing the compilation with different modes
  18521. * @returns A promise that resolves when the compilation completes
  18522. */
  18523. forceCompilationAsync(options?: Partial<{
  18524. useInstances: boolean;
  18525. }>): Promise<void>;
  18526. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18527. private _prepareShadowDefines;
  18528. /**
  18529. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18530. * @param subMesh The submesh we want to render in the shadow map
  18531. * @param useInstances Defines wether will draw in the map using instances
  18532. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18533. * @returns true if ready otherwise, false
  18534. */
  18535. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18536. /**
  18537. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18538. * @param defines Defines of the material we want to update
  18539. * @param lightIndex Index of the light in the enabled light list of the material
  18540. */
  18541. prepareDefines(defines: any, lightIndex: number): void;
  18542. /**
  18543. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18544. * defined in the generator but impacting the effect).
  18545. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18546. * @param effect The effect we are binfing the information for
  18547. */
  18548. bindShadowLight(lightIndex: string, effect: Effect): void;
  18549. /**
  18550. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18551. * (eq to shadow prjection matrix * light transform matrix)
  18552. * @returns The transform matrix used to create the shadow map
  18553. */
  18554. getTransformMatrix(): Matrix;
  18555. /**
  18556. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18557. * Cube and 2D textures for instance.
  18558. */
  18559. recreateShadowMap(): void;
  18560. protected _disposeBlurPostProcesses(): void;
  18561. protected _disposeRTTandPostProcesses(): void;
  18562. /**
  18563. * Disposes the ShadowGenerator.
  18564. * Returns nothing.
  18565. */
  18566. dispose(): void;
  18567. /**
  18568. * Serializes the shadow generator setup to a json object.
  18569. * @returns The serialized JSON object
  18570. */
  18571. serialize(): any;
  18572. /**
  18573. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18574. * @param parsedShadowGenerator The JSON object to parse
  18575. * @param scene The scene to create the shadow map for
  18576. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18577. * @returns The parsed shadow generator
  18578. */
  18579. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18580. }
  18581. }
  18582. declare module "babylonjs/Lights/light" {
  18583. import { Nullable } from "babylonjs/types";
  18584. import { Scene } from "babylonjs/scene";
  18585. import { Vector3 } from "babylonjs/Maths/math.vector";
  18586. import { Color3 } from "babylonjs/Maths/math.color";
  18587. import { Node } from "babylonjs/node";
  18588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18589. import { Effect } from "babylonjs/Materials/effect";
  18590. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18591. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18592. /**
  18593. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18594. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18595. * 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.
  18596. */
  18597. export abstract class Light extends Node {
  18598. /**
  18599. * Falloff Default: light is falling off following the material specification:
  18600. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18601. */
  18602. static readonly FALLOFF_DEFAULT: number;
  18603. /**
  18604. * Falloff Physical: light is falling off following the inverse squared distance law.
  18605. */
  18606. static readonly FALLOFF_PHYSICAL: number;
  18607. /**
  18608. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18609. * to enhance interoperability with other engines.
  18610. */
  18611. static readonly FALLOFF_GLTF: number;
  18612. /**
  18613. * Falloff Standard: light is falling off like in the standard material
  18614. * to enhance interoperability with other materials.
  18615. */
  18616. static readonly FALLOFF_STANDARD: number;
  18617. /**
  18618. * If every light affecting the material is in this lightmapMode,
  18619. * material.lightmapTexture adds or multiplies
  18620. * (depends on material.useLightmapAsShadowmap)
  18621. * after every other light calculations.
  18622. */
  18623. static readonly LIGHTMAP_DEFAULT: number;
  18624. /**
  18625. * material.lightmapTexture as only diffuse lighting from this light
  18626. * adds only specular lighting from this light
  18627. * adds dynamic shadows
  18628. */
  18629. static readonly LIGHTMAP_SPECULAR: number;
  18630. /**
  18631. * material.lightmapTexture as only lighting
  18632. * no light calculation from this light
  18633. * only adds dynamic shadows from this light
  18634. */
  18635. static readonly LIGHTMAP_SHADOWSONLY: number;
  18636. /**
  18637. * Each light type uses the default quantity according to its type:
  18638. * point/spot lights use luminous intensity
  18639. * directional lights use illuminance
  18640. */
  18641. static readonly INTENSITYMODE_AUTOMATIC: number;
  18642. /**
  18643. * lumen (lm)
  18644. */
  18645. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18646. /**
  18647. * candela (lm/sr)
  18648. */
  18649. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18650. /**
  18651. * lux (lm/m^2)
  18652. */
  18653. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18654. /**
  18655. * nit (cd/m^2)
  18656. */
  18657. static readonly INTENSITYMODE_LUMINANCE: number;
  18658. /**
  18659. * Light type const id of the point light.
  18660. */
  18661. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18662. /**
  18663. * Light type const id of the directional light.
  18664. */
  18665. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18666. /**
  18667. * Light type const id of the spot light.
  18668. */
  18669. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18670. /**
  18671. * Light type const id of the hemispheric light.
  18672. */
  18673. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18674. /**
  18675. * Diffuse gives the basic color to an object.
  18676. */
  18677. diffuse: Color3;
  18678. /**
  18679. * Specular produces a highlight color on an object.
  18680. * Note: This is note affecting PBR materials.
  18681. */
  18682. specular: Color3;
  18683. /**
  18684. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18685. * falling off base on range or angle.
  18686. * This can be set to any values in Light.FALLOFF_x.
  18687. *
  18688. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18689. * other types of materials.
  18690. */
  18691. falloffType: number;
  18692. /**
  18693. * Strength of the light.
  18694. * Note: By default it is define in the framework own unit.
  18695. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18696. */
  18697. intensity: number;
  18698. private _range;
  18699. protected _inverseSquaredRange: number;
  18700. /**
  18701. * Defines how far from the source the light is impacting in scene units.
  18702. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18703. */
  18704. get range(): number;
  18705. /**
  18706. * Defines how far from the source the light is impacting in scene units.
  18707. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18708. */
  18709. set range(value: number);
  18710. /**
  18711. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18712. * of light.
  18713. */
  18714. private _photometricScale;
  18715. private _intensityMode;
  18716. /**
  18717. * Gets the photometric scale used to interpret the intensity.
  18718. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18719. */
  18720. get intensityMode(): number;
  18721. /**
  18722. * Sets the photometric scale used to interpret the intensity.
  18723. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18724. */
  18725. set intensityMode(value: number);
  18726. private _radius;
  18727. /**
  18728. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18729. */
  18730. get radius(): number;
  18731. /**
  18732. * sets the light radius used by PBR Materials to simulate soft area lights.
  18733. */
  18734. set radius(value: number);
  18735. private _renderPriority;
  18736. /**
  18737. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18738. * exceeding the number allowed of the materials.
  18739. */
  18740. renderPriority: number;
  18741. private _shadowEnabled;
  18742. /**
  18743. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18744. * the current shadow generator.
  18745. */
  18746. get shadowEnabled(): boolean;
  18747. /**
  18748. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18749. * the current shadow generator.
  18750. */
  18751. set shadowEnabled(value: boolean);
  18752. private _includedOnlyMeshes;
  18753. /**
  18754. * Gets the only meshes impacted by this light.
  18755. */
  18756. get includedOnlyMeshes(): AbstractMesh[];
  18757. /**
  18758. * Sets the only meshes impacted by this light.
  18759. */
  18760. set includedOnlyMeshes(value: AbstractMesh[]);
  18761. private _excludedMeshes;
  18762. /**
  18763. * Gets the meshes not impacted by this light.
  18764. */
  18765. get excludedMeshes(): AbstractMesh[];
  18766. /**
  18767. * Sets the meshes not impacted by this light.
  18768. */
  18769. set excludedMeshes(value: AbstractMesh[]);
  18770. private _excludeWithLayerMask;
  18771. /**
  18772. * Gets the layer id use to find what meshes are not impacted by the light.
  18773. * Inactive if 0
  18774. */
  18775. get excludeWithLayerMask(): number;
  18776. /**
  18777. * Sets the layer id use to find what meshes are not impacted by the light.
  18778. * Inactive if 0
  18779. */
  18780. set excludeWithLayerMask(value: number);
  18781. private _includeOnlyWithLayerMask;
  18782. /**
  18783. * Gets the layer id use to find what meshes are impacted by the light.
  18784. * Inactive if 0
  18785. */
  18786. get includeOnlyWithLayerMask(): number;
  18787. /**
  18788. * Sets the layer id use to find what meshes are impacted by the light.
  18789. * Inactive if 0
  18790. */
  18791. set includeOnlyWithLayerMask(value: number);
  18792. private _lightmapMode;
  18793. /**
  18794. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18795. */
  18796. get lightmapMode(): number;
  18797. /**
  18798. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18799. */
  18800. set lightmapMode(value: number);
  18801. /**
  18802. * Shadow generator associted to the light.
  18803. * @hidden Internal use only.
  18804. */
  18805. _shadowGenerator: Nullable<IShadowGenerator>;
  18806. /**
  18807. * @hidden Internal use only.
  18808. */
  18809. _excludedMeshesIds: string[];
  18810. /**
  18811. * @hidden Internal use only.
  18812. */
  18813. _includedOnlyMeshesIds: string[];
  18814. /**
  18815. * The current light unifom buffer.
  18816. * @hidden Internal use only.
  18817. */
  18818. _uniformBuffer: UniformBuffer;
  18819. /** @hidden */
  18820. _renderId: number;
  18821. /**
  18822. * Creates a Light object in the scene.
  18823. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18824. * @param name The firendly name of the light
  18825. * @param scene The scene the light belongs too
  18826. */
  18827. constructor(name: string, scene: Scene);
  18828. protected abstract _buildUniformLayout(): void;
  18829. /**
  18830. * Sets the passed Effect "effect" with the Light information.
  18831. * @param effect The effect to update
  18832. * @param lightIndex The index of the light in the effect to update
  18833. * @returns The light
  18834. */
  18835. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18836. /**
  18837. * Sets the passed Effect "effect" with the Light textures.
  18838. * @param effect The effect to update
  18839. * @param lightIndex The index of the light in the effect to update
  18840. * @returns The light
  18841. */
  18842. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18843. /**
  18844. * Binds the lights information from the scene to the effect for the given mesh.
  18845. * @param lightIndex Light index
  18846. * @param scene The scene where the light belongs to
  18847. * @param effect The effect we are binding the data to
  18848. * @param useSpecular Defines if specular is supported
  18849. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18850. */
  18851. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18852. /**
  18853. * Sets the passed Effect "effect" with the Light information.
  18854. * @param effect The effect to update
  18855. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18856. * @returns The light
  18857. */
  18858. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18859. /**
  18860. * Returns the string "Light".
  18861. * @returns the class name
  18862. */
  18863. getClassName(): string;
  18864. /** @hidden */
  18865. readonly _isLight: boolean;
  18866. /**
  18867. * Converts the light information to a readable string for debug purpose.
  18868. * @param fullDetails Supports for multiple levels of logging within scene loading
  18869. * @returns the human readable light info
  18870. */
  18871. toString(fullDetails?: boolean): string;
  18872. /** @hidden */
  18873. protected _syncParentEnabledState(): void;
  18874. /**
  18875. * Set the enabled state of this node.
  18876. * @param value - the new enabled state
  18877. */
  18878. setEnabled(value: boolean): void;
  18879. /**
  18880. * Returns the Light associated shadow generator if any.
  18881. * @return the associated shadow generator.
  18882. */
  18883. getShadowGenerator(): Nullable<IShadowGenerator>;
  18884. /**
  18885. * Returns a Vector3, the absolute light position in the World.
  18886. * @returns the world space position of the light
  18887. */
  18888. getAbsolutePosition(): Vector3;
  18889. /**
  18890. * Specifies if the light will affect the passed mesh.
  18891. * @param mesh The mesh to test against the light
  18892. * @return true the mesh is affected otherwise, false.
  18893. */
  18894. canAffectMesh(mesh: AbstractMesh): boolean;
  18895. /**
  18896. * Sort function to order lights for rendering.
  18897. * @param a First Light object to compare to second.
  18898. * @param b Second Light object to compare first.
  18899. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18900. */
  18901. static CompareLightsPriority(a: Light, b: Light): number;
  18902. /**
  18903. * Releases resources associated with this node.
  18904. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18905. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18906. */
  18907. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18908. /**
  18909. * Returns the light type ID (integer).
  18910. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18911. */
  18912. getTypeID(): number;
  18913. /**
  18914. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18915. * @returns the scaled intensity in intensity mode unit
  18916. */
  18917. getScaledIntensity(): number;
  18918. /**
  18919. * Returns a new Light object, named "name", from the current one.
  18920. * @param name The name of the cloned light
  18921. * @param newParent The parent of this light, if it has one
  18922. * @returns the new created light
  18923. */
  18924. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18925. /**
  18926. * Serializes the current light into a Serialization object.
  18927. * @returns the serialized object.
  18928. */
  18929. serialize(): any;
  18930. /**
  18931. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18932. * This new light is named "name" and added to the passed scene.
  18933. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18934. * @param name The friendly name of the light
  18935. * @param scene The scene the new light will belong to
  18936. * @returns the constructor function
  18937. */
  18938. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18939. /**
  18940. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18941. * @param parsedLight The JSON representation of the light
  18942. * @param scene The scene to create the parsed light in
  18943. * @returns the created light after parsing
  18944. */
  18945. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18946. private _hookArrayForExcluded;
  18947. private _hookArrayForIncludedOnly;
  18948. private _resyncMeshes;
  18949. /**
  18950. * Forces the meshes to update their light related information in their rendering used effects
  18951. * @hidden Internal Use Only
  18952. */
  18953. _markMeshesAsLightDirty(): void;
  18954. /**
  18955. * Recomputes the cached photometric scale if needed.
  18956. */
  18957. private _computePhotometricScale;
  18958. /**
  18959. * Returns the Photometric Scale according to the light type and intensity mode.
  18960. */
  18961. private _getPhotometricScale;
  18962. /**
  18963. * Reorder the light in the scene according to their defined priority.
  18964. * @hidden Internal Use Only
  18965. */
  18966. _reorderLightsInScene(): void;
  18967. /**
  18968. * Prepares the list of defines specific to the light type.
  18969. * @param defines the list of defines
  18970. * @param lightIndex defines the index of the light for the effect
  18971. */
  18972. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18973. }
  18974. }
  18975. declare module "babylonjs/Materials/prePassConfiguration" {
  18976. import { Matrix } from "babylonjs/Maths/math.vector";
  18977. import { Mesh } from "babylonjs/Meshes/mesh";
  18978. import { Scene } from "babylonjs/scene";
  18979. import { Effect } from "babylonjs/Materials/effect";
  18980. /**
  18981. * Configuration needed for prepass-capable materials
  18982. */
  18983. export class PrePassConfiguration {
  18984. /**
  18985. * Previous world matrices of meshes carrying this material
  18986. * Used for computing velocity
  18987. */
  18988. previousWorldMatrices: {
  18989. [index: number]: Matrix;
  18990. };
  18991. /**
  18992. * Previous view project matrix
  18993. * Used for computing velocity
  18994. */
  18995. previousViewProjection: Matrix;
  18996. /**
  18997. * Previous bones of meshes carrying this material
  18998. * Used for computing velocity
  18999. */
  19000. previousBones: {
  19001. [index: number]: Float32Array;
  19002. };
  19003. /**
  19004. * Add the required uniforms to the current list.
  19005. * @param uniforms defines the current uniform list.
  19006. */
  19007. static AddUniforms(uniforms: string[]): void;
  19008. /**
  19009. * Add the required samplers to the current list.
  19010. * @param samplers defines the current sampler list.
  19011. */
  19012. static AddSamplers(samplers: string[]): void;
  19013. /**
  19014. * Binds the material data.
  19015. * @param effect defines the effect to update
  19016. * @param scene defines the scene the material belongs to.
  19017. * @param mesh The mesh
  19018. * @param world World matrix of this mesh
  19019. * @param isFrozen Is the material frozen
  19020. */
  19021. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19022. }
  19023. }
  19024. declare module "babylonjs/Cameras/targetCamera" {
  19025. import { Nullable } from "babylonjs/types";
  19026. import { Camera } from "babylonjs/Cameras/camera";
  19027. import { Scene } from "babylonjs/scene";
  19028. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19029. /**
  19030. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19031. * This is the base of the follow, arc rotate cameras and Free camera
  19032. * @see https://doc.babylonjs.com/features/cameras
  19033. */
  19034. export class TargetCamera extends Camera {
  19035. private static _RigCamTransformMatrix;
  19036. private static _TargetTransformMatrix;
  19037. private static _TargetFocalPoint;
  19038. private _tmpUpVector;
  19039. private _tmpTargetVector;
  19040. /**
  19041. * Define the current direction the camera is moving to
  19042. */
  19043. cameraDirection: Vector3;
  19044. /**
  19045. * Define the current rotation the camera is rotating to
  19046. */
  19047. cameraRotation: Vector2;
  19048. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19049. ignoreParentScaling: boolean;
  19050. /**
  19051. * When set, the up vector of the camera will be updated by the rotation of the camera
  19052. */
  19053. updateUpVectorFromRotation: boolean;
  19054. private _tmpQuaternion;
  19055. /**
  19056. * Define the current rotation of the camera
  19057. */
  19058. rotation: Vector3;
  19059. /**
  19060. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19061. */
  19062. rotationQuaternion: Quaternion;
  19063. /**
  19064. * Define the current speed of the camera
  19065. */
  19066. speed: number;
  19067. /**
  19068. * Add constraint to the camera to prevent it to move freely in all directions and
  19069. * around all axis.
  19070. */
  19071. noRotationConstraint: boolean;
  19072. /**
  19073. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19074. * panning
  19075. */
  19076. invertRotation: boolean;
  19077. /**
  19078. * Speed multiplier for inverse camera panning
  19079. */
  19080. inverseRotationSpeed: number;
  19081. /**
  19082. * Define the current target of the camera as an object or a position.
  19083. */
  19084. lockedTarget: any;
  19085. /** @hidden */
  19086. _currentTarget: Vector3;
  19087. /** @hidden */
  19088. _initialFocalDistance: number;
  19089. /** @hidden */
  19090. _viewMatrix: Matrix;
  19091. /** @hidden */
  19092. _camMatrix: Matrix;
  19093. /** @hidden */
  19094. _cameraTransformMatrix: Matrix;
  19095. /** @hidden */
  19096. _cameraRotationMatrix: Matrix;
  19097. /** @hidden */
  19098. _referencePoint: Vector3;
  19099. /** @hidden */
  19100. _transformedReferencePoint: Vector3;
  19101. /** @hidden */
  19102. _reset: () => void;
  19103. private _defaultUp;
  19104. /**
  19105. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19106. * This is the base of the follow, arc rotate cameras and Free camera
  19107. * @see https://doc.babylonjs.com/features/cameras
  19108. * @param name Defines the name of the camera in the scene
  19109. * @param position Defines the start position of the camera in the scene
  19110. * @param scene Defines the scene the camera belongs to
  19111. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19112. */
  19113. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19114. /**
  19115. * Gets the position in front of the camera at a given distance.
  19116. * @param distance The distance from the camera we want the position to be
  19117. * @returns the position
  19118. */
  19119. getFrontPosition(distance: number): Vector3;
  19120. /** @hidden */
  19121. _getLockedTargetPosition(): Nullable<Vector3>;
  19122. private _storedPosition;
  19123. private _storedRotation;
  19124. private _storedRotationQuaternion;
  19125. /**
  19126. * Store current camera state of the camera (fov, position, rotation, etc..)
  19127. * @returns the camera
  19128. */
  19129. storeState(): Camera;
  19130. /**
  19131. * Restored camera state. You must call storeState() first
  19132. * @returns whether it was successful or not
  19133. * @hidden
  19134. */
  19135. _restoreStateValues(): boolean;
  19136. /** @hidden */
  19137. _initCache(): void;
  19138. /** @hidden */
  19139. _updateCache(ignoreParentClass?: boolean): void;
  19140. /** @hidden */
  19141. _isSynchronizedViewMatrix(): boolean;
  19142. /** @hidden */
  19143. _computeLocalCameraSpeed(): number;
  19144. /**
  19145. * Defines the target the camera should look at.
  19146. * @param target Defines the new target as a Vector or a mesh
  19147. */
  19148. setTarget(target: Vector3): void;
  19149. /**
  19150. * Defines the target point of the camera.
  19151. * The camera looks towards it form the radius distance.
  19152. */
  19153. get target(): Vector3;
  19154. set target(value: Vector3);
  19155. /**
  19156. * Return the current target position of the camera. This value is expressed in local space.
  19157. * @returns the target position
  19158. */
  19159. getTarget(): Vector3;
  19160. /** @hidden */
  19161. _decideIfNeedsToMove(): boolean;
  19162. /** @hidden */
  19163. _updatePosition(): void;
  19164. /** @hidden */
  19165. _checkInputs(): void;
  19166. protected _updateCameraRotationMatrix(): void;
  19167. /**
  19168. * 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)
  19169. * @returns the current camera
  19170. */
  19171. private _rotateUpVectorWithCameraRotationMatrix;
  19172. private _cachedRotationZ;
  19173. private _cachedQuaternionRotationZ;
  19174. /** @hidden */
  19175. _getViewMatrix(): Matrix;
  19176. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19177. /**
  19178. * @hidden
  19179. */
  19180. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19181. /**
  19182. * @hidden
  19183. */
  19184. _updateRigCameras(): void;
  19185. private _getRigCamPositionAndTarget;
  19186. /**
  19187. * Gets the current object class name.
  19188. * @return the class name
  19189. */
  19190. getClassName(): string;
  19191. }
  19192. }
  19193. declare module "babylonjs/Events/keyboardEvents" {
  19194. /**
  19195. * Gather the list of keyboard event types as constants.
  19196. */
  19197. export class KeyboardEventTypes {
  19198. /**
  19199. * The keydown event is fired when a key becomes active (pressed).
  19200. */
  19201. static readonly KEYDOWN: number;
  19202. /**
  19203. * The keyup event is fired when a key has been released.
  19204. */
  19205. static readonly KEYUP: number;
  19206. }
  19207. /**
  19208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19209. */
  19210. export class KeyboardInfo {
  19211. /**
  19212. * Defines the type of event (KeyboardEventTypes)
  19213. */
  19214. type: number;
  19215. /**
  19216. * Defines the related dom event
  19217. */
  19218. event: KeyboardEvent;
  19219. /**
  19220. * Instantiates a new keyboard info.
  19221. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19222. * @param type Defines the type of event (KeyboardEventTypes)
  19223. * @param event Defines the related dom event
  19224. */
  19225. constructor(
  19226. /**
  19227. * Defines the type of event (KeyboardEventTypes)
  19228. */
  19229. type: number,
  19230. /**
  19231. * Defines the related dom event
  19232. */
  19233. event: KeyboardEvent);
  19234. }
  19235. /**
  19236. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19237. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19238. */
  19239. export class KeyboardInfoPre extends KeyboardInfo {
  19240. /**
  19241. * Defines the type of event (KeyboardEventTypes)
  19242. */
  19243. type: number;
  19244. /**
  19245. * Defines the related dom event
  19246. */
  19247. event: KeyboardEvent;
  19248. /**
  19249. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19250. */
  19251. skipOnPointerObservable: boolean;
  19252. /**
  19253. * Instantiates a new keyboard pre info.
  19254. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19255. * @param type Defines the type of event (KeyboardEventTypes)
  19256. * @param event Defines the related dom event
  19257. */
  19258. constructor(
  19259. /**
  19260. * Defines the type of event (KeyboardEventTypes)
  19261. */
  19262. type: number,
  19263. /**
  19264. * Defines the related dom event
  19265. */
  19266. event: KeyboardEvent);
  19267. }
  19268. }
  19269. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19270. import { Nullable } from "babylonjs/types";
  19271. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19272. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19273. /**
  19274. * Manage the keyboard inputs to control the movement of a free camera.
  19275. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19276. */
  19277. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19278. /**
  19279. * Defines the camera the input is attached to.
  19280. */
  19281. camera: FreeCamera;
  19282. /**
  19283. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19284. */
  19285. keysUp: number[];
  19286. /**
  19287. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19288. */
  19289. keysUpward: number[];
  19290. /**
  19291. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19292. */
  19293. keysDown: number[];
  19294. /**
  19295. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19296. */
  19297. keysDownward: number[];
  19298. /**
  19299. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19300. */
  19301. keysLeft: number[];
  19302. /**
  19303. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19304. */
  19305. keysRight: number[];
  19306. private _keys;
  19307. private _onCanvasBlurObserver;
  19308. private _onKeyboardObserver;
  19309. private _engine;
  19310. private _scene;
  19311. /**
  19312. * Attach the input controls to a specific dom element to get the input from.
  19313. * @param element Defines the element the controls should be listened from
  19314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19315. */
  19316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19317. /**
  19318. * Detach the current controls from the specified dom element.
  19319. * @param element Defines the element to stop listening the inputs from
  19320. */
  19321. detachControl(element: Nullable<HTMLElement>): void;
  19322. /**
  19323. * Update the current camera state depending on the inputs that have been used this frame.
  19324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19325. */
  19326. checkInputs(): void;
  19327. /**
  19328. * Gets the class name of the current intput.
  19329. * @returns the class name
  19330. */
  19331. getClassName(): string;
  19332. /** @hidden */
  19333. _onLostFocus(): void;
  19334. /**
  19335. * Get the friendly name associated with the input class.
  19336. * @returns the input friendly name
  19337. */
  19338. getSimpleName(): string;
  19339. }
  19340. }
  19341. declare module "babylonjs/Events/pointerEvents" {
  19342. import { Nullable } from "babylonjs/types";
  19343. import { Vector2 } from "babylonjs/Maths/math.vector";
  19344. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19345. import { Ray } from "babylonjs/Culling/ray";
  19346. /**
  19347. * Gather the list of pointer event types as constants.
  19348. */
  19349. export class PointerEventTypes {
  19350. /**
  19351. * 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.
  19352. */
  19353. static readonly POINTERDOWN: number;
  19354. /**
  19355. * The pointerup event is fired when a pointer is no longer active.
  19356. */
  19357. static readonly POINTERUP: number;
  19358. /**
  19359. * The pointermove event is fired when a pointer changes coordinates.
  19360. */
  19361. static readonly POINTERMOVE: number;
  19362. /**
  19363. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19364. */
  19365. static readonly POINTERWHEEL: number;
  19366. /**
  19367. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19368. */
  19369. static readonly POINTERPICK: number;
  19370. /**
  19371. * The pointertap event is fired when a the object has been touched and released without drag.
  19372. */
  19373. static readonly POINTERTAP: number;
  19374. /**
  19375. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19376. */
  19377. static readonly POINTERDOUBLETAP: number;
  19378. }
  19379. /**
  19380. * Base class of pointer info types.
  19381. */
  19382. export class PointerInfoBase {
  19383. /**
  19384. * Defines the type of event (PointerEventTypes)
  19385. */
  19386. type: number;
  19387. /**
  19388. * Defines the related dom event
  19389. */
  19390. event: PointerEvent | MouseWheelEvent;
  19391. /**
  19392. * Instantiates the base class of pointers info.
  19393. * @param type Defines the type of event (PointerEventTypes)
  19394. * @param event Defines the related dom event
  19395. */
  19396. constructor(
  19397. /**
  19398. * Defines the type of event (PointerEventTypes)
  19399. */
  19400. type: number,
  19401. /**
  19402. * Defines the related dom event
  19403. */
  19404. event: PointerEvent | MouseWheelEvent);
  19405. }
  19406. /**
  19407. * This class is used to store pointer related info for the onPrePointerObservable event.
  19408. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19409. */
  19410. export class PointerInfoPre extends PointerInfoBase {
  19411. /**
  19412. * Ray from a pointer if availible (eg. 6dof controller)
  19413. */
  19414. ray: Nullable<Ray>;
  19415. /**
  19416. * Defines the local position of the pointer on the canvas.
  19417. */
  19418. localPosition: Vector2;
  19419. /**
  19420. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19421. */
  19422. skipOnPointerObservable: boolean;
  19423. /**
  19424. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19425. * @param type Defines the type of event (PointerEventTypes)
  19426. * @param event Defines the related dom event
  19427. * @param localX Defines the local x coordinates of the pointer when the event occured
  19428. * @param localY Defines the local y coordinates of the pointer when the event occured
  19429. */
  19430. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19431. }
  19432. /**
  19433. * This type contains all the data related to a pointer event in Babylon.js.
  19434. * 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.
  19435. */
  19436. export class PointerInfo extends PointerInfoBase {
  19437. /**
  19438. * Defines the picking info associated to the info (if any)\
  19439. */
  19440. pickInfo: Nullable<PickingInfo>;
  19441. /**
  19442. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19443. * @param type Defines the type of event (PointerEventTypes)
  19444. * @param event Defines the related dom event
  19445. * @param pickInfo Defines the picking info associated to the info (if any)\
  19446. */
  19447. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19448. /**
  19449. * Defines the picking info associated to the info (if any)\
  19450. */
  19451. pickInfo: Nullable<PickingInfo>);
  19452. }
  19453. /**
  19454. * Data relating to a touch event on the screen.
  19455. */
  19456. export interface PointerTouch {
  19457. /**
  19458. * X coordinate of touch.
  19459. */
  19460. x: number;
  19461. /**
  19462. * Y coordinate of touch.
  19463. */
  19464. y: number;
  19465. /**
  19466. * Id of touch. Unique for each finger.
  19467. */
  19468. pointerId: number;
  19469. /**
  19470. * Event type passed from DOM.
  19471. */
  19472. type: any;
  19473. }
  19474. }
  19475. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19476. import { Observable } from "babylonjs/Misc/observable";
  19477. import { Nullable } from "babylonjs/types";
  19478. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19479. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19480. /**
  19481. * Manage the mouse inputs to control the movement of a free camera.
  19482. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19483. */
  19484. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19485. /**
  19486. * Define if touch is enabled in the mouse input
  19487. */
  19488. touchEnabled: boolean;
  19489. /**
  19490. * Defines the camera the input is attached to.
  19491. */
  19492. camera: FreeCamera;
  19493. /**
  19494. * Defines the buttons associated with the input to handle camera move.
  19495. */
  19496. buttons: number[];
  19497. /**
  19498. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19499. */
  19500. angularSensibility: number;
  19501. private _pointerInput;
  19502. private _onMouseMove;
  19503. private _observer;
  19504. private previousPosition;
  19505. /**
  19506. * Observable for when a pointer move event occurs containing the move offset
  19507. */
  19508. onPointerMovedObservable: Observable<{
  19509. offsetX: number;
  19510. offsetY: number;
  19511. }>;
  19512. /**
  19513. * @hidden
  19514. * If the camera should be rotated automatically based on pointer movement
  19515. */
  19516. _allowCameraRotation: boolean;
  19517. /**
  19518. * Manage the mouse inputs to control the movement of a free camera.
  19519. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19520. * @param touchEnabled Defines if touch is enabled or not
  19521. */
  19522. constructor(
  19523. /**
  19524. * Define if touch is enabled in the mouse input
  19525. */
  19526. touchEnabled?: boolean);
  19527. /**
  19528. * Attach the input controls to a specific dom element to get the input from.
  19529. * @param element Defines the element the controls should be listened from
  19530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19531. */
  19532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19533. /**
  19534. * Called on JS contextmenu event.
  19535. * Override this method to provide functionality.
  19536. */
  19537. protected onContextMenu(evt: PointerEvent): void;
  19538. /**
  19539. * Detach the current controls from the specified dom element.
  19540. * @param element Defines the element to stop listening the inputs from
  19541. */
  19542. detachControl(element: Nullable<HTMLElement>): void;
  19543. /**
  19544. * Gets the class name of the current intput.
  19545. * @returns the class name
  19546. */
  19547. getClassName(): string;
  19548. /**
  19549. * Get the friendly name associated with the input class.
  19550. * @returns the input friendly name
  19551. */
  19552. getSimpleName(): string;
  19553. }
  19554. }
  19555. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19556. import { Nullable } from "babylonjs/types";
  19557. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19558. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19559. /**
  19560. * Manage the touch inputs to control the movement of a free camera.
  19561. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19562. */
  19563. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19564. /**
  19565. * Define if mouse events can be treated as touch events
  19566. */
  19567. allowMouse: boolean;
  19568. /**
  19569. * Defines the camera the input is attached to.
  19570. */
  19571. camera: FreeCamera;
  19572. /**
  19573. * Defines the touch sensibility for rotation.
  19574. * The higher the faster.
  19575. */
  19576. touchAngularSensibility: number;
  19577. /**
  19578. * Defines the touch sensibility for move.
  19579. * The higher the faster.
  19580. */
  19581. touchMoveSensibility: number;
  19582. private _offsetX;
  19583. private _offsetY;
  19584. private _pointerPressed;
  19585. private _pointerInput;
  19586. private _observer;
  19587. private _onLostFocus;
  19588. /**
  19589. * Manage the touch inputs to control the movement of a free camera.
  19590. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19591. * @param allowMouse Defines if mouse events can be treated as touch events
  19592. */
  19593. constructor(
  19594. /**
  19595. * Define if mouse events can be treated as touch events
  19596. */
  19597. allowMouse?: boolean);
  19598. /**
  19599. * Attach the input controls to a specific dom element to get the input from.
  19600. * @param element Defines the element the controls should be listened from
  19601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19602. */
  19603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19604. /**
  19605. * Detach the current controls from the specified dom element.
  19606. * @param element Defines the element to stop listening the inputs from
  19607. */
  19608. detachControl(element: Nullable<HTMLElement>): void;
  19609. /**
  19610. * Update the current camera state depending on the inputs that have been used this frame.
  19611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19612. */
  19613. checkInputs(): void;
  19614. /**
  19615. * Gets the class name of the current intput.
  19616. * @returns the class name
  19617. */
  19618. getClassName(): string;
  19619. /**
  19620. * Get the friendly name associated with the input class.
  19621. * @returns the input friendly name
  19622. */
  19623. getSimpleName(): string;
  19624. }
  19625. }
  19626. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19627. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19628. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19629. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19630. import { Nullable } from "babylonjs/types";
  19631. /**
  19632. * Default Inputs manager for the FreeCamera.
  19633. * It groups all the default supported inputs for ease of use.
  19634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19635. */
  19636. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19637. /**
  19638. * @hidden
  19639. */
  19640. _mouseInput: Nullable<FreeCameraMouseInput>;
  19641. /**
  19642. * Instantiates a new FreeCameraInputsManager.
  19643. * @param camera Defines the camera the inputs belong to
  19644. */
  19645. constructor(camera: FreeCamera);
  19646. /**
  19647. * Add keyboard input support to the input manager.
  19648. * @returns the current input manager
  19649. */
  19650. addKeyboard(): FreeCameraInputsManager;
  19651. /**
  19652. * Add mouse input support to the input manager.
  19653. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19654. * @returns the current input manager
  19655. */
  19656. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19657. /**
  19658. * Removes the mouse input support from the manager
  19659. * @returns the current input manager
  19660. */
  19661. removeMouse(): FreeCameraInputsManager;
  19662. /**
  19663. * Add touch input support to the input manager.
  19664. * @returns the current input manager
  19665. */
  19666. addTouch(): FreeCameraInputsManager;
  19667. /**
  19668. * Remove all attached input methods from a camera
  19669. */
  19670. clear(): void;
  19671. }
  19672. }
  19673. declare module "babylonjs/Cameras/freeCamera" {
  19674. import { Vector3 } from "babylonjs/Maths/math.vector";
  19675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19676. import { Scene } from "babylonjs/scene";
  19677. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19678. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19679. /**
  19680. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19681. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19682. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19683. */
  19684. export class FreeCamera extends TargetCamera {
  19685. /**
  19686. * Define the collision ellipsoid of the camera.
  19687. * This is helpful to simulate a camera body like the player body around the camera
  19688. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19689. */
  19690. ellipsoid: Vector3;
  19691. /**
  19692. * Define an offset for the position of the ellipsoid around the camera.
  19693. * This can be helpful to determine the center of the body near the gravity center of the body
  19694. * instead of its head.
  19695. */
  19696. ellipsoidOffset: Vector3;
  19697. /**
  19698. * Enable or disable collisions of the camera with the rest of the scene objects.
  19699. */
  19700. checkCollisions: boolean;
  19701. /**
  19702. * Enable or disable gravity on the camera.
  19703. */
  19704. applyGravity: boolean;
  19705. /**
  19706. * Define the input manager associated to the camera.
  19707. */
  19708. inputs: FreeCameraInputsManager;
  19709. /**
  19710. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19711. * Higher values reduce sensitivity.
  19712. */
  19713. get angularSensibility(): number;
  19714. /**
  19715. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19716. * Higher values reduce sensitivity.
  19717. */
  19718. set angularSensibility(value: number);
  19719. /**
  19720. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19721. */
  19722. get keysUp(): number[];
  19723. set keysUp(value: number[]);
  19724. /**
  19725. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19726. */
  19727. get keysUpward(): number[];
  19728. set keysUpward(value: number[]);
  19729. /**
  19730. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19731. */
  19732. get keysDown(): number[];
  19733. set keysDown(value: number[]);
  19734. /**
  19735. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19736. */
  19737. get keysDownward(): number[];
  19738. set keysDownward(value: number[]);
  19739. /**
  19740. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19741. */
  19742. get keysLeft(): number[];
  19743. set keysLeft(value: number[]);
  19744. /**
  19745. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19746. */
  19747. get keysRight(): number[];
  19748. set keysRight(value: number[]);
  19749. /**
  19750. * Event raised when the camera collide with a mesh in the scene.
  19751. */
  19752. onCollide: (collidedMesh: AbstractMesh) => void;
  19753. private _collider;
  19754. private _needMoveForGravity;
  19755. private _oldPosition;
  19756. private _diffPosition;
  19757. private _newPosition;
  19758. /** @hidden */
  19759. _localDirection: Vector3;
  19760. /** @hidden */
  19761. _transformedDirection: Vector3;
  19762. /**
  19763. * Instantiates a Free Camera.
  19764. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19765. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19766. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19767. * @param name Define the name of the camera in the scene
  19768. * @param position Define the start position of the camera in the scene
  19769. * @param scene Define the scene the camera belongs to
  19770. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19771. */
  19772. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19773. /**
  19774. * Attached controls to the current camera.
  19775. * @param element Defines the element the controls should be listened from
  19776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19777. */
  19778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19779. /**
  19780. * Detach the current controls from the camera.
  19781. * The camera will stop reacting to inputs.
  19782. * @param element Defines the element to stop listening the inputs from
  19783. */
  19784. detachControl(element: HTMLElement): void;
  19785. private _collisionMask;
  19786. /**
  19787. * Define a collision mask to limit the list of object the camera can collide with
  19788. */
  19789. get collisionMask(): number;
  19790. set collisionMask(mask: number);
  19791. /** @hidden */
  19792. _collideWithWorld(displacement: Vector3): void;
  19793. private _onCollisionPositionChange;
  19794. /** @hidden */
  19795. _checkInputs(): void;
  19796. /** @hidden */
  19797. _decideIfNeedsToMove(): boolean;
  19798. /** @hidden */
  19799. _updatePosition(): void;
  19800. /**
  19801. * Destroy the camera and release the current resources hold by it.
  19802. */
  19803. dispose(): void;
  19804. /**
  19805. * Gets the current object class name.
  19806. * @return the class name
  19807. */
  19808. getClassName(): string;
  19809. }
  19810. }
  19811. declare module "babylonjs/Gamepads/gamepad" {
  19812. import { Observable } from "babylonjs/Misc/observable";
  19813. /**
  19814. * Represents a gamepad control stick position
  19815. */
  19816. export class StickValues {
  19817. /**
  19818. * The x component of the control stick
  19819. */
  19820. x: number;
  19821. /**
  19822. * The y component of the control stick
  19823. */
  19824. y: number;
  19825. /**
  19826. * Initializes the gamepad x and y control stick values
  19827. * @param x The x component of the gamepad control stick value
  19828. * @param y The y component of the gamepad control stick value
  19829. */
  19830. constructor(
  19831. /**
  19832. * The x component of the control stick
  19833. */
  19834. x: number,
  19835. /**
  19836. * The y component of the control stick
  19837. */
  19838. y: number);
  19839. }
  19840. /**
  19841. * An interface which manages callbacks for gamepad button changes
  19842. */
  19843. export interface GamepadButtonChanges {
  19844. /**
  19845. * Called when a gamepad has been changed
  19846. */
  19847. changed: boolean;
  19848. /**
  19849. * Called when a gamepad press event has been triggered
  19850. */
  19851. pressChanged: boolean;
  19852. /**
  19853. * Called when a touch event has been triggered
  19854. */
  19855. touchChanged: boolean;
  19856. /**
  19857. * Called when a value has changed
  19858. */
  19859. valueChanged: boolean;
  19860. }
  19861. /**
  19862. * Represents a gamepad
  19863. */
  19864. export class Gamepad {
  19865. /**
  19866. * The id of the gamepad
  19867. */
  19868. id: string;
  19869. /**
  19870. * The index of the gamepad
  19871. */
  19872. index: number;
  19873. /**
  19874. * The browser gamepad
  19875. */
  19876. browserGamepad: any;
  19877. /**
  19878. * Specifies what type of gamepad this represents
  19879. */
  19880. type: number;
  19881. private _leftStick;
  19882. private _rightStick;
  19883. /** @hidden */
  19884. _isConnected: boolean;
  19885. private _leftStickAxisX;
  19886. private _leftStickAxisY;
  19887. private _rightStickAxisX;
  19888. private _rightStickAxisY;
  19889. /**
  19890. * Triggered when the left control stick has been changed
  19891. */
  19892. private _onleftstickchanged;
  19893. /**
  19894. * Triggered when the right control stick has been changed
  19895. */
  19896. private _onrightstickchanged;
  19897. /**
  19898. * Represents a gamepad controller
  19899. */
  19900. static GAMEPAD: number;
  19901. /**
  19902. * Represents a generic controller
  19903. */
  19904. static GENERIC: number;
  19905. /**
  19906. * Represents an XBox controller
  19907. */
  19908. static XBOX: number;
  19909. /**
  19910. * Represents a pose-enabled controller
  19911. */
  19912. static POSE_ENABLED: number;
  19913. /**
  19914. * Represents an Dual Shock controller
  19915. */
  19916. static DUALSHOCK: number;
  19917. /**
  19918. * Specifies whether the left control stick should be Y-inverted
  19919. */
  19920. protected _invertLeftStickY: boolean;
  19921. /**
  19922. * Specifies if the gamepad has been connected
  19923. */
  19924. get isConnected(): boolean;
  19925. /**
  19926. * Initializes the gamepad
  19927. * @param id The id of the gamepad
  19928. * @param index The index of the gamepad
  19929. * @param browserGamepad The browser gamepad
  19930. * @param leftStickX The x component of the left joystick
  19931. * @param leftStickY The y component of the left joystick
  19932. * @param rightStickX The x component of the right joystick
  19933. * @param rightStickY The y component of the right joystick
  19934. */
  19935. constructor(
  19936. /**
  19937. * The id of the gamepad
  19938. */
  19939. id: string,
  19940. /**
  19941. * The index of the gamepad
  19942. */
  19943. index: number,
  19944. /**
  19945. * The browser gamepad
  19946. */
  19947. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19948. /**
  19949. * Callback triggered when the left joystick has changed
  19950. * @param callback
  19951. */
  19952. onleftstickchanged(callback: (values: StickValues) => void): void;
  19953. /**
  19954. * Callback triggered when the right joystick has changed
  19955. * @param callback
  19956. */
  19957. onrightstickchanged(callback: (values: StickValues) => void): void;
  19958. /**
  19959. * Gets the left joystick
  19960. */
  19961. get leftStick(): StickValues;
  19962. /**
  19963. * Sets the left joystick values
  19964. */
  19965. set leftStick(newValues: StickValues);
  19966. /**
  19967. * Gets the right joystick
  19968. */
  19969. get rightStick(): StickValues;
  19970. /**
  19971. * Sets the right joystick value
  19972. */
  19973. set rightStick(newValues: StickValues);
  19974. /**
  19975. * Updates the gamepad joystick positions
  19976. */
  19977. update(): void;
  19978. /**
  19979. * Disposes the gamepad
  19980. */
  19981. dispose(): void;
  19982. }
  19983. /**
  19984. * Represents a generic gamepad
  19985. */
  19986. export class GenericPad extends Gamepad {
  19987. private _buttons;
  19988. private _onbuttondown;
  19989. private _onbuttonup;
  19990. /**
  19991. * Observable triggered when a button has been pressed
  19992. */
  19993. onButtonDownObservable: Observable<number>;
  19994. /**
  19995. * Observable triggered when a button has been released
  19996. */
  19997. onButtonUpObservable: Observable<number>;
  19998. /**
  19999. * Callback triggered when a button has been pressed
  20000. * @param callback Called when a button has been pressed
  20001. */
  20002. onbuttondown(callback: (buttonPressed: number) => void): void;
  20003. /**
  20004. * Callback triggered when a button has been released
  20005. * @param callback Called when a button has been released
  20006. */
  20007. onbuttonup(callback: (buttonReleased: number) => void): void;
  20008. /**
  20009. * Initializes the generic gamepad
  20010. * @param id The id of the generic gamepad
  20011. * @param index The index of the generic gamepad
  20012. * @param browserGamepad The browser gamepad
  20013. */
  20014. constructor(id: string, index: number, browserGamepad: any);
  20015. private _setButtonValue;
  20016. /**
  20017. * Updates the generic gamepad
  20018. */
  20019. update(): void;
  20020. /**
  20021. * Disposes the generic gamepad
  20022. */
  20023. dispose(): void;
  20024. }
  20025. }
  20026. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20027. import { Observable } from "babylonjs/Misc/observable";
  20028. import { Nullable } from "babylonjs/types";
  20029. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20030. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20032. import { Ray } from "babylonjs/Culling/ray";
  20033. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20034. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20035. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20036. /**
  20037. * Defines the types of pose enabled controllers that are supported
  20038. */
  20039. export enum PoseEnabledControllerType {
  20040. /**
  20041. * HTC Vive
  20042. */
  20043. VIVE = 0,
  20044. /**
  20045. * Oculus Rift
  20046. */
  20047. OCULUS = 1,
  20048. /**
  20049. * Windows mixed reality
  20050. */
  20051. WINDOWS = 2,
  20052. /**
  20053. * Samsung gear VR
  20054. */
  20055. GEAR_VR = 3,
  20056. /**
  20057. * Google Daydream
  20058. */
  20059. DAYDREAM = 4,
  20060. /**
  20061. * Generic
  20062. */
  20063. GENERIC = 5
  20064. }
  20065. /**
  20066. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20067. */
  20068. export interface MutableGamepadButton {
  20069. /**
  20070. * Value of the button/trigger
  20071. */
  20072. value: number;
  20073. /**
  20074. * If the button/trigger is currently touched
  20075. */
  20076. touched: boolean;
  20077. /**
  20078. * If the button/trigger is currently pressed
  20079. */
  20080. pressed: boolean;
  20081. }
  20082. /**
  20083. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20084. * @hidden
  20085. */
  20086. export interface ExtendedGamepadButton extends GamepadButton {
  20087. /**
  20088. * If the button/trigger is currently pressed
  20089. */
  20090. readonly pressed: boolean;
  20091. /**
  20092. * If the button/trigger is currently touched
  20093. */
  20094. readonly touched: boolean;
  20095. /**
  20096. * Value of the button/trigger
  20097. */
  20098. readonly value: number;
  20099. }
  20100. /** @hidden */
  20101. export interface _GamePadFactory {
  20102. /**
  20103. * Returns whether or not the current gamepad can be created for this type of controller.
  20104. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20105. * @returns true if it can be created, otherwise false
  20106. */
  20107. canCreate(gamepadInfo: any): boolean;
  20108. /**
  20109. * Creates a new instance of the Gamepad.
  20110. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20111. * @returns the new gamepad instance
  20112. */
  20113. create(gamepadInfo: any): Gamepad;
  20114. }
  20115. /**
  20116. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20117. */
  20118. export class PoseEnabledControllerHelper {
  20119. /** @hidden */
  20120. static _ControllerFactories: _GamePadFactory[];
  20121. /** @hidden */
  20122. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20123. /**
  20124. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20125. * @param vrGamepad the gamepad to initialized
  20126. * @returns a vr controller of the type the gamepad identified as
  20127. */
  20128. static InitiateController(vrGamepad: any): Gamepad;
  20129. }
  20130. /**
  20131. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20132. */
  20133. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20134. /**
  20135. * If the controller is used in a webXR session
  20136. */
  20137. isXR: boolean;
  20138. private _deviceRoomPosition;
  20139. private _deviceRoomRotationQuaternion;
  20140. /**
  20141. * The device position in babylon space
  20142. */
  20143. devicePosition: Vector3;
  20144. /**
  20145. * The device rotation in babylon space
  20146. */
  20147. deviceRotationQuaternion: Quaternion;
  20148. /**
  20149. * The scale factor of the device in babylon space
  20150. */
  20151. deviceScaleFactor: number;
  20152. /**
  20153. * (Likely devicePosition should be used instead) The device position in its room space
  20154. */
  20155. position: Vector3;
  20156. /**
  20157. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20158. */
  20159. rotationQuaternion: Quaternion;
  20160. /**
  20161. * The type of controller (Eg. Windows mixed reality)
  20162. */
  20163. controllerType: PoseEnabledControllerType;
  20164. protected _calculatedPosition: Vector3;
  20165. private _calculatedRotation;
  20166. /**
  20167. * The raw pose from the device
  20168. */
  20169. rawPose: DevicePose;
  20170. private _trackPosition;
  20171. private _maxRotationDistFromHeadset;
  20172. private _draggedRoomRotation;
  20173. /**
  20174. * @hidden
  20175. */
  20176. _disableTrackPosition(fixedPosition: Vector3): void;
  20177. /**
  20178. * Internal, the mesh attached to the controller
  20179. * @hidden
  20180. */
  20181. _mesh: Nullable<AbstractMesh>;
  20182. private _poseControlledCamera;
  20183. private _leftHandSystemQuaternion;
  20184. /**
  20185. * Internal, matrix used to convert room space to babylon space
  20186. * @hidden
  20187. */
  20188. _deviceToWorld: Matrix;
  20189. /**
  20190. * Node to be used when casting a ray from the controller
  20191. * @hidden
  20192. */
  20193. _pointingPoseNode: Nullable<TransformNode>;
  20194. /**
  20195. * Name of the child mesh that can be used to cast a ray from the controller
  20196. */
  20197. static readonly POINTING_POSE: string;
  20198. /**
  20199. * Creates a new PoseEnabledController from a gamepad
  20200. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20201. */
  20202. constructor(browserGamepad: any);
  20203. private _workingMatrix;
  20204. /**
  20205. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20206. */
  20207. update(): void;
  20208. /**
  20209. * Updates only the pose device and mesh without doing any button event checking
  20210. */
  20211. protected _updatePoseAndMesh(): void;
  20212. /**
  20213. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20214. * @param poseData raw pose fromthe device
  20215. */
  20216. updateFromDevice(poseData: DevicePose): void;
  20217. /**
  20218. * @hidden
  20219. */
  20220. _meshAttachedObservable: Observable<AbstractMesh>;
  20221. /**
  20222. * Attaches a mesh to the controller
  20223. * @param mesh the mesh to be attached
  20224. */
  20225. attachToMesh(mesh: AbstractMesh): void;
  20226. /**
  20227. * Attaches the controllers mesh to a camera
  20228. * @param camera the camera the mesh should be attached to
  20229. */
  20230. attachToPoseControlledCamera(camera: TargetCamera): void;
  20231. /**
  20232. * Disposes of the controller
  20233. */
  20234. dispose(): void;
  20235. /**
  20236. * The mesh that is attached to the controller
  20237. */
  20238. get mesh(): Nullable<AbstractMesh>;
  20239. /**
  20240. * Gets the ray of the controller in the direction the controller is pointing
  20241. * @param length the length the resulting ray should be
  20242. * @returns a ray in the direction the controller is pointing
  20243. */
  20244. getForwardRay(length?: number): Ray;
  20245. }
  20246. }
  20247. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20248. import { Observable } from "babylonjs/Misc/observable";
  20249. import { Scene } from "babylonjs/scene";
  20250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20251. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20252. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20253. import { Nullable } from "babylonjs/types";
  20254. /**
  20255. * Defines the WebVRController object that represents controllers tracked in 3D space
  20256. */
  20257. export abstract class WebVRController extends PoseEnabledController {
  20258. /**
  20259. * Internal, the default controller model for the controller
  20260. */
  20261. protected _defaultModel: Nullable<AbstractMesh>;
  20262. /**
  20263. * Fired when the trigger state has changed
  20264. */
  20265. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20266. /**
  20267. * Fired when the main button state has changed
  20268. */
  20269. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20270. /**
  20271. * Fired when the secondary button state has changed
  20272. */
  20273. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20274. /**
  20275. * Fired when the pad state has changed
  20276. */
  20277. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20278. /**
  20279. * Fired when controllers stick values have changed
  20280. */
  20281. onPadValuesChangedObservable: Observable<StickValues>;
  20282. /**
  20283. * Array of button availible on the controller
  20284. */
  20285. protected _buttons: Array<MutableGamepadButton>;
  20286. private _onButtonStateChange;
  20287. /**
  20288. * Fired when a controller button's state has changed
  20289. * @param callback the callback containing the button that was modified
  20290. */
  20291. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20292. /**
  20293. * X and Y axis corresponding to the controllers joystick
  20294. */
  20295. pad: StickValues;
  20296. /**
  20297. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20298. */
  20299. hand: string;
  20300. /**
  20301. * The default controller model for the controller
  20302. */
  20303. get defaultModel(): Nullable<AbstractMesh>;
  20304. /**
  20305. * Creates a new WebVRController from a gamepad
  20306. * @param vrGamepad the gamepad that the WebVRController should be created from
  20307. */
  20308. constructor(vrGamepad: any);
  20309. /**
  20310. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20311. */
  20312. update(): void;
  20313. /**
  20314. * Function to be called when a button is modified
  20315. */
  20316. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20317. /**
  20318. * Loads a mesh and attaches it to the controller
  20319. * @param scene the scene the mesh should be added to
  20320. * @param meshLoaded callback for when the mesh has been loaded
  20321. */
  20322. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20323. private _setButtonValue;
  20324. private _changes;
  20325. private _checkChanges;
  20326. /**
  20327. * Disposes of th webVRCOntroller
  20328. */
  20329. dispose(): void;
  20330. }
  20331. }
  20332. declare module "babylonjs/Lights/hemisphericLight" {
  20333. import { Nullable } from "babylonjs/types";
  20334. import { Scene } from "babylonjs/scene";
  20335. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20336. import { Color3 } from "babylonjs/Maths/math.color";
  20337. import { Effect } from "babylonjs/Materials/effect";
  20338. import { Light } from "babylonjs/Lights/light";
  20339. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20340. /**
  20341. * The HemisphericLight simulates the ambient environment light,
  20342. * so the passed direction is the light reflection direction, not the incoming direction.
  20343. */
  20344. export class HemisphericLight extends Light {
  20345. /**
  20346. * The groundColor is the light in the opposite direction to the one specified during creation.
  20347. * 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.
  20348. */
  20349. groundColor: Color3;
  20350. /**
  20351. * The light reflection direction, not the incoming direction.
  20352. */
  20353. direction: Vector3;
  20354. /**
  20355. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20356. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20357. * The HemisphericLight can't cast shadows.
  20358. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20359. * @param name The friendly name of the light
  20360. * @param direction The direction of the light reflection
  20361. * @param scene The scene the light belongs to
  20362. */
  20363. constructor(name: string, direction: Vector3, scene: Scene);
  20364. protected _buildUniformLayout(): void;
  20365. /**
  20366. * Returns the string "HemisphericLight".
  20367. * @return The class name
  20368. */
  20369. getClassName(): string;
  20370. /**
  20371. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20372. * Returns the updated direction.
  20373. * @param target The target the direction should point to
  20374. * @return The computed direction
  20375. */
  20376. setDirectionToTarget(target: Vector3): Vector3;
  20377. /**
  20378. * Returns the shadow generator associated to the light.
  20379. * @returns Always null for hemispheric lights because it does not support shadows.
  20380. */
  20381. getShadowGenerator(): Nullable<IShadowGenerator>;
  20382. /**
  20383. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20384. * @param effect The effect to update
  20385. * @param lightIndex The index of the light in the effect to update
  20386. * @returns The hemispheric light
  20387. */
  20388. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20389. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20390. /**
  20391. * Computes the world matrix of the node
  20392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20393. * @param useWasUpdatedFlag defines a reserved property
  20394. * @returns the world matrix
  20395. */
  20396. computeWorldMatrix(): Matrix;
  20397. /**
  20398. * Returns the integer 3.
  20399. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20400. */
  20401. getTypeID(): number;
  20402. /**
  20403. * Prepares the list of defines specific to the light type.
  20404. * @param defines the list of defines
  20405. * @param lightIndex defines the index of the light for the effect
  20406. */
  20407. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20408. }
  20409. }
  20410. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20411. /** @hidden */
  20412. export var vrMultiviewToSingleviewPixelShader: {
  20413. name: string;
  20414. shader: string;
  20415. };
  20416. }
  20417. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20419. import { Scene } from "babylonjs/scene";
  20420. /**
  20421. * Renders to multiple views with a single draw call
  20422. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20423. */
  20424. export class MultiviewRenderTarget extends RenderTargetTexture {
  20425. /**
  20426. * Creates a multiview render target
  20427. * @param scene scene used with the render target
  20428. * @param size the size of the render target (used for each view)
  20429. */
  20430. constructor(scene: Scene, size?: number | {
  20431. width: number;
  20432. height: number;
  20433. } | {
  20434. ratio: number;
  20435. });
  20436. /**
  20437. * @hidden
  20438. * @param faceIndex the face index, if its a cube texture
  20439. */
  20440. _bindFrameBuffer(faceIndex?: number): void;
  20441. /**
  20442. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20443. * @returns the view count
  20444. */
  20445. getViewCount(): number;
  20446. }
  20447. }
  20448. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20449. import { Camera } from "babylonjs/Cameras/camera";
  20450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20451. import { Nullable } from "babylonjs/types";
  20452. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20453. import { Matrix } from "babylonjs/Maths/math.vector";
  20454. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20455. module "babylonjs/Engines/engine" {
  20456. interface Engine {
  20457. /**
  20458. * Creates a new multiview render target
  20459. * @param width defines the width of the texture
  20460. * @param height defines the height of the texture
  20461. * @returns the created multiview texture
  20462. */
  20463. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20464. /**
  20465. * Binds a multiview framebuffer to be drawn to
  20466. * @param multiviewTexture texture to bind
  20467. */
  20468. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20469. }
  20470. }
  20471. module "babylonjs/Cameras/camera" {
  20472. interface Camera {
  20473. /**
  20474. * @hidden
  20475. * 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)
  20476. */
  20477. _useMultiviewToSingleView: boolean;
  20478. /**
  20479. * @hidden
  20480. * 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)
  20481. */
  20482. _multiviewTexture: Nullable<RenderTargetTexture>;
  20483. /**
  20484. * @hidden
  20485. * ensures the multiview texture of the camera exists and has the specified width/height
  20486. * @param width height to set on the multiview texture
  20487. * @param height width to set on the multiview texture
  20488. */
  20489. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20490. }
  20491. }
  20492. module "babylonjs/scene" {
  20493. interface Scene {
  20494. /** @hidden */
  20495. _transformMatrixR: Matrix;
  20496. /** @hidden */
  20497. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20498. /** @hidden */
  20499. _createMultiviewUbo(): void;
  20500. /** @hidden */
  20501. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20502. /** @hidden */
  20503. _renderMultiviewToSingleView(camera: Camera): void;
  20504. }
  20505. }
  20506. }
  20507. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20508. import { Camera } from "babylonjs/Cameras/camera";
  20509. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20510. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20511. import "babylonjs/Engines/Extensions/engine.multiview";
  20512. /**
  20513. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20514. * This will not be used for webXR as it supports displaying texture arrays directly
  20515. */
  20516. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20517. /**
  20518. * Gets a string identifying the name of the class
  20519. * @returns "VRMultiviewToSingleviewPostProcess" string
  20520. */
  20521. getClassName(): string;
  20522. /**
  20523. * Initializes a VRMultiviewToSingleview
  20524. * @param name name of the post process
  20525. * @param camera camera to be applied to
  20526. * @param scaleFactor scaling factor to the size of the output texture
  20527. */
  20528. constructor(name: string, camera: Camera, scaleFactor: number);
  20529. }
  20530. }
  20531. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20532. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20533. import { Nullable } from "babylonjs/types";
  20534. import { Size } from "babylonjs/Maths/math.size";
  20535. import { Observable } from "babylonjs/Misc/observable";
  20536. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20537. /**
  20538. * Interface used to define additional presentation attributes
  20539. */
  20540. export interface IVRPresentationAttributes {
  20541. /**
  20542. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20543. */
  20544. highRefreshRate: boolean;
  20545. /**
  20546. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20547. */
  20548. foveationLevel: number;
  20549. }
  20550. module "babylonjs/Engines/engine" {
  20551. interface Engine {
  20552. /** @hidden */
  20553. _vrDisplay: any;
  20554. /** @hidden */
  20555. _vrSupported: boolean;
  20556. /** @hidden */
  20557. _oldSize: Size;
  20558. /** @hidden */
  20559. _oldHardwareScaleFactor: number;
  20560. /** @hidden */
  20561. _vrExclusivePointerMode: boolean;
  20562. /** @hidden */
  20563. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20564. /** @hidden */
  20565. _onVRDisplayPointerRestricted: () => void;
  20566. /** @hidden */
  20567. _onVRDisplayPointerUnrestricted: () => void;
  20568. /** @hidden */
  20569. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20570. /** @hidden */
  20571. _onVrDisplayDisconnect: Nullable<() => void>;
  20572. /** @hidden */
  20573. _onVrDisplayPresentChange: Nullable<() => void>;
  20574. /**
  20575. * Observable signaled when VR display mode changes
  20576. */
  20577. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20578. /**
  20579. * Observable signaled when VR request present is complete
  20580. */
  20581. onVRRequestPresentComplete: Observable<boolean>;
  20582. /**
  20583. * Observable signaled when VR request present starts
  20584. */
  20585. onVRRequestPresentStart: Observable<Engine>;
  20586. /**
  20587. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20588. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20589. */
  20590. isInVRExclusivePointerMode: boolean;
  20591. /**
  20592. * Gets a boolean indicating if a webVR device was detected
  20593. * @returns true if a webVR device was detected
  20594. */
  20595. isVRDevicePresent(): boolean;
  20596. /**
  20597. * Gets the current webVR device
  20598. * @returns the current webVR device (or null)
  20599. */
  20600. getVRDevice(): any;
  20601. /**
  20602. * Initializes a webVR display and starts listening to display change events
  20603. * The onVRDisplayChangedObservable will be notified upon these changes
  20604. * @returns A promise containing a VRDisplay and if vr is supported
  20605. */
  20606. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20607. /** @hidden */
  20608. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20609. /**
  20610. * Gets or sets the presentation attributes used to configure VR rendering
  20611. */
  20612. vrPresentationAttributes?: IVRPresentationAttributes;
  20613. /**
  20614. * Call this function to switch to webVR mode
  20615. * Will do nothing if webVR is not supported or if there is no webVR device
  20616. * @param options the webvr options provided to the camera. mainly used for multiview
  20617. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20618. */
  20619. enableVR(options: WebVROptions): void;
  20620. /** @hidden */
  20621. _onVRFullScreenTriggered(): void;
  20622. }
  20623. }
  20624. }
  20625. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20626. import { Nullable } from "babylonjs/types";
  20627. import { Observable } from "babylonjs/Misc/observable";
  20628. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20629. import { Scene } from "babylonjs/scene";
  20630. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20631. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20632. import { Node } from "babylonjs/node";
  20633. import { Ray } from "babylonjs/Culling/ray";
  20634. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20635. import "babylonjs/Engines/Extensions/engine.webVR";
  20636. /**
  20637. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20638. * IMPORTANT!! The data is right-hand data.
  20639. * @export
  20640. * @interface DevicePose
  20641. */
  20642. export interface DevicePose {
  20643. /**
  20644. * The position of the device, values in array are [x,y,z].
  20645. */
  20646. readonly position: Nullable<Float32Array>;
  20647. /**
  20648. * The linearVelocity of the device, values in array are [x,y,z].
  20649. */
  20650. readonly linearVelocity: Nullable<Float32Array>;
  20651. /**
  20652. * The linearAcceleration of the device, values in array are [x,y,z].
  20653. */
  20654. readonly linearAcceleration: Nullable<Float32Array>;
  20655. /**
  20656. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20657. */
  20658. readonly orientation: Nullable<Float32Array>;
  20659. /**
  20660. * The angularVelocity of the device, values in array are [x,y,z].
  20661. */
  20662. readonly angularVelocity: Nullable<Float32Array>;
  20663. /**
  20664. * The angularAcceleration of the device, values in array are [x,y,z].
  20665. */
  20666. readonly angularAcceleration: Nullable<Float32Array>;
  20667. }
  20668. /**
  20669. * Interface representing a pose controlled object in Babylon.
  20670. * A pose controlled object has both regular pose values as well as pose values
  20671. * from an external device such as a VR head mounted display
  20672. */
  20673. export interface PoseControlled {
  20674. /**
  20675. * The position of the object in babylon space.
  20676. */
  20677. position: Vector3;
  20678. /**
  20679. * The rotation quaternion of the object in babylon space.
  20680. */
  20681. rotationQuaternion: Quaternion;
  20682. /**
  20683. * The position of the device in babylon space.
  20684. */
  20685. devicePosition?: Vector3;
  20686. /**
  20687. * The rotation quaternion of the device in babylon space.
  20688. */
  20689. deviceRotationQuaternion: Quaternion;
  20690. /**
  20691. * The raw pose coming from the device.
  20692. */
  20693. rawPose: Nullable<DevicePose>;
  20694. /**
  20695. * The scale of the device to be used when translating from device space to babylon space.
  20696. */
  20697. deviceScaleFactor: number;
  20698. /**
  20699. * Updates the poseControlled values based on the input device pose.
  20700. * @param poseData the pose data to update the object with
  20701. */
  20702. updateFromDevice(poseData: DevicePose): void;
  20703. }
  20704. /**
  20705. * Set of options to customize the webVRCamera
  20706. */
  20707. export interface WebVROptions {
  20708. /**
  20709. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20710. */
  20711. trackPosition?: boolean;
  20712. /**
  20713. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20714. */
  20715. positionScale?: number;
  20716. /**
  20717. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20718. */
  20719. displayName?: string;
  20720. /**
  20721. * Should the native controller meshes be initialized. (default: true)
  20722. */
  20723. controllerMeshes?: boolean;
  20724. /**
  20725. * Creating a default HemiLight only on controllers. (default: true)
  20726. */
  20727. defaultLightingOnControllers?: boolean;
  20728. /**
  20729. * If you don't want to use the default VR button of the helper. (default: false)
  20730. */
  20731. useCustomVRButton?: boolean;
  20732. /**
  20733. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20734. */
  20735. customVRButton?: HTMLButtonElement;
  20736. /**
  20737. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20738. */
  20739. rayLength?: number;
  20740. /**
  20741. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20742. */
  20743. defaultHeight?: number;
  20744. /**
  20745. * If multiview should be used if availible (default: false)
  20746. */
  20747. useMultiview?: boolean;
  20748. }
  20749. /**
  20750. * This represents a WebVR camera.
  20751. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20752. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20753. */
  20754. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20755. private webVROptions;
  20756. /**
  20757. * @hidden
  20758. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20759. */
  20760. _vrDevice: any;
  20761. /**
  20762. * The rawPose of the vrDevice.
  20763. */
  20764. rawPose: Nullable<DevicePose>;
  20765. private _onVREnabled;
  20766. private _specsVersion;
  20767. private _attached;
  20768. private _frameData;
  20769. protected _descendants: Array<Node>;
  20770. private _deviceRoomPosition;
  20771. /** @hidden */
  20772. _deviceRoomRotationQuaternion: Quaternion;
  20773. private _standingMatrix;
  20774. /**
  20775. * Represents device position in babylon space.
  20776. */
  20777. devicePosition: Vector3;
  20778. /**
  20779. * Represents device rotation in babylon space.
  20780. */
  20781. deviceRotationQuaternion: Quaternion;
  20782. /**
  20783. * The scale of the device to be used when translating from device space to babylon space.
  20784. */
  20785. deviceScaleFactor: number;
  20786. private _deviceToWorld;
  20787. private _worldToDevice;
  20788. /**
  20789. * References to the webVR controllers for the vrDevice.
  20790. */
  20791. controllers: Array<WebVRController>;
  20792. /**
  20793. * Emits an event when a controller is attached.
  20794. */
  20795. onControllersAttachedObservable: Observable<WebVRController[]>;
  20796. /**
  20797. * Emits an event when a controller's mesh has been loaded;
  20798. */
  20799. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20800. /**
  20801. * Emits an event when the HMD's pose has been updated.
  20802. */
  20803. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20804. private _poseSet;
  20805. /**
  20806. * If the rig cameras be used as parent instead of this camera.
  20807. */
  20808. rigParenting: boolean;
  20809. private _lightOnControllers;
  20810. private _defaultHeight?;
  20811. /**
  20812. * Instantiates a WebVRFreeCamera.
  20813. * @param name The name of the WebVRFreeCamera
  20814. * @param position The starting anchor position for the camera
  20815. * @param scene The scene the camera belongs to
  20816. * @param webVROptions a set of customizable options for the webVRCamera
  20817. */
  20818. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20819. /**
  20820. * Gets the device distance from the ground in meters.
  20821. * @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.
  20822. */
  20823. deviceDistanceToRoomGround(): number;
  20824. /**
  20825. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20826. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20827. */
  20828. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20829. /**
  20830. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20831. * @returns A promise with a boolean set to if the standing matrix is supported.
  20832. */
  20833. useStandingMatrixAsync(): Promise<boolean>;
  20834. /**
  20835. * Disposes the camera
  20836. */
  20837. dispose(): void;
  20838. /**
  20839. * Gets a vrController by name.
  20840. * @param name The name of the controller to retreive
  20841. * @returns the controller matching the name specified or null if not found
  20842. */
  20843. getControllerByName(name: string): Nullable<WebVRController>;
  20844. private _leftController;
  20845. /**
  20846. * The controller corresponding to the users left hand.
  20847. */
  20848. get leftController(): Nullable<WebVRController>;
  20849. private _rightController;
  20850. /**
  20851. * The controller corresponding to the users right hand.
  20852. */
  20853. get rightController(): Nullable<WebVRController>;
  20854. /**
  20855. * Casts a ray forward from the vrCamera's gaze.
  20856. * @param length Length of the ray (default: 100)
  20857. * @returns the ray corresponding to the gaze
  20858. */
  20859. getForwardRay(length?: number): Ray;
  20860. /**
  20861. * @hidden
  20862. * Updates the camera based on device's frame data
  20863. */
  20864. _checkInputs(): void;
  20865. /**
  20866. * Updates the poseControlled values based on the input device pose.
  20867. * @param poseData Pose coming from the device
  20868. */
  20869. updateFromDevice(poseData: DevicePose): void;
  20870. private _htmlElementAttached;
  20871. private _detachIfAttached;
  20872. /**
  20873. * WebVR's attach control will start broadcasting frames to the device.
  20874. * Note that in certain browsers (chrome for example) this function must be called
  20875. * within a user-interaction callback. Example:
  20876. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20877. *
  20878. * @param element html element to attach the vrDevice to
  20879. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20880. */
  20881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20882. /**
  20883. * Detaches the camera from the html element and disables VR
  20884. *
  20885. * @param element html element to detach from
  20886. */
  20887. detachControl(element: HTMLElement): void;
  20888. /**
  20889. * @returns the name of this class
  20890. */
  20891. getClassName(): string;
  20892. /**
  20893. * Calls resetPose on the vrDisplay
  20894. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20895. */
  20896. resetToCurrentRotation(): void;
  20897. /**
  20898. * @hidden
  20899. * Updates the rig cameras (left and right eye)
  20900. */
  20901. _updateRigCameras(): void;
  20902. private _workingVector;
  20903. private _oneVector;
  20904. private _workingMatrix;
  20905. private updateCacheCalled;
  20906. private _correctPositionIfNotTrackPosition;
  20907. /**
  20908. * @hidden
  20909. * Updates the cached values of the camera
  20910. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20911. */
  20912. _updateCache(ignoreParentClass?: boolean): void;
  20913. /**
  20914. * @hidden
  20915. * Get current device position in babylon world
  20916. */
  20917. _computeDevicePosition(): void;
  20918. /**
  20919. * Updates the current device position and rotation in the babylon world
  20920. */
  20921. update(): void;
  20922. /**
  20923. * @hidden
  20924. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20925. * @returns an identity matrix
  20926. */
  20927. _getViewMatrix(): Matrix;
  20928. private _tmpMatrix;
  20929. /**
  20930. * This function is called by the two RIG cameras.
  20931. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20932. * @hidden
  20933. */
  20934. _getWebVRViewMatrix(): Matrix;
  20935. /** @hidden */
  20936. _getWebVRProjectionMatrix(): Matrix;
  20937. private _onGamepadConnectedObserver;
  20938. private _onGamepadDisconnectedObserver;
  20939. private _updateCacheWhenTrackingDisabledObserver;
  20940. /**
  20941. * Initializes the controllers and their meshes
  20942. */
  20943. initControllers(): void;
  20944. }
  20945. }
  20946. declare module "babylonjs/Materials/materialHelper" {
  20947. import { Nullable } from "babylonjs/types";
  20948. import { Scene } from "babylonjs/scene";
  20949. import { Engine } from "babylonjs/Engines/engine";
  20950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20951. import { Light } from "babylonjs/Lights/light";
  20952. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20953. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20954. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20956. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20957. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20958. /**
  20959. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20960. *
  20961. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20962. *
  20963. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20964. */
  20965. export class MaterialHelper {
  20966. /**
  20967. * Bind the current view position to an effect.
  20968. * @param effect The effect to be bound
  20969. * @param scene The scene the eyes position is used from
  20970. * @param variableName name of the shader variable that will hold the eye position
  20971. */
  20972. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20973. /**
  20974. * Helps preparing the defines values about the UVs in used in the effect.
  20975. * UVs are shared as much as we can accross channels in the shaders.
  20976. * @param texture The texture we are preparing the UVs for
  20977. * @param defines The defines to update
  20978. * @param key The channel key "diffuse", "specular"... used in the shader
  20979. */
  20980. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20981. /**
  20982. * Binds a texture matrix value to its corrsponding uniform
  20983. * @param texture The texture to bind the matrix for
  20984. * @param uniformBuffer The uniform buffer receivin the data
  20985. * @param key The channel key "diffuse", "specular"... used in the shader
  20986. */
  20987. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20988. /**
  20989. * Gets the current status of the fog (should it be enabled?)
  20990. * @param mesh defines the mesh to evaluate for fog support
  20991. * @param scene defines the hosting scene
  20992. * @returns true if fog must be enabled
  20993. */
  20994. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20995. /**
  20996. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20997. * @param mesh defines the current mesh
  20998. * @param scene defines the current scene
  20999. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21000. * @param pointsCloud defines if point cloud rendering has to be turned on
  21001. * @param fogEnabled defines if fog has to be turned on
  21002. * @param alphaTest defines if alpha testing has to be turned on
  21003. * @param defines defines the current list of defines
  21004. */
  21005. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21006. /**
  21007. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21008. * @param scene defines the current scene
  21009. * @param engine defines the current engine
  21010. * @param defines specifies the list of active defines
  21011. * @param useInstances defines if instances have to be turned on
  21012. * @param useClipPlane defines if clip plane have to be turned on
  21013. * @param useInstances defines if instances have to be turned on
  21014. * @param useThinInstances defines if thin instances have to be turned on
  21015. */
  21016. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21017. /**
  21018. * Prepares the defines for bones
  21019. * @param mesh The mesh containing the geometry data we will draw
  21020. * @param defines The defines to update
  21021. */
  21022. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21023. /**
  21024. * Prepares the defines for morph targets
  21025. * @param mesh The mesh containing the geometry data we will draw
  21026. * @param defines The defines to update
  21027. */
  21028. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21029. /**
  21030. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21031. * @param mesh The mesh containing the geometry data we will draw
  21032. * @param defines The defines to update
  21033. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21034. * @param useBones Precise whether bones should be used or not (override mesh info)
  21035. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21036. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21037. * @returns false if defines are considered not dirty and have not been checked
  21038. */
  21039. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21040. /**
  21041. * Prepares the defines related to multiview
  21042. * @param scene The scene we are intending to draw
  21043. * @param defines The defines to update
  21044. */
  21045. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21046. /**
  21047. * Prepares the defines related to the prepass
  21048. * @param scene The scene we are intending to draw
  21049. * @param defines The defines to update
  21050. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21051. */
  21052. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21053. /**
  21054. * Prepares the defines related to the light information passed in parameter
  21055. * @param scene The scene we are intending to draw
  21056. * @param mesh The mesh the effect is compiling for
  21057. * @param light The light the effect is compiling for
  21058. * @param lightIndex The index of the light
  21059. * @param defines The defines to update
  21060. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21061. * @param state Defines the current state regarding what is needed (normals, etc...)
  21062. */
  21063. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21064. needNormals: boolean;
  21065. needRebuild: boolean;
  21066. shadowEnabled: boolean;
  21067. specularEnabled: boolean;
  21068. lightmapMode: boolean;
  21069. }): void;
  21070. /**
  21071. * Prepares the defines related to the light information passed in parameter
  21072. * @param scene The scene we are intending to draw
  21073. * @param mesh The mesh the effect is compiling for
  21074. * @param defines The defines to update
  21075. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21076. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21077. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21078. * @returns true if normals will be required for the rest of the effect
  21079. */
  21080. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21081. /**
  21082. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21083. * @param lightIndex defines the light index
  21084. * @param uniformsList The uniform list
  21085. * @param samplersList The sampler list
  21086. * @param projectedLightTexture defines if projected texture must be used
  21087. * @param uniformBuffersList defines an optional list of uniform buffers
  21088. */
  21089. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21090. /**
  21091. * Prepares the uniforms and samplers list to be used in the effect
  21092. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21093. * @param samplersList The sampler list
  21094. * @param defines The defines helping in the list generation
  21095. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21096. */
  21097. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21098. /**
  21099. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21100. * @param defines The defines to update while falling back
  21101. * @param fallbacks The authorized effect fallbacks
  21102. * @param maxSimultaneousLights The maximum number of lights allowed
  21103. * @param rank the current rank of the Effect
  21104. * @returns The newly affected rank
  21105. */
  21106. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21107. private static _TmpMorphInfluencers;
  21108. /**
  21109. * Prepares the list of attributes required for morph targets according to the effect defines.
  21110. * @param attribs The current list of supported attribs
  21111. * @param mesh The mesh to prepare the morph targets attributes for
  21112. * @param influencers The number of influencers
  21113. */
  21114. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21115. /**
  21116. * Prepares the list of attributes required for morph targets according to the effect defines.
  21117. * @param attribs The current list of supported attribs
  21118. * @param mesh The mesh to prepare the morph targets attributes for
  21119. * @param defines The current Defines of the effect
  21120. */
  21121. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21122. /**
  21123. * Prepares the list of attributes required for bones according to the effect defines.
  21124. * @param attribs The current list of supported attribs
  21125. * @param mesh The mesh to prepare the bones attributes for
  21126. * @param defines The current Defines of the effect
  21127. * @param fallbacks The current efffect fallback strategy
  21128. */
  21129. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21130. /**
  21131. * Check and prepare the list of attributes required for instances according to the effect defines.
  21132. * @param attribs The current list of supported attribs
  21133. * @param defines The current MaterialDefines of the effect
  21134. */
  21135. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21136. /**
  21137. * Add the list of attributes required for instances to the attribs array.
  21138. * @param attribs The current list of supported attribs
  21139. */
  21140. static PushAttributesForInstances(attribs: string[]): void;
  21141. /**
  21142. * Binds the light information to the effect.
  21143. * @param light The light containing the generator
  21144. * @param effect The effect we are binding the data to
  21145. * @param lightIndex The light index in the effect used to render
  21146. */
  21147. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21148. /**
  21149. * Binds the lights information from the scene to the effect for the given mesh.
  21150. * @param light Light to bind
  21151. * @param lightIndex Light index
  21152. * @param scene The scene where the light belongs to
  21153. * @param effect The effect we are binding the data to
  21154. * @param useSpecular Defines if specular is supported
  21155. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21156. */
  21157. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21158. /**
  21159. * Binds the lights information from the scene to the effect for the given mesh.
  21160. * @param scene The scene the lights belongs to
  21161. * @param mesh The mesh we are binding the information to render
  21162. * @param effect The effect we are binding the data to
  21163. * @param defines The generated defines for the effect
  21164. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21165. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21166. */
  21167. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21168. private static _tempFogColor;
  21169. /**
  21170. * Binds the fog information from the scene to the effect for the given mesh.
  21171. * @param scene The scene the lights belongs to
  21172. * @param mesh The mesh we are binding the information to render
  21173. * @param effect The effect we are binding the data to
  21174. * @param linearSpace Defines if the fog effect is applied in linear space
  21175. */
  21176. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21177. /**
  21178. * Binds the bones information from the mesh to the effect.
  21179. * @param mesh The mesh we are binding the information to render
  21180. * @param effect The effect we are binding the data to
  21181. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21182. */
  21183. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21184. private static _CopyBonesTransformationMatrices;
  21185. /**
  21186. * Binds the morph targets information from the mesh to the effect.
  21187. * @param abstractMesh The mesh we are binding the information to render
  21188. * @param effect The effect we are binding the data to
  21189. */
  21190. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21191. /**
  21192. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21193. * @param defines The generated defines used in the effect
  21194. * @param effect The effect we are binding the data to
  21195. * @param scene The scene we are willing to render with logarithmic scale for
  21196. */
  21197. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21198. /**
  21199. * Binds the clip plane information from the scene to the effect.
  21200. * @param scene The scene the clip plane information are extracted from
  21201. * @param effect The effect we are binding the data to
  21202. */
  21203. static BindClipPlane(effect: Effect, scene: Scene): void;
  21204. }
  21205. }
  21206. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21208. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21209. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21210. import { Nullable } from "babylonjs/types";
  21211. import { Effect } from "babylonjs/Materials/effect";
  21212. import { Matrix } from "babylonjs/Maths/math.vector";
  21213. import { Scene } from "babylonjs/scene";
  21214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21216. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21217. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21218. import { Observable } from "babylonjs/Misc/observable";
  21219. /**
  21220. * Block used to expose an input value
  21221. */
  21222. export class InputBlock extends NodeMaterialBlock {
  21223. private _mode;
  21224. private _associatedVariableName;
  21225. private _storedValue;
  21226. private _valueCallback;
  21227. private _type;
  21228. private _animationType;
  21229. /** Gets or set a value used to limit the range of float values */
  21230. min: number;
  21231. /** Gets or set a value used to limit the range of float values */
  21232. max: number;
  21233. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21234. isBoolean: boolean;
  21235. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21236. matrixMode: number;
  21237. /** @hidden */
  21238. _systemValue: Nullable<NodeMaterialSystemValues>;
  21239. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21240. isConstant: boolean;
  21241. /** Gets or sets the group to use to display this block in the Inspector */
  21242. groupInInspector: string;
  21243. /** Gets an observable raised when the value is changed */
  21244. onValueChangedObservable: Observable<InputBlock>;
  21245. /**
  21246. * Gets or sets the connection point type (default is float)
  21247. */
  21248. get type(): NodeMaterialBlockConnectionPointTypes;
  21249. /**
  21250. * Creates a new InputBlock
  21251. * @param name defines the block name
  21252. * @param target defines the target of that block (Vertex by default)
  21253. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21254. */
  21255. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21256. /**
  21257. * Validates if a name is a reserve word.
  21258. * @param newName the new name to be given to the node.
  21259. * @returns false if the name is a reserve word, else true.
  21260. */
  21261. validateBlockName(newName: string): boolean;
  21262. /**
  21263. * Gets the output component
  21264. */
  21265. get output(): NodeMaterialConnectionPoint;
  21266. /**
  21267. * Set the source of this connection point to a vertex attribute
  21268. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21269. * @returns the current connection point
  21270. */
  21271. setAsAttribute(attributeName?: string): InputBlock;
  21272. /**
  21273. * Set the source of this connection point to a system value
  21274. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21275. * @returns the current connection point
  21276. */
  21277. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21278. /**
  21279. * Gets or sets the value of that point.
  21280. * Please note that this value will be ignored if valueCallback is defined
  21281. */
  21282. get value(): any;
  21283. set value(value: any);
  21284. /**
  21285. * Gets or sets a callback used to get the value of that point.
  21286. * Please note that setting this value will force the connection point to ignore the value property
  21287. */
  21288. get valueCallback(): () => any;
  21289. set valueCallback(value: () => any);
  21290. /**
  21291. * Gets or sets the associated variable name in the shader
  21292. */
  21293. get associatedVariableName(): string;
  21294. set associatedVariableName(value: string);
  21295. /** Gets or sets the type of animation applied to the input */
  21296. get animationType(): AnimatedInputBlockTypes;
  21297. set animationType(value: AnimatedInputBlockTypes);
  21298. /**
  21299. * Gets a boolean indicating that this connection point not defined yet
  21300. */
  21301. get isUndefined(): boolean;
  21302. /**
  21303. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21304. * In this case the connection point name must be the name of the uniform to use.
  21305. * Can only be set on inputs
  21306. */
  21307. get isUniform(): boolean;
  21308. set isUniform(value: boolean);
  21309. /**
  21310. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21311. * In this case the connection point name must be the name of the attribute to use
  21312. * Can only be set on inputs
  21313. */
  21314. get isAttribute(): boolean;
  21315. set isAttribute(value: boolean);
  21316. /**
  21317. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21318. * Can only be set on exit points
  21319. */
  21320. get isVarying(): boolean;
  21321. set isVarying(value: boolean);
  21322. /**
  21323. * Gets a boolean indicating that the current connection point is a system value
  21324. */
  21325. get isSystemValue(): boolean;
  21326. /**
  21327. * Gets or sets the current well known value or null if not defined as a system value
  21328. */
  21329. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21330. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21331. /**
  21332. * Gets the current class name
  21333. * @returns the class name
  21334. */
  21335. getClassName(): string;
  21336. /**
  21337. * Animate the input if animationType !== None
  21338. * @param scene defines the rendering scene
  21339. */
  21340. animate(scene: Scene): void;
  21341. private _emitDefine;
  21342. initialize(state: NodeMaterialBuildState): void;
  21343. /**
  21344. * Set the input block to its default value (based on its type)
  21345. */
  21346. setDefaultValue(): void;
  21347. private _emitConstant;
  21348. /** @hidden */
  21349. get _noContextSwitch(): boolean;
  21350. private _emit;
  21351. /** @hidden */
  21352. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21353. /** @hidden */
  21354. _transmit(effect: Effect, scene: Scene): void;
  21355. protected _buildBlock(state: NodeMaterialBuildState): void;
  21356. protected _dumpPropertiesCode(): string;
  21357. dispose(): void;
  21358. serialize(): any;
  21359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21360. }
  21361. }
  21362. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21363. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21364. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21365. import { Nullable } from "babylonjs/types";
  21366. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21367. import { Observable } from "babylonjs/Misc/observable";
  21368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21369. /**
  21370. * Enum used to define the compatibility state between two connection points
  21371. */
  21372. export enum NodeMaterialConnectionPointCompatibilityStates {
  21373. /** Points are compatibles */
  21374. Compatible = 0,
  21375. /** Points are incompatible because of their types */
  21376. TypeIncompatible = 1,
  21377. /** Points are incompatible because of their targets (vertex vs fragment) */
  21378. TargetIncompatible = 2
  21379. }
  21380. /**
  21381. * Defines the direction of a connection point
  21382. */
  21383. export enum NodeMaterialConnectionPointDirection {
  21384. /** Input */
  21385. Input = 0,
  21386. /** Output */
  21387. Output = 1
  21388. }
  21389. /**
  21390. * Defines a connection point for a block
  21391. */
  21392. export class NodeMaterialConnectionPoint {
  21393. /** @hidden */
  21394. _ownerBlock: NodeMaterialBlock;
  21395. /** @hidden */
  21396. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21397. private _endpoints;
  21398. private _associatedVariableName;
  21399. private _direction;
  21400. /** @hidden */
  21401. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21402. /** @hidden */
  21403. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21404. private _type;
  21405. /** @hidden */
  21406. _enforceAssociatedVariableName: boolean;
  21407. /** Gets the direction of the point */
  21408. get direction(): NodeMaterialConnectionPointDirection;
  21409. /** Indicates that this connection point needs dual validation before being connected to another point */
  21410. needDualDirectionValidation: boolean;
  21411. /**
  21412. * Gets or sets the additional types supported by this connection point
  21413. */
  21414. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21415. /**
  21416. * Gets or sets the additional types excluded by this connection point
  21417. */
  21418. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21419. /**
  21420. * Observable triggered when this point is connected
  21421. */
  21422. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21423. /**
  21424. * Gets or sets the associated variable name in the shader
  21425. */
  21426. get associatedVariableName(): string;
  21427. set associatedVariableName(value: string);
  21428. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21429. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21430. /**
  21431. * Gets or sets the connection point type (default is float)
  21432. */
  21433. get type(): NodeMaterialBlockConnectionPointTypes;
  21434. set type(value: NodeMaterialBlockConnectionPointTypes);
  21435. /**
  21436. * Gets or sets the connection point name
  21437. */
  21438. name: string;
  21439. /**
  21440. * Gets or sets the connection point name
  21441. */
  21442. displayName: string;
  21443. /**
  21444. * Gets or sets a boolean indicating that this connection point can be omitted
  21445. */
  21446. isOptional: boolean;
  21447. /**
  21448. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21449. */
  21450. isExposedOnFrame: boolean;
  21451. /**
  21452. * Gets or sets number indicating the position that the port is exposed to on a frame
  21453. */
  21454. exposedPortPosition: number;
  21455. /**
  21456. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21457. */
  21458. define: string;
  21459. /** @hidden */
  21460. _prioritizeVertex: boolean;
  21461. private _target;
  21462. /** Gets or sets the target of that connection point */
  21463. get target(): NodeMaterialBlockTargets;
  21464. set target(value: NodeMaterialBlockTargets);
  21465. /**
  21466. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21467. */
  21468. get isConnected(): boolean;
  21469. /**
  21470. * Gets a boolean indicating that the current point is connected to an input block
  21471. */
  21472. get isConnectedToInputBlock(): boolean;
  21473. /**
  21474. * Gets a the connected input block (if any)
  21475. */
  21476. get connectInputBlock(): Nullable<InputBlock>;
  21477. /** Get the other side of the connection (if any) */
  21478. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21479. /** Get the block that owns this connection point */
  21480. get ownerBlock(): NodeMaterialBlock;
  21481. /** Get the block connected on the other side of this connection (if any) */
  21482. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21483. /** Get the block connected on the endpoints of this connection (if any) */
  21484. get connectedBlocks(): Array<NodeMaterialBlock>;
  21485. /** Gets the list of connected endpoints */
  21486. get endpoints(): NodeMaterialConnectionPoint[];
  21487. /** Gets a boolean indicating if that output point is connected to at least one input */
  21488. get hasEndpoints(): boolean;
  21489. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21490. get isConnectedInVertexShader(): boolean;
  21491. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21492. get isConnectedInFragmentShader(): boolean;
  21493. /**
  21494. * Creates a block suitable to be used as an input for this input point.
  21495. * If null is returned, a block based on the point type will be created.
  21496. * @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
  21497. */
  21498. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21499. /**
  21500. * Creates a new connection point
  21501. * @param name defines the connection point name
  21502. * @param ownerBlock defines the block hosting this connection point
  21503. * @param direction defines the direction of the connection point
  21504. */
  21505. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21506. /**
  21507. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21508. * @returns the class name
  21509. */
  21510. getClassName(): string;
  21511. /**
  21512. * Gets a boolean indicating if the current point can be connected to another point
  21513. * @param connectionPoint defines the other connection point
  21514. * @returns a boolean
  21515. */
  21516. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21517. /**
  21518. * Gets a number indicating if the current point can be connected to another point
  21519. * @param connectionPoint defines the other connection point
  21520. * @returns a number defining the compatibility state
  21521. */
  21522. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21523. /**
  21524. * Connect this point to another connection point
  21525. * @param connectionPoint defines the other connection point
  21526. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21527. * @returns the current connection point
  21528. */
  21529. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21530. /**
  21531. * Disconnect this point from one of his endpoint
  21532. * @param endpoint defines the other connection point
  21533. * @returns the current connection point
  21534. */
  21535. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21536. /**
  21537. * Serializes this point in a JSON representation
  21538. * @param isInput defines if the connection point is an input (default is true)
  21539. * @returns the serialized point object
  21540. */
  21541. serialize(isInput?: boolean): any;
  21542. /**
  21543. * Release resources
  21544. */
  21545. dispose(): void;
  21546. }
  21547. }
  21548. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21549. /**
  21550. * Enum used to define the material modes
  21551. */
  21552. export enum NodeMaterialModes {
  21553. /** Regular material */
  21554. Material = 0,
  21555. /** For post process */
  21556. PostProcess = 1,
  21557. /** For particle system */
  21558. Particle = 2,
  21559. /** For procedural texture */
  21560. ProceduralTexture = 3
  21561. }
  21562. }
  21563. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21566. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21569. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21570. import { Effect } from "babylonjs/Materials/effect";
  21571. import { Mesh } from "babylonjs/Meshes/mesh";
  21572. import { Nullable } from "babylonjs/types";
  21573. import { Texture } from "babylonjs/Materials/Textures/texture";
  21574. import { Scene } from "babylonjs/scene";
  21575. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21576. /**
  21577. * Block used to read a texture from a sampler
  21578. */
  21579. export class TextureBlock extends NodeMaterialBlock {
  21580. private _defineName;
  21581. private _linearDefineName;
  21582. private _gammaDefineName;
  21583. private _tempTextureRead;
  21584. private _samplerName;
  21585. private _transformedUVName;
  21586. private _textureTransformName;
  21587. private _textureInfoName;
  21588. private _mainUVName;
  21589. private _mainUVDefineName;
  21590. private _fragmentOnly;
  21591. /**
  21592. * Gets or sets the texture associated with the node
  21593. */
  21594. texture: Nullable<Texture>;
  21595. /**
  21596. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21597. */
  21598. convertToGammaSpace: boolean;
  21599. /**
  21600. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21601. */
  21602. convertToLinearSpace: boolean;
  21603. /**
  21604. * Create a new TextureBlock
  21605. * @param name defines the block name
  21606. */
  21607. constructor(name: string, fragmentOnly?: boolean);
  21608. /**
  21609. * Gets the current class name
  21610. * @returns the class name
  21611. */
  21612. getClassName(): string;
  21613. /**
  21614. * Gets the uv input component
  21615. */
  21616. get uv(): NodeMaterialConnectionPoint;
  21617. /**
  21618. * Gets the rgba output component
  21619. */
  21620. get rgba(): NodeMaterialConnectionPoint;
  21621. /**
  21622. * Gets the rgb output component
  21623. */
  21624. get rgb(): NodeMaterialConnectionPoint;
  21625. /**
  21626. * Gets the r output component
  21627. */
  21628. get r(): NodeMaterialConnectionPoint;
  21629. /**
  21630. * Gets the g output component
  21631. */
  21632. get g(): NodeMaterialConnectionPoint;
  21633. /**
  21634. * Gets the b output component
  21635. */
  21636. get b(): NodeMaterialConnectionPoint;
  21637. /**
  21638. * Gets the a output component
  21639. */
  21640. get a(): NodeMaterialConnectionPoint;
  21641. get target(): NodeMaterialBlockTargets;
  21642. autoConfigure(material: NodeMaterial): void;
  21643. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21645. isReady(): boolean;
  21646. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21647. private get _isMixed();
  21648. private _injectVertexCode;
  21649. private _writeTextureRead;
  21650. private _writeOutput;
  21651. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21652. protected _dumpPropertiesCode(): string;
  21653. serialize(): any;
  21654. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21655. }
  21656. }
  21657. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21658. /** @hidden */
  21659. export var reflectionFunction: {
  21660. name: string;
  21661. shader: string;
  21662. };
  21663. }
  21664. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21670. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21671. import { Effect } from "babylonjs/Materials/effect";
  21672. import { Mesh } from "babylonjs/Meshes/mesh";
  21673. import { Nullable } from "babylonjs/types";
  21674. import { Scene } from "babylonjs/scene";
  21675. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21676. /**
  21677. * Base block used to read a reflection texture from a sampler
  21678. */
  21679. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21680. /** @hidden */
  21681. _define3DName: string;
  21682. /** @hidden */
  21683. _defineCubicName: string;
  21684. /** @hidden */
  21685. _defineExplicitName: string;
  21686. /** @hidden */
  21687. _defineProjectionName: string;
  21688. /** @hidden */
  21689. _defineLocalCubicName: string;
  21690. /** @hidden */
  21691. _defineSphericalName: string;
  21692. /** @hidden */
  21693. _definePlanarName: string;
  21694. /** @hidden */
  21695. _defineEquirectangularName: string;
  21696. /** @hidden */
  21697. _defineMirroredEquirectangularFixedName: string;
  21698. /** @hidden */
  21699. _defineEquirectangularFixedName: string;
  21700. /** @hidden */
  21701. _defineSkyboxName: string;
  21702. /** @hidden */
  21703. _defineOppositeZ: string;
  21704. /** @hidden */
  21705. _cubeSamplerName: string;
  21706. /** @hidden */
  21707. _2DSamplerName: string;
  21708. protected _positionUVWName: string;
  21709. protected _directionWName: string;
  21710. protected _reflectionVectorName: string;
  21711. /** @hidden */
  21712. _reflectionCoordsName: string;
  21713. /** @hidden */
  21714. _reflectionMatrixName: string;
  21715. protected _reflectionColorName: string;
  21716. /**
  21717. * Gets or sets the texture associated with the node
  21718. */
  21719. texture: Nullable<BaseTexture>;
  21720. /**
  21721. * Create a new ReflectionTextureBaseBlock
  21722. * @param name defines the block name
  21723. */
  21724. constructor(name: string);
  21725. /**
  21726. * Gets the current class name
  21727. * @returns the class name
  21728. */
  21729. getClassName(): string;
  21730. /**
  21731. * Gets the world position input component
  21732. */
  21733. abstract get position(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Gets the world position input component
  21736. */
  21737. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21738. /**
  21739. * Gets the world normal input component
  21740. */
  21741. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21742. /**
  21743. * Gets the world input component
  21744. */
  21745. abstract get world(): NodeMaterialConnectionPoint;
  21746. /**
  21747. * Gets the camera (or eye) position component
  21748. */
  21749. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21750. /**
  21751. * Gets the view input component
  21752. */
  21753. abstract get view(): NodeMaterialConnectionPoint;
  21754. protected _getTexture(): Nullable<BaseTexture>;
  21755. autoConfigure(material: NodeMaterial): void;
  21756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21757. isReady(): boolean;
  21758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21759. /**
  21760. * Gets the code to inject in the vertex shader
  21761. * @param state current state of the node material building
  21762. * @returns the shader code
  21763. */
  21764. handleVertexSide(state: NodeMaterialBuildState): string;
  21765. /**
  21766. * Handles the inits for the fragment code path
  21767. * @param state node material build state
  21768. */
  21769. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21770. /**
  21771. * Generates the reflection coords code for the fragment code path
  21772. * @param worldNormalVarName name of the world normal variable
  21773. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21774. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21775. * @returns the shader code
  21776. */
  21777. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21778. /**
  21779. * Generates the reflection color code for the fragment code path
  21780. * @param lodVarName name of the lod variable
  21781. * @param swizzleLookupTexture swizzle to use for the final color variable
  21782. * @returns the shader code
  21783. */
  21784. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21785. /**
  21786. * Generates the code corresponding to the connected output points
  21787. * @param state node material build state
  21788. * @param varName name of the variable to output
  21789. * @returns the shader code
  21790. */
  21791. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21792. protected _buildBlock(state: NodeMaterialBuildState): this;
  21793. protected _dumpPropertiesCode(): string;
  21794. serialize(): any;
  21795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21796. }
  21797. }
  21798. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21800. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21801. import { Nullable } from "babylonjs/types";
  21802. /**
  21803. * Defines a connection point to be used for points with a custom object type
  21804. */
  21805. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21806. private _blockType;
  21807. private _blockName;
  21808. private _nameForCheking?;
  21809. /**
  21810. * Creates a new connection point
  21811. * @param name defines the connection point name
  21812. * @param ownerBlock defines the block hosting this connection point
  21813. * @param direction defines the direction of the connection point
  21814. */
  21815. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21816. /**
  21817. * Gets a number indicating if the current point can be connected to another point
  21818. * @param connectionPoint defines the other connection point
  21819. * @returns a number defining the compatibility state
  21820. */
  21821. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21822. /**
  21823. * Creates a block suitable to be used as an input for this input point.
  21824. * If null is returned, a block based on the point type will be created.
  21825. * @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
  21826. */
  21827. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21828. }
  21829. }
  21830. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21831. /**
  21832. * Enum defining the type of properties that can be edited in the property pages in the NME
  21833. */
  21834. export enum PropertyTypeForEdition {
  21835. /** property is a boolean */
  21836. Boolean = 0,
  21837. /** property is a float */
  21838. Float = 1,
  21839. /** property is a Vector2 */
  21840. Vector2 = 2,
  21841. /** property is a list of values */
  21842. List = 3
  21843. }
  21844. /**
  21845. * Interface that defines an option in a variable of type list
  21846. */
  21847. export interface IEditablePropertyListOption {
  21848. /** label of the option */
  21849. "label": string;
  21850. /** value of the option */
  21851. "value": number;
  21852. }
  21853. /**
  21854. * Interface that defines the options available for an editable property
  21855. */
  21856. export interface IEditablePropertyOption {
  21857. /** min value */
  21858. "min"?: number;
  21859. /** max value */
  21860. "max"?: number;
  21861. /** notifiers: indicates which actions to take when the property is changed */
  21862. "notifiers"?: {
  21863. /** the material should be rebuilt */
  21864. "rebuild"?: boolean;
  21865. /** the preview should be updated */
  21866. "update"?: boolean;
  21867. };
  21868. /** list of the options for a variable of type list */
  21869. "options"?: IEditablePropertyListOption[];
  21870. }
  21871. /**
  21872. * Interface that describes an editable property
  21873. */
  21874. export interface IPropertyDescriptionForEdition {
  21875. /** name of the property */
  21876. "propertyName": string;
  21877. /** display name of the property */
  21878. "displayName": string;
  21879. /** type of the property */
  21880. "type": PropertyTypeForEdition;
  21881. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21882. "groupName": string;
  21883. /** options for the property */
  21884. "options": IEditablePropertyOption;
  21885. }
  21886. /**
  21887. * Decorator that flags a property in a node material block as being editable
  21888. */
  21889. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21890. }
  21891. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21892. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21894. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21896. import { Nullable } from "babylonjs/types";
  21897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21898. import { Mesh } from "babylonjs/Meshes/mesh";
  21899. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21900. import { Effect } from "babylonjs/Materials/effect";
  21901. import { Scene } from "babylonjs/scene";
  21902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21903. /**
  21904. * Block used to implement the refraction part of the sub surface module of the PBR material
  21905. */
  21906. export class RefractionBlock extends NodeMaterialBlock {
  21907. /** @hidden */
  21908. _define3DName: string;
  21909. /** @hidden */
  21910. _refractionMatrixName: string;
  21911. /** @hidden */
  21912. _defineLODRefractionAlpha: string;
  21913. /** @hidden */
  21914. _defineLinearSpecularRefraction: string;
  21915. /** @hidden */
  21916. _defineOppositeZ: string;
  21917. /** @hidden */
  21918. _cubeSamplerName: string;
  21919. /** @hidden */
  21920. _2DSamplerName: string;
  21921. /** @hidden */
  21922. _vRefractionMicrosurfaceInfosName: string;
  21923. /** @hidden */
  21924. _vRefractionInfosName: string;
  21925. private _scene;
  21926. /**
  21927. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21928. * Materials half opaque for instance using refraction could benefit from this control.
  21929. */
  21930. linkRefractionWithTransparency: boolean;
  21931. /**
  21932. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21933. */
  21934. invertRefractionY: boolean;
  21935. /**
  21936. * Gets or sets the texture associated with the node
  21937. */
  21938. texture: Nullable<BaseTexture>;
  21939. /**
  21940. * Create a new RefractionBlock
  21941. * @param name defines the block name
  21942. */
  21943. constructor(name: string);
  21944. /**
  21945. * Gets the current class name
  21946. * @returns the class name
  21947. */
  21948. getClassName(): string;
  21949. /**
  21950. * Gets the intensity input component
  21951. */
  21952. get intensity(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the index of refraction input component
  21955. */
  21956. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the tint at distance input component
  21959. */
  21960. get tintAtDistance(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the view input component
  21963. */
  21964. get view(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the refraction object output component
  21967. */
  21968. get refraction(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Returns true if the block has a texture
  21971. */
  21972. get hasTexture(): boolean;
  21973. protected _getTexture(): Nullable<BaseTexture>;
  21974. autoConfigure(material: NodeMaterial): void;
  21975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21976. isReady(): boolean;
  21977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21978. /**
  21979. * Gets the main code of the block (fragment side)
  21980. * @param state current state of the node material building
  21981. * @returns the shader code
  21982. */
  21983. getCode(state: NodeMaterialBuildState): string;
  21984. protected _buildBlock(state: NodeMaterialBuildState): this;
  21985. protected _dumpPropertiesCode(): string;
  21986. serialize(): any;
  21987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21988. }
  21989. }
  21990. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21993. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21996. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21998. import { Nullable } from "babylonjs/types";
  21999. import { Scene } from "babylonjs/scene";
  22000. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22001. /**
  22002. * Base block used as input for post process
  22003. */
  22004. export class CurrentScreenBlock extends NodeMaterialBlock {
  22005. private _samplerName;
  22006. private _linearDefineName;
  22007. private _gammaDefineName;
  22008. private _mainUVName;
  22009. private _tempTextureRead;
  22010. /**
  22011. * Gets or sets the texture associated with the node
  22012. */
  22013. texture: Nullable<BaseTexture>;
  22014. /**
  22015. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22016. */
  22017. convertToGammaSpace: boolean;
  22018. /**
  22019. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22020. */
  22021. convertToLinearSpace: boolean;
  22022. /**
  22023. * Create a new CurrentScreenBlock
  22024. * @param name defines the block name
  22025. */
  22026. constructor(name: string);
  22027. /**
  22028. * Gets the current class name
  22029. * @returns the class name
  22030. */
  22031. getClassName(): string;
  22032. /**
  22033. * Gets the uv input component
  22034. */
  22035. get uv(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Gets the rgba output component
  22038. */
  22039. get rgba(): NodeMaterialConnectionPoint;
  22040. /**
  22041. * Gets the rgb output component
  22042. */
  22043. get rgb(): NodeMaterialConnectionPoint;
  22044. /**
  22045. * Gets the r output component
  22046. */
  22047. get r(): NodeMaterialConnectionPoint;
  22048. /**
  22049. * Gets the g output component
  22050. */
  22051. get g(): NodeMaterialConnectionPoint;
  22052. /**
  22053. * Gets the b output component
  22054. */
  22055. get b(): NodeMaterialConnectionPoint;
  22056. /**
  22057. * Gets the a output component
  22058. */
  22059. get a(): NodeMaterialConnectionPoint;
  22060. /**
  22061. * Initialize the block and prepare the context for build
  22062. * @param state defines the state that will be used for the build
  22063. */
  22064. initialize(state: NodeMaterialBuildState): void;
  22065. get target(): NodeMaterialBlockTargets;
  22066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22067. isReady(): boolean;
  22068. private _injectVertexCode;
  22069. private _writeTextureRead;
  22070. private _writeOutput;
  22071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22072. serialize(): any;
  22073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22074. }
  22075. }
  22076. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22081. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22083. import { Nullable } from "babylonjs/types";
  22084. import { Scene } from "babylonjs/scene";
  22085. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22086. /**
  22087. * Base block used for the particle texture
  22088. */
  22089. export class ParticleTextureBlock extends NodeMaterialBlock {
  22090. private _samplerName;
  22091. private _linearDefineName;
  22092. private _gammaDefineName;
  22093. private _tempTextureRead;
  22094. /**
  22095. * Gets or sets the texture associated with the node
  22096. */
  22097. texture: Nullable<BaseTexture>;
  22098. /**
  22099. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22100. */
  22101. convertToGammaSpace: boolean;
  22102. /**
  22103. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22104. */
  22105. convertToLinearSpace: boolean;
  22106. /**
  22107. * Create a new ParticleTextureBlock
  22108. * @param name defines the block name
  22109. */
  22110. constructor(name: string);
  22111. /**
  22112. * Gets the current class name
  22113. * @returns the class name
  22114. */
  22115. getClassName(): string;
  22116. /**
  22117. * Gets the uv input component
  22118. */
  22119. get uv(): NodeMaterialConnectionPoint;
  22120. /**
  22121. * Gets the rgba output component
  22122. */
  22123. get rgba(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the rgb output component
  22126. */
  22127. get rgb(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Gets the r output component
  22130. */
  22131. get r(): NodeMaterialConnectionPoint;
  22132. /**
  22133. * Gets the g output component
  22134. */
  22135. get g(): NodeMaterialConnectionPoint;
  22136. /**
  22137. * Gets the b output component
  22138. */
  22139. get b(): NodeMaterialConnectionPoint;
  22140. /**
  22141. * Gets the a output component
  22142. */
  22143. get a(): NodeMaterialConnectionPoint;
  22144. /**
  22145. * Initialize the block and prepare the context for build
  22146. * @param state defines the state that will be used for the build
  22147. */
  22148. initialize(state: NodeMaterialBuildState): void;
  22149. autoConfigure(material: NodeMaterial): void;
  22150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22151. isReady(): boolean;
  22152. private _writeOutput;
  22153. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22154. serialize(): any;
  22155. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22156. }
  22157. }
  22158. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22161. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22162. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22163. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22164. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22165. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22166. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22167. import { Scene } from "babylonjs/scene";
  22168. /**
  22169. * Class used to store shared data between 2 NodeMaterialBuildState
  22170. */
  22171. export class NodeMaterialBuildStateSharedData {
  22172. /**
  22173. * Gets the list of emitted varyings
  22174. */
  22175. temps: string[];
  22176. /**
  22177. * Gets the list of emitted varyings
  22178. */
  22179. varyings: string[];
  22180. /**
  22181. * Gets the varying declaration string
  22182. */
  22183. varyingDeclaration: string;
  22184. /**
  22185. * Input blocks
  22186. */
  22187. inputBlocks: InputBlock[];
  22188. /**
  22189. * Input blocks
  22190. */
  22191. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22192. /**
  22193. * Bindable blocks (Blocks that need to set data to the effect)
  22194. */
  22195. bindableBlocks: NodeMaterialBlock[];
  22196. /**
  22197. * List of blocks that can provide a compilation fallback
  22198. */
  22199. blocksWithFallbacks: NodeMaterialBlock[];
  22200. /**
  22201. * List of blocks that can provide a define update
  22202. */
  22203. blocksWithDefines: NodeMaterialBlock[];
  22204. /**
  22205. * List of blocks that can provide a repeatable content
  22206. */
  22207. repeatableContentBlocks: NodeMaterialBlock[];
  22208. /**
  22209. * List of blocks that can provide a dynamic list of uniforms
  22210. */
  22211. dynamicUniformBlocks: NodeMaterialBlock[];
  22212. /**
  22213. * List of blocks that can block the isReady function for the material
  22214. */
  22215. blockingBlocks: NodeMaterialBlock[];
  22216. /**
  22217. * Gets the list of animated inputs
  22218. */
  22219. animatedInputs: InputBlock[];
  22220. /**
  22221. * Build Id used to avoid multiple recompilations
  22222. */
  22223. buildId: number;
  22224. /** List of emitted variables */
  22225. variableNames: {
  22226. [key: string]: number;
  22227. };
  22228. /** List of emitted defines */
  22229. defineNames: {
  22230. [key: string]: number;
  22231. };
  22232. /** Should emit comments? */
  22233. emitComments: boolean;
  22234. /** Emit build activity */
  22235. verbose: boolean;
  22236. /** Gets or sets the hosting scene */
  22237. scene: Scene;
  22238. /**
  22239. * Gets the compilation hints emitted at compilation time
  22240. */
  22241. hints: {
  22242. needWorldViewMatrix: boolean;
  22243. needWorldViewProjectionMatrix: boolean;
  22244. needAlphaBlending: boolean;
  22245. needAlphaTesting: boolean;
  22246. };
  22247. /**
  22248. * List of compilation checks
  22249. */
  22250. checks: {
  22251. emitVertex: boolean;
  22252. emitFragment: boolean;
  22253. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22254. };
  22255. /**
  22256. * Is vertex program allowed to be empty?
  22257. */
  22258. allowEmptyVertexProgram: boolean;
  22259. /** Creates a new shared data */
  22260. constructor();
  22261. /**
  22262. * Emits console errors and exceptions if there is a failing check
  22263. */
  22264. emitErrors(): void;
  22265. }
  22266. }
  22267. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22268. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22269. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22270. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22271. /**
  22272. * Class used to store node based material build state
  22273. */
  22274. export class NodeMaterialBuildState {
  22275. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22276. supportUniformBuffers: boolean;
  22277. /**
  22278. * Gets the list of emitted attributes
  22279. */
  22280. attributes: string[];
  22281. /**
  22282. * Gets the list of emitted uniforms
  22283. */
  22284. uniforms: string[];
  22285. /**
  22286. * Gets the list of emitted constants
  22287. */
  22288. constants: string[];
  22289. /**
  22290. * Gets the list of emitted samplers
  22291. */
  22292. samplers: string[];
  22293. /**
  22294. * Gets the list of emitted functions
  22295. */
  22296. functions: {
  22297. [key: string]: string;
  22298. };
  22299. /**
  22300. * Gets the list of emitted extensions
  22301. */
  22302. extensions: {
  22303. [key: string]: string;
  22304. };
  22305. /**
  22306. * Gets the target of the compilation state
  22307. */
  22308. target: NodeMaterialBlockTargets;
  22309. /**
  22310. * Gets the list of emitted counters
  22311. */
  22312. counters: {
  22313. [key: string]: number;
  22314. };
  22315. /**
  22316. * Shared data between multiple NodeMaterialBuildState instances
  22317. */
  22318. sharedData: NodeMaterialBuildStateSharedData;
  22319. /** @hidden */
  22320. _vertexState: NodeMaterialBuildState;
  22321. /** @hidden */
  22322. _attributeDeclaration: string;
  22323. /** @hidden */
  22324. _uniformDeclaration: string;
  22325. /** @hidden */
  22326. _constantDeclaration: string;
  22327. /** @hidden */
  22328. _samplerDeclaration: string;
  22329. /** @hidden */
  22330. _varyingTransfer: string;
  22331. /** @hidden */
  22332. _injectAtEnd: string;
  22333. private _repeatableContentAnchorIndex;
  22334. /** @hidden */
  22335. _builtCompilationString: string;
  22336. /**
  22337. * Gets the emitted compilation strings
  22338. */
  22339. compilationString: string;
  22340. /**
  22341. * Finalize the compilation strings
  22342. * @param state defines the current compilation state
  22343. */
  22344. finalize(state: NodeMaterialBuildState): void;
  22345. /** @hidden */
  22346. get _repeatableContentAnchor(): string;
  22347. /** @hidden */
  22348. _getFreeVariableName(prefix: string): string;
  22349. /** @hidden */
  22350. _getFreeDefineName(prefix: string): string;
  22351. /** @hidden */
  22352. _excludeVariableName(name: string): void;
  22353. /** @hidden */
  22354. _emit2DSampler(name: string): void;
  22355. /** @hidden */
  22356. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22357. /** @hidden */
  22358. _emitExtension(name: string, extension: string, define?: string): void;
  22359. /** @hidden */
  22360. _emitFunction(name: string, code: string, comments: string): void;
  22361. /** @hidden */
  22362. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22363. replaceStrings?: {
  22364. search: RegExp;
  22365. replace: string;
  22366. }[];
  22367. repeatKey?: string;
  22368. }): string;
  22369. /** @hidden */
  22370. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22371. repeatKey?: string;
  22372. removeAttributes?: boolean;
  22373. removeUniforms?: boolean;
  22374. removeVaryings?: boolean;
  22375. removeIfDef?: boolean;
  22376. replaceStrings?: {
  22377. search: RegExp;
  22378. replace: string;
  22379. }[];
  22380. }, storeKey?: string): void;
  22381. /** @hidden */
  22382. _registerTempVariable(name: string): boolean;
  22383. /** @hidden */
  22384. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22385. /** @hidden */
  22386. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22387. /** @hidden */
  22388. _emitFloat(value: number): string;
  22389. }
  22390. }
  22391. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22392. /**
  22393. * Helper class used to generate session unique ID
  22394. */
  22395. export class UniqueIdGenerator {
  22396. private static _UniqueIdCounter;
  22397. /**
  22398. * Gets an unique (relatively to the current scene) Id
  22399. */
  22400. static get UniqueId(): number;
  22401. }
  22402. }
  22403. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22404. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22406. import { Nullable } from "babylonjs/types";
  22407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22408. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22409. import { Effect } from "babylonjs/Materials/effect";
  22410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22411. import { Mesh } from "babylonjs/Meshes/mesh";
  22412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22413. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22414. import { Scene } from "babylonjs/scene";
  22415. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22416. /**
  22417. * Defines a block that can be used inside a node based material
  22418. */
  22419. export class NodeMaterialBlock {
  22420. private _buildId;
  22421. private _buildTarget;
  22422. private _target;
  22423. private _isFinalMerger;
  22424. private _isInput;
  22425. private _name;
  22426. protected _isUnique: boolean;
  22427. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22428. inputsAreExclusive: boolean;
  22429. /** @hidden */
  22430. _codeVariableName: string;
  22431. /** @hidden */
  22432. _inputs: NodeMaterialConnectionPoint[];
  22433. /** @hidden */
  22434. _outputs: NodeMaterialConnectionPoint[];
  22435. /** @hidden */
  22436. _preparationId: number;
  22437. /**
  22438. * Gets the name of the block
  22439. */
  22440. get name(): string;
  22441. /**
  22442. * Sets the name of the block. Will check if the name is valid.
  22443. */
  22444. set name(newName: string);
  22445. /**
  22446. * Gets or sets the unique id of the node
  22447. */
  22448. uniqueId: number;
  22449. /**
  22450. * Gets or sets the comments associated with this block
  22451. */
  22452. comments: string;
  22453. /**
  22454. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22455. */
  22456. get isUnique(): boolean;
  22457. /**
  22458. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22459. */
  22460. get isFinalMerger(): boolean;
  22461. /**
  22462. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22463. */
  22464. get isInput(): boolean;
  22465. /**
  22466. * Gets or sets the build Id
  22467. */
  22468. get buildId(): number;
  22469. set buildId(value: number);
  22470. /**
  22471. * Gets or sets the target of the block
  22472. */
  22473. get target(): NodeMaterialBlockTargets;
  22474. set target(value: NodeMaterialBlockTargets);
  22475. /**
  22476. * Gets the list of input points
  22477. */
  22478. get inputs(): NodeMaterialConnectionPoint[];
  22479. /** Gets the list of output points */
  22480. get outputs(): NodeMaterialConnectionPoint[];
  22481. /**
  22482. * Find an input by its name
  22483. * @param name defines the name of the input to look for
  22484. * @returns the input or null if not found
  22485. */
  22486. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22487. /**
  22488. * Find an output by its name
  22489. * @param name defines the name of the outputto look for
  22490. * @returns the output or null if not found
  22491. */
  22492. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22493. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22494. visibleInInspector: boolean;
  22495. /**
  22496. * Creates a new NodeMaterialBlock
  22497. * @param name defines the block name
  22498. * @param target defines the target of that block (Vertex by default)
  22499. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22500. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22501. */
  22502. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22503. /**
  22504. * Initialize the block and prepare the context for build
  22505. * @param state defines the state that will be used for the build
  22506. */
  22507. initialize(state: NodeMaterialBuildState): void;
  22508. /**
  22509. * Bind data to effect. Will only be called for blocks with isBindable === true
  22510. * @param effect defines the effect to bind data to
  22511. * @param nodeMaterial defines the hosting NodeMaterial
  22512. * @param mesh defines the mesh that will be rendered
  22513. * @param subMesh defines the submesh that will be rendered
  22514. */
  22515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22516. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22517. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22518. protected _writeFloat(value: number): string;
  22519. /**
  22520. * Gets the current class name e.g. "NodeMaterialBlock"
  22521. * @returns the class name
  22522. */
  22523. getClassName(): string;
  22524. /**
  22525. * Register a new input. Must be called inside a block constructor
  22526. * @param name defines the connection point name
  22527. * @param type defines the connection point type
  22528. * @param isOptional defines a boolean indicating that this input can be omitted
  22529. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22530. * @param point an already created connection point. If not provided, create a new one
  22531. * @returns the current block
  22532. */
  22533. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22534. /**
  22535. * Register a new output. Must be called inside a block constructor
  22536. * @param name defines the connection point name
  22537. * @param type defines the connection point type
  22538. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22539. * @param point an already created connection point. If not provided, create a new one
  22540. * @returns the current block
  22541. */
  22542. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22543. /**
  22544. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22545. * @param forOutput defines an optional connection point to check compatibility with
  22546. * @returns the first available input or null
  22547. */
  22548. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22549. /**
  22550. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22551. * @param forBlock defines an optional block to check compatibility with
  22552. * @returns the first available input or null
  22553. */
  22554. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22555. /**
  22556. * Gets the sibling of the given output
  22557. * @param current defines the current output
  22558. * @returns the next output in the list or null
  22559. */
  22560. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22561. /**
  22562. * Connect current block with another block
  22563. * @param other defines the block to connect with
  22564. * @param options define the various options to help pick the right connections
  22565. * @returns the current block
  22566. */
  22567. connectTo(other: NodeMaterialBlock, options?: {
  22568. input?: string;
  22569. output?: string;
  22570. outputSwizzle?: string;
  22571. }): this | undefined;
  22572. protected _buildBlock(state: NodeMaterialBuildState): void;
  22573. /**
  22574. * Add uniforms, samplers and uniform buffers at compilation time
  22575. * @param state defines the state to update
  22576. * @param nodeMaterial defines the node material requesting the update
  22577. * @param defines defines the material defines to update
  22578. * @param uniformBuffers defines the list of uniform buffer names
  22579. */
  22580. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22581. /**
  22582. * Add potential fallbacks if shader compilation fails
  22583. * @param mesh defines the mesh to be rendered
  22584. * @param fallbacks defines the current prioritized list of fallbacks
  22585. */
  22586. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22587. /**
  22588. * Initialize defines for shader compilation
  22589. * @param mesh defines the mesh to be rendered
  22590. * @param nodeMaterial defines the node material requesting the update
  22591. * @param defines defines the material defines to update
  22592. * @param useInstances specifies that instances should be used
  22593. */
  22594. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22595. /**
  22596. * Update defines for shader compilation
  22597. * @param mesh defines the mesh to be rendered
  22598. * @param nodeMaterial defines the node material requesting the update
  22599. * @param defines defines the material defines to update
  22600. * @param useInstances specifies that instances should be used
  22601. * @param subMesh defines which submesh to render
  22602. */
  22603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22604. /**
  22605. * Lets the block try to connect some inputs automatically
  22606. * @param material defines the hosting NodeMaterial
  22607. */
  22608. autoConfigure(material: NodeMaterial): void;
  22609. /**
  22610. * Function called when a block is declared as repeatable content generator
  22611. * @param vertexShaderState defines the current compilation state for the vertex shader
  22612. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22613. * @param mesh defines the mesh to be rendered
  22614. * @param defines defines the material defines to update
  22615. */
  22616. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22617. /**
  22618. * Checks if the block is ready
  22619. * @param mesh defines the mesh to be rendered
  22620. * @param nodeMaterial defines the node material requesting the update
  22621. * @param defines defines the material defines to update
  22622. * @param useInstances specifies that instances should be used
  22623. * @returns true if the block is ready
  22624. */
  22625. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22626. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22627. private _processBuild;
  22628. /**
  22629. * Validates the new name for the block node.
  22630. * @param newName the new name to be given to the node.
  22631. * @returns false if the name is a reserve word, else true.
  22632. */
  22633. validateBlockName(newName: string): boolean;
  22634. /**
  22635. * Compile the current node and generate the shader code
  22636. * @param state defines the current compilation state (uniforms, samplers, current string)
  22637. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22638. * @returns true if already built
  22639. */
  22640. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22641. protected _inputRename(name: string): string;
  22642. protected _outputRename(name: string): string;
  22643. protected _dumpPropertiesCode(): string;
  22644. /** @hidden */
  22645. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22646. /** @hidden */
  22647. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22648. /**
  22649. * Clone the current block to a new identical block
  22650. * @param scene defines the hosting scene
  22651. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22652. * @returns a copy of the current block
  22653. */
  22654. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22655. /**
  22656. * Serializes this block in a JSON representation
  22657. * @returns the serialized block object
  22658. */
  22659. serialize(): any;
  22660. /** @hidden */
  22661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22662. private _deserializePortDisplayNamesAndExposedOnFrame;
  22663. /**
  22664. * Release resources
  22665. */
  22666. dispose(): void;
  22667. }
  22668. }
  22669. declare module "babylonjs/Materials/pushMaterial" {
  22670. import { Nullable } from "babylonjs/types";
  22671. import { Scene } from "babylonjs/scene";
  22672. import { Matrix } from "babylonjs/Maths/math.vector";
  22673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22674. import { Mesh } from "babylonjs/Meshes/mesh";
  22675. import { Material } from "babylonjs/Materials/material";
  22676. import { Effect } from "babylonjs/Materials/effect";
  22677. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22678. /**
  22679. * Base class of materials working in push mode in babylon JS
  22680. * @hidden
  22681. */
  22682. export class PushMaterial extends Material {
  22683. protected _activeEffect: Effect;
  22684. protected _normalMatrix: Matrix;
  22685. constructor(name: string, scene: Scene);
  22686. getEffect(): Effect;
  22687. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22688. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22689. /**
  22690. * Binds the given world matrix to the active effect
  22691. *
  22692. * @param world the matrix to bind
  22693. */
  22694. bindOnlyWorldMatrix(world: Matrix): void;
  22695. /**
  22696. * Binds the given normal matrix to the active effect
  22697. *
  22698. * @param normalMatrix the matrix to bind
  22699. */
  22700. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22701. bind(world: Matrix, mesh?: Mesh): void;
  22702. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22703. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22704. }
  22705. }
  22706. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22708. /**
  22709. * Root class for all node material optimizers
  22710. */
  22711. export class NodeMaterialOptimizer {
  22712. /**
  22713. * Function used to optimize a NodeMaterial graph
  22714. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22715. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22716. */
  22717. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22718. }
  22719. }
  22720. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22724. import { Scene } from "babylonjs/scene";
  22725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22726. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22727. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22728. /**
  22729. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22730. */
  22731. export class TransformBlock extends NodeMaterialBlock {
  22732. /**
  22733. * Defines the value to use to complement W value to transform it to a Vector4
  22734. */
  22735. complementW: number;
  22736. /**
  22737. * Defines the value to use to complement z value to transform it to a Vector4
  22738. */
  22739. complementZ: number;
  22740. /**
  22741. * Creates a new TransformBlock
  22742. * @param name defines the block name
  22743. */
  22744. constructor(name: string);
  22745. /**
  22746. * Gets the current class name
  22747. * @returns the class name
  22748. */
  22749. getClassName(): string;
  22750. /**
  22751. * Gets the vector input
  22752. */
  22753. get vector(): NodeMaterialConnectionPoint;
  22754. /**
  22755. * Gets the output component
  22756. */
  22757. get output(): NodeMaterialConnectionPoint;
  22758. /**
  22759. * Gets the xyz output component
  22760. */
  22761. get xyz(): NodeMaterialConnectionPoint;
  22762. /**
  22763. * Gets the matrix transform input
  22764. */
  22765. get transform(): NodeMaterialConnectionPoint;
  22766. protected _buildBlock(state: NodeMaterialBuildState): this;
  22767. /**
  22768. * Update defines for shader compilation
  22769. * @param mesh defines the mesh to be rendered
  22770. * @param nodeMaterial defines the node material requesting the update
  22771. * @param defines defines the material defines to update
  22772. * @param useInstances specifies that instances should be used
  22773. * @param subMesh defines which submesh to render
  22774. */
  22775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22776. serialize(): any;
  22777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22778. protected _dumpPropertiesCode(): string;
  22779. }
  22780. }
  22781. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22785. /**
  22786. * Block used to output the vertex position
  22787. */
  22788. export class VertexOutputBlock extends NodeMaterialBlock {
  22789. /**
  22790. * Creates a new VertexOutputBlock
  22791. * @param name defines the block name
  22792. */
  22793. constructor(name: string);
  22794. /**
  22795. * Gets the current class name
  22796. * @returns the class name
  22797. */
  22798. getClassName(): string;
  22799. /**
  22800. * Gets the vector input component
  22801. */
  22802. get vector(): NodeMaterialConnectionPoint;
  22803. protected _buildBlock(state: NodeMaterialBuildState): this;
  22804. }
  22805. }
  22806. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22810. /**
  22811. * Block used to output the final color
  22812. */
  22813. export class FragmentOutputBlock extends NodeMaterialBlock {
  22814. /**
  22815. * Create a new FragmentOutputBlock
  22816. * @param name defines the block name
  22817. */
  22818. constructor(name: string);
  22819. /**
  22820. * Gets the current class name
  22821. * @returns the class name
  22822. */
  22823. getClassName(): string;
  22824. /**
  22825. * Gets the rgba input component
  22826. */
  22827. get rgba(): NodeMaterialConnectionPoint;
  22828. /**
  22829. * Gets the rgb input component
  22830. */
  22831. get rgb(): NodeMaterialConnectionPoint;
  22832. /**
  22833. * Gets the a input component
  22834. */
  22835. get a(): NodeMaterialConnectionPoint;
  22836. protected _buildBlock(state: NodeMaterialBuildState): this;
  22837. }
  22838. }
  22839. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22843. /**
  22844. * Block used for the particle ramp gradient section
  22845. */
  22846. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22847. /**
  22848. * Create a new ParticleRampGradientBlock
  22849. * @param name defines the block name
  22850. */
  22851. constructor(name: string);
  22852. /**
  22853. * Gets the current class name
  22854. * @returns the class name
  22855. */
  22856. getClassName(): string;
  22857. /**
  22858. * Gets the color input component
  22859. */
  22860. get color(): NodeMaterialConnectionPoint;
  22861. /**
  22862. * Gets the rampColor output component
  22863. */
  22864. get rampColor(): NodeMaterialConnectionPoint;
  22865. /**
  22866. * Initialize the block and prepare the context for build
  22867. * @param state defines the state that will be used for the build
  22868. */
  22869. initialize(state: NodeMaterialBuildState): void;
  22870. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22871. }
  22872. }
  22873. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22877. /**
  22878. * Block used for the particle blend multiply section
  22879. */
  22880. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22881. /**
  22882. * Create a new ParticleBlendMultiplyBlock
  22883. * @param name defines the block name
  22884. */
  22885. constructor(name: string);
  22886. /**
  22887. * Gets the current class name
  22888. * @returns the class name
  22889. */
  22890. getClassName(): string;
  22891. /**
  22892. * Gets the color input component
  22893. */
  22894. get color(): NodeMaterialConnectionPoint;
  22895. /**
  22896. * Gets the alphaTexture input component
  22897. */
  22898. get alphaTexture(): NodeMaterialConnectionPoint;
  22899. /**
  22900. * Gets the alphaColor input component
  22901. */
  22902. get alphaColor(): NodeMaterialConnectionPoint;
  22903. /**
  22904. * Gets the blendColor output component
  22905. */
  22906. get blendColor(): NodeMaterialConnectionPoint;
  22907. /**
  22908. * Initialize the block and prepare the context for build
  22909. * @param state defines the state that will be used for the build
  22910. */
  22911. initialize(state: NodeMaterialBuildState): void;
  22912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22913. }
  22914. }
  22915. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22919. /**
  22920. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22921. */
  22922. export class VectorMergerBlock extends NodeMaterialBlock {
  22923. /**
  22924. * Create a new VectorMergerBlock
  22925. * @param name defines the block name
  22926. */
  22927. constructor(name: string);
  22928. /**
  22929. * Gets the current class name
  22930. * @returns the class name
  22931. */
  22932. getClassName(): string;
  22933. /**
  22934. * Gets the xyz component (input)
  22935. */
  22936. get xyzIn(): NodeMaterialConnectionPoint;
  22937. /**
  22938. * Gets the xy component (input)
  22939. */
  22940. get xyIn(): NodeMaterialConnectionPoint;
  22941. /**
  22942. * Gets the x component (input)
  22943. */
  22944. get x(): NodeMaterialConnectionPoint;
  22945. /**
  22946. * Gets the y component (input)
  22947. */
  22948. get y(): NodeMaterialConnectionPoint;
  22949. /**
  22950. * Gets the z component (input)
  22951. */
  22952. get z(): NodeMaterialConnectionPoint;
  22953. /**
  22954. * Gets the w component (input)
  22955. */
  22956. get w(): NodeMaterialConnectionPoint;
  22957. /**
  22958. * Gets the xyzw component (output)
  22959. */
  22960. get xyzw(): NodeMaterialConnectionPoint;
  22961. /**
  22962. * Gets the xyz component (output)
  22963. */
  22964. get xyzOut(): NodeMaterialConnectionPoint;
  22965. /**
  22966. * Gets the xy component (output)
  22967. */
  22968. get xyOut(): NodeMaterialConnectionPoint;
  22969. /**
  22970. * Gets the xy component (output)
  22971. * @deprecated Please use xyOut instead.
  22972. */
  22973. get xy(): NodeMaterialConnectionPoint;
  22974. /**
  22975. * Gets the xyz component (output)
  22976. * @deprecated Please use xyzOut instead.
  22977. */
  22978. get xyz(): NodeMaterialConnectionPoint;
  22979. protected _buildBlock(state: NodeMaterialBuildState): this;
  22980. }
  22981. }
  22982. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22986. import { Vector2 } from "babylonjs/Maths/math.vector";
  22987. import { Scene } from "babylonjs/scene";
  22988. /**
  22989. * Block used to remap a float from a range to a new one
  22990. */
  22991. export class RemapBlock extends NodeMaterialBlock {
  22992. /**
  22993. * Gets or sets the source range
  22994. */
  22995. sourceRange: Vector2;
  22996. /**
  22997. * Gets or sets the target range
  22998. */
  22999. targetRange: Vector2;
  23000. /**
  23001. * Creates a new RemapBlock
  23002. * @param name defines the block name
  23003. */
  23004. constructor(name: string);
  23005. /**
  23006. * Gets the current class name
  23007. * @returns the class name
  23008. */
  23009. getClassName(): string;
  23010. /**
  23011. * Gets the input component
  23012. */
  23013. get input(): NodeMaterialConnectionPoint;
  23014. /**
  23015. * Gets the source min input component
  23016. */
  23017. get sourceMin(): NodeMaterialConnectionPoint;
  23018. /**
  23019. * Gets the source max input component
  23020. */
  23021. get sourceMax(): NodeMaterialConnectionPoint;
  23022. /**
  23023. * Gets the target min input component
  23024. */
  23025. get targetMin(): NodeMaterialConnectionPoint;
  23026. /**
  23027. * Gets the target max input component
  23028. */
  23029. get targetMax(): NodeMaterialConnectionPoint;
  23030. /**
  23031. * Gets the output component
  23032. */
  23033. get output(): NodeMaterialConnectionPoint;
  23034. protected _buildBlock(state: NodeMaterialBuildState): this;
  23035. protected _dumpPropertiesCode(): string;
  23036. serialize(): any;
  23037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23038. }
  23039. }
  23040. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23044. /**
  23045. * Block used to multiply 2 values
  23046. */
  23047. export class MultiplyBlock extends NodeMaterialBlock {
  23048. /**
  23049. * Creates a new MultiplyBlock
  23050. * @param name defines the block name
  23051. */
  23052. constructor(name: string);
  23053. /**
  23054. * Gets the current class name
  23055. * @returns the class name
  23056. */
  23057. getClassName(): string;
  23058. /**
  23059. * Gets the left operand input component
  23060. */
  23061. get left(): NodeMaterialConnectionPoint;
  23062. /**
  23063. * Gets the right operand input component
  23064. */
  23065. get right(): NodeMaterialConnectionPoint;
  23066. /**
  23067. * Gets the output component
  23068. */
  23069. get output(): NodeMaterialConnectionPoint;
  23070. protected _buildBlock(state: NodeMaterialBuildState): this;
  23071. }
  23072. }
  23073. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23077. /**
  23078. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23079. */
  23080. export class ColorSplitterBlock extends NodeMaterialBlock {
  23081. /**
  23082. * Create a new ColorSplitterBlock
  23083. * @param name defines the block name
  23084. */
  23085. constructor(name: string);
  23086. /**
  23087. * Gets the current class name
  23088. * @returns the class name
  23089. */
  23090. getClassName(): string;
  23091. /**
  23092. * Gets the rgba component (input)
  23093. */
  23094. get rgba(): NodeMaterialConnectionPoint;
  23095. /**
  23096. * Gets the rgb component (input)
  23097. */
  23098. get rgbIn(): NodeMaterialConnectionPoint;
  23099. /**
  23100. * Gets the rgb component (output)
  23101. */
  23102. get rgbOut(): NodeMaterialConnectionPoint;
  23103. /**
  23104. * Gets the r component (output)
  23105. */
  23106. get r(): NodeMaterialConnectionPoint;
  23107. /**
  23108. * Gets the g component (output)
  23109. */
  23110. get g(): NodeMaterialConnectionPoint;
  23111. /**
  23112. * Gets the b component (output)
  23113. */
  23114. get b(): NodeMaterialConnectionPoint;
  23115. /**
  23116. * Gets the a component (output)
  23117. */
  23118. get a(): NodeMaterialConnectionPoint;
  23119. protected _inputRename(name: string): string;
  23120. protected _outputRename(name: string): string;
  23121. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23122. }
  23123. }
  23124. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23128. import { Scene } from "babylonjs/scene";
  23129. /**
  23130. * Operations supported by the Trigonometry block
  23131. */
  23132. export enum TrigonometryBlockOperations {
  23133. /** Cos */
  23134. Cos = 0,
  23135. /** Sin */
  23136. Sin = 1,
  23137. /** Abs */
  23138. Abs = 2,
  23139. /** Exp */
  23140. Exp = 3,
  23141. /** Exp2 */
  23142. Exp2 = 4,
  23143. /** Round */
  23144. Round = 5,
  23145. /** Floor */
  23146. Floor = 6,
  23147. /** Ceiling */
  23148. Ceiling = 7,
  23149. /** Square root */
  23150. Sqrt = 8,
  23151. /** Log */
  23152. Log = 9,
  23153. /** Tangent */
  23154. Tan = 10,
  23155. /** Arc tangent */
  23156. ArcTan = 11,
  23157. /** Arc cosinus */
  23158. ArcCos = 12,
  23159. /** Arc sinus */
  23160. ArcSin = 13,
  23161. /** Fraction */
  23162. Fract = 14,
  23163. /** Sign */
  23164. Sign = 15,
  23165. /** To radians (from degrees) */
  23166. Radians = 16,
  23167. /** To degrees (from radians) */
  23168. Degrees = 17
  23169. }
  23170. /**
  23171. * Block used to apply trigonometry operation to floats
  23172. */
  23173. export class TrigonometryBlock extends NodeMaterialBlock {
  23174. /**
  23175. * Gets or sets the operation applied by the block
  23176. */
  23177. operation: TrigonometryBlockOperations;
  23178. /**
  23179. * Creates a new TrigonometryBlock
  23180. * @param name defines the block name
  23181. */
  23182. constructor(name: string);
  23183. /**
  23184. * Gets the current class name
  23185. * @returns the class name
  23186. */
  23187. getClassName(): string;
  23188. /**
  23189. * Gets the input component
  23190. */
  23191. get input(): NodeMaterialConnectionPoint;
  23192. /**
  23193. * Gets the output component
  23194. */
  23195. get output(): NodeMaterialConnectionPoint;
  23196. protected _buildBlock(state: NodeMaterialBuildState): this;
  23197. serialize(): any;
  23198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23199. protected _dumpPropertiesCode(): string;
  23200. }
  23201. }
  23202. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23204. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23205. import { Scene } from "babylonjs/scene";
  23206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23207. import { Matrix } from "babylonjs/Maths/math.vector";
  23208. import { Mesh } from "babylonjs/Meshes/mesh";
  23209. import { Engine } from "babylonjs/Engines/engine";
  23210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23211. import { Observable } from "babylonjs/Misc/observable";
  23212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23213. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23214. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23215. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23216. import { Nullable } from "babylonjs/types";
  23217. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23218. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23219. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23220. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23221. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23222. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23223. import { Effect } from "babylonjs/Materials/effect";
  23224. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23225. import { Camera } from "babylonjs/Cameras/camera";
  23226. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23227. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23228. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23229. /**
  23230. * Interface used to configure the node material editor
  23231. */
  23232. export interface INodeMaterialEditorOptions {
  23233. /** Define the URl to load node editor script */
  23234. editorURL?: string;
  23235. }
  23236. /** @hidden */
  23237. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23238. NORMAL: boolean;
  23239. TANGENT: boolean;
  23240. UV1: boolean;
  23241. /** BONES */
  23242. NUM_BONE_INFLUENCERS: number;
  23243. BonesPerMesh: number;
  23244. BONETEXTURE: boolean;
  23245. /** MORPH TARGETS */
  23246. MORPHTARGETS: boolean;
  23247. MORPHTARGETS_NORMAL: boolean;
  23248. MORPHTARGETS_TANGENT: boolean;
  23249. MORPHTARGETS_UV: boolean;
  23250. NUM_MORPH_INFLUENCERS: number;
  23251. /** IMAGE PROCESSING */
  23252. IMAGEPROCESSING: boolean;
  23253. VIGNETTE: boolean;
  23254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23255. VIGNETTEBLENDMODEOPAQUE: boolean;
  23256. TONEMAPPING: boolean;
  23257. TONEMAPPING_ACES: boolean;
  23258. CONTRAST: boolean;
  23259. EXPOSURE: boolean;
  23260. COLORCURVES: boolean;
  23261. COLORGRADING: boolean;
  23262. COLORGRADING3D: boolean;
  23263. SAMPLER3DGREENDEPTH: boolean;
  23264. SAMPLER3DBGRMAP: boolean;
  23265. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23266. /** MISC. */
  23267. BUMPDIRECTUV: number;
  23268. constructor();
  23269. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23270. }
  23271. /**
  23272. * Class used to configure NodeMaterial
  23273. */
  23274. export interface INodeMaterialOptions {
  23275. /**
  23276. * Defines if blocks should emit comments
  23277. */
  23278. emitComments: boolean;
  23279. }
  23280. /**
  23281. * Class used to create a node based material built by assembling shader blocks
  23282. */
  23283. export class NodeMaterial extends PushMaterial {
  23284. private static _BuildIdGenerator;
  23285. private _options;
  23286. private _vertexCompilationState;
  23287. private _fragmentCompilationState;
  23288. private _sharedData;
  23289. private _buildId;
  23290. private _buildWasSuccessful;
  23291. private _cachedWorldViewMatrix;
  23292. private _cachedWorldViewProjectionMatrix;
  23293. private _optimizers;
  23294. private _animationFrame;
  23295. /** Define the Url to load node editor script */
  23296. static EditorURL: string;
  23297. /** Define the Url to load snippets */
  23298. static SnippetUrl: string;
  23299. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23300. static IgnoreTexturesAtLoadTime: boolean;
  23301. private BJSNODEMATERIALEDITOR;
  23302. /** Get the inspector from bundle or global */
  23303. private _getGlobalNodeMaterialEditor;
  23304. /**
  23305. * Snippet ID if the material was created from the snippet server
  23306. */
  23307. snippetId: string;
  23308. /**
  23309. * Gets or sets data used by visual editor
  23310. * @see https://nme.babylonjs.com
  23311. */
  23312. editorData: any;
  23313. /**
  23314. * 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)
  23315. */
  23316. ignoreAlpha: boolean;
  23317. /**
  23318. * Defines the maximum number of lights that can be used in the material
  23319. */
  23320. maxSimultaneousLights: number;
  23321. /**
  23322. * Observable raised when the material is built
  23323. */
  23324. onBuildObservable: Observable<NodeMaterial>;
  23325. /**
  23326. * Gets or sets the root nodes of the material vertex shader
  23327. */
  23328. _vertexOutputNodes: NodeMaterialBlock[];
  23329. /**
  23330. * Gets or sets the root nodes of the material fragment (pixel) shader
  23331. */
  23332. _fragmentOutputNodes: NodeMaterialBlock[];
  23333. /** Gets or sets options to control the node material overall behavior */
  23334. get options(): INodeMaterialOptions;
  23335. set options(options: INodeMaterialOptions);
  23336. /**
  23337. * Default configuration related to image processing available in the standard Material.
  23338. */
  23339. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23340. /**
  23341. * Gets the image processing configuration used either in this material.
  23342. */
  23343. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23344. /**
  23345. * Sets the Default image processing configuration used either in the this material.
  23346. *
  23347. * If sets to null, the scene one is in use.
  23348. */
  23349. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23350. /**
  23351. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23352. */
  23353. attachedBlocks: NodeMaterialBlock[];
  23354. /**
  23355. * Specifies the mode of the node material
  23356. * @hidden
  23357. */
  23358. _mode: NodeMaterialModes;
  23359. /**
  23360. * Gets the mode property
  23361. */
  23362. get mode(): NodeMaterialModes;
  23363. /**
  23364. * Create a new node based material
  23365. * @param name defines the material name
  23366. * @param scene defines the hosting scene
  23367. * @param options defines creation option
  23368. */
  23369. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23370. /**
  23371. * Gets the current class name of the material e.g. "NodeMaterial"
  23372. * @returns the class name
  23373. */
  23374. getClassName(): string;
  23375. /**
  23376. * Keep track of the image processing observer to allow dispose and replace.
  23377. */
  23378. private _imageProcessingObserver;
  23379. /**
  23380. * Attaches a new image processing configuration to the Standard Material.
  23381. * @param configuration
  23382. */
  23383. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23384. /**
  23385. * Get a block by its name
  23386. * @param name defines the name of the block to retrieve
  23387. * @returns the required block or null if not found
  23388. */
  23389. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23390. /**
  23391. * Get a block by its name
  23392. * @param predicate defines the predicate used to find the good candidate
  23393. * @returns the required block or null if not found
  23394. */
  23395. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23396. /**
  23397. * Get an input block by its name
  23398. * @param predicate defines the predicate used to find the good candidate
  23399. * @returns the required input block or null if not found
  23400. */
  23401. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23402. /**
  23403. * Gets the list of input blocks attached to this material
  23404. * @returns an array of InputBlocks
  23405. */
  23406. getInputBlocks(): InputBlock[];
  23407. /**
  23408. * Adds a new optimizer to the list of optimizers
  23409. * @param optimizer defines the optimizers to add
  23410. * @returns the current material
  23411. */
  23412. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23413. /**
  23414. * Remove an optimizer from the list of optimizers
  23415. * @param optimizer defines the optimizers to remove
  23416. * @returns the current material
  23417. */
  23418. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23419. /**
  23420. * Add a new block to the list of output nodes
  23421. * @param node defines the node to add
  23422. * @returns the current material
  23423. */
  23424. addOutputNode(node: NodeMaterialBlock): this;
  23425. /**
  23426. * Remove a block from the list of root nodes
  23427. * @param node defines the node to remove
  23428. * @returns the current material
  23429. */
  23430. removeOutputNode(node: NodeMaterialBlock): this;
  23431. private _addVertexOutputNode;
  23432. private _removeVertexOutputNode;
  23433. private _addFragmentOutputNode;
  23434. private _removeFragmentOutputNode;
  23435. /**
  23436. * Specifies if the material will require alpha blending
  23437. * @returns a boolean specifying if alpha blending is needed
  23438. */
  23439. needAlphaBlending(): boolean;
  23440. /**
  23441. * Specifies if this material should be rendered in alpha test mode
  23442. * @returns a boolean specifying if an alpha test is needed.
  23443. */
  23444. needAlphaTesting(): boolean;
  23445. private _initializeBlock;
  23446. private _resetDualBlocks;
  23447. /**
  23448. * Remove a block from the current node material
  23449. * @param block defines the block to remove
  23450. */
  23451. removeBlock(block: NodeMaterialBlock): void;
  23452. /**
  23453. * Build the material and generates the inner effect
  23454. * @param verbose defines if the build should log activity
  23455. */
  23456. build(verbose?: boolean): void;
  23457. /**
  23458. * Runs an otpimization phase to try to improve the shader code
  23459. */
  23460. optimize(): void;
  23461. private _prepareDefinesForAttributes;
  23462. /**
  23463. * Create a post process from the material
  23464. * @param camera The camera to apply the render pass to.
  23465. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23467. * @param engine The engine which the post process will be applied. (default: current engine)
  23468. * @param reusable If the post process can be reused on the same frame. (default: false)
  23469. * @param textureType Type of textures used when performing the post process. (default: 0)
  23470. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23471. * @returns the post process created
  23472. */
  23473. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23474. /**
  23475. * Create the post process effect from the material
  23476. * @param postProcess The post process to create the effect for
  23477. */
  23478. createEffectForPostProcess(postProcess: PostProcess): void;
  23479. private _createEffectForPostProcess;
  23480. /**
  23481. * Create a new procedural texture based on this node material
  23482. * @param size defines the size of the texture
  23483. * @param scene defines the hosting scene
  23484. * @returns the new procedural texture attached to this node material
  23485. */
  23486. createProceduralTexture(size: number | {
  23487. width: number;
  23488. height: number;
  23489. layers?: number;
  23490. }, scene: Scene): Nullable<ProceduralTexture>;
  23491. private _createEffectForParticles;
  23492. private _checkInternals;
  23493. /**
  23494. * Create the effect to be used as the custom effect for a particle system
  23495. * @param particleSystem Particle system to create the effect for
  23496. * @param onCompiled defines a function to call when the effect creation is successful
  23497. * @param onError defines a function to call when the effect creation has failed
  23498. */
  23499. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23500. private _processDefines;
  23501. /**
  23502. * Get if the submesh is ready to be used and all its information available.
  23503. * Child classes can use it to update shaders
  23504. * @param mesh defines the mesh to check
  23505. * @param subMesh defines which submesh to check
  23506. * @param useInstances specifies that instances should be used
  23507. * @returns a boolean indicating that the submesh is ready or not
  23508. */
  23509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23510. /**
  23511. * Get a string representing the shaders built by the current node graph
  23512. */
  23513. get compiledShaders(): string;
  23514. /**
  23515. * Binds the world matrix to the material
  23516. * @param world defines the world transformation matrix
  23517. */
  23518. bindOnlyWorldMatrix(world: Matrix): void;
  23519. /**
  23520. * Binds the submesh to this material by preparing the effect and shader to draw
  23521. * @param world defines the world transformation matrix
  23522. * @param mesh defines the mesh containing the submesh
  23523. * @param subMesh defines the submesh to bind the material to
  23524. */
  23525. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23526. /**
  23527. * Gets the active textures from the material
  23528. * @returns an array of textures
  23529. */
  23530. getActiveTextures(): BaseTexture[];
  23531. /**
  23532. * Gets the list of texture blocks
  23533. * @returns an array of texture blocks
  23534. */
  23535. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23536. /**
  23537. * Specifies if the material uses a texture
  23538. * @param texture defines the texture to check against the material
  23539. * @returns a boolean specifying if the material uses the texture
  23540. */
  23541. hasTexture(texture: BaseTexture): boolean;
  23542. /**
  23543. * Disposes the material
  23544. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23545. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23546. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23547. */
  23548. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23549. /** Creates the node editor window. */
  23550. private _createNodeEditor;
  23551. /**
  23552. * Launch the node material editor
  23553. * @param config Define the configuration of the editor
  23554. * @return a promise fulfilled when the node editor is visible
  23555. */
  23556. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23557. /**
  23558. * Clear the current material
  23559. */
  23560. clear(): void;
  23561. /**
  23562. * Clear the current material and set it to a default state
  23563. */
  23564. setToDefault(): void;
  23565. /**
  23566. * Clear the current material and set it to a default state for post process
  23567. */
  23568. setToDefaultPostProcess(): void;
  23569. /**
  23570. * Clear the current material and set it to a default state for procedural texture
  23571. */
  23572. setToDefaultProceduralTexture(): void;
  23573. /**
  23574. * Clear the current material and set it to a default state for particle
  23575. */
  23576. setToDefaultParticle(): void;
  23577. /**
  23578. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23579. * @param url defines the url to load from
  23580. * @returns a promise that will fullfil when the material is fully loaded
  23581. */
  23582. loadAsync(url: string): Promise<void>;
  23583. private _gatherBlocks;
  23584. /**
  23585. * Generate a string containing the code declaration required to create an equivalent of this material
  23586. * @returns a string
  23587. */
  23588. generateCode(): string;
  23589. /**
  23590. * Serializes this material in a JSON representation
  23591. * @returns the serialized material object
  23592. */
  23593. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23594. private _restoreConnections;
  23595. /**
  23596. * Clear the current graph and load a new one from a serialization object
  23597. * @param source defines the JSON representation of the material
  23598. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23599. * @param merge defines whether or not the source must be merged or replace the current content
  23600. */
  23601. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23602. /**
  23603. * Makes a duplicate of the current material.
  23604. * @param name - name to use for the new material.
  23605. */
  23606. clone(name: string): NodeMaterial;
  23607. /**
  23608. * Creates a node material from parsed material data
  23609. * @param source defines the JSON representation of the material
  23610. * @param scene defines the hosting scene
  23611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23612. * @returns a new node material
  23613. */
  23614. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23615. /**
  23616. * Creates a node material from a snippet saved in a remote file
  23617. * @param name defines the name of the material to create
  23618. * @param url defines the url to load from
  23619. * @param scene defines the hosting scene
  23620. * @returns a promise that will resolve to the new node material
  23621. */
  23622. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23623. /**
  23624. * Creates a node material from a snippet saved by the node material editor
  23625. * @param snippetId defines the snippet to load
  23626. * @param scene defines the hosting scene
  23627. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23628. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23629. * @returns a promise that will resolve to the new node material
  23630. */
  23631. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23632. /**
  23633. * Creates a new node material set to default basic configuration
  23634. * @param name defines the name of the material
  23635. * @param scene defines the hosting scene
  23636. * @returns a new NodeMaterial
  23637. */
  23638. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23639. }
  23640. }
  23641. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23643. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23644. import { Nullable } from "babylonjs/types";
  23645. module "babylonjs/Engines/thinEngine" {
  23646. interface ThinEngine {
  23647. /**
  23648. * Unbind a list of render target textures from the webGL context
  23649. * This is used only when drawBuffer extension or webGL2 are active
  23650. * @param textures defines the render target textures to unbind
  23651. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23652. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23653. */
  23654. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23655. /**
  23656. * Create a multi render target texture
  23657. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23658. * @param size defines the size of the texture
  23659. * @param options defines the creation options
  23660. * @returns the cube texture as an InternalTexture
  23661. */
  23662. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23663. /**
  23664. * Update the sample count for a given multiple render target texture
  23665. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23666. * @param textures defines the textures to update
  23667. * @param samples defines the sample count to set
  23668. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23669. */
  23670. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23671. /**
  23672. * Select a subsets of attachments to draw to.
  23673. * @param attachments gl attachments
  23674. */
  23675. bindAttachments(attachments: number[]): void;
  23676. /**
  23677. * Creates a layout object to draw/clear on specific textures in a MRT
  23678. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23679. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23680. */
  23681. buildTextureLayout(textureStatus: boolean[]): number[];
  23682. /**
  23683. * Restores the webgl state to only draw on the main color attachment
  23684. */
  23685. restoreSingleAttachment(): void;
  23686. }
  23687. }
  23688. }
  23689. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23690. import { Scene } from "babylonjs/scene";
  23691. import { Engine } from "babylonjs/Engines/engine";
  23692. import { Texture } from "babylonjs/Materials/Textures/texture";
  23693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23694. import "babylonjs/Engines/Extensions/engine.multiRender";
  23695. /**
  23696. * Creation options of the multi render target texture.
  23697. */
  23698. export interface IMultiRenderTargetOptions {
  23699. /**
  23700. * Define if the texture needs to create mip maps after render.
  23701. */
  23702. generateMipMaps?: boolean;
  23703. /**
  23704. * Define the types of all the draw buffers we want to create
  23705. */
  23706. types?: number[];
  23707. /**
  23708. * Define the sampling modes of all the draw buffers we want to create
  23709. */
  23710. samplingModes?: number[];
  23711. /**
  23712. * Define if a depth buffer is required
  23713. */
  23714. generateDepthBuffer?: boolean;
  23715. /**
  23716. * Define if a stencil buffer is required
  23717. */
  23718. generateStencilBuffer?: boolean;
  23719. /**
  23720. * Define if a depth texture is required instead of a depth buffer
  23721. */
  23722. generateDepthTexture?: boolean;
  23723. /**
  23724. * Define the number of desired draw buffers
  23725. */
  23726. textureCount?: number;
  23727. /**
  23728. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23729. */
  23730. doNotChangeAspectRatio?: boolean;
  23731. /**
  23732. * Define the default type of the buffers we are creating
  23733. */
  23734. defaultType?: number;
  23735. }
  23736. /**
  23737. * A multi render target, like a render target provides the ability to render to a texture.
  23738. * Unlike the render target, it can render to several draw buffers in one draw.
  23739. * This is specially interesting in deferred rendering or for any effects requiring more than
  23740. * just one color from a single pass.
  23741. */
  23742. export class MultiRenderTarget extends RenderTargetTexture {
  23743. private _internalTextures;
  23744. private _textures;
  23745. private _multiRenderTargetOptions;
  23746. private _count;
  23747. /**
  23748. * Get if draw buffers are currently supported by the used hardware and browser.
  23749. */
  23750. get isSupported(): boolean;
  23751. /**
  23752. * Get the list of textures generated by the multi render target.
  23753. */
  23754. get textures(): Texture[];
  23755. /**
  23756. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23757. */
  23758. get count(): number;
  23759. /**
  23760. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23761. */
  23762. get depthTexture(): Texture;
  23763. /**
  23764. * Set the wrapping mode on U of all the textures we are rendering to.
  23765. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23766. */
  23767. set wrapU(wrap: number);
  23768. /**
  23769. * Set the wrapping mode on V of all the textures we are rendering to.
  23770. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23771. */
  23772. set wrapV(wrap: number);
  23773. /**
  23774. * Instantiate a new multi render target texture.
  23775. * A multi render target, like a render target provides the ability to render to a texture.
  23776. * Unlike the render target, it can render to several draw buffers in one draw.
  23777. * This is specially interesting in deferred rendering or for any effects requiring more than
  23778. * just one color from a single pass.
  23779. * @param name Define the name of the texture
  23780. * @param size Define the size of the buffers to render to
  23781. * @param count Define the number of target we are rendering into
  23782. * @param scene Define the scene the texture belongs to
  23783. * @param options Define the options used to create the multi render target
  23784. */
  23785. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23786. private _initTypes;
  23787. /** @hidden */
  23788. _rebuild(forceFullRebuild?: boolean): void;
  23789. private _createInternalTextures;
  23790. private _createTextures;
  23791. /**
  23792. * Replaces a texture within the MRT.
  23793. * @param texture The new texture to insert in the MRT
  23794. * @param index The index of the texture to replace
  23795. */
  23796. replaceTexture(texture: Texture, index: number): void;
  23797. /**
  23798. * Define the number of samples used if MSAA is enabled.
  23799. */
  23800. get samples(): number;
  23801. set samples(value: number);
  23802. /**
  23803. * Resize all the textures in the multi render target.
  23804. * Be careful as it will recreate all the data in the new texture.
  23805. * @param size Define the new size
  23806. */
  23807. resize(size: any): void;
  23808. /**
  23809. * Changes the number of render targets in this MRT
  23810. * Be careful as it will recreate all the data in the new texture.
  23811. * @param count new texture count
  23812. * @param options Specifies texture types and sampling modes for new textures
  23813. */
  23814. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23815. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23816. /**
  23817. * Dispose the render targets and their associated resources
  23818. */
  23819. dispose(): void;
  23820. /**
  23821. * Release all the underlying texture used as draw buffers.
  23822. */
  23823. releaseInternalTextures(): void;
  23824. }
  23825. }
  23826. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23827. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23828. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23829. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23830. /** @hidden */
  23831. export var imageProcessingPixelShader: {
  23832. name: string;
  23833. shader: string;
  23834. };
  23835. }
  23836. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23837. import { Nullable } from "babylonjs/types";
  23838. import { Color4 } from "babylonjs/Maths/math.color";
  23839. import { Camera } from "babylonjs/Cameras/camera";
  23840. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23841. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23842. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23843. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23844. import { Engine } from "babylonjs/Engines/engine";
  23845. import "babylonjs/Shaders/imageProcessing.fragment";
  23846. import "babylonjs/Shaders/postprocess.vertex";
  23847. /**
  23848. * ImageProcessingPostProcess
  23849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23850. */
  23851. export class ImageProcessingPostProcess extends PostProcess {
  23852. /**
  23853. * Default configuration related to image processing available in the PBR Material.
  23854. */
  23855. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23856. /**
  23857. * Gets the image processing configuration used either in this material.
  23858. */
  23859. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23860. /**
  23861. * Sets the Default image processing configuration used either in the this material.
  23862. *
  23863. * If sets to null, the scene one is in use.
  23864. */
  23865. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23866. /**
  23867. * Keep track of the image processing observer to allow dispose and replace.
  23868. */
  23869. private _imageProcessingObserver;
  23870. /**
  23871. * Attaches a new image processing configuration to the PBR Material.
  23872. * @param configuration
  23873. */
  23874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23875. /**
  23876. * If the post process is supported.
  23877. */
  23878. get isSupported(): boolean;
  23879. /**
  23880. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23881. */
  23882. get colorCurves(): Nullable<ColorCurves>;
  23883. /**
  23884. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23885. */
  23886. set colorCurves(value: Nullable<ColorCurves>);
  23887. /**
  23888. * Gets wether the color curves effect is enabled.
  23889. */
  23890. get colorCurvesEnabled(): boolean;
  23891. /**
  23892. * Sets wether the color curves effect is enabled.
  23893. */
  23894. set colorCurvesEnabled(value: boolean);
  23895. /**
  23896. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23897. */
  23898. get colorGradingTexture(): Nullable<BaseTexture>;
  23899. /**
  23900. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23901. */
  23902. set colorGradingTexture(value: Nullable<BaseTexture>);
  23903. /**
  23904. * Gets wether the color grading effect is enabled.
  23905. */
  23906. get colorGradingEnabled(): boolean;
  23907. /**
  23908. * Gets wether the color grading effect is enabled.
  23909. */
  23910. set colorGradingEnabled(value: boolean);
  23911. /**
  23912. * Gets exposure used in the effect.
  23913. */
  23914. get exposure(): number;
  23915. /**
  23916. * Sets exposure used in the effect.
  23917. */
  23918. set exposure(value: number);
  23919. /**
  23920. * Gets wether tonemapping is enabled or not.
  23921. */
  23922. get toneMappingEnabled(): boolean;
  23923. /**
  23924. * Sets wether tonemapping is enabled or not
  23925. */
  23926. set toneMappingEnabled(value: boolean);
  23927. /**
  23928. * Gets the type of tone mapping effect.
  23929. */
  23930. get toneMappingType(): number;
  23931. /**
  23932. * Sets the type of tone mapping effect.
  23933. */
  23934. set toneMappingType(value: number);
  23935. /**
  23936. * Gets contrast used in the effect.
  23937. */
  23938. get contrast(): number;
  23939. /**
  23940. * Sets contrast used in the effect.
  23941. */
  23942. set contrast(value: number);
  23943. /**
  23944. * Gets Vignette stretch size.
  23945. */
  23946. get vignetteStretch(): number;
  23947. /**
  23948. * Sets Vignette stretch size.
  23949. */
  23950. set vignetteStretch(value: number);
  23951. /**
  23952. * Gets Vignette centre X Offset.
  23953. */
  23954. get vignetteCentreX(): number;
  23955. /**
  23956. * Sets Vignette centre X Offset.
  23957. */
  23958. set vignetteCentreX(value: number);
  23959. /**
  23960. * Gets Vignette centre Y Offset.
  23961. */
  23962. get vignetteCentreY(): number;
  23963. /**
  23964. * Sets Vignette centre Y Offset.
  23965. */
  23966. set vignetteCentreY(value: number);
  23967. /**
  23968. * Gets Vignette weight or intensity of the vignette effect.
  23969. */
  23970. get vignetteWeight(): number;
  23971. /**
  23972. * Sets Vignette weight or intensity of the vignette effect.
  23973. */
  23974. set vignetteWeight(value: number);
  23975. /**
  23976. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23977. * if vignetteEnabled is set to true.
  23978. */
  23979. get vignetteColor(): Color4;
  23980. /**
  23981. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23982. * if vignetteEnabled is set to true.
  23983. */
  23984. set vignetteColor(value: Color4);
  23985. /**
  23986. * Gets Camera field of view used by the Vignette effect.
  23987. */
  23988. get vignetteCameraFov(): number;
  23989. /**
  23990. * Sets Camera field of view used by the Vignette effect.
  23991. */
  23992. set vignetteCameraFov(value: number);
  23993. /**
  23994. * Gets the vignette blend mode allowing different kind of effect.
  23995. */
  23996. get vignetteBlendMode(): number;
  23997. /**
  23998. * Sets the vignette blend mode allowing different kind of effect.
  23999. */
  24000. set vignetteBlendMode(value: number);
  24001. /**
  24002. * Gets wether the vignette effect is enabled.
  24003. */
  24004. get vignetteEnabled(): boolean;
  24005. /**
  24006. * Sets wether the vignette effect is enabled.
  24007. */
  24008. set vignetteEnabled(value: boolean);
  24009. private _fromLinearSpace;
  24010. /**
  24011. * Gets wether the input of the processing is in Gamma or Linear Space.
  24012. */
  24013. get fromLinearSpace(): boolean;
  24014. /**
  24015. * Sets wether the input of the processing is in Gamma or Linear Space.
  24016. */
  24017. set fromLinearSpace(value: boolean);
  24018. /**
  24019. * Defines cache preventing GC.
  24020. */
  24021. private _defines;
  24022. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24023. /**
  24024. * "ImageProcessingPostProcess"
  24025. * @returns "ImageProcessingPostProcess"
  24026. */
  24027. getClassName(): string;
  24028. /**
  24029. * @hidden
  24030. */
  24031. _updateParameters(): void;
  24032. dispose(camera?: Camera): void;
  24033. }
  24034. }
  24035. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24036. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24037. /**
  24038. * Interface for defining prepass effects in the prepass post-process pipeline
  24039. */
  24040. export interface PrePassEffectConfiguration {
  24041. /**
  24042. * Name of the effect
  24043. */
  24044. name: string;
  24045. /**
  24046. * Post process to attach for this effect
  24047. */
  24048. postProcess?: PostProcess;
  24049. /**
  24050. * Textures required in the MRT
  24051. */
  24052. texturesRequired: number[];
  24053. /**
  24054. * Is the effect enabled
  24055. */
  24056. enabled: boolean;
  24057. /**
  24058. * Disposes the effect configuration
  24059. */
  24060. dispose?: () => void;
  24061. /**
  24062. * Creates the associated post process
  24063. */
  24064. createPostProcess?: () => PostProcess;
  24065. }
  24066. }
  24067. declare module "babylonjs/Materials/fresnelParameters" {
  24068. import { DeepImmutable } from "babylonjs/types";
  24069. import { Color3 } from "babylonjs/Maths/math.color";
  24070. /**
  24071. * Options to be used when creating a FresnelParameters.
  24072. */
  24073. export type IFresnelParametersCreationOptions = {
  24074. /**
  24075. * Define the color used on edges (grazing angle)
  24076. */
  24077. leftColor?: Color3;
  24078. /**
  24079. * Define the color used on center
  24080. */
  24081. rightColor?: Color3;
  24082. /**
  24083. * Define bias applied to computed fresnel term
  24084. */
  24085. bias?: number;
  24086. /**
  24087. * Defined the power exponent applied to fresnel term
  24088. */
  24089. power?: number;
  24090. /**
  24091. * Define if the fresnel effect is enable or not.
  24092. */
  24093. isEnabled?: boolean;
  24094. };
  24095. /**
  24096. * Serialized format for FresnelParameters.
  24097. */
  24098. export type IFresnelParametersSerialized = {
  24099. /**
  24100. * Define the color used on edges (grazing angle) [as an array]
  24101. */
  24102. leftColor: number[];
  24103. /**
  24104. * Define the color used on center [as an array]
  24105. */
  24106. rightColor: number[];
  24107. /**
  24108. * Define bias applied to computed fresnel term
  24109. */
  24110. bias: number;
  24111. /**
  24112. * Defined the power exponent applied to fresnel term
  24113. */
  24114. power?: number;
  24115. /**
  24116. * Define if the fresnel effect is enable or not.
  24117. */
  24118. isEnabled: boolean;
  24119. };
  24120. /**
  24121. * This represents all the required information to add a fresnel effect on a material:
  24122. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24123. */
  24124. export class FresnelParameters {
  24125. private _isEnabled;
  24126. /**
  24127. * Define if the fresnel effect is enable or not.
  24128. */
  24129. get isEnabled(): boolean;
  24130. set isEnabled(value: boolean);
  24131. /**
  24132. * Define the color used on edges (grazing angle)
  24133. */
  24134. leftColor: Color3;
  24135. /**
  24136. * Define the color used on center
  24137. */
  24138. rightColor: Color3;
  24139. /**
  24140. * Define bias applied to computed fresnel term
  24141. */
  24142. bias: number;
  24143. /**
  24144. * Defined the power exponent applied to fresnel term
  24145. */
  24146. power: number;
  24147. /**
  24148. * Creates a new FresnelParameters object.
  24149. *
  24150. * @param options provide your own settings to optionally to override defaults
  24151. */
  24152. constructor(options?: IFresnelParametersCreationOptions);
  24153. /**
  24154. * Clones the current fresnel and its valuues
  24155. * @returns a clone fresnel configuration
  24156. */
  24157. clone(): FresnelParameters;
  24158. /**
  24159. * Determines equality between FresnelParameters objects
  24160. * @param otherFresnelParameters defines the second operand
  24161. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24162. */
  24163. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24164. /**
  24165. * Serializes the current fresnel parameters to a JSON representation.
  24166. * @return the JSON serialization
  24167. */
  24168. serialize(): IFresnelParametersSerialized;
  24169. /**
  24170. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24171. * @param parsedFresnelParameters Define the JSON representation
  24172. * @returns the parsed parameters
  24173. */
  24174. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24175. }
  24176. }
  24177. declare module "babylonjs/Materials/materialFlags" {
  24178. /**
  24179. * This groups all the flags used to control the materials channel.
  24180. */
  24181. export class MaterialFlags {
  24182. private static _DiffuseTextureEnabled;
  24183. /**
  24184. * Are diffuse textures enabled in the application.
  24185. */
  24186. static get DiffuseTextureEnabled(): boolean;
  24187. static set DiffuseTextureEnabled(value: boolean);
  24188. private static _DetailTextureEnabled;
  24189. /**
  24190. * Are detail textures enabled in the application.
  24191. */
  24192. static get DetailTextureEnabled(): boolean;
  24193. static set DetailTextureEnabled(value: boolean);
  24194. private static _AmbientTextureEnabled;
  24195. /**
  24196. * Are ambient textures enabled in the application.
  24197. */
  24198. static get AmbientTextureEnabled(): boolean;
  24199. static set AmbientTextureEnabled(value: boolean);
  24200. private static _OpacityTextureEnabled;
  24201. /**
  24202. * Are opacity textures enabled in the application.
  24203. */
  24204. static get OpacityTextureEnabled(): boolean;
  24205. static set OpacityTextureEnabled(value: boolean);
  24206. private static _ReflectionTextureEnabled;
  24207. /**
  24208. * Are reflection textures enabled in the application.
  24209. */
  24210. static get ReflectionTextureEnabled(): boolean;
  24211. static set ReflectionTextureEnabled(value: boolean);
  24212. private static _EmissiveTextureEnabled;
  24213. /**
  24214. * Are emissive textures enabled in the application.
  24215. */
  24216. static get EmissiveTextureEnabled(): boolean;
  24217. static set EmissiveTextureEnabled(value: boolean);
  24218. private static _SpecularTextureEnabled;
  24219. /**
  24220. * Are specular textures enabled in the application.
  24221. */
  24222. static get SpecularTextureEnabled(): boolean;
  24223. static set SpecularTextureEnabled(value: boolean);
  24224. private static _BumpTextureEnabled;
  24225. /**
  24226. * Are bump textures enabled in the application.
  24227. */
  24228. static get BumpTextureEnabled(): boolean;
  24229. static set BumpTextureEnabled(value: boolean);
  24230. private static _LightmapTextureEnabled;
  24231. /**
  24232. * Are lightmap textures enabled in the application.
  24233. */
  24234. static get LightmapTextureEnabled(): boolean;
  24235. static set LightmapTextureEnabled(value: boolean);
  24236. private static _RefractionTextureEnabled;
  24237. /**
  24238. * Are refraction textures enabled in the application.
  24239. */
  24240. static get RefractionTextureEnabled(): boolean;
  24241. static set RefractionTextureEnabled(value: boolean);
  24242. private static _ColorGradingTextureEnabled;
  24243. /**
  24244. * Are color grading textures enabled in the application.
  24245. */
  24246. static get ColorGradingTextureEnabled(): boolean;
  24247. static set ColorGradingTextureEnabled(value: boolean);
  24248. private static _FresnelEnabled;
  24249. /**
  24250. * Are fresnels enabled in the application.
  24251. */
  24252. static get FresnelEnabled(): boolean;
  24253. static set FresnelEnabled(value: boolean);
  24254. private static _ClearCoatTextureEnabled;
  24255. /**
  24256. * Are clear coat textures enabled in the application.
  24257. */
  24258. static get ClearCoatTextureEnabled(): boolean;
  24259. static set ClearCoatTextureEnabled(value: boolean);
  24260. private static _ClearCoatBumpTextureEnabled;
  24261. /**
  24262. * Are clear coat bump textures enabled in the application.
  24263. */
  24264. static get ClearCoatBumpTextureEnabled(): boolean;
  24265. static set ClearCoatBumpTextureEnabled(value: boolean);
  24266. private static _ClearCoatTintTextureEnabled;
  24267. /**
  24268. * Are clear coat tint textures enabled in the application.
  24269. */
  24270. static get ClearCoatTintTextureEnabled(): boolean;
  24271. static set ClearCoatTintTextureEnabled(value: boolean);
  24272. private static _SheenTextureEnabled;
  24273. /**
  24274. * Are sheen textures enabled in the application.
  24275. */
  24276. static get SheenTextureEnabled(): boolean;
  24277. static set SheenTextureEnabled(value: boolean);
  24278. private static _AnisotropicTextureEnabled;
  24279. /**
  24280. * Are anisotropic textures enabled in the application.
  24281. */
  24282. static get AnisotropicTextureEnabled(): boolean;
  24283. static set AnisotropicTextureEnabled(value: boolean);
  24284. private static _ThicknessTextureEnabled;
  24285. /**
  24286. * Are thickness textures enabled in the application.
  24287. */
  24288. static get ThicknessTextureEnabled(): boolean;
  24289. static set ThicknessTextureEnabled(value: boolean);
  24290. }
  24291. }
  24292. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24293. /** @hidden */
  24294. export var defaultFragmentDeclaration: {
  24295. name: string;
  24296. shader: string;
  24297. };
  24298. }
  24299. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24300. /** @hidden */
  24301. export var defaultUboDeclaration: {
  24302. name: string;
  24303. shader: string;
  24304. };
  24305. }
  24306. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24307. /** @hidden */
  24308. export var prePassDeclaration: {
  24309. name: string;
  24310. shader: string;
  24311. };
  24312. }
  24313. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24314. /** @hidden */
  24315. export var lightFragmentDeclaration: {
  24316. name: string;
  24317. shader: string;
  24318. };
  24319. }
  24320. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24321. /** @hidden */
  24322. export var lightUboDeclaration: {
  24323. name: string;
  24324. shader: string;
  24325. };
  24326. }
  24327. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24328. /** @hidden */
  24329. export var lightsFragmentFunctions: {
  24330. name: string;
  24331. shader: string;
  24332. };
  24333. }
  24334. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24335. /** @hidden */
  24336. export var shadowsFragmentFunctions: {
  24337. name: string;
  24338. shader: string;
  24339. };
  24340. }
  24341. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24342. /** @hidden */
  24343. export var fresnelFunction: {
  24344. name: string;
  24345. shader: string;
  24346. };
  24347. }
  24348. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24349. /** @hidden */
  24350. export var bumpFragmentMainFunctions: {
  24351. name: string;
  24352. shader: string;
  24353. };
  24354. }
  24355. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24356. /** @hidden */
  24357. export var bumpFragmentFunctions: {
  24358. name: string;
  24359. shader: string;
  24360. };
  24361. }
  24362. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24363. /** @hidden */
  24364. export var logDepthDeclaration: {
  24365. name: string;
  24366. shader: string;
  24367. };
  24368. }
  24369. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24370. /** @hidden */
  24371. export var bumpFragment: {
  24372. name: string;
  24373. shader: string;
  24374. };
  24375. }
  24376. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24377. /** @hidden */
  24378. export var depthPrePass: {
  24379. name: string;
  24380. shader: string;
  24381. };
  24382. }
  24383. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24384. /** @hidden */
  24385. export var lightFragment: {
  24386. name: string;
  24387. shader: string;
  24388. };
  24389. }
  24390. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24391. /** @hidden */
  24392. export var logDepthFragment: {
  24393. name: string;
  24394. shader: string;
  24395. };
  24396. }
  24397. declare module "babylonjs/Shaders/default.fragment" {
  24398. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24399. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24400. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24401. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24402. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24403. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24404. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24405. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24406. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24407. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24408. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24409. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24410. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24411. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24412. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24413. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24414. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24415. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24416. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24417. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24418. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24419. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24420. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24421. /** @hidden */
  24422. export var defaultPixelShader: {
  24423. name: string;
  24424. shader: string;
  24425. };
  24426. }
  24427. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24428. /** @hidden */
  24429. export var defaultVertexDeclaration: {
  24430. name: string;
  24431. shader: string;
  24432. };
  24433. }
  24434. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24435. /** @hidden */
  24436. export var prePassVertexDeclaration: {
  24437. name: string;
  24438. shader: string;
  24439. };
  24440. }
  24441. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24442. /** @hidden */
  24443. export var bumpVertexDeclaration: {
  24444. name: string;
  24445. shader: string;
  24446. };
  24447. }
  24448. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24449. /** @hidden */
  24450. export var prePassVertex: {
  24451. name: string;
  24452. shader: string;
  24453. };
  24454. }
  24455. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24456. /** @hidden */
  24457. export var bumpVertex: {
  24458. name: string;
  24459. shader: string;
  24460. };
  24461. }
  24462. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24463. /** @hidden */
  24464. export var fogVertex: {
  24465. name: string;
  24466. shader: string;
  24467. };
  24468. }
  24469. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24470. /** @hidden */
  24471. export var shadowsVertex: {
  24472. name: string;
  24473. shader: string;
  24474. };
  24475. }
  24476. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24477. /** @hidden */
  24478. export var pointCloudVertex: {
  24479. name: string;
  24480. shader: string;
  24481. };
  24482. }
  24483. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24484. /** @hidden */
  24485. export var logDepthVertex: {
  24486. name: string;
  24487. shader: string;
  24488. };
  24489. }
  24490. declare module "babylonjs/Shaders/default.vertex" {
  24491. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24492. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24493. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24495. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24496. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24497. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24499. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24500. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24501. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24504. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24506. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24507. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24508. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24509. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24510. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24511. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24512. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24513. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24514. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24515. /** @hidden */
  24516. export var defaultVertexShader: {
  24517. name: string;
  24518. shader: string;
  24519. };
  24520. }
  24521. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24522. import { Nullable } from "babylonjs/types";
  24523. import { Scene } from "babylonjs/scene";
  24524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24525. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24526. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24527. /**
  24528. * @hidden
  24529. */
  24530. export interface IMaterialDetailMapDefines {
  24531. DETAIL: boolean;
  24532. DETAILDIRECTUV: number;
  24533. DETAIL_NORMALBLENDMETHOD: number;
  24534. /** @hidden */
  24535. _areTexturesDirty: boolean;
  24536. }
  24537. /**
  24538. * Define the code related to the detail map parameters of a material
  24539. *
  24540. * Inspired from:
  24541. * 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
  24542. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24543. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24544. */
  24545. export class DetailMapConfiguration {
  24546. private _texture;
  24547. /**
  24548. * The detail texture of the material.
  24549. */
  24550. texture: Nullable<BaseTexture>;
  24551. /**
  24552. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24553. * Bigger values mean stronger blending
  24554. */
  24555. diffuseBlendLevel: number;
  24556. /**
  24557. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24558. * Bigger values mean stronger blending. Only used with PBR materials
  24559. */
  24560. roughnessBlendLevel: number;
  24561. /**
  24562. * Defines how strong the bump effect from the detail map is
  24563. * Bigger values mean stronger effect
  24564. */
  24565. bumpLevel: number;
  24566. private _normalBlendMethod;
  24567. /**
  24568. * The method used to blend the bump and detail normals together
  24569. */
  24570. normalBlendMethod: number;
  24571. private _isEnabled;
  24572. /**
  24573. * Enable or disable the detail map on this material
  24574. */
  24575. isEnabled: boolean;
  24576. /** @hidden */
  24577. private _internalMarkAllSubMeshesAsTexturesDirty;
  24578. /** @hidden */
  24579. _markAllSubMeshesAsTexturesDirty(): void;
  24580. /**
  24581. * Instantiate a new detail map
  24582. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24583. */
  24584. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24585. /**
  24586. * Gets whether the submesh is ready to be used or not.
  24587. * @param defines the list of "defines" to update.
  24588. * @param scene defines the scene the material belongs to.
  24589. * @returns - boolean indicating that the submesh is ready or not.
  24590. */
  24591. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24592. /**
  24593. * Update the defines for detail map usage
  24594. * @param defines the list of "defines" to update.
  24595. * @param scene defines the scene the material belongs to.
  24596. */
  24597. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24598. /**
  24599. * Binds the material data.
  24600. * @param uniformBuffer defines the Uniform buffer to fill in.
  24601. * @param scene defines the scene the material belongs to.
  24602. * @param isFrozen defines whether the material is frozen or not.
  24603. */
  24604. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24605. /**
  24606. * Checks to see if a texture is used in the material.
  24607. * @param texture - Base texture to use.
  24608. * @returns - Boolean specifying if a texture is used in the material.
  24609. */
  24610. hasTexture(texture: BaseTexture): boolean;
  24611. /**
  24612. * Returns an array of the actively used textures.
  24613. * @param activeTextures Array of BaseTextures
  24614. */
  24615. getActiveTextures(activeTextures: BaseTexture[]): void;
  24616. /**
  24617. * Returns the animatable textures.
  24618. * @param animatables Array of animatable textures.
  24619. */
  24620. getAnimatables(animatables: IAnimatable[]): void;
  24621. /**
  24622. * Disposes the resources of the material.
  24623. * @param forceDisposeTextures - Forces the disposal of all textures.
  24624. */
  24625. dispose(forceDisposeTextures?: boolean): void;
  24626. /**
  24627. * Get the current class name useful for serialization or dynamic coding.
  24628. * @returns "DetailMap"
  24629. */
  24630. getClassName(): string;
  24631. /**
  24632. * Add the required uniforms to the current list.
  24633. * @param uniforms defines the current uniform list.
  24634. */
  24635. static AddUniforms(uniforms: string[]): void;
  24636. /**
  24637. * Add the required samplers to the current list.
  24638. * @param samplers defines the current sampler list.
  24639. */
  24640. static AddSamplers(samplers: string[]): void;
  24641. /**
  24642. * Add the required uniforms to the current buffer.
  24643. * @param uniformBuffer defines the current uniform buffer.
  24644. */
  24645. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24646. /**
  24647. * Makes a duplicate of the current instance into another one.
  24648. * @param detailMap define the instance where to copy the info
  24649. */
  24650. copyTo(detailMap: DetailMapConfiguration): void;
  24651. /**
  24652. * Serializes this detail map instance
  24653. * @returns - An object with the serialized instance.
  24654. */
  24655. serialize(): any;
  24656. /**
  24657. * Parses a detail map setting from a serialized object.
  24658. * @param source - Serialized object.
  24659. * @param scene Defines the scene we are parsing for
  24660. * @param rootUrl Defines the rootUrl to load from
  24661. */
  24662. parse(source: any, scene: Scene, rootUrl: string): void;
  24663. }
  24664. }
  24665. declare module "babylonjs/Materials/standardMaterial" {
  24666. import { SmartArray } from "babylonjs/Misc/smartArray";
  24667. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24668. import { Nullable } from "babylonjs/types";
  24669. import { Scene } from "babylonjs/scene";
  24670. import { Matrix } from "babylonjs/Maths/math.vector";
  24671. import { Color3 } from "babylonjs/Maths/math.color";
  24672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24674. import { Mesh } from "babylonjs/Meshes/mesh";
  24675. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24676. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24677. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24678. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24679. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24680. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24682. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24683. import "babylonjs/Shaders/default.fragment";
  24684. import "babylonjs/Shaders/default.vertex";
  24685. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24686. /** @hidden */
  24687. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24688. MAINUV1: boolean;
  24689. MAINUV2: boolean;
  24690. DIFFUSE: boolean;
  24691. DIFFUSEDIRECTUV: number;
  24692. DETAIL: boolean;
  24693. DETAILDIRECTUV: number;
  24694. DETAIL_NORMALBLENDMETHOD: number;
  24695. AMBIENT: boolean;
  24696. AMBIENTDIRECTUV: number;
  24697. OPACITY: boolean;
  24698. OPACITYDIRECTUV: number;
  24699. OPACITYRGB: boolean;
  24700. REFLECTION: boolean;
  24701. EMISSIVE: boolean;
  24702. EMISSIVEDIRECTUV: number;
  24703. SPECULAR: boolean;
  24704. SPECULARDIRECTUV: number;
  24705. BUMP: boolean;
  24706. BUMPDIRECTUV: number;
  24707. PARALLAX: boolean;
  24708. PARALLAXOCCLUSION: boolean;
  24709. SPECULAROVERALPHA: boolean;
  24710. CLIPPLANE: boolean;
  24711. CLIPPLANE2: boolean;
  24712. CLIPPLANE3: boolean;
  24713. CLIPPLANE4: boolean;
  24714. CLIPPLANE5: boolean;
  24715. CLIPPLANE6: boolean;
  24716. ALPHATEST: boolean;
  24717. DEPTHPREPASS: boolean;
  24718. ALPHAFROMDIFFUSE: boolean;
  24719. POINTSIZE: boolean;
  24720. FOG: boolean;
  24721. SPECULARTERM: boolean;
  24722. DIFFUSEFRESNEL: boolean;
  24723. OPACITYFRESNEL: boolean;
  24724. REFLECTIONFRESNEL: boolean;
  24725. REFRACTIONFRESNEL: boolean;
  24726. EMISSIVEFRESNEL: boolean;
  24727. FRESNEL: boolean;
  24728. NORMAL: boolean;
  24729. UV1: boolean;
  24730. UV2: boolean;
  24731. VERTEXCOLOR: boolean;
  24732. VERTEXALPHA: boolean;
  24733. NUM_BONE_INFLUENCERS: number;
  24734. BonesPerMesh: number;
  24735. BONETEXTURE: boolean;
  24736. BONES_VELOCITY_ENABLED: boolean;
  24737. INSTANCES: boolean;
  24738. THIN_INSTANCES: boolean;
  24739. GLOSSINESS: boolean;
  24740. ROUGHNESS: boolean;
  24741. EMISSIVEASILLUMINATION: boolean;
  24742. LINKEMISSIVEWITHDIFFUSE: boolean;
  24743. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24744. LIGHTMAP: boolean;
  24745. LIGHTMAPDIRECTUV: number;
  24746. OBJECTSPACE_NORMALMAP: boolean;
  24747. USELIGHTMAPASSHADOWMAP: boolean;
  24748. REFLECTIONMAP_3D: boolean;
  24749. REFLECTIONMAP_SPHERICAL: boolean;
  24750. REFLECTIONMAP_PLANAR: boolean;
  24751. REFLECTIONMAP_CUBIC: boolean;
  24752. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24753. REFLECTIONMAP_PROJECTION: boolean;
  24754. REFLECTIONMAP_SKYBOX: boolean;
  24755. REFLECTIONMAP_EXPLICIT: boolean;
  24756. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24757. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24758. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24759. INVERTCUBICMAP: boolean;
  24760. LOGARITHMICDEPTH: boolean;
  24761. REFRACTION: boolean;
  24762. REFRACTIONMAP_3D: boolean;
  24763. REFLECTIONOVERALPHA: boolean;
  24764. TWOSIDEDLIGHTING: boolean;
  24765. SHADOWFLOAT: boolean;
  24766. MORPHTARGETS: boolean;
  24767. MORPHTARGETS_NORMAL: boolean;
  24768. MORPHTARGETS_TANGENT: boolean;
  24769. MORPHTARGETS_UV: boolean;
  24770. NUM_MORPH_INFLUENCERS: number;
  24771. NONUNIFORMSCALING: boolean;
  24772. PREMULTIPLYALPHA: boolean;
  24773. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24774. ALPHABLEND: boolean;
  24775. PREPASS: boolean;
  24776. PREPASS_IRRADIANCE: boolean;
  24777. PREPASS_IRRADIANCE_INDEX: number;
  24778. PREPASS_ALBEDO: boolean;
  24779. PREPASS_ALBEDO_INDEX: number;
  24780. PREPASS_DEPTHNORMAL: boolean;
  24781. PREPASS_DEPTHNORMAL_INDEX: number;
  24782. PREPASS_POSITION: boolean;
  24783. PREPASS_POSITION_INDEX: number;
  24784. PREPASS_VELOCITY: boolean;
  24785. PREPASS_VELOCITY_INDEX: number;
  24786. PREPASS_REFLECTIVITY: boolean;
  24787. PREPASS_REFLECTIVITY_INDEX: number;
  24788. SCENE_MRT_COUNT: number;
  24789. RGBDLIGHTMAP: boolean;
  24790. RGBDREFLECTION: boolean;
  24791. RGBDREFRACTION: boolean;
  24792. IMAGEPROCESSING: boolean;
  24793. VIGNETTE: boolean;
  24794. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24795. VIGNETTEBLENDMODEOPAQUE: boolean;
  24796. TONEMAPPING: boolean;
  24797. TONEMAPPING_ACES: boolean;
  24798. CONTRAST: boolean;
  24799. COLORCURVES: boolean;
  24800. COLORGRADING: boolean;
  24801. COLORGRADING3D: boolean;
  24802. SAMPLER3DGREENDEPTH: boolean;
  24803. SAMPLER3DBGRMAP: boolean;
  24804. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24805. MULTIVIEW: boolean;
  24806. /**
  24807. * If the reflection texture on this material is in linear color space
  24808. * @hidden
  24809. */
  24810. IS_REFLECTION_LINEAR: boolean;
  24811. /**
  24812. * If the refraction texture on this material is in linear color space
  24813. * @hidden
  24814. */
  24815. IS_REFRACTION_LINEAR: boolean;
  24816. EXPOSURE: boolean;
  24817. constructor();
  24818. setReflectionMode(modeToEnable: string): void;
  24819. }
  24820. /**
  24821. * This is the default material used in Babylon. It is the best trade off between quality
  24822. * and performances.
  24823. * @see https://doc.babylonjs.com/babylon101/materials
  24824. */
  24825. export class StandardMaterial extends PushMaterial {
  24826. private _diffuseTexture;
  24827. /**
  24828. * The basic texture of the material as viewed under a light.
  24829. */
  24830. diffuseTexture: Nullable<BaseTexture>;
  24831. private _ambientTexture;
  24832. /**
  24833. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24834. */
  24835. ambientTexture: Nullable<BaseTexture>;
  24836. private _opacityTexture;
  24837. /**
  24838. * Define the transparency of the material from a texture.
  24839. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24840. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24841. */
  24842. opacityTexture: Nullable<BaseTexture>;
  24843. private _reflectionTexture;
  24844. /**
  24845. * Define the texture used to display the reflection.
  24846. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24847. */
  24848. reflectionTexture: Nullable<BaseTexture>;
  24849. private _emissiveTexture;
  24850. /**
  24851. * Define texture of the material as if self lit.
  24852. * This will be mixed in the final result even in the absence of light.
  24853. */
  24854. emissiveTexture: Nullable<BaseTexture>;
  24855. private _specularTexture;
  24856. /**
  24857. * Define how the color and intensity of the highlight given by the light in the material.
  24858. */
  24859. specularTexture: Nullable<BaseTexture>;
  24860. private _bumpTexture;
  24861. /**
  24862. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24863. * 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.
  24864. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24865. */
  24866. bumpTexture: Nullable<BaseTexture>;
  24867. private _lightmapTexture;
  24868. /**
  24869. * Complex lighting can be computationally expensive to compute at runtime.
  24870. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24871. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24872. */
  24873. lightmapTexture: Nullable<BaseTexture>;
  24874. private _refractionTexture;
  24875. /**
  24876. * Define the texture used to display the refraction.
  24877. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24878. */
  24879. refractionTexture: Nullable<BaseTexture>;
  24880. /**
  24881. * The color of the material lit by the environmental background lighting.
  24882. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24883. */
  24884. ambientColor: Color3;
  24885. /**
  24886. * The basic color of the material as viewed under a light.
  24887. */
  24888. diffuseColor: Color3;
  24889. /**
  24890. * Define how the color and intensity of the highlight given by the light in the material.
  24891. */
  24892. specularColor: Color3;
  24893. /**
  24894. * Define the color of the material as if self lit.
  24895. * This will be mixed in the final result even in the absence of light.
  24896. */
  24897. emissiveColor: Color3;
  24898. /**
  24899. * Defines how sharp are the highlights in the material.
  24900. * The bigger the value the sharper giving a more glossy feeling to the result.
  24901. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24902. */
  24903. specularPower: number;
  24904. private _useAlphaFromDiffuseTexture;
  24905. /**
  24906. * Does the transparency come from the diffuse texture alpha channel.
  24907. */
  24908. useAlphaFromDiffuseTexture: boolean;
  24909. private _useEmissiveAsIllumination;
  24910. /**
  24911. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24912. */
  24913. useEmissiveAsIllumination: boolean;
  24914. private _linkEmissiveWithDiffuse;
  24915. /**
  24916. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24917. * the emissive level when the final color is close to one.
  24918. */
  24919. linkEmissiveWithDiffuse: boolean;
  24920. private _useSpecularOverAlpha;
  24921. /**
  24922. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24923. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24924. */
  24925. useSpecularOverAlpha: boolean;
  24926. private _useReflectionOverAlpha;
  24927. /**
  24928. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24929. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24930. */
  24931. useReflectionOverAlpha: boolean;
  24932. private _disableLighting;
  24933. /**
  24934. * Does lights from the scene impacts this material.
  24935. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24936. */
  24937. disableLighting: boolean;
  24938. private _useObjectSpaceNormalMap;
  24939. /**
  24940. * Allows using an object space normal map (instead of tangent space).
  24941. */
  24942. useObjectSpaceNormalMap: boolean;
  24943. private _useParallax;
  24944. /**
  24945. * Is parallax enabled or not.
  24946. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24947. */
  24948. useParallax: boolean;
  24949. private _useParallaxOcclusion;
  24950. /**
  24951. * Is parallax occlusion enabled or not.
  24952. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24953. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24954. */
  24955. useParallaxOcclusion: boolean;
  24956. /**
  24957. * 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.
  24958. */
  24959. parallaxScaleBias: number;
  24960. private _roughness;
  24961. /**
  24962. * Helps to define how blurry the reflections should appears in the material.
  24963. */
  24964. roughness: number;
  24965. /**
  24966. * In case of refraction, define the value of the index of refraction.
  24967. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24968. */
  24969. indexOfRefraction: number;
  24970. /**
  24971. * Invert the refraction texture alongside the y axis.
  24972. * It can be useful with procedural textures or probe for instance.
  24973. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24974. */
  24975. invertRefractionY: boolean;
  24976. /**
  24977. * Defines the alpha limits in alpha test mode.
  24978. */
  24979. alphaCutOff: number;
  24980. private _useLightmapAsShadowmap;
  24981. /**
  24982. * In case of light mapping, define whether the map contains light or shadow informations.
  24983. */
  24984. useLightmapAsShadowmap: boolean;
  24985. private _diffuseFresnelParameters;
  24986. /**
  24987. * Define the diffuse fresnel parameters of the material.
  24988. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24989. */
  24990. diffuseFresnelParameters: FresnelParameters;
  24991. private _opacityFresnelParameters;
  24992. /**
  24993. * Define the opacity fresnel parameters of the material.
  24994. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24995. */
  24996. opacityFresnelParameters: FresnelParameters;
  24997. private _reflectionFresnelParameters;
  24998. /**
  24999. * Define the reflection fresnel parameters of the material.
  25000. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25001. */
  25002. reflectionFresnelParameters: FresnelParameters;
  25003. private _refractionFresnelParameters;
  25004. /**
  25005. * Define the refraction fresnel parameters of the material.
  25006. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25007. */
  25008. refractionFresnelParameters: FresnelParameters;
  25009. private _emissiveFresnelParameters;
  25010. /**
  25011. * Define the emissive fresnel parameters of the material.
  25012. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25013. */
  25014. emissiveFresnelParameters: FresnelParameters;
  25015. private _useReflectionFresnelFromSpecular;
  25016. /**
  25017. * If true automatically deducts the fresnels values from the material specularity.
  25018. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25019. */
  25020. useReflectionFresnelFromSpecular: boolean;
  25021. private _useGlossinessFromSpecularMapAlpha;
  25022. /**
  25023. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25024. */
  25025. useGlossinessFromSpecularMapAlpha: boolean;
  25026. private _maxSimultaneousLights;
  25027. /**
  25028. * Defines the maximum number of lights that can be used in the material
  25029. */
  25030. maxSimultaneousLights: number;
  25031. private _invertNormalMapX;
  25032. /**
  25033. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25034. */
  25035. invertNormalMapX: boolean;
  25036. private _invertNormalMapY;
  25037. /**
  25038. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25039. */
  25040. invertNormalMapY: boolean;
  25041. private _twoSidedLighting;
  25042. /**
  25043. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25044. */
  25045. twoSidedLighting: boolean;
  25046. /**
  25047. * Default configuration related to image processing available in the standard Material.
  25048. */
  25049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25050. /**
  25051. * Gets the image processing configuration used either in this material.
  25052. */
  25053. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25054. /**
  25055. * Sets the Default image processing configuration used either in the this material.
  25056. *
  25057. * If sets to null, the scene one is in use.
  25058. */
  25059. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25060. /**
  25061. * Keep track of the image processing observer to allow dispose and replace.
  25062. */
  25063. private _imageProcessingObserver;
  25064. /**
  25065. * Attaches a new image processing configuration to the Standard Material.
  25066. * @param configuration
  25067. */
  25068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25069. /**
  25070. * Defines additionnal PrePass parameters for the material.
  25071. */
  25072. readonly prePassConfiguration: PrePassConfiguration;
  25073. /**
  25074. * Gets wether the color curves effect is enabled.
  25075. */
  25076. get cameraColorCurvesEnabled(): boolean;
  25077. /**
  25078. * Sets wether the color curves effect is enabled.
  25079. */
  25080. set cameraColorCurvesEnabled(value: boolean);
  25081. /**
  25082. * Gets wether the color grading effect is enabled.
  25083. */
  25084. get cameraColorGradingEnabled(): boolean;
  25085. /**
  25086. * Gets wether the color grading effect is enabled.
  25087. */
  25088. set cameraColorGradingEnabled(value: boolean);
  25089. /**
  25090. * Gets wether tonemapping is enabled or not.
  25091. */
  25092. get cameraToneMappingEnabled(): boolean;
  25093. /**
  25094. * Sets wether tonemapping is enabled or not
  25095. */
  25096. set cameraToneMappingEnabled(value: boolean);
  25097. /**
  25098. * The camera exposure used on this material.
  25099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25100. * This corresponds to a photographic exposure.
  25101. */
  25102. get cameraExposure(): number;
  25103. /**
  25104. * The camera exposure used on this material.
  25105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25106. * This corresponds to a photographic exposure.
  25107. */
  25108. set cameraExposure(value: number);
  25109. /**
  25110. * Gets The camera contrast used on this material.
  25111. */
  25112. get cameraContrast(): number;
  25113. /**
  25114. * Sets The camera contrast used on this material.
  25115. */
  25116. set cameraContrast(value: number);
  25117. /**
  25118. * Gets the Color Grading 2D Lookup Texture.
  25119. */
  25120. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25121. /**
  25122. * Sets the Color Grading 2D Lookup Texture.
  25123. */
  25124. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25125. /**
  25126. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25127. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25128. * 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;
  25129. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25130. */
  25131. get cameraColorCurves(): Nullable<ColorCurves>;
  25132. /**
  25133. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25134. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25135. * 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;
  25136. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25137. */
  25138. set cameraColorCurves(value: Nullable<ColorCurves>);
  25139. /**
  25140. * Can this material render to several textures at once
  25141. */
  25142. get canRenderToMRT(): boolean;
  25143. /**
  25144. * Defines the detail map parameters for the material.
  25145. */
  25146. readonly detailMap: DetailMapConfiguration;
  25147. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25148. protected _worldViewProjectionMatrix: Matrix;
  25149. protected _globalAmbientColor: Color3;
  25150. protected _useLogarithmicDepth: boolean;
  25151. protected _rebuildInParallel: boolean;
  25152. /**
  25153. * Instantiates a new standard material.
  25154. * This is the default material used in Babylon. It is the best trade off between quality
  25155. * and performances.
  25156. * @see https://doc.babylonjs.com/babylon101/materials
  25157. * @param name Define the name of the material in the scene
  25158. * @param scene Define the scene the material belong to
  25159. */
  25160. constructor(name: string, scene: Scene);
  25161. /**
  25162. * Gets a boolean indicating that current material needs to register RTT
  25163. */
  25164. get hasRenderTargetTextures(): boolean;
  25165. /**
  25166. * Gets the current class name of the material e.g. "StandardMaterial"
  25167. * Mainly use in serialization.
  25168. * @returns the class name
  25169. */
  25170. getClassName(): string;
  25171. /**
  25172. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25173. * You can try switching to logarithmic depth.
  25174. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25175. */
  25176. get useLogarithmicDepth(): boolean;
  25177. set useLogarithmicDepth(value: boolean);
  25178. /**
  25179. * Specifies if the material will require alpha blending
  25180. * @returns a boolean specifying if alpha blending is needed
  25181. */
  25182. needAlphaBlending(): boolean;
  25183. /**
  25184. * Specifies if this material should be rendered in alpha test mode
  25185. * @returns a boolean specifying if an alpha test is needed.
  25186. */
  25187. needAlphaTesting(): boolean;
  25188. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25189. /**
  25190. * Get the texture used for alpha test purpose.
  25191. * @returns the diffuse texture in case of the standard material.
  25192. */
  25193. getAlphaTestTexture(): Nullable<BaseTexture>;
  25194. /**
  25195. * Get if the submesh is ready to be used and all its information available.
  25196. * Child classes can use it to update shaders
  25197. * @param mesh defines the mesh to check
  25198. * @param subMesh defines which submesh to check
  25199. * @param useInstances specifies that instances should be used
  25200. * @returns a boolean indicating that the submesh is ready or not
  25201. */
  25202. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25203. /**
  25204. * Builds the material UBO layouts.
  25205. * Used internally during the effect preparation.
  25206. */
  25207. buildUniformLayout(): void;
  25208. /**
  25209. * Unbinds the material from the mesh
  25210. */
  25211. unbind(): void;
  25212. /**
  25213. * Binds the submesh to this material by preparing the effect and shader to draw
  25214. * @param world defines the world transformation matrix
  25215. * @param mesh defines the mesh containing the submesh
  25216. * @param subMesh defines the submesh to bind the material to
  25217. */
  25218. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25219. /**
  25220. * Get the list of animatables in the material.
  25221. * @returns the list of animatables object used in the material
  25222. */
  25223. getAnimatables(): IAnimatable[];
  25224. /**
  25225. * Gets the active textures from the material
  25226. * @returns an array of textures
  25227. */
  25228. getActiveTextures(): BaseTexture[];
  25229. /**
  25230. * Specifies if the material uses a texture
  25231. * @param texture defines the texture to check against the material
  25232. * @returns a boolean specifying if the material uses the texture
  25233. */
  25234. hasTexture(texture: BaseTexture): boolean;
  25235. /**
  25236. * Disposes the material
  25237. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25238. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25239. */
  25240. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25241. /**
  25242. * Makes a duplicate of the material, and gives it a new name
  25243. * @param name defines the new name for the duplicated material
  25244. * @returns the cloned material
  25245. */
  25246. clone(name: string): StandardMaterial;
  25247. /**
  25248. * Serializes this material in a JSON representation
  25249. * @returns the serialized material object
  25250. */
  25251. serialize(): any;
  25252. /**
  25253. * Creates a standard material from parsed material data
  25254. * @param source defines the JSON representation of the material
  25255. * @param scene defines the hosting scene
  25256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25257. * @returns a new standard material
  25258. */
  25259. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25260. /**
  25261. * Are diffuse textures enabled in the application.
  25262. */
  25263. static get DiffuseTextureEnabled(): boolean;
  25264. static set DiffuseTextureEnabled(value: boolean);
  25265. /**
  25266. * Are detail textures enabled in the application.
  25267. */
  25268. static get DetailTextureEnabled(): boolean;
  25269. static set DetailTextureEnabled(value: boolean);
  25270. /**
  25271. * Are ambient textures enabled in the application.
  25272. */
  25273. static get AmbientTextureEnabled(): boolean;
  25274. static set AmbientTextureEnabled(value: boolean);
  25275. /**
  25276. * Are opacity textures enabled in the application.
  25277. */
  25278. static get OpacityTextureEnabled(): boolean;
  25279. static set OpacityTextureEnabled(value: boolean);
  25280. /**
  25281. * Are reflection textures enabled in the application.
  25282. */
  25283. static get ReflectionTextureEnabled(): boolean;
  25284. static set ReflectionTextureEnabled(value: boolean);
  25285. /**
  25286. * Are emissive textures enabled in the application.
  25287. */
  25288. static get EmissiveTextureEnabled(): boolean;
  25289. static set EmissiveTextureEnabled(value: boolean);
  25290. /**
  25291. * Are specular textures enabled in the application.
  25292. */
  25293. static get SpecularTextureEnabled(): boolean;
  25294. static set SpecularTextureEnabled(value: boolean);
  25295. /**
  25296. * Are bump textures enabled in the application.
  25297. */
  25298. static get BumpTextureEnabled(): boolean;
  25299. static set BumpTextureEnabled(value: boolean);
  25300. /**
  25301. * Are lightmap textures enabled in the application.
  25302. */
  25303. static get LightmapTextureEnabled(): boolean;
  25304. static set LightmapTextureEnabled(value: boolean);
  25305. /**
  25306. * Are refraction textures enabled in the application.
  25307. */
  25308. static get RefractionTextureEnabled(): boolean;
  25309. static set RefractionTextureEnabled(value: boolean);
  25310. /**
  25311. * Are color grading textures enabled in the application.
  25312. */
  25313. static get ColorGradingTextureEnabled(): boolean;
  25314. static set ColorGradingTextureEnabled(value: boolean);
  25315. /**
  25316. * Are fresnels enabled in the application.
  25317. */
  25318. static get FresnelEnabled(): boolean;
  25319. static set FresnelEnabled(value: boolean);
  25320. }
  25321. }
  25322. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25323. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25324. /** @hidden */
  25325. export var rgbdDecodePixelShader: {
  25326. name: string;
  25327. shader: string;
  25328. };
  25329. }
  25330. declare module "babylonjs/Misc/rgbdTextureTools" {
  25331. import "babylonjs/Shaders/rgbdDecode.fragment";
  25332. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25333. import { Texture } from "babylonjs/Materials/Textures/texture";
  25334. /**
  25335. * Class used to host RGBD texture specific utilities
  25336. */
  25337. export class RGBDTextureTools {
  25338. /**
  25339. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25340. * @param texture the texture to expand.
  25341. */
  25342. static ExpandRGBDTexture(texture: Texture): void;
  25343. }
  25344. }
  25345. declare module "babylonjs/Misc/brdfTextureTools" {
  25346. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25347. import { Scene } from "babylonjs/scene";
  25348. /**
  25349. * Class used to host texture specific utilities
  25350. */
  25351. export class BRDFTextureTools {
  25352. /**
  25353. * Prevents texture cache collision
  25354. */
  25355. private static _instanceNumber;
  25356. /**
  25357. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25358. * @param scene defines the hosting scene
  25359. * @returns the environment BRDF texture
  25360. */
  25361. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25362. private static _environmentBRDFBase64Texture;
  25363. }
  25364. }
  25365. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25366. import { Nullable } from "babylonjs/types";
  25367. import { Color3 } from "babylonjs/Maths/math.color";
  25368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25369. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25371. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25372. import { Engine } from "babylonjs/Engines/engine";
  25373. import { Scene } from "babylonjs/scene";
  25374. /**
  25375. * @hidden
  25376. */
  25377. export interface IMaterialClearCoatDefines {
  25378. CLEARCOAT: boolean;
  25379. CLEARCOAT_DEFAULTIOR: boolean;
  25380. CLEARCOAT_TEXTURE: boolean;
  25381. CLEARCOAT_TEXTUREDIRECTUV: number;
  25382. CLEARCOAT_BUMP: boolean;
  25383. CLEARCOAT_BUMPDIRECTUV: number;
  25384. CLEARCOAT_REMAP_F0: boolean;
  25385. CLEARCOAT_TINT: boolean;
  25386. CLEARCOAT_TINT_TEXTURE: boolean;
  25387. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25388. /** @hidden */
  25389. _areTexturesDirty: boolean;
  25390. }
  25391. /**
  25392. * Define the code related to the clear coat parameters of the pbr material.
  25393. */
  25394. export class PBRClearCoatConfiguration {
  25395. /**
  25396. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25397. * The default fits with a polyurethane material.
  25398. */
  25399. private static readonly _DefaultIndexOfRefraction;
  25400. private _isEnabled;
  25401. /**
  25402. * Defines if the clear coat is enabled in the material.
  25403. */
  25404. isEnabled: boolean;
  25405. /**
  25406. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25407. */
  25408. intensity: number;
  25409. /**
  25410. * Defines the clear coat layer roughness.
  25411. */
  25412. roughness: number;
  25413. private _indexOfRefraction;
  25414. /**
  25415. * Defines the index of refraction of the clear coat.
  25416. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25417. * The default fits with a polyurethane material.
  25418. * Changing the default value is more performance intensive.
  25419. */
  25420. indexOfRefraction: number;
  25421. private _texture;
  25422. /**
  25423. * Stores the clear coat values in a texture.
  25424. */
  25425. texture: Nullable<BaseTexture>;
  25426. private _remapF0OnInterfaceChange;
  25427. /**
  25428. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25429. */
  25430. remapF0OnInterfaceChange: boolean;
  25431. private _bumpTexture;
  25432. /**
  25433. * Define the clear coat specific bump texture.
  25434. */
  25435. bumpTexture: Nullable<BaseTexture>;
  25436. private _isTintEnabled;
  25437. /**
  25438. * Defines if the clear coat tint is enabled in the material.
  25439. */
  25440. isTintEnabled: boolean;
  25441. /**
  25442. * Defines the clear coat tint of the material.
  25443. * This is only use if tint is enabled
  25444. */
  25445. tintColor: Color3;
  25446. /**
  25447. * Defines the distance at which the tint color should be found in the
  25448. * clear coat media.
  25449. * This is only use if tint is enabled
  25450. */
  25451. tintColorAtDistance: number;
  25452. /**
  25453. * Defines the clear coat layer thickness.
  25454. * This is only use if tint is enabled
  25455. */
  25456. tintThickness: number;
  25457. private _tintTexture;
  25458. /**
  25459. * Stores the clear tint values in a texture.
  25460. * rgb is tint
  25461. * a is a thickness factor
  25462. */
  25463. tintTexture: Nullable<BaseTexture>;
  25464. /** @hidden */
  25465. private _internalMarkAllSubMeshesAsTexturesDirty;
  25466. /** @hidden */
  25467. _markAllSubMeshesAsTexturesDirty(): void;
  25468. /**
  25469. * Instantiate a new istance of clear coat configuration.
  25470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25471. */
  25472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25473. /**
  25474. * Gets wehter the submesh is ready to be used or not.
  25475. * @param defines the list of "defines" to update.
  25476. * @param scene defines the scene the material belongs to.
  25477. * @param engine defines the engine the material belongs to.
  25478. * @param disableBumpMap defines wether the material disables bump or not.
  25479. * @returns - boolean indicating that the submesh is ready or not.
  25480. */
  25481. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25482. /**
  25483. * Checks to see if a texture is used in the material.
  25484. * @param defines the list of "defines" to update.
  25485. * @param scene defines the scene to the material belongs to.
  25486. */
  25487. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25488. /**
  25489. * Binds the material data.
  25490. * @param uniformBuffer defines the Uniform buffer to fill in.
  25491. * @param scene defines the scene the material belongs to.
  25492. * @param engine defines the engine the material belongs to.
  25493. * @param disableBumpMap defines wether the material disables bump or not.
  25494. * @param isFrozen defines wether the material is frozen or not.
  25495. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25496. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25497. */
  25498. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  25499. /**
  25500. * Checks to see if a texture is used in the material.
  25501. * @param texture - Base texture to use.
  25502. * @returns - Boolean specifying if a texture is used in the material.
  25503. */
  25504. hasTexture(texture: BaseTexture): boolean;
  25505. /**
  25506. * Returns an array of the actively used textures.
  25507. * @param activeTextures Array of BaseTextures
  25508. */
  25509. getActiveTextures(activeTextures: BaseTexture[]): void;
  25510. /**
  25511. * Returns the animatable textures.
  25512. * @param animatables Array of animatable textures.
  25513. */
  25514. getAnimatables(animatables: IAnimatable[]): void;
  25515. /**
  25516. * Disposes the resources of the material.
  25517. * @param forceDisposeTextures - Forces the disposal of all textures.
  25518. */
  25519. dispose(forceDisposeTextures?: boolean): void;
  25520. /**
  25521. * Get the current class name of the texture useful for serialization or dynamic coding.
  25522. * @returns "PBRClearCoatConfiguration"
  25523. */
  25524. getClassName(): string;
  25525. /**
  25526. * Add fallbacks to the effect fallbacks list.
  25527. * @param defines defines the Base texture to use.
  25528. * @param fallbacks defines the current fallback list.
  25529. * @param currentRank defines the current fallback rank.
  25530. * @returns the new fallback rank.
  25531. */
  25532. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25533. /**
  25534. * Add the required uniforms to the current list.
  25535. * @param uniforms defines the current uniform list.
  25536. */
  25537. static AddUniforms(uniforms: string[]): void;
  25538. /**
  25539. * Add the required samplers to the current list.
  25540. * @param samplers defines the current sampler list.
  25541. */
  25542. static AddSamplers(samplers: string[]): void;
  25543. /**
  25544. * Add the required uniforms to the current buffer.
  25545. * @param uniformBuffer defines the current uniform buffer.
  25546. */
  25547. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25548. /**
  25549. * Makes a duplicate of the current configuration into another one.
  25550. * @param clearCoatConfiguration define the config where to copy the info
  25551. */
  25552. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25553. /**
  25554. * Serializes this clear coat configuration.
  25555. * @returns - An object with the serialized config.
  25556. */
  25557. serialize(): any;
  25558. /**
  25559. * Parses a anisotropy Configuration from a serialized object.
  25560. * @param source - Serialized object.
  25561. * @param scene Defines the scene we are parsing for
  25562. * @param rootUrl Defines the rootUrl to load from
  25563. */
  25564. parse(source: any, scene: Scene, rootUrl: string): void;
  25565. }
  25566. }
  25567. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25568. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25570. import { Vector2 } from "babylonjs/Maths/math.vector";
  25571. import { Scene } from "babylonjs/scene";
  25572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25573. import { Nullable } from "babylonjs/types";
  25574. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25575. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25576. /**
  25577. * @hidden
  25578. */
  25579. export interface IMaterialAnisotropicDefines {
  25580. ANISOTROPIC: boolean;
  25581. ANISOTROPIC_TEXTURE: boolean;
  25582. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25583. MAINUV1: boolean;
  25584. _areTexturesDirty: boolean;
  25585. _needUVs: boolean;
  25586. }
  25587. /**
  25588. * Define the code related to the anisotropic parameters of the pbr material.
  25589. */
  25590. export class PBRAnisotropicConfiguration {
  25591. private _isEnabled;
  25592. /**
  25593. * Defines if the anisotropy is enabled in the material.
  25594. */
  25595. isEnabled: boolean;
  25596. /**
  25597. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25598. */
  25599. intensity: number;
  25600. /**
  25601. * Defines if the effect is along the tangents, bitangents or in between.
  25602. * By default, the effect is "strectching" the highlights along the tangents.
  25603. */
  25604. direction: Vector2;
  25605. private _texture;
  25606. /**
  25607. * Stores the anisotropy values in a texture.
  25608. * rg is direction (like normal from -1 to 1)
  25609. * b is a intensity
  25610. */
  25611. texture: Nullable<BaseTexture>;
  25612. /** @hidden */
  25613. private _internalMarkAllSubMeshesAsTexturesDirty;
  25614. /** @hidden */
  25615. _markAllSubMeshesAsTexturesDirty(): void;
  25616. /**
  25617. * Instantiate a new istance of anisotropy configuration.
  25618. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25619. */
  25620. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25621. /**
  25622. * Specifies that the submesh is ready to be used.
  25623. * @param defines the list of "defines" to update.
  25624. * @param scene defines the scene the material belongs to.
  25625. * @returns - boolean indicating that the submesh is ready or not.
  25626. */
  25627. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25628. /**
  25629. * Checks to see if a texture is used in the material.
  25630. * @param defines the list of "defines" to update.
  25631. * @param mesh the mesh we are preparing the defines for.
  25632. * @param scene defines the scene the material belongs to.
  25633. */
  25634. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25635. /**
  25636. * Binds the material data.
  25637. * @param uniformBuffer defines the Uniform buffer to fill in.
  25638. * @param scene defines the scene the material belongs to.
  25639. * @param isFrozen defines wether the material is frozen or not.
  25640. */
  25641. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25642. /**
  25643. * Checks to see if a texture is used in the material.
  25644. * @param texture - Base texture to use.
  25645. * @returns - Boolean specifying if a texture is used in the material.
  25646. */
  25647. hasTexture(texture: BaseTexture): boolean;
  25648. /**
  25649. * Returns an array of the actively used textures.
  25650. * @param activeTextures Array of BaseTextures
  25651. */
  25652. getActiveTextures(activeTextures: BaseTexture[]): void;
  25653. /**
  25654. * Returns the animatable textures.
  25655. * @param animatables Array of animatable textures.
  25656. */
  25657. getAnimatables(animatables: IAnimatable[]): void;
  25658. /**
  25659. * Disposes the resources of the material.
  25660. * @param forceDisposeTextures - Forces the disposal of all textures.
  25661. */
  25662. dispose(forceDisposeTextures?: boolean): void;
  25663. /**
  25664. * Get the current class name of the texture useful for serialization or dynamic coding.
  25665. * @returns "PBRAnisotropicConfiguration"
  25666. */
  25667. getClassName(): string;
  25668. /**
  25669. * Add fallbacks to the effect fallbacks list.
  25670. * @param defines defines the Base texture to use.
  25671. * @param fallbacks defines the current fallback list.
  25672. * @param currentRank defines the current fallback rank.
  25673. * @returns the new fallback rank.
  25674. */
  25675. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25676. /**
  25677. * Add the required uniforms to the current list.
  25678. * @param uniforms defines the current uniform list.
  25679. */
  25680. static AddUniforms(uniforms: string[]): void;
  25681. /**
  25682. * Add the required uniforms to the current buffer.
  25683. * @param uniformBuffer defines the current uniform buffer.
  25684. */
  25685. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25686. /**
  25687. * Add the required samplers to the current list.
  25688. * @param samplers defines the current sampler list.
  25689. */
  25690. static AddSamplers(samplers: string[]): void;
  25691. /**
  25692. * Makes a duplicate of the current configuration into another one.
  25693. * @param anisotropicConfiguration define the config where to copy the info
  25694. */
  25695. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25696. /**
  25697. * Serializes this anisotropy configuration.
  25698. * @returns - An object with the serialized config.
  25699. */
  25700. serialize(): any;
  25701. /**
  25702. * Parses a anisotropy Configuration from a serialized object.
  25703. * @param source - Serialized object.
  25704. * @param scene Defines the scene we are parsing for
  25705. * @param rootUrl Defines the rootUrl to load from
  25706. */
  25707. parse(source: any, scene: Scene, rootUrl: string): void;
  25708. }
  25709. }
  25710. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25711. import { Scene } from "babylonjs/scene";
  25712. /**
  25713. * @hidden
  25714. */
  25715. export interface IMaterialBRDFDefines {
  25716. BRDF_V_HEIGHT_CORRELATED: boolean;
  25717. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25718. SPHERICAL_HARMONICS: boolean;
  25719. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25720. /** @hidden */
  25721. _areMiscDirty: boolean;
  25722. }
  25723. /**
  25724. * Define the code related to the BRDF parameters of the pbr material.
  25725. */
  25726. export class PBRBRDFConfiguration {
  25727. /**
  25728. * Default value used for the energy conservation.
  25729. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25730. */
  25731. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25732. /**
  25733. * Default value used for the Smith Visibility Height Correlated mode.
  25734. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25735. */
  25736. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25737. /**
  25738. * Default value used for the IBL diffuse part.
  25739. * This can help switching back to the polynomials mode globally which is a tiny bit
  25740. * less GPU intensive at the drawback of a lower quality.
  25741. */
  25742. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25743. /**
  25744. * Default value used for activating energy conservation for the specular workflow.
  25745. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25746. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25747. */
  25748. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25749. private _useEnergyConservation;
  25750. /**
  25751. * Defines if the material uses energy conservation.
  25752. */
  25753. useEnergyConservation: boolean;
  25754. private _useSmithVisibilityHeightCorrelated;
  25755. /**
  25756. * LEGACY Mode set to false
  25757. * Defines if the material uses height smith correlated visibility term.
  25758. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25759. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25760. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25761. * Not relying on height correlated will also disable energy conservation.
  25762. */
  25763. useSmithVisibilityHeightCorrelated: boolean;
  25764. private _useSphericalHarmonics;
  25765. /**
  25766. * LEGACY Mode set to false
  25767. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25768. * diffuse part of the IBL.
  25769. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25770. * to the ground truth.
  25771. */
  25772. useSphericalHarmonics: boolean;
  25773. private _useSpecularGlossinessInputEnergyConservation;
  25774. /**
  25775. * Defines if the material uses energy conservation, when the specular workflow is active.
  25776. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25777. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25778. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25779. */
  25780. useSpecularGlossinessInputEnergyConservation: boolean;
  25781. /** @hidden */
  25782. private _internalMarkAllSubMeshesAsMiscDirty;
  25783. /** @hidden */
  25784. _markAllSubMeshesAsMiscDirty(): void;
  25785. /**
  25786. * Instantiate a new istance of clear coat configuration.
  25787. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25788. */
  25789. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25790. /**
  25791. * Checks to see if a texture is used in the material.
  25792. * @param defines the list of "defines" to update.
  25793. */
  25794. prepareDefines(defines: IMaterialBRDFDefines): void;
  25795. /**
  25796. * Get the current class name of the texture useful for serialization or dynamic coding.
  25797. * @returns "PBRClearCoatConfiguration"
  25798. */
  25799. getClassName(): string;
  25800. /**
  25801. * Makes a duplicate of the current configuration into another one.
  25802. * @param brdfConfiguration define the config where to copy the info
  25803. */
  25804. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25805. /**
  25806. * Serializes this BRDF configuration.
  25807. * @returns - An object with the serialized config.
  25808. */
  25809. serialize(): any;
  25810. /**
  25811. * Parses a anisotropy Configuration from a serialized object.
  25812. * @param source - Serialized object.
  25813. * @param scene Defines the scene we are parsing for
  25814. * @param rootUrl Defines the rootUrl to load from
  25815. */
  25816. parse(source: any, scene: Scene, rootUrl: string): void;
  25817. }
  25818. }
  25819. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25820. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25821. import { Color3 } from "babylonjs/Maths/math.color";
  25822. import { Scene } from "babylonjs/scene";
  25823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25824. import { Nullable } from "babylonjs/types";
  25825. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25826. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25827. /**
  25828. * @hidden
  25829. */
  25830. export interface IMaterialSheenDefines {
  25831. SHEEN: boolean;
  25832. SHEEN_TEXTURE: boolean;
  25833. SHEEN_TEXTUREDIRECTUV: number;
  25834. SHEEN_LINKWITHALBEDO: boolean;
  25835. SHEEN_ROUGHNESS: boolean;
  25836. SHEEN_ALBEDOSCALING: boolean;
  25837. /** @hidden */
  25838. _areTexturesDirty: boolean;
  25839. }
  25840. /**
  25841. * Define the code related to the Sheen parameters of the pbr material.
  25842. */
  25843. export class PBRSheenConfiguration {
  25844. private _isEnabled;
  25845. /**
  25846. * Defines if the material uses sheen.
  25847. */
  25848. isEnabled: boolean;
  25849. private _linkSheenWithAlbedo;
  25850. /**
  25851. * Defines if the sheen is linked to the sheen color.
  25852. */
  25853. linkSheenWithAlbedo: boolean;
  25854. /**
  25855. * Defines the sheen intensity.
  25856. */
  25857. intensity: number;
  25858. /**
  25859. * Defines the sheen color.
  25860. */
  25861. color: Color3;
  25862. private _texture;
  25863. /**
  25864. * Stores the sheen tint values in a texture.
  25865. * rgb is tint
  25866. * a is a intensity or roughness if roughness has been defined
  25867. */
  25868. texture: Nullable<BaseTexture>;
  25869. private _roughness;
  25870. /**
  25871. * Defines the sheen roughness.
  25872. * It is not taken into account if linkSheenWithAlbedo is true.
  25873. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25874. */
  25875. roughness: Nullable<number>;
  25876. private _albedoScaling;
  25877. /**
  25878. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25879. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25880. * making it easier to setup and tweak the effect
  25881. */
  25882. albedoScaling: boolean;
  25883. /** @hidden */
  25884. private _internalMarkAllSubMeshesAsTexturesDirty;
  25885. /** @hidden */
  25886. _markAllSubMeshesAsTexturesDirty(): void;
  25887. /**
  25888. * Instantiate a new istance of clear coat configuration.
  25889. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25890. */
  25891. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25892. /**
  25893. * Specifies that the submesh is ready to be used.
  25894. * @param defines the list of "defines" to update.
  25895. * @param scene defines the scene the material belongs to.
  25896. * @returns - boolean indicating that the submesh is ready or not.
  25897. */
  25898. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25899. /**
  25900. * Checks to see if a texture is used in the material.
  25901. * @param defines the list of "defines" to update.
  25902. * @param scene defines the scene the material belongs to.
  25903. */
  25904. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25905. /**
  25906. * Binds the material data.
  25907. * @param uniformBuffer defines the Uniform buffer to fill in.
  25908. * @param scene defines the scene the material belongs to.
  25909. * @param isFrozen defines wether the material is frozen or not.
  25910. */
  25911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25912. /**
  25913. * Checks to see if a texture is used in the material.
  25914. * @param texture - Base texture to use.
  25915. * @returns - Boolean specifying if a texture is used in the material.
  25916. */
  25917. hasTexture(texture: BaseTexture): boolean;
  25918. /**
  25919. * Returns an array of the actively used textures.
  25920. * @param activeTextures Array of BaseTextures
  25921. */
  25922. getActiveTextures(activeTextures: BaseTexture[]): void;
  25923. /**
  25924. * Returns the animatable textures.
  25925. * @param animatables Array of animatable textures.
  25926. */
  25927. getAnimatables(animatables: IAnimatable[]): void;
  25928. /**
  25929. * Disposes the resources of the material.
  25930. * @param forceDisposeTextures - Forces the disposal of all textures.
  25931. */
  25932. dispose(forceDisposeTextures?: boolean): void;
  25933. /**
  25934. * Get the current class name of the texture useful for serialization or dynamic coding.
  25935. * @returns "PBRSheenConfiguration"
  25936. */
  25937. getClassName(): string;
  25938. /**
  25939. * Add fallbacks to the effect fallbacks list.
  25940. * @param defines defines the Base texture to use.
  25941. * @param fallbacks defines the current fallback list.
  25942. * @param currentRank defines the current fallback rank.
  25943. * @returns the new fallback rank.
  25944. */
  25945. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25946. /**
  25947. * Add the required uniforms to the current list.
  25948. * @param uniforms defines the current uniform list.
  25949. */
  25950. static AddUniforms(uniforms: string[]): void;
  25951. /**
  25952. * Add the required uniforms to the current buffer.
  25953. * @param uniformBuffer defines the current uniform buffer.
  25954. */
  25955. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25956. /**
  25957. * Add the required samplers to the current list.
  25958. * @param samplers defines the current sampler list.
  25959. */
  25960. static AddSamplers(samplers: string[]): void;
  25961. /**
  25962. * Makes a duplicate of the current configuration into another one.
  25963. * @param sheenConfiguration define the config where to copy the info
  25964. */
  25965. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25966. /**
  25967. * Serializes this BRDF configuration.
  25968. * @returns - An object with the serialized config.
  25969. */
  25970. serialize(): any;
  25971. /**
  25972. * Parses a anisotropy Configuration from a serialized object.
  25973. * @param source - Serialized object.
  25974. * @param scene Defines the scene we are parsing for
  25975. * @param rootUrl Defines the rootUrl to load from
  25976. */
  25977. parse(source: any, scene: Scene, rootUrl: string): void;
  25978. }
  25979. }
  25980. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  25981. import { Nullable } from "babylonjs/types";
  25982. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25983. import { Color3 } from "babylonjs/Maths/math.color";
  25984. import { SmartArray } from "babylonjs/Misc/smartArray";
  25985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25986. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25987. import { Effect } from "babylonjs/Materials/effect";
  25988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25989. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25990. import { Engine } from "babylonjs/Engines/engine";
  25991. import { Scene } from "babylonjs/scene";
  25992. /**
  25993. * @hidden
  25994. */
  25995. export interface IMaterialSubSurfaceDefines {
  25996. SUBSURFACE: boolean;
  25997. SS_REFRACTION: boolean;
  25998. SS_TRANSLUCENCY: boolean;
  25999. SS_SCATTERING: boolean;
  26000. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26001. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26002. SS_REFRACTIONMAP_3D: boolean;
  26003. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26004. SS_LODINREFRACTIONALPHA: boolean;
  26005. SS_GAMMAREFRACTION: boolean;
  26006. SS_RGBDREFRACTION: boolean;
  26007. SS_LINEARSPECULARREFRACTION: boolean;
  26008. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26009. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26010. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26011. /** @hidden */
  26012. _areTexturesDirty: boolean;
  26013. }
  26014. /**
  26015. * Define the code related to the sub surface parameters of the pbr material.
  26016. */
  26017. export class PBRSubSurfaceConfiguration {
  26018. private _isRefractionEnabled;
  26019. /**
  26020. * Defines if the refraction is enabled in the material.
  26021. */
  26022. isRefractionEnabled: boolean;
  26023. private _isTranslucencyEnabled;
  26024. /**
  26025. * Defines if the translucency is enabled in the material.
  26026. */
  26027. isTranslucencyEnabled: boolean;
  26028. private _isScatteringEnabled;
  26029. /**
  26030. * Defines if the sub surface scattering is enabled in the material.
  26031. */
  26032. isScatteringEnabled: boolean;
  26033. private _scatteringDiffusionProfileIndex;
  26034. /**
  26035. * Diffusion profile for subsurface scattering.
  26036. * Useful for better scattering in the skins or foliages.
  26037. */
  26038. get scatteringDiffusionProfile(): Nullable<Color3>;
  26039. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26040. /**
  26041. * Defines the refraction intensity of the material.
  26042. * The refraction when enabled replaces the Diffuse part of the material.
  26043. * The intensity helps transitionning between diffuse and refraction.
  26044. */
  26045. refractionIntensity: number;
  26046. /**
  26047. * Defines the translucency intensity of the material.
  26048. * When translucency has been enabled, this defines how much of the "translucency"
  26049. * is addded to the diffuse part of the material.
  26050. */
  26051. translucencyIntensity: number;
  26052. /**
  26053. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26054. */
  26055. useAlbedoToTintRefraction: boolean;
  26056. private _thicknessTexture;
  26057. /**
  26058. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26059. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26060. * 0 would mean minimumThickness
  26061. * 1 would mean maximumThickness
  26062. * The other channels might be use as a mask to vary the different effects intensity.
  26063. */
  26064. thicknessTexture: Nullable<BaseTexture>;
  26065. private _refractionTexture;
  26066. /**
  26067. * Defines the texture to use for refraction.
  26068. */
  26069. refractionTexture: Nullable<BaseTexture>;
  26070. private _indexOfRefraction;
  26071. /**
  26072. * Index of refraction of the material base layer.
  26073. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26074. *
  26075. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26076. *
  26077. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26078. */
  26079. indexOfRefraction: number;
  26080. private _volumeIndexOfRefraction;
  26081. /**
  26082. * Index of refraction of the material's volume.
  26083. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26084. *
  26085. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26086. * the volume will use the same IOR as the surface.
  26087. */
  26088. get volumeIndexOfRefraction(): number;
  26089. set volumeIndexOfRefraction(value: number);
  26090. private _invertRefractionY;
  26091. /**
  26092. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26093. */
  26094. invertRefractionY: boolean;
  26095. private _linkRefractionWithTransparency;
  26096. /**
  26097. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26098. * Materials half opaque for instance using refraction could benefit from this control.
  26099. */
  26100. linkRefractionWithTransparency: boolean;
  26101. /**
  26102. * Defines the minimum thickness stored in the thickness map.
  26103. * If no thickness map is defined, this value will be used to simulate thickness.
  26104. */
  26105. minimumThickness: number;
  26106. /**
  26107. * Defines the maximum thickness stored in the thickness map.
  26108. */
  26109. maximumThickness: number;
  26110. /**
  26111. * Defines the volume tint of the material.
  26112. * This is used for both translucency and scattering.
  26113. */
  26114. tintColor: Color3;
  26115. /**
  26116. * Defines the distance at which the tint color should be found in the media.
  26117. * This is used for refraction only.
  26118. */
  26119. tintColorAtDistance: number;
  26120. /**
  26121. * Defines how far each channel transmit through the media.
  26122. * It is defined as a color to simplify it selection.
  26123. */
  26124. diffusionDistance: Color3;
  26125. private _useMaskFromThicknessTexture;
  26126. /**
  26127. * Stores the intensity of the different subsurface effects in the thickness texture.
  26128. * * the green channel is the translucency intensity.
  26129. * * the blue channel is the scattering intensity.
  26130. * * the alpha channel is the refraction intensity.
  26131. */
  26132. useMaskFromThicknessTexture: boolean;
  26133. private _scene;
  26134. /** @hidden */
  26135. private _internalMarkAllSubMeshesAsTexturesDirty;
  26136. private _internalMarkScenePrePassDirty;
  26137. /** @hidden */
  26138. _markAllSubMeshesAsTexturesDirty(): void;
  26139. /** @hidden */
  26140. _markScenePrePassDirty(): void;
  26141. /**
  26142. * Instantiate a new istance of sub surface configuration.
  26143. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26144. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26145. * @param scene The scene
  26146. */
  26147. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26148. /**
  26149. * Gets wehter the submesh is ready to be used or not.
  26150. * @param defines the list of "defines" to update.
  26151. * @param scene defines the scene the material belongs to.
  26152. * @returns - boolean indicating that the submesh is ready or not.
  26153. */
  26154. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26155. /**
  26156. * Checks to see if a texture is used in the material.
  26157. * @param defines the list of "defines" to update.
  26158. * @param scene defines the scene to the material belongs to.
  26159. */
  26160. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26161. /**
  26162. * Binds the material data.
  26163. * @param uniformBuffer defines the Uniform buffer to fill in.
  26164. * @param scene defines the scene the material belongs to.
  26165. * @param engine defines the engine the material belongs to.
  26166. * @param isFrozen defines whether the material is frozen or not.
  26167. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26168. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26169. */
  26170. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26171. /**
  26172. * Unbinds the material from the mesh.
  26173. * @param activeEffect defines the effect that should be unbound from.
  26174. * @returns true if unbound, otherwise false
  26175. */
  26176. unbind(activeEffect: Effect): boolean;
  26177. /**
  26178. * Returns the texture used for refraction or null if none is used.
  26179. * @param scene defines the scene the material belongs to.
  26180. * @returns - Refraction texture if present. If no refraction texture and refraction
  26181. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26182. */
  26183. private _getRefractionTexture;
  26184. /**
  26185. * Returns true if alpha blending should be disabled.
  26186. */
  26187. get disableAlphaBlending(): boolean;
  26188. /**
  26189. * Fills the list of render target textures.
  26190. * @param renderTargets the list of render targets to update
  26191. */
  26192. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26193. /**
  26194. * Checks to see if a texture is used in the material.
  26195. * @param texture - Base texture to use.
  26196. * @returns - Boolean specifying if a texture is used in the material.
  26197. */
  26198. hasTexture(texture: BaseTexture): boolean;
  26199. /**
  26200. * Gets a boolean indicating that current material needs to register RTT
  26201. * @returns true if this uses a render target otherwise false.
  26202. */
  26203. hasRenderTargetTextures(): boolean;
  26204. /**
  26205. * Returns an array of the actively used textures.
  26206. * @param activeTextures Array of BaseTextures
  26207. */
  26208. getActiveTextures(activeTextures: BaseTexture[]): void;
  26209. /**
  26210. * Returns the animatable textures.
  26211. * @param animatables Array of animatable textures.
  26212. */
  26213. getAnimatables(animatables: IAnimatable[]): void;
  26214. /**
  26215. * Disposes the resources of the material.
  26216. * @param forceDisposeTextures - Forces the disposal of all textures.
  26217. */
  26218. dispose(forceDisposeTextures?: boolean): void;
  26219. /**
  26220. * Get the current class name of the texture useful for serialization or dynamic coding.
  26221. * @returns "PBRSubSurfaceConfiguration"
  26222. */
  26223. getClassName(): string;
  26224. /**
  26225. * Add fallbacks to the effect fallbacks list.
  26226. * @param defines defines the Base texture to use.
  26227. * @param fallbacks defines the current fallback list.
  26228. * @param currentRank defines the current fallback rank.
  26229. * @returns the new fallback rank.
  26230. */
  26231. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26232. /**
  26233. * Add the required uniforms to the current list.
  26234. * @param uniforms defines the current uniform list.
  26235. */
  26236. static AddUniforms(uniforms: string[]): void;
  26237. /**
  26238. * Add the required samplers to the current list.
  26239. * @param samplers defines the current sampler list.
  26240. */
  26241. static AddSamplers(samplers: string[]): void;
  26242. /**
  26243. * Add the required uniforms to the current buffer.
  26244. * @param uniformBuffer defines the current uniform buffer.
  26245. */
  26246. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26247. /**
  26248. * Makes a duplicate of the current configuration into another one.
  26249. * @param configuration define the config where to copy the info
  26250. */
  26251. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26252. /**
  26253. * Serializes this Sub Surface configuration.
  26254. * @returns - An object with the serialized config.
  26255. */
  26256. serialize(): any;
  26257. /**
  26258. * Parses a anisotropy Configuration from a serialized object.
  26259. * @param source - Serialized object.
  26260. * @param scene Defines the scene we are parsing for
  26261. * @param rootUrl Defines the rootUrl to load from
  26262. */
  26263. parse(source: any, scene: Scene, rootUrl: string): void;
  26264. }
  26265. }
  26266. declare module "babylonjs/Maths/sphericalPolynomial" {
  26267. import { Vector3 } from "babylonjs/Maths/math.vector";
  26268. import { Color3 } from "babylonjs/Maths/math.color";
  26269. /**
  26270. * Class representing spherical harmonics coefficients to the 3rd degree
  26271. */
  26272. export class SphericalHarmonics {
  26273. /**
  26274. * Defines whether or not the harmonics have been prescaled for rendering.
  26275. */
  26276. preScaled: boolean;
  26277. /**
  26278. * The l0,0 coefficients of the spherical harmonics
  26279. */
  26280. l00: Vector3;
  26281. /**
  26282. * The l1,-1 coefficients of the spherical harmonics
  26283. */
  26284. l1_1: Vector3;
  26285. /**
  26286. * The l1,0 coefficients of the spherical harmonics
  26287. */
  26288. l10: Vector3;
  26289. /**
  26290. * The l1,1 coefficients of the spherical harmonics
  26291. */
  26292. l11: Vector3;
  26293. /**
  26294. * The l2,-2 coefficients of the spherical harmonics
  26295. */
  26296. l2_2: Vector3;
  26297. /**
  26298. * The l2,-1 coefficients of the spherical harmonics
  26299. */
  26300. l2_1: Vector3;
  26301. /**
  26302. * The l2,0 coefficients of the spherical harmonics
  26303. */
  26304. l20: Vector3;
  26305. /**
  26306. * The l2,1 coefficients of the spherical harmonics
  26307. */
  26308. l21: Vector3;
  26309. /**
  26310. * The l2,2 coefficients of the spherical harmonics
  26311. */
  26312. l22: Vector3;
  26313. /**
  26314. * Adds a light to the spherical harmonics
  26315. * @param direction the direction of the light
  26316. * @param color the color of the light
  26317. * @param deltaSolidAngle the delta solid angle of the light
  26318. */
  26319. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26320. /**
  26321. * Scales the spherical harmonics by the given amount
  26322. * @param scale the amount to scale
  26323. */
  26324. scaleInPlace(scale: number): void;
  26325. /**
  26326. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26327. *
  26328. * ```
  26329. * E_lm = A_l * L_lm
  26330. * ```
  26331. *
  26332. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26333. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26334. * the scaling factors are given in equation 9.
  26335. */
  26336. convertIncidentRadianceToIrradiance(): void;
  26337. /**
  26338. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26339. *
  26340. * ```
  26341. * L = (1/pi) * E * rho
  26342. * ```
  26343. *
  26344. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26345. */
  26346. convertIrradianceToLambertianRadiance(): void;
  26347. /**
  26348. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26349. * required operations at run time.
  26350. *
  26351. * This is simply done by scaling back the SH with Ylm constants parameter.
  26352. * The trigonometric part being applied by the shader at run time.
  26353. */
  26354. preScaleForRendering(): void;
  26355. /**
  26356. * Constructs a spherical harmonics from an array.
  26357. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26358. * @returns the spherical harmonics
  26359. */
  26360. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26361. /**
  26362. * Gets the spherical harmonics from polynomial
  26363. * @param polynomial the spherical polynomial
  26364. * @returns the spherical harmonics
  26365. */
  26366. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26367. }
  26368. /**
  26369. * Class representing spherical polynomial coefficients to the 3rd degree
  26370. */
  26371. export class SphericalPolynomial {
  26372. private _harmonics;
  26373. /**
  26374. * The spherical harmonics used to create the polynomials.
  26375. */
  26376. get preScaledHarmonics(): SphericalHarmonics;
  26377. /**
  26378. * The x coefficients of the spherical polynomial
  26379. */
  26380. x: Vector3;
  26381. /**
  26382. * The y coefficients of the spherical polynomial
  26383. */
  26384. y: Vector3;
  26385. /**
  26386. * The z coefficients of the spherical polynomial
  26387. */
  26388. z: Vector3;
  26389. /**
  26390. * The xx coefficients of the spherical polynomial
  26391. */
  26392. xx: Vector3;
  26393. /**
  26394. * The yy coefficients of the spherical polynomial
  26395. */
  26396. yy: Vector3;
  26397. /**
  26398. * The zz coefficients of the spherical polynomial
  26399. */
  26400. zz: Vector3;
  26401. /**
  26402. * The xy coefficients of the spherical polynomial
  26403. */
  26404. xy: Vector3;
  26405. /**
  26406. * The yz coefficients of the spherical polynomial
  26407. */
  26408. yz: Vector3;
  26409. /**
  26410. * The zx coefficients of the spherical polynomial
  26411. */
  26412. zx: Vector3;
  26413. /**
  26414. * Adds an ambient color to the spherical polynomial
  26415. * @param color the color to add
  26416. */
  26417. addAmbient(color: Color3): void;
  26418. /**
  26419. * Scales the spherical polynomial by the given amount
  26420. * @param scale the amount to scale
  26421. */
  26422. scaleInPlace(scale: number): void;
  26423. /**
  26424. * Gets the spherical polynomial from harmonics
  26425. * @param harmonics the spherical harmonics
  26426. * @returns the spherical polynomial
  26427. */
  26428. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26429. /**
  26430. * Constructs a spherical polynomial from an array.
  26431. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26432. * @returns the spherical polynomial
  26433. */
  26434. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26435. }
  26436. }
  26437. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26438. import { Nullable } from "babylonjs/types";
  26439. /**
  26440. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26441. */
  26442. export interface CubeMapInfo {
  26443. /**
  26444. * The pixel array for the front face.
  26445. * This is stored in format, left to right, up to down format.
  26446. */
  26447. front: Nullable<ArrayBufferView>;
  26448. /**
  26449. * The pixel array for the back face.
  26450. * This is stored in format, left to right, up to down format.
  26451. */
  26452. back: Nullable<ArrayBufferView>;
  26453. /**
  26454. * The pixel array for the left face.
  26455. * This is stored in format, left to right, up to down format.
  26456. */
  26457. left: Nullable<ArrayBufferView>;
  26458. /**
  26459. * The pixel array for the right face.
  26460. * This is stored in format, left to right, up to down format.
  26461. */
  26462. right: Nullable<ArrayBufferView>;
  26463. /**
  26464. * The pixel array for the up face.
  26465. * This is stored in format, left to right, up to down format.
  26466. */
  26467. up: Nullable<ArrayBufferView>;
  26468. /**
  26469. * The pixel array for the down face.
  26470. * This is stored in format, left to right, up to down format.
  26471. */
  26472. down: Nullable<ArrayBufferView>;
  26473. /**
  26474. * The size of the cubemap stored.
  26475. *
  26476. * Each faces will be size * size pixels.
  26477. */
  26478. size: number;
  26479. /**
  26480. * The format of the texture.
  26481. *
  26482. * RGBA, RGB.
  26483. */
  26484. format: number;
  26485. /**
  26486. * The type of the texture data.
  26487. *
  26488. * UNSIGNED_INT, FLOAT.
  26489. */
  26490. type: number;
  26491. /**
  26492. * Specifies whether the texture is in gamma space.
  26493. */
  26494. gammaSpace: boolean;
  26495. }
  26496. /**
  26497. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26498. */
  26499. export class PanoramaToCubeMapTools {
  26500. private static FACE_LEFT;
  26501. private static FACE_RIGHT;
  26502. private static FACE_FRONT;
  26503. private static FACE_BACK;
  26504. private static FACE_DOWN;
  26505. private static FACE_UP;
  26506. /**
  26507. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26508. *
  26509. * @param float32Array The source data.
  26510. * @param inputWidth The width of the input panorama.
  26511. * @param inputHeight The height of the input panorama.
  26512. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26513. * @return The cubemap data
  26514. */
  26515. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26516. private static CreateCubemapTexture;
  26517. private static CalcProjectionSpherical;
  26518. }
  26519. }
  26520. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26521. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26523. import { Nullable } from "babylonjs/types";
  26524. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26525. /**
  26526. * Helper class dealing with the extraction of spherical polynomial dataArray
  26527. * from a cube map.
  26528. */
  26529. export class CubeMapToSphericalPolynomialTools {
  26530. private static FileFaces;
  26531. /**
  26532. * Converts a texture to the according Spherical Polynomial data.
  26533. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26534. *
  26535. * @param texture The texture to extract the information from.
  26536. * @return The Spherical Polynomial data.
  26537. */
  26538. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26539. /**
  26540. * Converts a cubemap to the according Spherical Polynomial data.
  26541. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26542. *
  26543. * @param cubeInfo The Cube map to extract the information from.
  26544. * @return The Spherical Polynomial data.
  26545. */
  26546. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26547. }
  26548. }
  26549. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26550. import { Nullable } from "babylonjs/types";
  26551. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26552. module "babylonjs/Materials/Textures/baseTexture" {
  26553. interface BaseTexture {
  26554. /**
  26555. * Get the polynomial representation of the texture data.
  26556. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26557. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26558. */
  26559. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26560. }
  26561. }
  26562. }
  26563. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26564. /** @hidden */
  26565. export var pbrFragmentDeclaration: {
  26566. name: string;
  26567. shader: string;
  26568. };
  26569. }
  26570. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26571. /** @hidden */
  26572. export var pbrUboDeclaration: {
  26573. name: string;
  26574. shader: string;
  26575. };
  26576. }
  26577. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26578. /** @hidden */
  26579. export var pbrFragmentExtraDeclaration: {
  26580. name: string;
  26581. shader: string;
  26582. };
  26583. }
  26584. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26585. /** @hidden */
  26586. export var pbrFragmentSamplersDeclaration: {
  26587. name: string;
  26588. shader: string;
  26589. };
  26590. }
  26591. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26592. /** @hidden */
  26593. export var subSurfaceScatteringFunctions: {
  26594. name: string;
  26595. shader: string;
  26596. };
  26597. }
  26598. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26599. /** @hidden */
  26600. export var importanceSampling: {
  26601. name: string;
  26602. shader: string;
  26603. };
  26604. }
  26605. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26606. /** @hidden */
  26607. export var pbrHelperFunctions: {
  26608. name: string;
  26609. shader: string;
  26610. };
  26611. }
  26612. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26613. /** @hidden */
  26614. export var harmonicsFunctions: {
  26615. name: string;
  26616. shader: string;
  26617. };
  26618. }
  26619. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26620. /** @hidden */
  26621. export var pbrDirectLightingSetupFunctions: {
  26622. name: string;
  26623. shader: string;
  26624. };
  26625. }
  26626. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26627. /** @hidden */
  26628. export var pbrDirectLightingFalloffFunctions: {
  26629. name: string;
  26630. shader: string;
  26631. };
  26632. }
  26633. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26634. /** @hidden */
  26635. export var pbrBRDFFunctions: {
  26636. name: string;
  26637. shader: string;
  26638. };
  26639. }
  26640. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26641. /** @hidden */
  26642. export var hdrFilteringFunctions: {
  26643. name: string;
  26644. shader: string;
  26645. };
  26646. }
  26647. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26648. /** @hidden */
  26649. export var pbrDirectLightingFunctions: {
  26650. name: string;
  26651. shader: string;
  26652. };
  26653. }
  26654. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26655. /** @hidden */
  26656. export var pbrIBLFunctions: {
  26657. name: string;
  26658. shader: string;
  26659. };
  26660. }
  26661. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26662. /** @hidden */
  26663. export var pbrBlockAlbedoOpacity: {
  26664. name: string;
  26665. shader: string;
  26666. };
  26667. }
  26668. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26669. /** @hidden */
  26670. export var pbrBlockReflectivity: {
  26671. name: string;
  26672. shader: string;
  26673. };
  26674. }
  26675. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26676. /** @hidden */
  26677. export var pbrBlockAmbientOcclusion: {
  26678. name: string;
  26679. shader: string;
  26680. };
  26681. }
  26682. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26683. /** @hidden */
  26684. export var pbrBlockAlphaFresnel: {
  26685. name: string;
  26686. shader: string;
  26687. };
  26688. }
  26689. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26690. /** @hidden */
  26691. export var pbrBlockAnisotropic: {
  26692. name: string;
  26693. shader: string;
  26694. };
  26695. }
  26696. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26697. /** @hidden */
  26698. export var pbrBlockReflection: {
  26699. name: string;
  26700. shader: string;
  26701. };
  26702. }
  26703. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26704. /** @hidden */
  26705. export var pbrBlockSheen: {
  26706. name: string;
  26707. shader: string;
  26708. };
  26709. }
  26710. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26711. /** @hidden */
  26712. export var pbrBlockClearcoat: {
  26713. name: string;
  26714. shader: string;
  26715. };
  26716. }
  26717. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26718. /** @hidden */
  26719. export var pbrBlockSubSurface: {
  26720. name: string;
  26721. shader: string;
  26722. };
  26723. }
  26724. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26725. /** @hidden */
  26726. export var pbrBlockNormalGeometric: {
  26727. name: string;
  26728. shader: string;
  26729. };
  26730. }
  26731. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26732. /** @hidden */
  26733. export var pbrBlockNormalFinal: {
  26734. name: string;
  26735. shader: string;
  26736. };
  26737. }
  26738. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26739. /** @hidden */
  26740. export var pbrBlockLightmapInit: {
  26741. name: string;
  26742. shader: string;
  26743. };
  26744. }
  26745. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26746. /** @hidden */
  26747. export var pbrBlockGeometryInfo: {
  26748. name: string;
  26749. shader: string;
  26750. };
  26751. }
  26752. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26753. /** @hidden */
  26754. export var pbrBlockReflectance0: {
  26755. name: string;
  26756. shader: string;
  26757. };
  26758. }
  26759. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26760. /** @hidden */
  26761. export var pbrBlockReflectance: {
  26762. name: string;
  26763. shader: string;
  26764. };
  26765. }
  26766. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26767. /** @hidden */
  26768. export var pbrBlockDirectLighting: {
  26769. name: string;
  26770. shader: string;
  26771. };
  26772. }
  26773. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26774. /** @hidden */
  26775. export var pbrBlockFinalLitComponents: {
  26776. name: string;
  26777. shader: string;
  26778. };
  26779. }
  26780. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26781. /** @hidden */
  26782. export var pbrBlockFinalUnlitComponents: {
  26783. name: string;
  26784. shader: string;
  26785. };
  26786. }
  26787. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26788. /** @hidden */
  26789. export var pbrBlockFinalColorComposition: {
  26790. name: string;
  26791. shader: string;
  26792. };
  26793. }
  26794. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26795. /** @hidden */
  26796. export var pbrBlockImageProcessing: {
  26797. name: string;
  26798. shader: string;
  26799. };
  26800. }
  26801. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26802. /** @hidden */
  26803. export var pbrDebug: {
  26804. name: string;
  26805. shader: string;
  26806. };
  26807. }
  26808. declare module "babylonjs/Shaders/pbr.fragment" {
  26809. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26810. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26811. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26812. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26813. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26814. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26821. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26822. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26823. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26824. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26825. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26826. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26827. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26828. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26829. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26830. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26831. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26832. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26833. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26834. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26835. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26836. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26837. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26838. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26839. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26840. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26841. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26842. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26843. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26844. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26845. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26846. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26847. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26848. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26849. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26850. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26851. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26852. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26853. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26854. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26855. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26856. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26857. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26858. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26859. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26860. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26861. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26862. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26863. /** @hidden */
  26864. export var pbrPixelShader: {
  26865. name: string;
  26866. shader: string;
  26867. };
  26868. }
  26869. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26870. /** @hidden */
  26871. export var pbrVertexDeclaration: {
  26872. name: string;
  26873. shader: string;
  26874. };
  26875. }
  26876. declare module "babylonjs/Shaders/pbr.vertex" {
  26877. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26878. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26880. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26881. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26882. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26883. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26884. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26885. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26886. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26887. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26888. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26889. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26891. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26892. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26893. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26894. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26895. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26896. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26897. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26898. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26899. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26900. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26901. /** @hidden */
  26902. export var pbrVertexShader: {
  26903. name: string;
  26904. shader: string;
  26905. };
  26906. }
  26907. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26908. import { Nullable } from "babylonjs/types";
  26909. import { Scene } from "babylonjs/scene";
  26910. import { Matrix } from "babylonjs/Maths/math.vector";
  26911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26913. import { Mesh } from "babylonjs/Meshes/mesh";
  26914. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26915. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26916. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26917. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26918. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26919. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26920. import { Color3 } from "babylonjs/Maths/math.color";
  26921. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26922. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26923. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26924. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26925. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26926. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26927. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  26928. import "babylonjs/Shaders/pbr.fragment";
  26929. import "babylonjs/Shaders/pbr.vertex";
  26930. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  26931. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  26932. /**
  26933. * Manages the defines for the PBR Material.
  26934. * @hidden
  26935. */
  26936. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26937. PBR: boolean;
  26938. NUM_SAMPLES: string;
  26939. REALTIME_FILTERING: boolean;
  26940. MAINUV1: boolean;
  26941. MAINUV2: boolean;
  26942. UV1: boolean;
  26943. UV2: boolean;
  26944. ALBEDO: boolean;
  26945. GAMMAALBEDO: boolean;
  26946. ALBEDODIRECTUV: number;
  26947. VERTEXCOLOR: boolean;
  26948. DETAIL: boolean;
  26949. DETAILDIRECTUV: number;
  26950. DETAIL_NORMALBLENDMETHOD: number;
  26951. AMBIENT: boolean;
  26952. AMBIENTDIRECTUV: number;
  26953. AMBIENTINGRAYSCALE: boolean;
  26954. OPACITY: boolean;
  26955. VERTEXALPHA: boolean;
  26956. OPACITYDIRECTUV: number;
  26957. OPACITYRGB: boolean;
  26958. ALPHATEST: boolean;
  26959. DEPTHPREPASS: boolean;
  26960. ALPHABLEND: boolean;
  26961. ALPHAFROMALBEDO: boolean;
  26962. ALPHATESTVALUE: string;
  26963. SPECULAROVERALPHA: boolean;
  26964. RADIANCEOVERALPHA: boolean;
  26965. ALPHAFRESNEL: boolean;
  26966. LINEARALPHAFRESNEL: boolean;
  26967. PREMULTIPLYALPHA: boolean;
  26968. EMISSIVE: boolean;
  26969. EMISSIVEDIRECTUV: number;
  26970. REFLECTIVITY: boolean;
  26971. REFLECTIVITYDIRECTUV: number;
  26972. SPECULARTERM: boolean;
  26973. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26974. MICROSURFACEAUTOMATIC: boolean;
  26975. LODBASEDMICROSFURACE: boolean;
  26976. MICROSURFACEMAP: boolean;
  26977. MICROSURFACEMAPDIRECTUV: number;
  26978. METALLICWORKFLOW: boolean;
  26979. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26980. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26981. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26982. AOSTOREINMETALMAPRED: boolean;
  26983. METALLIC_REFLECTANCE: boolean;
  26984. METALLIC_REFLECTANCEDIRECTUV: number;
  26985. ENVIRONMENTBRDF: boolean;
  26986. ENVIRONMENTBRDF_RGBD: boolean;
  26987. NORMAL: boolean;
  26988. TANGENT: boolean;
  26989. BUMP: boolean;
  26990. BUMPDIRECTUV: number;
  26991. OBJECTSPACE_NORMALMAP: boolean;
  26992. PARALLAX: boolean;
  26993. PARALLAXOCCLUSION: boolean;
  26994. NORMALXYSCALE: boolean;
  26995. LIGHTMAP: boolean;
  26996. LIGHTMAPDIRECTUV: number;
  26997. USELIGHTMAPASSHADOWMAP: boolean;
  26998. GAMMALIGHTMAP: boolean;
  26999. RGBDLIGHTMAP: boolean;
  27000. REFLECTION: boolean;
  27001. REFLECTIONMAP_3D: boolean;
  27002. REFLECTIONMAP_SPHERICAL: boolean;
  27003. REFLECTIONMAP_PLANAR: boolean;
  27004. REFLECTIONMAP_CUBIC: boolean;
  27005. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27006. REFLECTIONMAP_PROJECTION: boolean;
  27007. REFLECTIONMAP_SKYBOX: boolean;
  27008. REFLECTIONMAP_EXPLICIT: boolean;
  27009. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27010. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27011. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27012. INVERTCUBICMAP: boolean;
  27013. USESPHERICALFROMREFLECTIONMAP: boolean;
  27014. USEIRRADIANCEMAP: boolean;
  27015. SPHERICAL_HARMONICS: boolean;
  27016. USESPHERICALINVERTEX: boolean;
  27017. REFLECTIONMAP_OPPOSITEZ: boolean;
  27018. LODINREFLECTIONALPHA: boolean;
  27019. GAMMAREFLECTION: boolean;
  27020. RGBDREFLECTION: boolean;
  27021. LINEARSPECULARREFLECTION: boolean;
  27022. RADIANCEOCCLUSION: boolean;
  27023. HORIZONOCCLUSION: boolean;
  27024. INSTANCES: boolean;
  27025. THIN_INSTANCES: boolean;
  27026. PREPASS: boolean;
  27027. PREPASS_IRRADIANCE: boolean;
  27028. PREPASS_IRRADIANCE_INDEX: number;
  27029. PREPASS_ALBEDO: boolean;
  27030. PREPASS_ALBEDO_INDEX: number;
  27031. PREPASS_DEPTHNORMAL: boolean;
  27032. PREPASS_DEPTHNORMAL_INDEX: number;
  27033. PREPASS_POSITION: boolean;
  27034. PREPASS_POSITION_INDEX: number;
  27035. PREPASS_VELOCITY: boolean;
  27036. PREPASS_VELOCITY_INDEX: number;
  27037. PREPASS_REFLECTIVITY: boolean;
  27038. PREPASS_REFLECTIVITY_INDEX: number;
  27039. SCENE_MRT_COUNT: number;
  27040. NUM_BONE_INFLUENCERS: number;
  27041. BonesPerMesh: number;
  27042. BONETEXTURE: boolean;
  27043. BONES_VELOCITY_ENABLED: boolean;
  27044. NONUNIFORMSCALING: boolean;
  27045. MORPHTARGETS: boolean;
  27046. MORPHTARGETS_NORMAL: boolean;
  27047. MORPHTARGETS_TANGENT: boolean;
  27048. MORPHTARGETS_UV: boolean;
  27049. NUM_MORPH_INFLUENCERS: number;
  27050. IMAGEPROCESSING: boolean;
  27051. VIGNETTE: boolean;
  27052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27053. VIGNETTEBLENDMODEOPAQUE: boolean;
  27054. TONEMAPPING: boolean;
  27055. TONEMAPPING_ACES: boolean;
  27056. CONTRAST: boolean;
  27057. COLORCURVES: boolean;
  27058. COLORGRADING: boolean;
  27059. COLORGRADING3D: boolean;
  27060. SAMPLER3DGREENDEPTH: boolean;
  27061. SAMPLER3DBGRMAP: boolean;
  27062. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27063. EXPOSURE: boolean;
  27064. MULTIVIEW: boolean;
  27065. USEPHYSICALLIGHTFALLOFF: boolean;
  27066. USEGLTFLIGHTFALLOFF: boolean;
  27067. TWOSIDEDLIGHTING: boolean;
  27068. SHADOWFLOAT: boolean;
  27069. CLIPPLANE: boolean;
  27070. CLIPPLANE2: boolean;
  27071. CLIPPLANE3: boolean;
  27072. CLIPPLANE4: boolean;
  27073. CLIPPLANE5: boolean;
  27074. CLIPPLANE6: boolean;
  27075. POINTSIZE: boolean;
  27076. FOG: boolean;
  27077. LOGARITHMICDEPTH: boolean;
  27078. FORCENORMALFORWARD: boolean;
  27079. SPECULARAA: boolean;
  27080. CLEARCOAT: boolean;
  27081. CLEARCOAT_DEFAULTIOR: boolean;
  27082. CLEARCOAT_TEXTURE: boolean;
  27083. CLEARCOAT_TEXTUREDIRECTUV: number;
  27084. CLEARCOAT_BUMP: boolean;
  27085. CLEARCOAT_BUMPDIRECTUV: number;
  27086. CLEARCOAT_REMAP_F0: boolean;
  27087. CLEARCOAT_TINT: boolean;
  27088. CLEARCOAT_TINT_TEXTURE: boolean;
  27089. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27090. ANISOTROPIC: boolean;
  27091. ANISOTROPIC_TEXTURE: boolean;
  27092. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27093. BRDF_V_HEIGHT_CORRELATED: boolean;
  27094. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27095. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27096. SHEEN: boolean;
  27097. SHEEN_TEXTURE: boolean;
  27098. SHEEN_TEXTUREDIRECTUV: number;
  27099. SHEEN_LINKWITHALBEDO: boolean;
  27100. SHEEN_ROUGHNESS: boolean;
  27101. SHEEN_ALBEDOSCALING: boolean;
  27102. SUBSURFACE: boolean;
  27103. SS_REFRACTION: boolean;
  27104. SS_TRANSLUCENCY: boolean;
  27105. SS_SCATTERING: boolean;
  27106. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27107. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27108. SS_REFRACTIONMAP_3D: boolean;
  27109. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27110. SS_LODINREFRACTIONALPHA: boolean;
  27111. SS_GAMMAREFRACTION: boolean;
  27112. SS_RGBDREFRACTION: boolean;
  27113. SS_LINEARSPECULARREFRACTION: boolean;
  27114. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27115. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27116. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27117. UNLIT: boolean;
  27118. DEBUGMODE: number;
  27119. /**
  27120. * Initializes the PBR Material defines.
  27121. */
  27122. constructor();
  27123. /**
  27124. * Resets the PBR Material defines.
  27125. */
  27126. reset(): void;
  27127. }
  27128. /**
  27129. * The Physically based material base class of BJS.
  27130. *
  27131. * This offers the main features of a standard PBR material.
  27132. * For more information, please refer to the documentation :
  27133. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27134. */
  27135. export abstract class PBRBaseMaterial extends PushMaterial {
  27136. /**
  27137. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27138. */
  27139. static readonly PBRMATERIAL_OPAQUE: number;
  27140. /**
  27141. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27142. */
  27143. static readonly PBRMATERIAL_ALPHATEST: number;
  27144. /**
  27145. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27146. */
  27147. static readonly PBRMATERIAL_ALPHABLEND: number;
  27148. /**
  27149. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27150. * They are also discarded below the alpha cutoff threshold to improve performances.
  27151. */
  27152. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27153. /**
  27154. * Defines the default value of how much AO map is occluding the analytical lights
  27155. * (point spot...).
  27156. */
  27157. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27158. /**
  27159. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27160. */
  27161. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27162. /**
  27163. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27164. * to enhance interoperability with other engines.
  27165. */
  27166. static readonly LIGHTFALLOFF_GLTF: number;
  27167. /**
  27168. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27169. * to enhance interoperability with other materials.
  27170. */
  27171. static readonly LIGHTFALLOFF_STANDARD: number;
  27172. /**
  27173. * Intensity of the direct lights e.g. the four lights available in your scene.
  27174. * This impacts both the direct diffuse and specular highlights.
  27175. */
  27176. protected _directIntensity: number;
  27177. /**
  27178. * Intensity of the emissive part of the material.
  27179. * This helps controlling the emissive effect without modifying the emissive color.
  27180. */
  27181. protected _emissiveIntensity: number;
  27182. /**
  27183. * Intensity of the environment e.g. how much the environment will light the object
  27184. * either through harmonics for rough material or through the refelction for shiny ones.
  27185. */
  27186. protected _environmentIntensity: number;
  27187. /**
  27188. * This is a special control allowing the reduction of the specular highlights coming from the
  27189. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27190. */
  27191. protected _specularIntensity: number;
  27192. /**
  27193. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27194. */
  27195. private _lightingInfos;
  27196. /**
  27197. * Debug Control allowing disabling the bump map on this material.
  27198. */
  27199. protected _disableBumpMap: boolean;
  27200. /**
  27201. * AKA Diffuse Texture in standard nomenclature.
  27202. */
  27203. protected _albedoTexture: Nullable<BaseTexture>;
  27204. /**
  27205. * AKA Occlusion Texture in other nomenclature.
  27206. */
  27207. protected _ambientTexture: Nullable<BaseTexture>;
  27208. /**
  27209. * AKA Occlusion Texture Intensity in other nomenclature.
  27210. */
  27211. protected _ambientTextureStrength: number;
  27212. /**
  27213. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27214. * 1 means it completely occludes it
  27215. * 0 mean it has no impact
  27216. */
  27217. protected _ambientTextureImpactOnAnalyticalLights: number;
  27218. /**
  27219. * Stores the alpha values in a texture.
  27220. */
  27221. protected _opacityTexture: Nullable<BaseTexture>;
  27222. /**
  27223. * Stores the reflection values in a texture.
  27224. */
  27225. protected _reflectionTexture: Nullable<BaseTexture>;
  27226. /**
  27227. * Stores the emissive values in a texture.
  27228. */
  27229. protected _emissiveTexture: Nullable<BaseTexture>;
  27230. /**
  27231. * AKA Specular texture in other nomenclature.
  27232. */
  27233. protected _reflectivityTexture: Nullable<BaseTexture>;
  27234. /**
  27235. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27236. */
  27237. protected _metallicTexture: Nullable<BaseTexture>;
  27238. /**
  27239. * Specifies the metallic scalar of the metallic/roughness workflow.
  27240. * Can also be used to scale the metalness values of the metallic texture.
  27241. */
  27242. protected _metallic: Nullable<number>;
  27243. /**
  27244. * Specifies the roughness scalar of the metallic/roughness workflow.
  27245. * Can also be used to scale the roughness values of the metallic texture.
  27246. */
  27247. protected _roughness: Nullable<number>;
  27248. /**
  27249. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27250. * By default the indexOfrefraction is used to compute F0;
  27251. *
  27252. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27253. *
  27254. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27255. * F90 = metallicReflectanceColor;
  27256. */
  27257. protected _metallicF0Factor: number;
  27258. /**
  27259. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27260. * By default the F90 is always 1;
  27261. *
  27262. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27263. *
  27264. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27265. * F90 = metallicReflectanceColor;
  27266. */
  27267. protected _metallicReflectanceColor: Color3;
  27268. /**
  27269. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27270. * This is multiply against the scalar values defined in the material.
  27271. */
  27272. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27273. /**
  27274. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27275. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27276. */
  27277. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27278. /**
  27279. * Stores surface normal data used to displace a mesh in a texture.
  27280. */
  27281. protected _bumpTexture: Nullable<BaseTexture>;
  27282. /**
  27283. * Stores the pre-calculated light information of a mesh in a texture.
  27284. */
  27285. protected _lightmapTexture: Nullable<BaseTexture>;
  27286. /**
  27287. * The color of a material in ambient lighting.
  27288. */
  27289. protected _ambientColor: Color3;
  27290. /**
  27291. * AKA Diffuse Color in other nomenclature.
  27292. */
  27293. protected _albedoColor: Color3;
  27294. /**
  27295. * AKA Specular Color in other nomenclature.
  27296. */
  27297. protected _reflectivityColor: Color3;
  27298. /**
  27299. * The color applied when light is reflected from a material.
  27300. */
  27301. protected _reflectionColor: Color3;
  27302. /**
  27303. * The color applied when light is emitted from a material.
  27304. */
  27305. protected _emissiveColor: Color3;
  27306. /**
  27307. * AKA Glossiness in other nomenclature.
  27308. */
  27309. protected _microSurface: number;
  27310. /**
  27311. * Specifies that the material will use the light map as a show map.
  27312. */
  27313. protected _useLightmapAsShadowmap: boolean;
  27314. /**
  27315. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27316. * makes the reflect vector face the model (under horizon).
  27317. */
  27318. protected _useHorizonOcclusion: boolean;
  27319. /**
  27320. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27321. * too much the area relying on ambient texture to define their ambient occlusion.
  27322. */
  27323. protected _useRadianceOcclusion: boolean;
  27324. /**
  27325. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27326. */
  27327. protected _useAlphaFromAlbedoTexture: boolean;
  27328. /**
  27329. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27330. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27331. */
  27332. protected _useSpecularOverAlpha: boolean;
  27333. /**
  27334. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27335. */
  27336. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27337. /**
  27338. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27339. */
  27340. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27341. /**
  27342. * Specifies if the metallic texture contains the roughness information in its green channel.
  27343. */
  27344. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27345. /**
  27346. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27347. */
  27348. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27349. /**
  27350. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27351. */
  27352. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27353. /**
  27354. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27355. */
  27356. protected _useAmbientInGrayScale: boolean;
  27357. /**
  27358. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27359. * The material will try to infer what glossiness each pixel should be.
  27360. */
  27361. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27362. /**
  27363. * Defines the falloff type used in this material.
  27364. * It by default is Physical.
  27365. */
  27366. protected _lightFalloff: number;
  27367. /**
  27368. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27369. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27370. */
  27371. protected _useRadianceOverAlpha: boolean;
  27372. /**
  27373. * Allows using an object space normal map (instead of tangent space).
  27374. */
  27375. protected _useObjectSpaceNormalMap: boolean;
  27376. /**
  27377. * Allows using the bump map in parallax mode.
  27378. */
  27379. protected _useParallax: boolean;
  27380. /**
  27381. * Allows using the bump map in parallax occlusion mode.
  27382. */
  27383. protected _useParallaxOcclusion: boolean;
  27384. /**
  27385. * Controls the scale bias of the parallax mode.
  27386. */
  27387. protected _parallaxScaleBias: number;
  27388. /**
  27389. * If sets to true, disables all the lights affecting the material.
  27390. */
  27391. protected _disableLighting: boolean;
  27392. /**
  27393. * Number of Simultaneous lights allowed on the material.
  27394. */
  27395. protected _maxSimultaneousLights: number;
  27396. /**
  27397. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27398. */
  27399. protected _invertNormalMapX: boolean;
  27400. /**
  27401. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27402. */
  27403. protected _invertNormalMapY: boolean;
  27404. /**
  27405. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27406. */
  27407. protected _twoSidedLighting: boolean;
  27408. /**
  27409. * Defines the alpha limits in alpha test mode.
  27410. */
  27411. protected _alphaCutOff: number;
  27412. /**
  27413. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27414. */
  27415. protected _forceAlphaTest: boolean;
  27416. /**
  27417. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27418. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27419. */
  27420. protected _useAlphaFresnel: boolean;
  27421. /**
  27422. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27423. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27424. */
  27425. protected _useLinearAlphaFresnel: boolean;
  27426. /**
  27427. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27428. * from cos thetav and roughness:
  27429. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27430. */
  27431. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27432. /**
  27433. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27434. */
  27435. protected _forceIrradianceInFragment: boolean;
  27436. private _realTimeFiltering;
  27437. /**
  27438. * Enables realtime filtering on the texture.
  27439. */
  27440. get realTimeFiltering(): boolean;
  27441. set realTimeFiltering(b: boolean);
  27442. private _realTimeFilteringQuality;
  27443. /**
  27444. * Quality switch for realtime filtering
  27445. */
  27446. get realTimeFilteringQuality(): number;
  27447. set realTimeFilteringQuality(n: number);
  27448. /**
  27449. * Can this material render to several textures at once
  27450. */
  27451. get canRenderToMRT(): boolean;
  27452. /**
  27453. * Force normal to face away from face.
  27454. */
  27455. protected _forceNormalForward: boolean;
  27456. /**
  27457. * Enables specular anti aliasing in the PBR shader.
  27458. * It will both interacts on the Geometry for analytical and IBL lighting.
  27459. * It also prefilter the roughness map based on the bump values.
  27460. */
  27461. protected _enableSpecularAntiAliasing: boolean;
  27462. /**
  27463. * Default configuration related to image processing available in the PBR Material.
  27464. */
  27465. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27466. /**
  27467. * Keep track of the image processing observer to allow dispose and replace.
  27468. */
  27469. private _imageProcessingObserver;
  27470. /**
  27471. * Attaches a new image processing configuration to the PBR Material.
  27472. * @param configuration
  27473. */
  27474. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27475. /**
  27476. * Stores the available render targets.
  27477. */
  27478. private _renderTargets;
  27479. /**
  27480. * Sets the global ambient color for the material used in lighting calculations.
  27481. */
  27482. private _globalAmbientColor;
  27483. /**
  27484. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27485. */
  27486. private _useLogarithmicDepth;
  27487. /**
  27488. * If set to true, no lighting calculations will be applied.
  27489. */
  27490. private _unlit;
  27491. private _debugMode;
  27492. /**
  27493. * @hidden
  27494. * This is reserved for the inspector.
  27495. * Defines the material debug mode.
  27496. * It helps seeing only some components of the material while troubleshooting.
  27497. */
  27498. debugMode: number;
  27499. /**
  27500. * @hidden
  27501. * This is reserved for the inspector.
  27502. * Specify from where on screen the debug mode should start.
  27503. * The value goes from -1 (full screen) to 1 (not visible)
  27504. * It helps with side by side comparison against the final render
  27505. * This defaults to -1
  27506. */
  27507. private debugLimit;
  27508. /**
  27509. * @hidden
  27510. * This is reserved for the inspector.
  27511. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27512. * You can use the factor to better multiply the final value.
  27513. */
  27514. private debugFactor;
  27515. /**
  27516. * Defines the clear coat layer parameters for the material.
  27517. */
  27518. readonly clearCoat: PBRClearCoatConfiguration;
  27519. /**
  27520. * Defines the anisotropic parameters for the material.
  27521. */
  27522. readonly anisotropy: PBRAnisotropicConfiguration;
  27523. /**
  27524. * Defines the BRDF parameters for the material.
  27525. */
  27526. readonly brdf: PBRBRDFConfiguration;
  27527. /**
  27528. * Defines the Sheen parameters for the material.
  27529. */
  27530. readonly sheen: PBRSheenConfiguration;
  27531. /**
  27532. * Defines the SubSurface parameters for the material.
  27533. */
  27534. readonly subSurface: PBRSubSurfaceConfiguration;
  27535. /**
  27536. * Defines additionnal PrePass parameters for the material.
  27537. */
  27538. readonly prePassConfiguration: PrePassConfiguration;
  27539. /**
  27540. * Defines the detail map parameters for the material.
  27541. */
  27542. readonly detailMap: DetailMapConfiguration;
  27543. protected _rebuildInParallel: boolean;
  27544. /**
  27545. * Instantiates a new PBRMaterial instance.
  27546. *
  27547. * @param name The material name
  27548. * @param scene The scene the material will be use in.
  27549. */
  27550. constructor(name: string, scene: Scene);
  27551. /**
  27552. * Gets a boolean indicating that current material needs to register RTT
  27553. */
  27554. get hasRenderTargetTextures(): boolean;
  27555. /**
  27556. * Gets the name of the material class.
  27557. */
  27558. getClassName(): string;
  27559. /**
  27560. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27561. */
  27562. get useLogarithmicDepth(): boolean;
  27563. /**
  27564. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27565. */
  27566. set useLogarithmicDepth(value: boolean);
  27567. /**
  27568. * Returns true if alpha blending should be disabled.
  27569. */
  27570. protected get _disableAlphaBlending(): boolean;
  27571. /**
  27572. * Specifies whether or not this material should be rendered in alpha blend mode.
  27573. */
  27574. needAlphaBlending(): boolean;
  27575. /**
  27576. * Specifies whether or not this material should be rendered in alpha test mode.
  27577. */
  27578. needAlphaTesting(): boolean;
  27579. /**
  27580. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27581. */
  27582. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27583. /**
  27584. * Gets the texture used for the alpha test.
  27585. */
  27586. getAlphaTestTexture(): Nullable<BaseTexture>;
  27587. /**
  27588. * Specifies that the submesh is ready to be used.
  27589. * @param mesh - BJS mesh.
  27590. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27591. * @param useInstances - Specifies that instances should be used.
  27592. * @returns - boolean indicating that the submesh is ready or not.
  27593. */
  27594. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27595. /**
  27596. * Specifies if the material uses metallic roughness workflow.
  27597. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27598. */
  27599. isMetallicWorkflow(): boolean;
  27600. private _prepareEffect;
  27601. private _prepareDefines;
  27602. /**
  27603. * Force shader compilation
  27604. */
  27605. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27606. /**
  27607. * Initializes the uniform buffer layout for the shader.
  27608. */
  27609. buildUniformLayout(): void;
  27610. /**
  27611. * Unbinds the material from the mesh
  27612. */
  27613. unbind(): void;
  27614. /**
  27615. * Binds the submesh data.
  27616. * @param world - The world matrix.
  27617. * @param mesh - The BJS mesh.
  27618. * @param subMesh - A submesh of the BJS mesh.
  27619. */
  27620. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27621. /**
  27622. * Returns the animatable textures.
  27623. * @returns - Array of animatable textures.
  27624. */
  27625. getAnimatables(): IAnimatable[];
  27626. /**
  27627. * Returns the texture used for reflections.
  27628. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27629. */
  27630. private _getReflectionTexture;
  27631. /**
  27632. * Returns an array of the actively used textures.
  27633. * @returns - Array of BaseTextures
  27634. */
  27635. getActiveTextures(): BaseTexture[];
  27636. /**
  27637. * Checks to see if a texture is used in the material.
  27638. * @param texture - Base texture to use.
  27639. * @returns - Boolean specifying if a texture is used in the material.
  27640. */
  27641. hasTexture(texture: BaseTexture): boolean;
  27642. /**
  27643. * Sets the required values to the prepass renderer.
  27644. * @param prePassRenderer defines the prepass renderer to setup
  27645. */
  27646. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27647. /**
  27648. * Disposes the resources of the material.
  27649. * @param forceDisposeEffect - Forces the disposal of effects.
  27650. * @param forceDisposeTextures - Forces the disposal of all textures.
  27651. */
  27652. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27653. }
  27654. }
  27655. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27656. import { Nullable } from "babylonjs/types";
  27657. import { Scene } from "babylonjs/scene";
  27658. import { Color3 } from "babylonjs/Maths/math.color";
  27659. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27660. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27662. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27663. /**
  27664. * The Physically based material of BJS.
  27665. *
  27666. * This offers the main features of a standard PBR material.
  27667. * For more information, please refer to the documentation :
  27668. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27669. */
  27670. export class PBRMaterial extends PBRBaseMaterial {
  27671. /**
  27672. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27673. */
  27674. static readonly PBRMATERIAL_OPAQUE: number;
  27675. /**
  27676. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27677. */
  27678. static readonly PBRMATERIAL_ALPHATEST: number;
  27679. /**
  27680. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27681. */
  27682. static readonly PBRMATERIAL_ALPHABLEND: number;
  27683. /**
  27684. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27685. * They are also discarded below the alpha cutoff threshold to improve performances.
  27686. */
  27687. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27688. /**
  27689. * Defines the default value of how much AO map is occluding the analytical lights
  27690. * (point spot...).
  27691. */
  27692. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27693. /**
  27694. * Intensity of the direct lights e.g. the four lights available in your scene.
  27695. * This impacts both the direct diffuse and specular highlights.
  27696. */
  27697. directIntensity: number;
  27698. /**
  27699. * Intensity of the emissive part of the material.
  27700. * This helps controlling the emissive effect without modifying the emissive color.
  27701. */
  27702. emissiveIntensity: number;
  27703. /**
  27704. * Intensity of the environment e.g. how much the environment will light the object
  27705. * either through harmonics for rough material or through the refelction for shiny ones.
  27706. */
  27707. environmentIntensity: number;
  27708. /**
  27709. * This is a special control allowing the reduction of the specular highlights coming from the
  27710. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27711. */
  27712. specularIntensity: number;
  27713. /**
  27714. * Debug Control allowing disabling the bump map on this material.
  27715. */
  27716. disableBumpMap: boolean;
  27717. /**
  27718. * AKA Diffuse Texture in standard nomenclature.
  27719. */
  27720. albedoTexture: BaseTexture;
  27721. /**
  27722. * AKA Occlusion Texture in other nomenclature.
  27723. */
  27724. ambientTexture: BaseTexture;
  27725. /**
  27726. * AKA Occlusion Texture Intensity in other nomenclature.
  27727. */
  27728. ambientTextureStrength: number;
  27729. /**
  27730. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27731. * 1 means it completely occludes it
  27732. * 0 mean it has no impact
  27733. */
  27734. ambientTextureImpactOnAnalyticalLights: number;
  27735. /**
  27736. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27737. */
  27738. opacityTexture: BaseTexture;
  27739. /**
  27740. * Stores the reflection values in a texture.
  27741. */
  27742. reflectionTexture: Nullable<BaseTexture>;
  27743. /**
  27744. * Stores the emissive values in a texture.
  27745. */
  27746. emissiveTexture: BaseTexture;
  27747. /**
  27748. * AKA Specular texture in other nomenclature.
  27749. */
  27750. reflectivityTexture: BaseTexture;
  27751. /**
  27752. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27753. */
  27754. metallicTexture: BaseTexture;
  27755. /**
  27756. * Specifies the metallic scalar of the metallic/roughness workflow.
  27757. * Can also be used to scale the metalness values of the metallic texture.
  27758. */
  27759. metallic: Nullable<number>;
  27760. /**
  27761. * Specifies the roughness scalar of the metallic/roughness workflow.
  27762. * Can also be used to scale the roughness values of the metallic texture.
  27763. */
  27764. roughness: Nullable<number>;
  27765. /**
  27766. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27767. * By default the indexOfrefraction is used to compute F0;
  27768. *
  27769. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27770. *
  27771. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27772. * F90 = metallicReflectanceColor;
  27773. */
  27774. metallicF0Factor: number;
  27775. /**
  27776. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27777. * By default the F90 is always 1;
  27778. *
  27779. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27780. *
  27781. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27782. * F90 = metallicReflectanceColor;
  27783. */
  27784. metallicReflectanceColor: Color3;
  27785. /**
  27786. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27787. * This is multiply against the scalar values defined in the material.
  27788. */
  27789. metallicReflectanceTexture: Nullable<BaseTexture>;
  27790. /**
  27791. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27792. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27793. */
  27794. microSurfaceTexture: BaseTexture;
  27795. /**
  27796. * Stores surface normal data used to displace a mesh in a texture.
  27797. */
  27798. bumpTexture: BaseTexture;
  27799. /**
  27800. * Stores the pre-calculated light information of a mesh in a texture.
  27801. */
  27802. lightmapTexture: BaseTexture;
  27803. /**
  27804. * Stores the refracted light information in a texture.
  27805. */
  27806. get refractionTexture(): Nullable<BaseTexture>;
  27807. set refractionTexture(value: Nullable<BaseTexture>);
  27808. /**
  27809. * The color of a material in ambient lighting.
  27810. */
  27811. ambientColor: Color3;
  27812. /**
  27813. * AKA Diffuse Color in other nomenclature.
  27814. */
  27815. albedoColor: Color3;
  27816. /**
  27817. * AKA Specular Color in other nomenclature.
  27818. */
  27819. reflectivityColor: Color3;
  27820. /**
  27821. * The color reflected from the material.
  27822. */
  27823. reflectionColor: Color3;
  27824. /**
  27825. * The color emitted from the material.
  27826. */
  27827. emissiveColor: Color3;
  27828. /**
  27829. * AKA Glossiness in other nomenclature.
  27830. */
  27831. microSurface: number;
  27832. /**
  27833. * Index of refraction of the material base layer.
  27834. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27835. *
  27836. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27837. *
  27838. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27839. */
  27840. get indexOfRefraction(): number;
  27841. set indexOfRefraction(value: number);
  27842. /**
  27843. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27844. */
  27845. get invertRefractionY(): boolean;
  27846. set invertRefractionY(value: boolean);
  27847. /**
  27848. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27849. * Materials half opaque for instance using refraction could benefit from this control.
  27850. */
  27851. get linkRefractionWithTransparency(): boolean;
  27852. set linkRefractionWithTransparency(value: boolean);
  27853. /**
  27854. * If true, the light map contains occlusion information instead of lighting info.
  27855. */
  27856. useLightmapAsShadowmap: boolean;
  27857. /**
  27858. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27859. */
  27860. useAlphaFromAlbedoTexture: boolean;
  27861. /**
  27862. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27863. */
  27864. forceAlphaTest: boolean;
  27865. /**
  27866. * Defines the alpha limits in alpha test mode.
  27867. */
  27868. alphaCutOff: number;
  27869. /**
  27870. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27871. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27872. */
  27873. useSpecularOverAlpha: boolean;
  27874. /**
  27875. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27876. */
  27877. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27878. /**
  27879. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27880. */
  27881. useRoughnessFromMetallicTextureAlpha: boolean;
  27882. /**
  27883. * Specifies if the metallic texture contains the roughness information in its green channel.
  27884. */
  27885. useRoughnessFromMetallicTextureGreen: boolean;
  27886. /**
  27887. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27888. */
  27889. useMetallnessFromMetallicTextureBlue: boolean;
  27890. /**
  27891. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27892. */
  27893. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27894. /**
  27895. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27896. */
  27897. useAmbientInGrayScale: boolean;
  27898. /**
  27899. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27900. * The material will try to infer what glossiness each pixel should be.
  27901. */
  27902. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27903. /**
  27904. * BJS is using an harcoded light falloff based on a manually sets up range.
  27905. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27906. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27907. */
  27908. get usePhysicalLightFalloff(): boolean;
  27909. /**
  27910. * BJS is using an harcoded light falloff based on a manually sets up range.
  27911. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27912. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27913. */
  27914. set usePhysicalLightFalloff(value: boolean);
  27915. /**
  27916. * In order to support the falloff compatibility with gltf, a special mode has been added
  27917. * to reproduce the gltf light falloff.
  27918. */
  27919. get useGLTFLightFalloff(): boolean;
  27920. /**
  27921. * In order to support the falloff compatibility with gltf, a special mode has been added
  27922. * to reproduce the gltf light falloff.
  27923. */
  27924. set useGLTFLightFalloff(value: boolean);
  27925. /**
  27926. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27927. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27928. */
  27929. useRadianceOverAlpha: boolean;
  27930. /**
  27931. * Allows using an object space normal map (instead of tangent space).
  27932. */
  27933. useObjectSpaceNormalMap: boolean;
  27934. /**
  27935. * Allows using the bump map in parallax mode.
  27936. */
  27937. useParallax: boolean;
  27938. /**
  27939. * Allows using the bump map in parallax occlusion mode.
  27940. */
  27941. useParallaxOcclusion: boolean;
  27942. /**
  27943. * Controls the scale bias of the parallax mode.
  27944. */
  27945. parallaxScaleBias: number;
  27946. /**
  27947. * If sets to true, disables all the lights affecting the material.
  27948. */
  27949. disableLighting: boolean;
  27950. /**
  27951. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27952. */
  27953. forceIrradianceInFragment: boolean;
  27954. /**
  27955. * Number of Simultaneous lights allowed on the material.
  27956. */
  27957. maxSimultaneousLights: number;
  27958. /**
  27959. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27960. */
  27961. invertNormalMapX: boolean;
  27962. /**
  27963. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27964. */
  27965. invertNormalMapY: boolean;
  27966. /**
  27967. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27968. */
  27969. twoSidedLighting: boolean;
  27970. /**
  27971. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27972. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27973. */
  27974. useAlphaFresnel: boolean;
  27975. /**
  27976. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27977. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27978. */
  27979. useLinearAlphaFresnel: boolean;
  27980. /**
  27981. * Let user defines the brdf lookup texture used for IBL.
  27982. * A default 8bit version is embedded but you could point at :
  27983. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27984. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27985. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27986. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27987. */
  27988. environmentBRDFTexture: Nullable<BaseTexture>;
  27989. /**
  27990. * Force normal to face away from face.
  27991. */
  27992. forceNormalForward: boolean;
  27993. /**
  27994. * Enables specular anti aliasing in the PBR shader.
  27995. * It will both interacts on the Geometry for analytical and IBL lighting.
  27996. * It also prefilter the roughness map based on the bump values.
  27997. */
  27998. enableSpecularAntiAliasing: boolean;
  27999. /**
  28000. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28001. * makes the reflect vector face the model (under horizon).
  28002. */
  28003. useHorizonOcclusion: boolean;
  28004. /**
  28005. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28006. * too much the area relying on ambient texture to define their ambient occlusion.
  28007. */
  28008. useRadianceOcclusion: boolean;
  28009. /**
  28010. * If set to true, no lighting calculations will be applied.
  28011. */
  28012. unlit: boolean;
  28013. /**
  28014. * Gets the image processing configuration used either in this material.
  28015. */
  28016. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28017. /**
  28018. * Sets the Default image processing configuration used either in the this material.
  28019. *
  28020. * If sets to null, the scene one is in use.
  28021. */
  28022. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28023. /**
  28024. * Gets wether the color curves effect is enabled.
  28025. */
  28026. get cameraColorCurvesEnabled(): boolean;
  28027. /**
  28028. * Sets wether the color curves effect is enabled.
  28029. */
  28030. set cameraColorCurvesEnabled(value: boolean);
  28031. /**
  28032. * Gets wether the color grading effect is enabled.
  28033. */
  28034. get cameraColorGradingEnabled(): boolean;
  28035. /**
  28036. * Gets wether the color grading effect is enabled.
  28037. */
  28038. set cameraColorGradingEnabled(value: boolean);
  28039. /**
  28040. * Gets wether tonemapping is enabled or not.
  28041. */
  28042. get cameraToneMappingEnabled(): boolean;
  28043. /**
  28044. * Sets wether tonemapping is enabled or not
  28045. */
  28046. set cameraToneMappingEnabled(value: boolean);
  28047. /**
  28048. * The camera exposure used on this material.
  28049. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28050. * This corresponds to a photographic exposure.
  28051. */
  28052. get cameraExposure(): number;
  28053. /**
  28054. * The camera exposure used on this material.
  28055. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28056. * This corresponds to a photographic exposure.
  28057. */
  28058. set cameraExposure(value: number);
  28059. /**
  28060. * Gets The camera contrast used on this material.
  28061. */
  28062. get cameraContrast(): number;
  28063. /**
  28064. * Sets The camera contrast used on this material.
  28065. */
  28066. set cameraContrast(value: number);
  28067. /**
  28068. * Gets the Color Grading 2D Lookup Texture.
  28069. */
  28070. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28071. /**
  28072. * Sets the Color Grading 2D Lookup Texture.
  28073. */
  28074. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28075. /**
  28076. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28077. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28078. * 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;
  28079. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28080. */
  28081. get cameraColorCurves(): Nullable<ColorCurves>;
  28082. /**
  28083. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28084. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28085. * 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;
  28086. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28087. */
  28088. set cameraColorCurves(value: Nullable<ColorCurves>);
  28089. /**
  28090. * Instantiates a new PBRMaterial instance.
  28091. *
  28092. * @param name The material name
  28093. * @param scene The scene the material will be use in.
  28094. */
  28095. constructor(name: string, scene: Scene);
  28096. /**
  28097. * Returns the name of this material class.
  28098. */
  28099. getClassName(): string;
  28100. /**
  28101. * Makes a duplicate of the current material.
  28102. * @param name - name to use for the new material.
  28103. */
  28104. clone(name: string): PBRMaterial;
  28105. /**
  28106. * Serializes this PBR Material.
  28107. * @returns - An object with the serialized material.
  28108. */
  28109. serialize(): any;
  28110. /**
  28111. * Parses a PBR Material from a serialized object.
  28112. * @param source - Serialized object.
  28113. * @param scene - BJS scene instance.
  28114. * @param rootUrl - url for the scene object
  28115. * @returns - PBRMaterial
  28116. */
  28117. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28118. }
  28119. }
  28120. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28121. /** @hidden */
  28122. export var mrtFragmentDeclaration: {
  28123. name: string;
  28124. shader: string;
  28125. };
  28126. }
  28127. declare module "babylonjs/Shaders/geometry.fragment" {
  28128. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28129. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28130. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28131. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28132. /** @hidden */
  28133. export var geometryPixelShader: {
  28134. name: string;
  28135. shader: string;
  28136. };
  28137. }
  28138. declare module "babylonjs/Shaders/geometry.vertex" {
  28139. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28140. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28141. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28142. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28143. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28144. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28145. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28146. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28147. /** @hidden */
  28148. export var geometryVertexShader: {
  28149. name: string;
  28150. shader: string;
  28151. };
  28152. }
  28153. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28154. import { Matrix } from "babylonjs/Maths/math.vector";
  28155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28156. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28157. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28158. import { Effect } from "babylonjs/Materials/effect";
  28159. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28160. import { Scene } from "babylonjs/scene";
  28161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28162. import { Nullable } from "babylonjs/types";
  28163. import "babylonjs/Shaders/geometry.fragment";
  28164. import "babylonjs/Shaders/geometry.vertex";
  28165. /** @hidden */
  28166. interface ISavedTransformationMatrix {
  28167. world: Matrix;
  28168. viewProjection: Matrix;
  28169. }
  28170. /**
  28171. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28172. */
  28173. export class GeometryBufferRenderer {
  28174. /**
  28175. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28176. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28177. */
  28178. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28179. /**
  28180. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28181. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28182. */
  28183. static readonly POSITION_TEXTURE_TYPE: number;
  28184. /**
  28185. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28186. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28187. */
  28188. static readonly VELOCITY_TEXTURE_TYPE: number;
  28189. /**
  28190. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28191. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28192. */
  28193. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28194. /**
  28195. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28196. * in order to compute objects velocities when enableVelocity is set to "true"
  28197. * @hidden
  28198. */
  28199. _previousTransformationMatrices: {
  28200. [index: number]: ISavedTransformationMatrix;
  28201. };
  28202. /**
  28203. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28204. * in order to compute objects velocities when enableVelocity is set to "true"
  28205. * @hidden
  28206. */
  28207. _previousBonesTransformationMatrices: {
  28208. [index: number]: Float32Array;
  28209. };
  28210. /**
  28211. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28212. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28213. */
  28214. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28215. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28216. renderTransparentMeshes: boolean;
  28217. private _scene;
  28218. private _resizeObserver;
  28219. private _multiRenderTarget;
  28220. private _ratio;
  28221. private _enablePosition;
  28222. private _enableVelocity;
  28223. private _enableReflectivity;
  28224. private _positionIndex;
  28225. private _velocityIndex;
  28226. private _reflectivityIndex;
  28227. private _depthNormalIndex;
  28228. private _linkedWithPrePass;
  28229. private _prePassRenderer;
  28230. private _attachments;
  28231. protected _effect: Effect;
  28232. protected _cachedDefines: string;
  28233. /**
  28234. * @hidden
  28235. * Sets up internal structures to share outputs with PrePassRenderer
  28236. * This method should only be called by the PrePassRenderer itself
  28237. */
  28238. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28239. /**
  28240. * @hidden
  28241. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28242. * This method should only be called by the PrePassRenderer itself
  28243. */
  28244. _unlinkPrePassRenderer(): void;
  28245. /**
  28246. * @hidden
  28247. * Resets the geometry buffer layout
  28248. */
  28249. _resetLayout(): void;
  28250. /**
  28251. * @hidden
  28252. * Replaces a texture in the geometry buffer renderer
  28253. * Useful when linking textures of the prepass renderer
  28254. */
  28255. _forceTextureType(geometryBufferType: number, index: number): void;
  28256. /**
  28257. * @hidden
  28258. * Sets texture attachments
  28259. * Useful when linking textures of the prepass renderer
  28260. */
  28261. _setAttachments(attachments: number[]): void;
  28262. /**
  28263. * @hidden
  28264. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28265. * Useful when linking textures of the prepass renderer
  28266. */
  28267. _linkInternalTexture(internalTexture: InternalTexture): void;
  28268. /**
  28269. * Gets the render list (meshes to be rendered) used in the G buffer.
  28270. */
  28271. get renderList(): Nullable<AbstractMesh[]>;
  28272. /**
  28273. * Set the render list (meshes to be rendered) used in the G buffer.
  28274. */
  28275. set renderList(meshes: Nullable<AbstractMesh[]>);
  28276. /**
  28277. * Gets wether or not G buffer are supported by the running hardware.
  28278. * This requires draw buffer supports
  28279. */
  28280. get isSupported(): boolean;
  28281. /**
  28282. * Returns the index of the given texture type in the G-Buffer textures array
  28283. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28284. * @returns the index of the given texture type in the G-Buffer textures array
  28285. */
  28286. getTextureIndex(textureType: number): number;
  28287. /**
  28288. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28289. */
  28290. get enablePosition(): boolean;
  28291. /**
  28292. * Sets whether or not objects positions are enabled for the G buffer.
  28293. */
  28294. set enablePosition(enable: boolean);
  28295. /**
  28296. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28297. */
  28298. get enableVelocity(): boolean;
  28299. /**
  28300. * Sets wether or not objects velocities are enabled for the G buffer.
  28301. */
  28302. set enableVelocity(enable: boolean);
  28303. /**
  28304. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28305. */
  28306. get enableReflectivity(): boolean;
  28307. /**
  28308. * Sets wether or not objects roughness are enabled for the G buffer.
  28309. */
  28310. set enableReflectivity(enable: boolean);
  28311. /**
  28312. * Gets the scene associated with the buffer.
  28313. */
  28314. get scene(): Scene;
  28315. /**
  28316. * Gets the ratio used by the buffer during its creation.
  28317. * How big is the buffer related to the main canvas.
  28318. */
  28319. get ratio(): number;
  28320. /** @hidden */
  28321. static _SceneComponentInitialization: (scene: Scene) => void;
  28322. /**
  28323. * Creates a new G Buffer for the scene
  28324. * @param scene The scene the buffer belongs to
  28325. * @param ratio How big is the buffer related to the main canvas.
  28326. */
  28327. constructor(scene: Scene, ratio?: number);
  28328. /**
  28329. * Checks wether everything is ready to render a submesh to the G buffer.
  28330. * @param subMesh the submesh to check readiness for
  28331. * @param useInstances is the mesh drawn using instance or not
  28332. * @returns true if ready otherwise false
  28333. */
  28334. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28335. /**
  28336. * Gets the current underlying G Buffer.
  28337. * @returns the buffer
  28338. */
  28339. getGBuffer(): MultiRenderTarget;
  28340. /**
  28341. * Gets the number of samples used to render the buffer (anti aliasing).
  28342. */
  28343. get samples(): number;
  28344. /**
  28345. * Sets the number of samples used to render the buffer (anti aliasing).
  28346. */
  28347. set samples(value: number);
  28348. /**
  28349. * Disposes the renderer and frees up associated resources.
  28350. */
  28351. dispose(): void;
  28352. private _assignRenderTargetIndices;
  28353. protected _createRenderTargets(): void;
  28354. private _copyBonesTransformationMatrices;
  28355. }
  28356. }
  28357. declare module "babylonjs/Rendering/prePassRenderer" {
  28358. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28359. import { Scene } from "babylonjs/scene";
  28360. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28361. import { Effect } from "babylonjs/Materials/effect";
  28362. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28364. import { Material } from "babylonjs/Materials/material";
  28365. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28366. /**
  28367. * Renders a pre pass of the scene
  28368. * This means every mesh in the scene will be rendered to a render target texture
  28369. * And then this texture will be composited to the rendering canvas with post processes
  28370. * It is necessary for effects like subsurface scattering or deferred shading
  28371. */
  28372. export class PrePassRenderer {
  28373. /** @hidden */
  28374. static _SceneComponentInitialization: (scene: Scene) => void;
  28375. private _textureFormats;
  28376. /**
  28377. * To save performance, we can excluded skinned meshes from the prepass
  28378. */
  28379. excludedSkinnedMesh: AbstractMesh[];
  28380. /**
  28381. * Force material to be excluded from the prepass
  28382. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28383. * and you don't want a material to show in the effect.
  28384. */
  28385. excludedMaterials: Material[];
  28386. private _textureIndices;
  28387. private _scene;
  28388. private _engine;
  28389. private _isDirty;
  28390. /**
  28391. * Number of textures in the multi render target texture where the scene is directly rendered
  28392. */
  28393. mrtCount: number;
  28394. /**
  28395. * The render target where the scene is directly rendered
  28396. */
  28397. prePassRT: MultiRenderTarget;
  28398. private _multiRenderAttachments;
  28399. private _defaultAttachments;
  28400. private _clearAttachments;
  28401. private _postProcesses;
  28402. private readonly _clearColor;
  28403. /**
  28404. * Image processing post process for composition
  28405. */
  28406. imageProcessingPostProcess: ImageProcessingPostProcess;
  28407. /**
  28408. * Configuration for prepass effects
  28409. */
  28410. private _effectConfigurations;
  28411. private _mrtFormats;
  28412. private _mrtLayout;
  28413. private _enabled;
  28414. /**
  28415. * Indicates if the prepass is enabled
  28416. */
  28417. get enabled(): boolean;
  28418. /**
  28419. * How many samples are used for MSAA of the scene render target
  28420. */
  28421. get samples(): number;
  28422. set samples(n: number);
  28423. private _geometryBuffer;
  28424. private _useGeometryBufferFallback;
  28425. /**
  28426. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28427. */
  28428. get useGeometryBufferFallback(): boolean;
  28429. set useGeometryBufferFallback(value: boolean);
  28430. /**
  28431. * Instanciates a prepass renderer
  28432. * @param scene The scene
  28433. */
  28434. constructor(scene: Scene);
  28435. private _initializeAttachments;
  28436. private _createCompositionEffect;
  28437. /**
  28438. * Indicates if rendering a prepass is supported
  28439. */
  28440. get isSupported(): boolean;
  28441. /**
  28442. * Sets the proper output textures to draw in the engine.
  28443. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28444. * @param subMesh Submesh on which the effect is applied
  28445. */
  28446. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28447. /**
  28448. * @hidden
  28449. */
  28450. _beforeCameraDraw(): void;
  28451. /**
  28452. * @hidden
  28453. */
  28454. _afterCameraDraw(): void;
  28455. private _checkRTSize;
  28456. private _bindFrameBuffer;
  28457. /**
  28458. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28459. */
  28460. clear(): void;
  28461. private _setState;
  28462. private _updateGeometryBufferLayout;
  28463. /**
  28464. * Adds an effect configuration to the prepass.
  28465. * If an effect has already been added, it won't add it twice and will return the configuration
  28466. * already present.
  28467. * @param cfg the effect configuration
  28468. * @return the effect configuration now used by the prepass
  28469. */
  28470. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28471. /**
  28472. * Returns the index of a texture in the multi render target texture array.
  28473. * @param type Texture type
  28474. * @return The index
  28475. */
  28476. getIndex(type: number): number;
  28477. private _enable;
  28478. private _disable;
  28479. private _resetLayout;
  28480. private _resetPostProcessChain;
  28481. private _bindPostProcessChain;
  28482. /**
  28483. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28484. */
  28485. markAsDirty(): void;
  28486. /**
  28487. * Enables a texture on the MultiRenderTarget for prepass
  28488. */
  28489. private _enableTextures;
  28490. private _update;
  28491. private _markAllMaterialsAsPrePassDirty;
  28492. /**
  28493. * Disposes the prepass renderer.
  28494. */
  28495. dispose(): void;
  28496. }
  28497. }
  28498. declare module "babylonjs/PostProcesses/postProcess" {
  28499. import { Nullable } from "babylonjs/types";
  28500. import { SmartArray } from "babylonjs/Misc/smartArray";
  28501. import { Observable } from "babylonjs/Misc/observable";
  28502. import { Vector2 } from "babylonjs/Maths/math.vector";
  28503. import { Camera } from "babylonjs/Cameras/camera";
  28504. import { Effect } from "babylonjs/Materials/effect";
  28505. import "babylonjs/Shaders/postprocess.vertex";
  28506. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28507. import { Engine } from "babylonjs/Engines/engine";
  28508. import { Color4 } from "babylonjs/Maths/math.color";
  28509. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28510. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28511. import { Scene } from "babylonjs/scene";
  28512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28513. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28514. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28515. /**
  28516. * Size options for a post process
  28517. */
  28518. export type PostProcessOptions = {
  28519. width: number;
  28520. height: number;
  28521. };
  28522. /**
  28523. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28524. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28525. */
  28526. export class PostProcess {
  28527. /**
  28528. * Gets or sets the unique id of the post process
  28529. */
  28530. uniqueId: number;
  28531. /** Name of the PostProcess. */
  28532. name: string;
  28533. /**
  28534. * Width of the texture to apply the post process on
  28535. */
  28536. width: number;
  28537. /**
  28538. * Height of the texture to apply the post process on
  28539. */
  28540. height: number;
  28541. /**
  28542. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28543. */
  28544. nodeMaterialSource: Nullable<NodeMaterial>;
  28545. /**
  28546. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28547. * @hidden
  28548. */
  28549. _outputTexture: Nullable<InternalTexture>;
  28550. /**
  28551. * Sampling mode used by the shader
  28552. * See https://doc.babylonjs.com/classes/3.1/texture
  28553. */
  28554. renderTargetSamplingMode: number;
  28555. /**
  28556. * Clear color to use when screen clearing
  28557. */
  28558. clearColor: Color4;
  28559. /**
  28560. * If the buffer needs to be cleared before applying the post process. (default: true)
  28561. * Should be set to false if shader will overwrite all previous pixels.
  28562. */
  28563. autoClear: boolean;
  28564. /**
  28565. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28566. */
  28567. alphaMode: number;
  28568. /**
  28569. * Sets the setAlphaBlendConstants of the babylon engine
  28570. */
  28571. alphaConstants: Color4;
  28572. /**
  28573. * Animations to be used for the post processing
  28574. */
  28575. animations: import("babylonjs/Animations/animation").Animation[];
  28576. /**
  28577. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28578. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28579. */
  28580. enablePixelPerfectMode: boolean;
  28581. /**
  28582. * Force the postprocess to be applied without taking in account viewport
  28583. */
  28584. forceFullscreenViewport: boolean;
  28585. /**
  28586. * List of inspectable custom properties (used by the Inspector)
  28587. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28588. */
  28589. inspectableCustomProperties: IInspectable[];
  28590. /**
  28591. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28592. *
  28593. * | Value | Type | Description |
  28594. * | ----- | ----------------------------------- | ----------- |
  28595. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28596. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28597. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28598. *
  28599. */
  28600. scaleMode: number;
  28601. /**
  28602. * Force textures to be a power of two (default: false)
  28603. */
  28604. alwaysForcePOT: boolean;
  28605. private _samples;
  28606. /**
  28607. * Number of sample textures (default: 1)
  28608. */
  28609. get samples(): number;
  28610. set samples(n: number);
  28611. /**
  28612. * Modify the scale of the post process to be the same as the viewport (default: false)
  28613. */
  28614. adaptScaleToCurrentViewport: boolean;
  28615. private _camera;
  28616. protected _scene: Scene;
  28617. private _engine;
  28618. private _options;
  28619. private _reusable;
  28620. private _textureType;
  28621. private _textureFormat;
  28622. /**
  28623. * Smart array of input and output textures for the post process.
  28624. * @hidden
  28625. */
  28626. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28627. /**
  28628. * The index in _textures that corresponds to the output texture.
  28629. * @hidden
  28630. */
  28631. _currentRenderTextureInd: number;
  28632. private _effect;
  28633. private _samplers;
  28634. private _fragmentUrl;
  28635. private _vertexUrl;
  28636. private _parameters;
  28637. private _scaleRatio;
  28638. protected _indexParameters: any;
  28639. private _shareOutputWithPostProcess;
  28640. private _texelSize;
  28641. private _forcedOutputTexture;
  28642. /**
  28643. * Prepass configuration in case this post process needs a texture from prepass
  28644. * @hidden
  28645. */
  28646. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28647. /**
  28648. * Returns the fragment url or shader name used in the post process.
  28649. * @returns the fragment url or name in the shader store.
  28650. */
  28651. getEffectName(): string;
  28652. /**
  28653. * An event triggered when the postprocess is activated.
  28654. */
  28655. onActivateObservable: Observable<Camera>;
  28656. private _onActivateObserver;
  28657. /**
  28658. * A function that is added to the onActivateObservable
  28659. */
  28660. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28661. /**
  28662. * An event triggered when the postprocess changes its size.
  28663. */
  28664. onSizeChangedObservable: Observable<PostProcess>;
  28665. private _onSizeChangedObserver;
  28666. /**
  28667. * A function that is added to the onSizeChangedObservable
  28668. */
  28669. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28670. /**
  28671. * An event triggered when the postprocess applies its effect.
  28672. */
  28673. onApplyObservable: Observable<Effect>;
  28674. private _onApplyObserver;
  28675. /**
  28676. * A function that is added to the onApplyObservable
  28677. */
  28678. set onApply(callback: (effect: Effect) => void);
  28679. /**
  28680. * An event triggered before rendering the postprocess
  28681. */
  28682. onBeforeRenderObservable: Observable<Effect>;
  28683. private _onBeforeRenderObserver;
  28684. /**
  28685. * A function that is added to the onBeforeRenderObservable
  28686. */
  28687. set onBeforeRender(callback: (effect: Effect) => void);
  28688. /**
  28689. * An event triggered after rendering the postprocess
  28690. */
  28691. onAfterRenderObservable: Observable<Effect>;
  28692. private _onAfterRenderObserver;
  28693. /**
  28694. * A function that is added to the onAfterRenderObservable
  28695. */
  28696. set onAfterRender(callback: (efect: Effect) => void);
  28697. /**
  28698. * 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
  28699. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28700. */
  28701. get inputTexture(): InternalTexture;
  28702. set inputTexture(value: InternalTexture);
  28703. /**
  28704. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28705. * the only way to unset it is to use this function to restore its internal state
  28706. */
  28707. restoreDefaultInputTexture(): void;
  28708. /**
  28709. * Gets the camera which post process is applied to.
  28710. * @returns The camera the post process is applied to.
  28711. */
  28712. getCamera(): Camera;
  28713. /**
  28714. * Gets the texel size of the postprocess.
  28715. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28716. */
  28717. get texelSize(): Vector2;
  28718. /**
  28719. * Creates a new instance PostProcess
  28720. * @param name The name of the PostProcess.
  28721. * @param fragmentUrl The url of the fragment shader to be used.
  28722. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28723. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28724. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28725. * @param camera The camera to apply the render pass to.
  28726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28727. * @param engine The engine which the post process will be applied. (default: current engine)
  28728. * @param reusable If the post process can be reused on the same frame. (default: false)
  28729. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28730. * @param textureType Type of textures used when performing the post process. (default: 0)
  28731. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28732. * @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
  28733. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28734. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28735. */
  28736. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  28737. /**
  28738. * Gets a string identifying the name of the class
  28739. * @returns "PostProcess" string
  28740. */
  28741. getClassName(): string;
  28742. /**
  28743. * Gets the engine which this post process belongs to.
  28744. * @returns The engine the post process was enabled with.
  28745. */
  28746. getEngine(): Engine;
  28747. /**
  28748. * The effect that is created when initializing the post process.
  28749. * @returns The created effect corresponding the the postprocess.
  28750. */
  28751. getEffect(): Effect;
  28752. /**
  28753. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28754. * @param postProcess The post process to share the output with.
  28755. * @returns This post process.
  28756. */
  28757. shareOutputWith(postProcess: PostProcess): PostProcess;
  28758. /**
  28759. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28760. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28761. */
  28762. useOwnOutput(): void;
  28763. /**
  28764. * Updates the effect with the current post process compile time values and recompiles the shader.
  28765. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28766. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28767. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28768. * @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
  28769. * @param onCompiled Called when the shader has been compiled.
  28770. * @param onError Called if there is an error when compiling a shader.
  28771. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28772. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28773. */
  28774. 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;
  28775. /**
  28776. * The post process is reusable if it can be used multiple times within one frame.
  28777. * @returns If the post process is reusable
  28778. */
  28779. isReusable(): boolean;
  28780. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28781. markTextureDirty(): void;
  28782. /**
  28783. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28784. * 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.
  28785. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28786. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28787. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28788. * @returns The target texture that was bound to be written to.
  28789. */
  28790. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28791. /**
  28792. * If the post process is supported.
  28793. */
  28794. get isSupported(): boolean;
  28795. /**
  28796. * The aspect ratio of the output texture.
  28797. */
  28798. get aspectRatio(): number;
  28799. /**
  28800. * Get a value indicating if the post-process is ready to be used
  28801. * @returns true if the post-process is ready (shader is compiled)
  28802. */
  28803. isReady(): boolean;
  28804. /**
  28805. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28806. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28807. */
  28808. apply(): Nullable<Effect>;
  28809. private _disposeTextures;
  28810. /**
  28811. * Sets the required values to the prepass renderer.
  28812. * @param prePassRenderer defines the prepass renderer to setup.
  28813. * @returns true if the pre pass is needed.
  28814. */
  28815. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28816. /**
  28817. * Disposes the post process.
  28818. * @param camera The camera to dispose the post process on.
  28819. */
  28820. dispose(camera?: Camera): void;
  28821. /**
  28822. * Serializes the particle system to a JSON object
  28823. * @returns the JSON object
  28824. */
  28825. serialize(): any;
  28826. /**
  28827. * Creates a material from parsed material data
  28828. * @param parsedPostProcess defines parsed post process data
  28829. * @param scene defines the hosting scene
  28830. * @param rootUrl defines the root URL to use to load textures
  28831. * @returns a new post process
  28832. */
  28833. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28834. }
  28835. }
  28836. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28837. /** @hidden */
  28838. export var kernelBlurVaryingDeclaration: {
  28839. name: string;
  28840. shader: string;
  28841. };
  28842. }
  28843. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28844. /** @hidden */
  28845. export var kernelBlurFragment: {
  28846. name: string;
  28847. shader: string;
  28848. };
  28849. }
  28850. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28851. /** @hidden */
  28852. export var kernelBlurFragment2: {
  28853. name: string;
  28854. shader: string;
  28855. };
  28856. }
  28857. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28858. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28859. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28860. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28861. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28862. /** @hidden */
  28863. export var kernelBlurPixelShader: {
  28864. name: string;
  28865. shader: string;
  28866. };
  28867. }
  28868. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28869. /** @hidden */
  28870. export var kernelBlurVertex: {
  28871. name: string;
  28872. shader: string;
  28873. };
  28874. }
  28875. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28876. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28877. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28878. /** @hidden */
  28879. export var kernelBlurVertexShader: {
  28880. name: string;
  28881. shader: string;
  28882. };
  28883. }
  28884. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28885. import { Vector2 } from "babylonjs/Maths/math.vector";
  28886. import { Nullable } from "babylonjs/types";
  28887. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28888. import { Camera } from "babylonjs/Cameras/camera";
  28889. import { Effect } from "babylonjs/Materials/effect";
  28890. import { Engine } from "babylonjs/Engines/engine";
  28891. import "babylonjs/Shaders/kernelBlur.fragment";
  28892. import "babylonjs/Shaders/kernelBlur.vertex";
  28893. import { Scene } from "babylonjs/scene";
  28894. /**
  28895. * The Blur Post Process which blurs an image based on a kernel and direction.
  28896. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28897. */
  28898. export class BlurPostProcess extends PostProcess {
  28899. private blockCompilation;
  28900. protected _kernel: number;
  28901. protected _idealKernel: number;
  28902. protected _packedFloat: boolean;
  28903. private _staticDefines;
  28904. /** The direction in which to blur the image. */
  28905. direction: Vector2;
  28906. /**
  28907. * Sets the length in pixels of the blur sample region
  28908. */
  28909. set kernel(v: number);
  28910. /**
  28911. * Gets the length in pixels of the blur sample region
  28912. */
  28913. get kernel(): number;
  28914. /**
  28915. * Sets wether or not the blur needs to unpack/repack floats
  28916. */
  28917. set packedFloat(v: boolean);
  28918. /**
  28919. * Gets wether or not the blur is unpacking/repacking floats
  28920. */
  28921. get packedFloat(): boolean;
  28922. /**
  28923. * Gets a string identifying the name of the class
  28924. * @returns "BlurPostProcess" string
  28925. */
  28926. getClassName(): string;
  28927. /**
  28928. * Creates a new instance BlurPostProcess
  28929. * @param name The name of the effect.
  28930. * @param direction The direction in which to blur the image.
  28931. * @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.
  28932. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28933. * @param camera The camera to apply the render pass to.
  28934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28935. * @param engine The engine which the post process will be applied. (default: current engine)
  28936. * @param reusable If the post process can be reused on the same frame. (default: false)
  28937. * @param textureType Type of textures used when performing the post process. (default: 0)
  28938. * @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)
  28939. */
  28940. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  28941. /**
  28942. * Updates the effect with the current post process compile time values and recompiles the shader.
  28943. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28944. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28945. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28946. * @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
  28947. * @param onCompiled Called when the shader has been compiled.
  28948. * @param onError Called if there is an error when compiling a shader.
  28949. */
  28950. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28951. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28952. /**
  28953. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28954. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28955. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28956. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28957. * The gaps between physical kernels are compensated for in the weighting of the samples
  28958. * @param idealKernel Ideal blur kernel.
  28959. * @return Nearest best kernel.
  28960. */
  28961. protected _nearestBestKernel(idealKernel: number): number;
  28962. /**
  28963. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28964. * @param x The point on the Gaussian distribution to sample.
  28965. * @return the value of the Gaussian function at x.
  28966. */
  28967. protected _gaussianWeight(x: number): number;
  28968. /**
  28969. * Generates a string that can be used as a floating point number in GLSL.
  28970. * @param x Value to print.
  28971. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28972. * @return GLSL float string.
  28973. */
  28974. protected _glslFloat(x: number, decimalFigures?: number): string;
  28975. /** @hidden */
  28976. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28977. }
  28978. }
  28979. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  28980. import { Scene } from "babylonjs/scene";
  28981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28982. import { Plane } from "babylonjs/Maths/math.plane";
  28983. /**
  28984. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28985. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28986. * You can then easily use it as a reflectionTexture on a flat surface.
  28987. * In case the surface is not a plane, please consider relying on reflection probes.
  28988. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28989. */
  28990. export class MirrorTexture extends RenderTargetTexture {
  28991. private scene;
  28992. /**
  28993. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28994. * 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.
  28995. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28996. */
  28997. mirrorPlane: Plane;
  28998. /**
  28999. * Define the blur ratio used to blur the reflection if needed.
  29000. */
  29001. set blurRatio(value: number);
  29002. get blurRatio(): number;
  29003. /**
  29004. * Define the adaptive blur kernel used to blur the reflection if needed.
  29005. * This will autocompute the closest best match for the `blurKernel`
  29006. */
  29007. set adaptiveBlurKernel(value: number);
  29008. /**
  29009. * Define the blur kernel used to blur the reflection if needed.
  29010. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29011. */
  29012. set blurKernel(value: number);
  29013. /**
  29014. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29015. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29016. */
  29017. set blurKernelX(value: number);
  29018. get blurKernelX(): number;
  29019. /**
  29020. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29021. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29022. */
  29023. set blurKernelY(value: number);
  29024. get blurKernelY(): number;
  29025. private _autoComputeBlurKernel;
  29026. protected _onRatioRescale(): void;
  29027. private _updateGammaSpace;
  29028. private _imageProcessingConfigChangeObserver;
  29029. private _transformMatrix;
  29030. private _mirrorMatrix;
  29031. private _savedViewMatrix;
  29032. private _blurX;
  29033. private _blurY;
  29034. private _adaptiveBlurKernel;
  29035. private _blurKernelX;
  29036. private _blurKernelY;
  29037. private _blurRatio;
  29038. /**
  29039. * Instantiates a Mirror Texture.
  29040. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29041. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29042. * You can then easily use it as a reflectionTexture on a flat surface.
  29043. * In case the surface is not a plane, please consider relying on reflection probes.
  29044. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29045. * @param name
  29046. * @param size
  29047. * @param scene
  29048. * @param generateMipMaps
  29049. * @param type
  29050. * @param samplingMode
  29051. * @param generateDepthBuffer
  29052. */
  29053. constructor(name: string, size: number | {
  29054. width: number;
  29055. height: number;
  29056. } | {
  29057. ratio: number;
  29058. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29059. private _preparePostProcesses;
  29060. /**
  29061. * Clone the mirror texture.
  29062. * @returns the cloned texture
  29063. */
  29064. clone(): MirrorTexture;
  29065. /**
  29066. * Serialize the texture to a JSON representation you could use in Parse later on
  29067. * @returns the serialized JSON representation
  29068. */
  29069. serialize(): any;
  29070. /**
  29071. * Dispose the texture and release its associated resources.
  29072. */
  29073. dispose(): void;
  29074. }
  29075. }
  29076. declare module "babylonjs/Materials/Textures/texture" {
  29077. import { Observable } from "babylonjs/Misc/observable";
  29078. import { Nullable } from "babylonjs/types";
  29079. import { Matrix } from "babylonjs/Maths/math.vector";
  29080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29081. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29082. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29083. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29084. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29085. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29086. import { Scene } from "babylonjs/scene";
  29087. /**
  29088. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29089. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29090. */
  29091. export class Texture extends BaseTexture {
  29092. /**
  29093. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29094. */
  29095. static SerializeBuffers: boolean;
  29096. /** @hidden */
  29097. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29098. /** @hidden */
  29099. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29100. /** @hidden */
  29101. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29102. /** nearest is mag = nearest and min = nearest and mip = linear */
  29103. static readonly NEAREST_SAMPLINGMODE: number;
  29104. /** nearest is mag = nearest and min = nearest and mip = linear */
  29105. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29106. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29107. static readonly BILINEAR_SAMPLINGMODE: number;
  29108. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29109. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29110. /** Trilinear is mag = linear and min = linear and mip = linear */
  29111. static readonly TRILINEAR_SAMPLINGMODE: number;
  29112. /** Trilinear is mag = linear and min = linear and mip = linear */
  29113. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29114. /** mag = nearest and min = nearest and mip = nearest */
  29115. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29116. /** mag = nearest and min = linear and mip = nearest */
  29117. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29118. /** mag = nearest and min = linear and mip = linear */
  29119. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29120. /** mag = nearest and min = linear and mip = none */
  29121. static readonly NEAREST_LINEAR: number;
  29122. /** mag = nearest and min = nearest and mip = none */
  29123. static readonly NEAREST_NEAREST: number;
  29124. /** mag = linear and min = nearest and mip = nearest */
  29125. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29126. /** mag = linear and min = nearest and mip = linear */
  29127. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29128. /** mag = linear and min = linear and mip = none */
  29129. static readonly LINEAR_LINEAR: number;
  29130. /** mag = linear and min = nearest and mip = none */
  29131. static readonly LINEAR_NEAREST: number;
  29132. /** Explicit coordinates mode */
  29133. static readonly EXPLICIT_MODE: number;
  29134. /** Spherical coordinates mode */
  29135. static readonly SPHERICAL_MODE: number;
  29136. /** Planar coordinates mode */
  29137. static readonly PLANAR_MODE: number;
  29138. /** Cubic coordinates mode */
  29139. static readonly CUBIC_MODE: number;
  29140. /** Projection coordinates mode */
  29141. static readonly PROJECTION_MODE: number;
  29142. /** Inverse Cubic coordinates mode */
  29143. static readonly SKYBOX_MODE: number;
  29144. /** Inverse Cubic coordinates mode */
  29145. static readonly INVCUBIC_MODE: number;
  29146. /** Equirectangular coordinates mode */
  29147. static readonly EQUIRECTANGULAR_MODE: number;
  29148. /** Equirectangular Fixed coordinates mode */
  29149. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29150. /** Equirectangular Fixed Mirrored coordinates mode */
  29151. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29152. /** Texture is not repeating outside of 0..1 UVs */
  29153. static readonly CLAMP_ADDRESSMODE: number;
  29154. /** Texture is repeating outside of 0..1 UVs */
  29155. static readonly WRAP_ADDRESSMODE: number;
  29156. /** Texture is repeating and mirrored */
  29157. static readonly MIRROR_ADDRESSMODE: number;
  29158. /**
  29159. * 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
  29160. */
  29161. static UseSerializedUrlIfAny: boolean;
  29162. /**
  29163. * Define the url of the texture.
  29164. */
  29165. url: Nullable<string>;
  29166. /**
  29167. * Define an offset on the texture to offset the u coordinates of the UVs
  29168. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29169. */
  29170. uOffset: number;
  29171. /**
  29172. * Define an offset on the texture to offset the v coordinates of the UVs
  29173. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29174. */
  29175. vOffset: number;
  29176. /**
  29177. * Define an offset on the texture to scale the u coordinates of the UVs
  29178. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29179. */
  29180. uScale: number;
  29181. /**
  29182. * Define an offset on the texture to scale the v coordinates of the UVs
  29183. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29184. */
  29185. vScale: number;
  29186. /**
  29187. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29188. * @see https://doc.babylonjs.com/how_to/more_materials
  29189. */
  29190. uAng: number;
  29191. /**
  29192. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29193. * @see https://doc.babylonjs.com/how_to/more_materials
  29194. */
  29195. vAng: number;
  29196. /**
  29197. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29198. * @see https://doc.babylonjs.com/how_to/more_materials
  29199. */
  29200. wAng: number;
  29201. /**
  29202. * Defines the center of rotation (U)
  29203. */
  29204. uRotationCenter: number;
  29205. /**
  29206. * Defines the center of rotation (V)
  29207. */
  29208. vRotationCenter: number;
  29209. /**
  29210. * Defines the center of rotation (W)
  29211. */
  29212. wRotationCenter: number;
  29213. /**
  29214. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29215. */
  29216. homogeneousRotationInUVTransform: boolean;
  29217. /**
  29218. * Are mip maps generated for this texture or not.
  29219. */
  29220. get noMipmap(): boolean;
  29221. /**
  29222. * List of inspectable custom properties (used by the Inspector)
  29223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29224. */
  29225. inspectableCustomProperties: Nullable<IInspectable[]>;
  29226. private _noMipmap;
  29227. /** @hidden */
  29228. _invertY: boolean;
  29229. private _rowGenerationMatrix;
  29230. private _cachedTextureMatrix;
  29231. private _projectionModeMatrix;
  29232. private _t0;
  29233. private _t1;
  29234. private _t2;
  29235. private _cachedUOffset;
  29236. private _cachedVOffset;
  29237. private _cachedUScale;
  29238. private _cachedVScale;
  29239. private _cachedUAng;
  29240. private _cachedVAng;
  29241. private _cachedWAng;
  29242. private _cachedProjectionMatrixId;
  29243. private _cachedURotationCenter;
  29244. private _cachedVRotationCenter;
  29245. private _cachedWRotationCenter;
  29246. private _cachedHomogeneousRotationInUVTransform;
  29247. private _cachedCoordinatesMode;
  29248. /** @hidden */
  29249. protected _initialSamplingMode: number;
  29250. /** @hidden */
  29251. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29252. private _deleteBuffer;
  29253. protected _format: Nullable<number>;
  29254. private _delayedOnLoad;
  29255. private _delayedOnError;
  29256. private _mimeType?;
  29257. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29258. get mimeType(): string | undefined;
  29259. /**
  29260. * Observable triggered once the texture has been loaded.
  29261. */
  29262. onLoadObservable: Observable<Texture>;
  29263. protected _isBlocking: boolean;
  29264. /**
  29265. * Is the texture preventing material to render while loading.
  29266. * If false, a default texture will be used instead of the loading one during the preparation step.
  29267. */
  29268. set isBlocking(value: boolean);
  29269. get isBlocking(): boolean;
  29270. /**
  29271. * Get the current sampling mode associated with the texture.
  29272. */
  29273. get samplingMode(): number;
  29274. /**
  29275. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29276. */
  29277. get invertY(): boolean;
  29278. /**
  29279. * Instantiates a new texture.
  29280. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29281. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29282. * @param url defines the url of the picture to load as a texture
  29283. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29284. * @param noMipmap defines if the texture will require mip maps or not
  29285. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29286. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29287. * @param onLoad defines a callback triggered when the texture has been loaded
  29288. * @param onError defines a callback triggered when an error occurred during the loading session
  29289. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29290. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29291. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29292. * @param mimeType defines an optional mime type information
  29293. */
  29294. 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);
  29295. /**
  29296. * Update the url (and optional buffer) of this texture if url was null during construction.
  29297. * @param url the url of the texture
  29298. * @param buffer the buffer of the texture (defaults to null)
  29299. * @param onLoad callback called when the texture is loaded (defaults to null)
  29300. */
  29301. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29302. /**
  29303. * Finish the loading sequence of a texture flagged as delayed load.
  29304. * @hidden
  29305. */
  29306. delayLoad(): void;
  29307. private _prepareRowForTextureGeneration;
  29308. /**
  29309. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29310. * @returns the transform matrix of the texture.
  29311. */
  29312. getTextureMatrix(uBase?: number): Matrix;
  29313. /**
  29314. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29315. * @returns The reflection texture transform
  29316. */
  29317. getReflectionTextureMatrix(): Matrix;
  29318. /**
  29319. * Clones the texture.
  29320. * @returns the cloned texture
  29321. */
  29322. clone(): Texture;
  29323. /**
  29324. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29325. * @returns The JSON representation of the texture
  29326. */
  29327. serialize(): any;
  29328. /**
  29329. * Get the current class name of the texture useful for serialization or dynamic coding.
  29330. * @returns "Texture"
  29331. */
  29332. getClassName(): string;
  29333. /**
  29334. * Dispose the texture and release its associated resources.
  29335. */
  29336. dispose(): void;
  29337. /**
  29338. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29339. * @param parsedTexture Define the JSON representation of the texture
  29340. * @param scene Define the scene the parsed texture should be instantiated in
  29341. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29342. * @returns The parsed texture if successful
  29343. */
  29344. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29345. /**
  29346. * Creates a texture from its base 64 representation.
  29347. * @param data Define the base64 payload without the data: prefix
  29348. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29349. * @param scene Define the scene the texture should belong to
  29350. * @param noMipmap Forces the texture to not create mip map information if true
  29351. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29352. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29353. * @param onLoad define a callback triggered when the texture has been loaded
  29354. * @param onError define a callback triggered when an error occurred during the loading session
  29355. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29356. * @returns the created texture
  29357. */
  29358. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29359. /**
  29360. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29361. * @param data Define the base64 payload without the data: prefix
  29362. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29363. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29364. * @param scene Define the scene the texture should belong to
  29365. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29366. * @param noMipmap Forces the texture to not create mip map information if true
  29367. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29368. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29369. * @param onLoad define a callback triggered when the texture has been loaded
  29370. * @param onError define a callback triggered when an error occurred during the loading session
  29371. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29372. * @returns the created texture
  29373. */
  29374. 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;
  29375. }
  29376. }
  29377. declare module "babylonjs/PostProcesses/postProcessManager" {
  29378. import { Nullable } from "babylonjs/types";
  29379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29381. import { Scene } from "babylonjs/scene";
  29382. /**
  29383. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29384. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29385. */
  29386. export class PostProcessManager {
  29387. private _scene;
  29388. private _indexBuffer;
  29389. private _vertexBuffers;
  29390. /**
  29391. * Creates a new instance PostProcess
  29392. * @param scene The scene that the post process is associated with.
  29393. */
  29394. constructor(scene: Scene);
  29395. private _prepareBuffers;
  29396. private _buildIndexBuffer;
  29397. /**
  29398. * Rebuilds the vertex buffers of the manager.
  29399. * @hidden
  29400. */
  29401. _rebuild(): void;
  29402. /**
  29403. * Prepares a frame to be run through a post process.
  29404. * @param sourceTexture The input texture to the post procesess. (default: null)
  29405. * @param postProcesses An array of post processes to be run. (default: null)
  29406. * @returns True if the post processes were able to be run.
  29407. * @hidden
  29408. */
  29409. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29410. /**
  29411. * Manually render a set of post processes to a texture.
  29412. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29413. * @param postProcesses An array of post processes to be run.
  29414. * @param targetTexture The target texture to render to.
  29415. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29416. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29417. * @param lodLevel defines which lod of the texture to render to
  29418. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29419. */
  29420. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29421. /**
  29422. * Finalize the result of the output of the postprocesses.
  29423. * @param doNotPresent If true the result will not be displayed to the screen.
  29424. * @param targetTexture The target texture to render to.
  29425. * @param faceIndex The index of the face to bind the target texture to.
  29426. * @param postProcesses The array of post processes to render.
  29427. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29428. * @hidden
  29429. */
  29430. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29431. /**
  29432. * Disposes of the post process manager.
  29433. */
  29434. dispose(): void;
  29435. }
  29436. }
  29437. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29438. import { Observable } from "babylonjs/Misc/observable";
  29439. import { SmartArray } from "babylonjs/Misc/smartArray";
  29440. import { Nullable, Immutable } from "babylonjs/types";
  29441. import { Camera } from "babylonjs/Cameras/camera";
  29442. import { Scene } from "babylonjs/scene";
  29443. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29444. import { Color4 } from "babylonjs/Maths/math.color";
  29445. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29448. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29449. import { Texture } from "babylonjs/Materials/Textures/texture";
  29450. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29451. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29452. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29453. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29454. import { Engine } from "babylonjs/Engines/engine";
  29455. /**
  29456. * This Helps creating a texture that will be created from a camera in your scene.
  29457. * It is basically a dynamic texture that could be used to create special effects for instance.
  29458. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29459. */
  29460. export class RenderTargetTexture extends Texture {
  29461. /**
  29462. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29463. */
  29464. static readonly REFRESHRATE_RENDER_ONCE: number;
  29465. /**
  29466. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29467. */
  29468. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29469. /**
  29470. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29471. * the central point of your effect and can save a lot of performances.
  29472. */
  29473. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29474. /**
  29475. * Use this predicate to dynamically define the list of mesh you want to render.
  29476. * If set, the renderList property will be overwritten.
  29477. */
  29478. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29479. private _renderList;
  29480. /**
  29481. * Use this list to define the list of mesh you want to render.
  29482. */
  29483. get renderList(): Nullable<Array<AbstractMesh>>;
  29484. set renderList(value: Nullable<Array<AbstractMesh>>);
  29485. /**
  29486. * Use this function to overload the renderList array at rendering time.
  29487. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29488. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29489. * the cube (if the RTT is a cube, else layerOrFace=0).
  29490. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29491. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29492. * hold dummy elements!
  29493. */
  29494. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29495. private _hookArray;
  29496. /**
  29497. * Define if particles should be rendered in your texture.
  29498. */
  29499. renderParticles: boolean;
  29500. /**
  29501. * Define if sprites should be rendered in your texture.
  29502. */
  29503. renderSprites: boolean;
  29504. /**
  29505. * Define the camera used to render the texture.
  29506. */
  29507. activeCamera: Nullable<Camera>;
  29508. /**
  29509. * Override the mesh isReady function with your own one.
  29510. */
  29511. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29512. /**
  29513. * Override the render function of the texture with your own one.
  29514. */
  29515. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29516. /**
  29517. * Define if camera post processes should be use while rendering the texture.
  29518. */
  29519. useCameraPostProcesses: boolean;
  29520. /**
  29521. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29522. */
  29523. ignoreCameraViewport: boolean;
  29524. private _postProcessManager;
  29525. private _postProcesses;
  29526. private _resizeObserver;
  29527. /**
  29528. * An event triggered when the texture is unbind.
  29529. */
  29530. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29531. /**
  29532. * An event triggered when the texture is unbind.
  29533. */
  29534. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29535. private _onAfterUnbindObserver;
  29536. /**
  29537. * Set a after unbind callback in the texture.
  29538. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29539. */
  29540. set onAfterUnbind(callback: () => void);
  29541. /**
  29542. * An event triggered before rendering the texture
  29543. */
  29544. onBeforeRenderObservable: Observable<number>;
  29545. private _onBeforeRenderObserver;
  29546. /**
  29547. * Set a before render callback in the texture.
  29548. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29549. */
  29550. set onBeforeRender(callback: (faceIndex: number) => void);
  29551. /**
  29552. * An event triggered after rendering the texture
  29553. */
  29554. onAfterRenderObservable: Observable<number>;
  29555. private _onAfterRenderObserver;
  29556. /**
  29557. * Set a after render callback in the texture.
  29558. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29559. */
  29560. set onAfterRender(callback: (faceIndex: number) => void);
  29561. /**
  29562. * An event triggered after the texture clear
  29563. */
  29564. onClearObservable: Observable<Engine>;
  29565. private _onClearObserver;
  29566. /**
  29567. * Set a clear callback in the texture.
  29568. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29569. */
  29570. set onClear(callback: (Engine: Engine) => void);
  29571. /**
  29572. * An event triggered when the texture is resized.
  29573. */
  29574. onResizeObservable: Observable<RenderTargetTexture>;
  29575. /**
  29576. * Define the clear color of the Render Target if it should be different from the scene.
  29577. */
  29578. clearColor: Color4;
  29579. protected _size: number | {
  29580. width: number;
  29581. height: number;
  29582. layers?: number;
  29583. };
  29584. protected _initialSizeParameter: number | {
  29585. width: number;
  29586. height: number;
  29587. } | {
  29588. ratio: number;
  29589. };
  29590. protected _sizeRatio: Nullable<number>;
  29591. /** @hidden */
  29592. _generateMipMaps: boolean;
  29593. protected _renderingManager: RenderingManager;
  29594. /** @hidden */
  29595. _waitingRenderList?: string[];
  29596. protected _doNotChangeAspectRatio: boolean;
  29597. protected _currentRefreshId: number;
  29598. protected _refreshRate: number;
  29599. protected _textureMatrix: Matrix;
  29600. protected _samples: number;
  29601. protected _renderTargetOptions: RenderTargetCreationOptions;
  29602. /**
  29603. * Gets render target creation options that were used.
  29604. */
  29605. get renderTargetOptions(): RenderTargetCreationOptions;
  29606. protected _onRatioRescale(): void;
  29607. /**
  29608. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29609. * It must define where the camera used to render the texture is set
  29610. */
  29611. boundingBoxPosition: Vector3;
  29612. private _boundingBoxSize;
  29613. /**
  29614. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29615. * When defined, the cubemap will switch to local mode
  29616. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29617. * @example https://www.babylonjs-playground.com/#RNASML
  29618. */
  29619. set boundingBoxSize(value: Vector3);
  29620. get boundingBoxSize(): Vector3;
  29621. /**
  29622. * In case the RTT has been created with a depth texture, get the associated
  29623. * depth texture.
  29624. * Otherwise, return null.
  29625. */
  29626. get depthStencilTexture(): Nullable<InternalTexture>;
  29627. /**
  29628. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29629. * or used a shadow, depth texture...
  29630. * @param name The friendly name of the texture
  29631. * @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)
  29632. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29633. * @param generateMipMaps True if mip maps need to be generated after render.
  29634. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29635. * @param type The type of the buffer in the RTT (int, half float, float...)
  29636. * @param isCube True if a cube texture needs to be created
  29637. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29638. * @param generateDepthBuffer True to generate a depth buffer
  29639. * @param generateStencilBuffer True to generate a stencil buffer
  29640. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29641. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29642. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29643. */
  29644. constructor(name: string, size: number | {
  29645. width: number;
  29646. height: number;
  29647. layers?: number;
  29648. } | {
  29649. ratio: number;
  29650. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29651. /**
  29652. * Creates a depth stencil texture.
  29653. * This is only available in WebGL 2 or with the depth texture extension available.
  29654. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29655. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29656. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29657. */
  29658. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29659. private _processSizeParameter;
  29660. /**
  29661. * Define the number of samples to use in case of MSAA.
  29662. * It defaults to one meaning no MSAA has been enabled.
  29663. */
  29664. get samples(): number;
  29665. set samples(value: number);
  29666. /**
  29667. * Resets the refresh counter of the texture and start bak from scratch.
  29668. * Could be useful to regenerate the texture if it is setup to render only once.
  29669. */
  29670. resetRefreshCounter(): void;
  29671. /**
  29672. * Define the refresh rate of the texture or the rendering frequency.
  29673. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29674. */
  29675. get refreshRate(): number;
  29676. set refreshRate(value: number);
  29677. /**
  29678. * Adds a post process to the render target rendering passes.
  29679. * @param postProcess define the post process to add
  29680. */
  29681. addPostProcess(postProcess: PostProcess): void;
  29682. /**
  29683. * Clear all the post processes attached to the render target
  29684. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29685. */
  29686. clearPostProcesses(dispose?: boolean): void;
  29687. /**
  29688. * Remove one of the post process from the list of attached post processes to the texture
  29689. * @param postProcess define the post process to remove from the list
  29690. */
  29691. removePostProcess(postProcess: PostProcess): void;
  29692. /** @hidden */
  29693. _shouldRender(): boolean;
  29694. /**
  29695. * Gets the actual render size of the texture.
  29696. * @returns the width of the render size
  29697. */
  29698. getRenderSize(): number;
  29699. /**
  29700. * Gets the actual render width of the texture.
  29701. * @returns the width of the render size
  29702. */
  29703. getRenderWidth(): number;
  29704. /**
  29705. * Gets the actual render height of the texture.
  29706. * @returns the height of the render size
  29707. */
  29708. getRenderHeight(): number;
  29709. /**
  29710. * Gets the actual number of layers of the texture.
  29711. * @returns the number of layers
  29712. */
  29713. getRenderLayers(): number;
  29714. /**
  29715. * Get if the texture can be rescaled or not.
  29716. */
  29717. get canRescale(): boolean;
  29718. /**
  29719. * Resize the texture using a ratio.
  29720. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29721. */
  29722. scale(ratio: number): void;
  29723. /**
  29724. * Get the texture reflection matrix used to rotate/transform the reflection.
  29725. * @returns the reflection matrix
  29726. */
  29727. getReflectionTextureMatrix(): Matrix;
  29728. /**
  29729. * Resize the texture to a new desired size.
  29730. * Be carrefull as it will recreate all the data in the new texture.
  29731. * @param size Define the new size. It can be:
  29732. * - a number for squared texture,
  29733. * - an object containing { width: number, height: number }
  29734. * - or an object containing a ratio { ratio: number }
  29735. */
  29736. resize(size: number | {
  29737. width: number;
  29738. height: number;
  29739. } | {
  29740. ratio: number;
  29741. }): void;
  29742. private _defaultRenderListPrepared;
  29743. /**
  29744. * Renders all the objects from the render list into the texture.
  29745. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29746. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29747. */
  29748. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29749. private _bestReflectionRenderTargetDimension;
  29750. private _prepareRenderingManager;
  29751. /**
  29752. * @hidden
  29753. * @param faceIndex face index to bind to if this is a cubetexture
  29754. * @param layer defines the index of the texture to bind in the array
  29755. */
  29756. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29757. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29758. private renderToTarget;
  29759. /**
  29760. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29761. * This allowed control for front to back rendering or reversly depending of the special needs.
  29762. *
  29763. * @param renderingGroupId The rendering group id corresponding to its index
  29764. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29765. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29766. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29767. */
  29768. 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;
  29769. /**
  29770. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29771. *
  29772. * @param renderingGroupId The rendering group id corresponding to its index
  29773. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29774. */
  29775. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29776. /**
  29777. * Clones the texture.
  29778. * @returns the cloned texture
  29779. */
  29780. clone(): RenderTargetTexture;
  29781. /**
  29782. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29783. * @returns The JSON representation of the texture
  29784. */
  29785. serialize(): any;
  29786. /**
  29787. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29788. */
  29789. disposeFramebufferObjects(): void;
  29790. /**
  29791. * Dispose the texture and release its associated resources.
  29792. */
  29793. dispose(): void;
  29794. /** @hidden */
  29795. _rebuild(): void;
  29796. /**
  29797. * Clear the info related to rendering groups preventing retention point in material dispose.
  29798. */
  29799. freeRenderingGroups(): void;
  29800. /**
  29801. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29802. * @returns the view count
  29803. */
  29804. getViewCount(): number;
  29805. }
  29806. }
  29807. declare module "babylonjs/Misc/guid" {
  29808. /**
  29809. * Class used to manipulate GUIDs
  29810. */
  29811. export class GUID {
  29812. /**
  29813. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29814. * Be aware Math.random() could cause collisions, but:
  29815. * "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"
  29816. * @returns a pseudo random id
  29817. */
  29818. static RandomId(): string;
  29819. }
  29820. }
  29821. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29822. import { Nullable } from "babylonjs/types";
  29823. import { Scene } from "babylonjs/scene";
  29824. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29825. import { Material } from "babylonjs/Materials/material";
  29826. import { Effect } from "babylonjs/Materials/effect";
  29827. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29828. /**
  29829. * Options to be used when creating a shadow depth material
  29830. */
  29831. export interface IIOptionShadowDepthMaterial {
  29832. /** Variables in the vertex shader code that need to have their names remapped.
  29833. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29834. * "var_name" should be either: worldPos or vNormalW
  29835. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29836. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29837. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29838. */
  29839. remappedVariables?: string[];
  29840. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29841. standalone?: boolean;
  29842. }
  29843. /**
  29844. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29845. */
  29846. export class ShadowDepthWrapper {
  29847. private _scene;
  29848. private _options?;
  29849. private _baseMaterial;
  29850. private _onEffectCreatedObserver;
  29851. private _subMeshToEffect;
  29852. private _subMeshToDepthEffect;
  29853. private _meshes;
  29854. /** @hidden */
  29855. _matriceNames: any;
  29856. /** Gets the standalone status of the wrapper */
  29857. get standalone(): boolean;
  29858. /** Gets the base material the wrapper is built upon */
  29859. get baseMaterial(): Material;
  29860. /**
  29861. * Instantiate a new shadow depth wrapper.
  29862. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29863. * generate the shadow depth map. For more information, please refer to the documentation:
  29864. * https://doc.babylonjs.com/babylon101/shadows
  29865. * @param baseMaterial Material to wrap
  29866. * @param scene Define the scene the material belongs to
  29867. * @param options Options used to create the wrapper
  29868. */
  29869. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29870. /**
  29871. * Gets the effect to use to generate the depth map
  29872. * @param subMesh subMesh to get the effect for
  29873. * @param shadowGenerator shadow generator to get the effect for
  29874. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29875. */
  29876. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29877. /**
  29878. * Specifies that the submesh is ready to be used for depth rendering
  29879. * @param subMesh submesh to check
  29880. * @param defines the list of defines to take into account when checking the effect
  29881. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29882. * @param useInstances specifies that instances should be used
  29883. * @returns a boolean indicating that the submesh is ready or not
  29884. */
  29885. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29886. /**
  29887. * Disposes the resources
  29888. */
  29889. dispose(): void;
  29890. private _makeEffect;
  29891. }
  29892. }
  29893. declare module "babylonjs/Materials/material" {
  29894. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29895. import { SmartArray } from "babylonjs/Misc/smartArray";
  29896. import { Observable } from "babylonjs/Misc/observable";
  29897. import { Nullable } from "babylonjs/types";
  29898. import { Scene } from "babylonjs/scene";
  29899. import { Matrix } from "babylonjs/Maths/math.vector";
  29900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29902. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29903. import { Effect } from "babylonjs/Materials/effect";
  29904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29906. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29907. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29908. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  29909. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  29910. import { Mesh } from "babylonjs/Meshes/mesh";
  29911. import { Animation } from "babylonjs/Animations/animation";
  29912. /**
  29913. * Options for compiling materials.
  29914. */
  29915. export interface IMaterialCompilationOptions {
  29916. /**
  29917. * Defines whether clip planes are enabled.
  29918. */
  29919. clipPlane: boolean;
  29920. /**
  29921. * Defines whether instances are enabled.
  29922. */
  29923. useInstances: boolean;
  29924. }
  29925. /**
  29926. * Options passed when calling customShaderNameResolve
  29927. */
  29928. export interface ICustomShaderNameResolveOptions {
  29929. /**
  29930. * 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
  29931. */
  29932. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29933. }
  29934. /**
  29935. * Base class for the main features of a material in Babylon.js
  29936. */
  29937. export class Material implements IAnimatable {
  29938. /**
  29939. * Returns the triangle fill mode
  29940. */
  29941. static readonly TriangleFillMode: number;
  29942. /**
  29943. * Returns the wireframe mode
  29944. */
  29945. static readonly WireFrameFillMode: number;
  29946. /**
  29947. * Returns the point fill mode
  29948. */
  29949. static readonly PointFillMode: number;
  29950. /**
  29951. * Returns the point list draw mode
  29952. */
  29953. static readonly PointListDrawMode: number;
  29954. /**
  29955. * Returns the line list draw mode
  29956. */
  29957. static readonly LineListDrawMode: number;
  29958. /**
  29959. * Returns the line loop draw mode
  29960. */
  29961. static readonly LineLoopDrawMode: number;
  29962. /**
  29963. * Returns the line strip draw mode
  29964. */
  29965. static readonly LineStripDrawMode: number;
  29966. /**
  29967. * Returns the triangle strip draw mode
  29968. */
  29969. static readonly TriangleStripDrawMode: number;
  29970. /**
  29971. * Returns the triangle fan draw mode
  29972. */
  29973. static readonly TriangleFanDrawMode: number;
  29974. /**
  29975. * Stores the clock-wise side orientation
  29976. */
  29977. static readonly ClockWiseSideOrientation: number;
  29978. /**
  29979. * Stores the counter clock-wise side orientation
  29980. */
  29981. static readonly CounterClockWiseSideOrientation: number;
  29982. /**
  29983. * The dirty texture flag value
  29984. */
  29985. static readonly TextureDirtyFlag: number;
  29986. /**
  29987. * The dirty light flag value
  29988. */
  29989. static readonly LightDirtyFlag: number;
  29990. /**
  29991. * The dirty fresnel flag value
  29992. */
  29993. static readonly FresnelDirtyFlag: number;
  29994. /**
  29995. * The dirty attribute flag value
  29996. */
  29997. static readonly AttributesDirtyFlag: number;
  29998. /**
  29999. * The dirty misc flag value
  30000. */
  30001. static readonly MiscDirtyFlag: number;
  30002. /**
  30003. * The dirty prepass flag value
  30004. */
  30005. static readonly PrePassDirtyFlag: number;
  30006. /**
  30007. * The all dirty flag value
  30008. */
  30009. static readonly AllDirtyFlag: number;
  30010. /**
  30011. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30012. */
  30013. static readonly MATERIAL_OPAQUE: number;
  30014. /**
  30015. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30016. */
  30017. static readonly MATERIAL_ALPHATEST: number;
  30018. /**
  30019. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30020. */
  30021. static readonly MATERIAL_ALPHABLEND: number;
  30022. /**
  30023. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30024. * They are also discarded below the alpha cutoff threshold to improve performances.
  30025. */
  30026. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30027. /**
  30028. * The Whiteout method is used to blend normals.
  30029. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30030. */
  30031. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30032. /**
  30033. * The Reoriented Normal Mapping method is used to blend normals.
  30034. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30035. */
  30036. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30037. /**
  30038. * Custom callback helping to override the default shader used in the material.
  30039. */
  30040. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30041. /**
  30042. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30043. */
  30044. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30045. /**
  30046. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30047. * This means that the material can keep using a previous shader while a new one is being compiled.
  30048. * This is mostly used when shader parallel compilation is supported (true by default)
  30049. */
  30050. allowShaderHotSwapping: boolean;
  30051. /**
  30052. * The ID of the material
  30053. */
  30054. id: string;
  30055. /**
  30056. * Gets or sets the unique id of the material
  30057. */
  30058. uniqueId: number;
  30059. /**
  30060. * The name of the material
  30061. */
  30062. name: string;
  30063. /**
  30064. * Gets or sets user defined metadata
  30065. */
  30066. metadata: any;
  30067. /**
  30068. * For internal use only. Please do not use.
  30069. */
  30070. reservedDataStore: any;
  30071. /**
  30072. * Specifies if the ready state should be checked on each call
  30073. */
  30074. checkReadyOnEveryCall: boolean;
  30075. /**
  30076. * Specifies if the ready state should be checked once
  30077. */
  30078. checkReadyOnlyOnce: boolean;
  30079. /**
  30080. * The state of the material
  30081. */
  30082. state: string;
  30083. /**
  30084. * If the material can be rendered to several textures with MRT extension
  30085. */
  30086. get canRenderToMRT(): boolean;
  30087. /**
  30088. * The alpha value of the material
  30089. */
  30090. protected _alpha: number;
  30091. /**
  30092. * List of inspectable custom properties (used by the Inspector)
  30093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30094. */
  30095. inspectableCustomProperties: IInspectable[];
  30096. /**
  30097. * Sets the alpha value of the material
  30098. */
  30099. set alpha(value: number);
  30100. /**
  30101. * Gets the alpha value of the material
  30102. */
  30103. get alpha(): number;
  30104. /**
  30105. * Specifies if back face culling is enabled
  30106. */
  30107. protected _backFaceCulling: boolean;
  30108. /**
  30109. * Sets the back-face culling state
  30110. */
  30111. set backFaceCulling(value: boolean);
  30112. /**
  30113. * Gets the back-face culling state
  30114. */
  30115. get backFaceCulling(): boolean;
  30116. /**
  30117. * Stores the value for side orientation
  30118. */
  30119. sideOrientation: number;
  30120. /**
  30121. * Callback triggered when the material is compiled
  30122. */
  30123. onCompiled: Nullable<(effect: Effect) => void>;
  30124. /**
  30125. * Callback triggered when an error occurs
  30126. */
  30127. onError: Nullable<(effect: Effect, errors: string) => void>;
  30128. /**
  30129. * Callback triggered to get the render target textures
  30130. */
  30131. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30132. /**
  30133. * Gets a boolean indicating that current material needs to register RTT
  30134. */
  30135. get hasRenderTargetTextures(): boolean;
  30136. /**
  30137. * Specifies if the material should be serialized
  30138. */
  30139. doNotSerialize: boolean;
  30140. /**
  30141. * @hidden
  30142. */
  30143. _storeEffectOnSubMeshes: boolean;
  30144. /**
  30145. * Stores the animations for the material
  30146. */
  30147. animations: Nullable<Array<Animation>>;
  30148. /**
  30149. * An event triggered when the material is disposed
  30150. */
  30151. onDisposeObservable: Observable<Material>;
  30152. /**
  30153. * An observer which watches for dispose events
  30154. */
  30155. private _onDisposeObserver;
  30156. private _onUnBindObservable;
  30157. /**
  30158. * Called during a dispose event
  30159. */
  30160. set onDispose(callback: () => void);
  30161. private _onBindObservable;
  30162. /**
  30163. * An event triggered when the material is bound
  30164. */
  30165. get onBindObservable(): Observable<AbstractMesh>;
  30166. /**
  30167. * An observer which watches for bind events
  30168. */
  30169. private _onBindObserver;
  30170. /**
  30171. * Called during a bind event
  30172. */
  30173. set onBind(callback: (Mesh: AbstractMesh) => void);
  30174. /**
  30175. * An event triggered when the material is unbound
  30176. */
  30177. get onUnBindObservable(): Observable<Material>;
  30178. protected _onEffectCreatedObservable: Nullable<Observable<{
  30179. effect: Effect;
  30180. subMesh: Nullable<SubMesh>;
  30181. }>>;
  30182. /**
  30183. * An event triggered when the effect is (re)created
  30184. */
  30185. get onEffectCreatedObservable(): Observable<{
  30186. effect: Effect;
  30187. subMesh: Nullable<SubMesh>;
  30188. }>;
  30189. /**
  30190. * Stores the value of the alpha mode
  30191. */
  30192. private _alphaMode;
  30193. /**
  30194. * Sets the value of the alpha mode.
  30195. *
  30196. * | Value | Type | Description |
  30197. * | --- | --- | --- |
  30198. * | 0 | ALPHA_DISABLE | |
  30199. * | 1 | ALPHA_ADD | |
  30200. * | 2 | ALPHA_COMBINE | |
  30201. * | 3 | ALPHA_SUBTRACT | |
  30202. * | 4 | ALPHA_MULTIPLY | |
  30203. * | 5 | ALPHA_MAXIMIZED | |
  30204. * | 6 | ALPHA_ONEONE | |
  30205. * | 7 | ALPHA_PREMULTIPLIED | |
  30206. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30207. * | 9 | ALPHA_INTERPOLATE | |
  30208. * | 10 | ALPHA_SCREENMODE | |
  30209. *
  30210. */
  30211. set alphaMode(value: number);
  30212. /**
  30213. * Gets the value of the alpha mode
  30214. */
  30215. get alphaMode(): number;
  30216. /**
  30217. * Stores the state of the need depth pre-pass value
  30218. */
  30219. private _needDepthPrePass;
  30220. /**
  30221. * Sets the need depth pre-pass value
  30222. */
  30223. set needDepthPrePass(value: boolean);
  30224. /**
  30225. * Gets the depth pre-pass value
  30226. */
  30227. get needDepthPrePass(): boolean;
  30228. /**
  30229. * Specifies if depth writing should be disabled
  30230. */
  30231. disableDepthWrite: boolean;
  30232. /**
  30233. * Specifies if color writing should be disabled
  30234. */
  30235. disableColorWrite: boolean;
  30236. /**
  30237. * Specifies if depth writing should be forced
  30238. */
  30239. forceDepthWrite: boolean;
  30240. /**
  30241. * Specifies the depth function that should be used. 0 means the default engine function
  30242. */
  30243. depthFunction: number;
  30244. /**
  30245. * Specifies if there should be a separate pass for culling
  30246. */
  30247. separateCullingPass: boolean;
  30248. /**
  30249. * Stores the state specifing if fog should be enabled
  30250. */
  30251. private _fogEnabled;
  30252. /**
  30253. * Sets the state for enabling fog
  30254. */
  30255. set fogEnabled(value: boolean);
  30256. /**
  30257. * Gets the value of the fog enabled state
  30258. */
  30259. get fogEnabled(): boolean;
  30260. /**
  30261. * Stores the size of points
  30262. */
  30263. pointSize: number;
  30264. /**
  30265. * Stores the z offset value
  30266. */
  30267. zOffset: number;
  30268. get wireframe(): boolean;
  30269. /**
  30270. * Sets the state of wireframe mode
  30271. */
  30272. set wireframe(value: boolean);
  30273. /**
  30274. * Gets the value specifying if point clouds are enabled
  30275. */
  30276. get pointsCloud(): boolean;
  30277. /**
  30278. * Sets the state of point cloud mode
  30279. */
  30280. set pointsCloud(value: boolean);
  30281. /**
  30282. * Gets the material fill mode
  30283. */
  30284. get fillMode(): number;
  30285. /**
  30286. * Sets the material fill mode
  30287. */
  30288. set fillMode(value: number);
  30289. /**
  30290. * @hidden
  30291. * Stores the effects for the material
  30292. */
  30293. _effect: Nullable<Effect>;
  30294. /**
  30295. * Specifies if uniform buffers should be used
  30296. */
  30297. private _useUBO;
  30298. /**
  30299. * Stores a reference to the scene
  30300. */
  30301. private _scene;
  30302. /**
  30303. * Stores the fill mode state
  30304. */
  30305. private _fillMode;
  30306. /**
  30307. * Specifies if the depth write state should be cached
  30308. */
  30309. private _cachedDepthWriteState;
  30310. /**
  30311. * Specifies if the color write state should be cached
  30312. */
  30313. private _cachedColorWriteState;
  30314. /**
  30315. * Specifies if the depth function state should be cached
  30316. */
  30317. private _cachedDepthFunctionState;
  30318. /**
  30319. * Stores the uniform buffer
  30320. */
  30321. protected _uniformBuffer: UniformBuffer;
  30322. /** @hidden */
  30323. _indexInSceneMaterialArray: number;
  30324. /** @hidden */
  30325. meshMap: Nullable<{
  30326. [id: string]: AbstractMesh | undefined;
  30327. }>;
  30328. /**
  30329. * Creates a material instance
  30330. * @param name defines the name of the material
  30331. * @param scene defines the scene to reference
  30332. * @param doNotAdd specifies if the material should be added to the scene
  30333. */
  30334. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30335. /**
  30336. * Returns a string representation of the current material
  30337. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30338. * @returns a string with material information
  30339. */
  30340. toString(fullDetails?: boolean): string;
  30341. /**
  30342. * Gets the class name of the material
  30343. * @returns a string with the class name of the material
  30344. */
  30345. getClassName(): string;
  30346. /**
  30347. * Specifies if updates for the material been locked
  30348. */
  30349. get isFrozen(): boolean;
  30350. /**
  30351. * Locks updates for the material
  30352. */
  30353. freeze(): void;
  30354. /**
  30355. * Unlocks updates for the material
  30356. */
  30357. unfreeze(): void;
  30358. /**
  30359. * Specifies if the material is ready to be used
  30360. * @param mesh defines the mesh to check
  30361. * @param useInstances specifies if instances should be used
  30362. * @returns a boolean indicating if the material is ready to be used
  30363. */
  30364. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30365. /**
  30366. * Specifies that the submesh is ready to be used
  30367. * @param mesh defines the mesh to check
  30368. * @param subMesh defines which submesh to check
  30369. * @param useInstances specifies that instances should be used
  30370. * @returns a boolean indicating that the submesh is ready or not
  30371. */
  30372. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30373. /**
  30374. * Returns the material effect
  30375. * @returns the effect associated with the material
  30376. */
  30377. getEffect(): Nullable<Effect>;
  30378. /**
  30379. * Returns the current scene
  30380. * @returns a Scene
  30381. */
  30382. getScene(): Scene;
  30383. /**
  30384. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30385. */
  30386. protected _forceAlphaTest: boolean;
  30387. /**
  30388. * The transparency mode of the material.
  30389. */
  30390. protected _transparencyMode: Nullable<number>;
  30391. /**
  30392. * Gets the current transparency mode.
  30393. */
  30394. get transparencyMode(): Nullable<number>;
  30395. /**
  30396. * Sets the transparency mode of the material.
  30397. *
  30398. * | Value | Type | Description |
  30399. * | ----- | ----------------------------------- | ----------- |
  30400. * | 0 | OPAQUE | |
  30401. * | 1 | ALPHATEST | |
  30402. * | 2 | ALPHABLEND | |
  30403. * | 3 | ALPHATESTANDBLEND | |
  30404. *
  30405. */
  30406. set transparencyMode(value: Nullable<number>);
  30407. /**
  30408. * Returns true if alpha blending should be disabled.
  30409. */
  30410. protected get _disableAlphaBlending(): boolean;
  30411. /**
  30412. * Specifies whether or not this material should be rendered in alpha blend mode.
  30413. * @returns a boolean specifying if alpha blending is needed
  30414. */
  30415. needAlphaBlending(): boolean;
  30416. /**
  30417. * Specifies if the mesh will require alpha blending
  30418. * @param mesh defines the mesh to check
  30419. * @returns a boolean specifying if alpha blending is needed for the mesh
  30420. */
  30421. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30422. /**
  30423. * Specifies whether or not this material should be rendered in alpha test mode.
  30424. * @returns a boolean specifying if an alpha test is needed.
  30425. */
  30426. needAlphaTesting(): boolean;
  30427. /**
  30428. * Specifies if material alpha testing should be turned on for the mesh
  30429. * @param mesh defines the mesh to check
  30430. */
  30431. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30432. /**
  30433. * Gets the texture used for the alpha test
  30434. * @returns the texture to use for alpha testing
  30435. */
  30436. getAlphaTestTexture(): Nullable<BaseTexture>;
  30437. /**
  30438. * Marks the material to indicate that it needs to be re-calculated
  30439. */
  30440. markDirty(): void;
  30441. /** @hidden */
  30442. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30443. /**
  30444. * Binds the material to the mesh
  30445. * @param world defines the world transformation matrix
  30446. * @param mesh defines the mesh to bind the material to
  30447. */
  30448. bind(world: Matrix, mesh?: Mesh): void;
  30449. /**
  30450. * Binds the submesh to the material
  30451. * @param world defines the world transformation matrix
  30452. * @param mesh defines the mesh containing the submesh
  30453. * @param subMesh defines the submesh to bind the material to
  30454. */
  30455. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30456. /**
  30457. * Binds the world matrix to the material
  30458. * @param world defines the world transformation matrix
  30459. */
  30460. bindOnlyWorldMatrix(world: Matrix): void;
  30461. /**
  30462. * Binds the scene's uniform buffer to the effect.
  30463. * @param effect defines the effect to bind to the scene uniform buffer
  30464. * @param sceneUbo defines the uniform buffer storing scene data
  30465. */
  30466. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30467. /**
  30468. * Binds the view matrix to the effect
  30469. * @param effect defines the effect to bind the view matrix to
  30470. */
  30471. bindView(effect: Effect): void;
  30472. /**
  30473. * Binds the view projection matrix to the effect
  30474. * @param effect defines the effect to bind the view projection matrix to
  30475. */
  30476. bindViewProjection(effect: Effect): void;
  30477. /**
  30478. * Processes to execute after binding the material to a mesh
  30479. * @param mesh defines the rendered mesh
  30480. */
  30481. protected _afterBind(mesh?: Mesh): void;
  30482. /**
  30483. * Unbinds the material from the mesh
  30484. */
  30485. unbind(): void;
  30486. /**
  30487. * Gets the active textures from the material
  30488. * @returns an array of textures
  30489. */
  30490. getActiveTextures(): BaseTexture[];
  30491. /**
  30492. * Specifies if the material uses a texture
  30493. * @param texture defines the texture to check against the material
  30494. * @returns a boolean specifying if the material uses the texture
  30495. */
  30496. hasTexture(texture: BaseTexture): boolean;
  30497. /**
  30498. * Makes a duplicate of the material, and gives it a new name
  30499. * @param name defines the new name for the duplicated material
  30500. * @returns the cloned material
  30501. */
  30502. clone(name: string): Nullable<Material>;
  30503. /**
  30504. * Gets the meshes bound to the material
  30505. * @returns an array of meshes bound to the material
  30506. */
  30507. getBindedMeshes(): AbstractMesh[];
  30508. /**
  30509. * Force shader compilation
  30510. * @param mesh defines the mesh associated with this material
  30511. * @param onCompiled defines a function to execute once the material is compiled
  30512. * @param options defines the options to configure the compilation
  30513. * @param onError defines a function to execute if the material fails compiling
  30514. */
  30515. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30516. /**
  30517. * Force shader compilation
  30518. * @param mesh defines the mesh that will use this material
  30519. * @param options defines additional options for compiling the shaders
  30520. * @returns a promise that resolves when the compilation completes
  30521. */
  30522. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30523. private static readonly _AllDirtyCallBack;
  30524. private static readonly _ImageProcessingDirtyCallBack;
  30525. private static readonly _TextureDirtyCallBack;
  30526. private static readonly _FresnelDirtyCallBack;
  30527. private static readonly _MiscDirtyCallBack;
  30528. private static readonly _PrePassDirtyCallBack;
  30529. private static readonly _LightsDirtyCallBack;
  30530. private static readonly _AttributeDirtyCallBack;
  30531. private static _FresnelAndMiscDirtyCallBack;
  30532. private static _TextureAndMiscDirtyCallBack;
  30533. private static readonly _DirtyCallbackArray;
  30534. private static readonly _RunDirtyCallBacks;
  30535. /**
  30536. * Marks a define in the material to indicate that it needs to be re-computed
  30537. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30538. */
  30539. markAsDirty(flag: number): void;
  30540. /**
  30541. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30542. * @param func defines a function which checks material defines against the submeshes
  30543. */
  30544. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30545. /**
  30546. * Indicates that the scene should check if the rendering now needs a prepass
  30547. */
  30548. protected _markScenePrePassDirty(): void;
  30549. /**
  30550. * Indicates that we need to re-calculated for all submeshes
  30551. */
  30552. protected _markAllSubMeshesAsAllDirty(): void;
  30553. /**
  30554. * Indicates that image processing needs to be re-calculated for all submeshes
  30555. */
  30556. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30557. /**
  30558. * Indicates that textures need to be re-calculated for all submeshes
  30559. */
  30560. protected _markAllSubMeshesAsTexturesDirty(): void;
  30561. /**
  30562. * Indicates that fresnel needs to be re-calculated for all submeshes
  30563. */
  30564. protected _markAllSubMeshesAsFresnelDirty(): void;
  30565. /**
  30566. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30567. */
  30568. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30569. /**
  30570. * Indicates that lights need to be re-calculated for all submeshes
  30571. */
  30572. protected _markAllSubMeshesAsLightsDirty(): void;
  30573. /**
  30574. * Indicates that attributes need to be re-calculated for all submeshes
  30575. */
  30576. protected _markAllSubMeshesAsAttributesDirty(): void;
  30577. /**
  30578. * Indicates that misc needs to be re-calculated for all submeshes
  30579. */
  30580. protected _markAllSubMeshesAsMiscDirty(): void;
  30581. /**
  30582. * Indicates that prepass needs to be re-calculated for all submeshes
  30583. */
  30584. protected _markAllSubMeshesAsPrePassDirty(): void;
  30585. /**
  30586. * Indicates that textures and misc need to be re-calculated for all submeshes
  30587. */
  30588. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30589. /**
  30590. * Sets the required values to the prepass renderer.
  30591. * @param prePassRenderer defines the prepass renderer to setup.
  30592. * @returns true if the pre pass is needed.
  30593. */
  30594. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30595. /**
  30596. * Disposes the material
  30597. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30598. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30599. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30600. */
  30601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30602. /** @hidden */
  30603. private releaseVertexArrayObject;
  30604. /**
  30605. * Serializes this material
  30606. * @returns the serialized material object
  30607. */
  30608. serialize(): any;
  30609. /**
  30610. * Creates a material from parsed material data
  30611. * @param parsedMaterial defines parsed material data
  30612. * @param scene defines the hosting scene
  30613. * @param rootUrl defines the root URL to use to load textures
  30614. * @returns a new material
  30615. */
  30616. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30617. }
  30618. }
  30619. declare module "babylonjs/Materials/multiMaterial" {
  30620. import { Nullable } from "babylonjs/types";
  30621. import { Scene } from "babylonjs/scene";
  30622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30623. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30625. import { Material } from "babylonjs/Materials/material";
  30626. /**
  30627. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30628. * separate meshes. This can be use to improve performances.
  30629. * @see https://doc.babylonjs.com/how_to/multi_materials
  30630. */
  30631. export class MultiMaterial extends Material {
  30632. private _subMaterials;
  30633. /**
  30634. * Gets or Sets the list of Materials used within the multi material.
  30635. * They need to be ordered according to the submeshes order in the associated mesh
  30636. */
  30637. get subMaterials(): Nullable<Material>[];
  30638. set subMaterials(value: Nullable<Material>[]);
  30639. /**
  30640. * Function used to align with Node.getChildren()
  30641. * @returns the list of Materials used within the multi material
  30642. */
  30643. getChildren(): Nullable<Material>[];
  30644. /**
  30645. * Instantiates a new Multi Material
  30646. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30647. * separate meshes. This can be use to improve performances.
  30648. * @see https://doc.babylonjs.com/how_to/multi_materials
  30649. * @param name Define the name in the scene
  30650. * @param scene Define the scene the material belongs to
  30651. */
  30652. constructor(name: string, scene: Scene);
  30653. private _hookArray;
  30654. /**
  30655. * Get one of the submaterial by its index in the submaterials array
  30656. * @param index The index to look the sub material at
  30657. * @returns The Material if the index has been defined
  30658. */
  30659. getSubMaterial(index: number): Nullable<Material>;
  30660. /**
  30661. * Get the list of active textures for the whole sub materials list.
  30662. * @returns All the textures that will be used during the rendering
  30663. */
  30664. getActiveTextures(): BaseTexture[];
  30665. /**
  30666. * Gets the current class name of the material e.g. "MultiMaterial"
  30667. * Mainly use in serialization.
  30668. * @returns the class name
  30669. */
  30670. getClassName(): string;
  30671. /**
  30672. * Checks if the material is ready to render the requested sub mesh
  30673. * @param mesh Define the mesh the submesh belongs to
  30674. * @param subMesh Define the sub mesh to look readyness for
  30675. * @param useInstances Define whether or not the material is used with instances
  30676. * @returns true if ready, otherwise false
  30677. */
  30678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30679. /**
  30680. * Clones the current material and its related sub materials
  30681. * @param name Define the name of the newly cloned material
  30682. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30683. * @returns the cloned material
  30684. */
  30685. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30686. /**
  30687. * Serializes the materials into a JSON representation.
  30688. * @returns the JSON representation
  30689. */
  30690. serialize(): any;
  30691. /**
  30692. * Dispose the material and release its associated resources
  30693. * @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)
  30694. * @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)
  30695. * @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)
  30696. */
  30697. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30698. /**
  30699. * Creates a MultiMaterial from parsed MultiMaterial data.
  30700. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30701. * @param scene defines the hosting scene
  30702. * @returns a new MultiMaterial
  30703. */
  30704. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30705. }
  30706. }
  30707. declare module "babylonjs/Meshes/subMesh" {
  30708. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30709. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30710. import { Engine } from "babylonjs/Engines/engine";
  30711. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30712. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30713. import { Effect } from "babylonjs/Materials/effect";
  30714. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30715. import { Plane } from "babylonjs/Maths/math.plane";
  30716. import { Collider } from "babylonjs/Collisions/collider";
  30717. import { Material } from "babylonjs/Materials/material";
  30718. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30720. import { Mesh } from "babylonjs/Meshes/mesh";
  30721. import { Ray } from "babylonjs/Culling/ray";
  30722. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30723. /**
  30724. * Defines a subdivision inside a mesh
  30725. */
  30726. export class SubMesh implements ICullable {
  30727. /** the material index to use */
  30728. materialIndex: number;
  30729. /** vertex index start */
  30730. verticesStart: number;
  30731. /** vertices count */
  30732. verticesCount: number;
  30733. /** index start */
  30734. indexStart: number;
  30735. /** indices count */
  30736. indexCount: number;
  30737. /** @hidden */
  30738. _materialDefines: Nullable<MaterialDefines>;
  30739. /** @hidden */
  30740. _materialEffect: Nullable<Effect>;
  30741. /** @hidden */
  30742. _effectOverride: Nullable<Effect>;
  30743. /**
  30744. * Gets material defines used by the effect associated to the sub mesh
  30745. */
  30746. get materialDefines(): Nullable<MaterialDefines>;
  30747. /**
  30748. * Sets material defines used by the effect associated to the sub mesh
  30749. */
  30750. set materialDefines(defines: Nullable<MaterialDefines>);
  30751. /**
  30752. * Gets associated effect
  30753. */
  30754. get effect(): Nullable<Effect>;
  30755. /**
  30756. * Sets associated effect (effect used to render this submesh)
  30757. * @param effect defines the effect to associate with
  30758. * @param defines defines the set of defines used to compile this effect
  30759. */
  30760. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30761. /** @hidden */
  30762. _linesIndexCount: number;
  30763. private _mesh;
  30764. private _renderingMesh;
  30765. private _boundingInfo;
  30766. private _linesIndexBuffer;
  30767. /** @hidden */
  30768. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30769. /** @hidden */
  30770. _trianglePlanes: Plane[];
  30771. /** @hidden */
  30772. _lastColliderTransformMatrix: Nullable<Matrix>;
  30773. /** @hidden */
  30774. _renderId: number;
  30775. /** @hidden */
  30776. _alphaIndex: number;
  30777. /** @hidden */
  30778. _distanceToCamera: number;
  30779. /** @hidden */
  30780. _id: number;
  30781. private _currentMaterial;
  30782. /**
  30783. * Add a new submesh to a mesh
  30784. * @param materialIndex defines the material index to use
  30785. * @param verticesStart defines vertex index start
  30786. * @param verticesCount defines vertices count
  30787. * @param indexStart defines index start
  30788. * @param indexCount defines indices count
  30789. * @param mesh defines the parent mesh
  30790. * @param renderingMesh defines an optional rendering mesh
  30791. * @param createBoundingBox defines if bounding box should be created for this submesh
  30792. * @returns the new submesh
  30793. */
  30794. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30795. /**
  30796. * Creates a new submesh
  30797. * @param materialIndex defines the material index to use
  30798. * @param verticesStart defines vertex index start
  30799. * @param verticesCount defines vertices count
  30800. * @param indexStart defines index start
  30801. * @param indexCount defines indices count
  30802. * @param mesh defines the parent mesh
  30803. * @param renderingMesh defines an optional rendering mesh
  30804. * @param createBoundingBox defines if bounding box should be created for this submesh
  30805. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30806. */
  30807. constructor(
  30808. /** the material index to use */
  30809. materialIndex: number,
  30810. /** vertex index start */
  30811. verticesStart: number,
  30812. /** vertices count */
  30813. verticesCount: number,
  30814. /** index start */
  30815. indexStart: number,
  30816. /** indices count */
  30817. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30818. /**
  30819. * Returns true if this submesh covers the entire parent mesh
  30820. * @ignorenaming
  30821. */
  30822. get IsGlobal(): boolean;
  30823. /**
  30824. * Returns the submesh BoudingInfo object
  30825. * @returns current bounding info (or mesh's one if the submesh is global)
  30826. */
  30827. getBoundingInfo(): BoundingInfo;
  30828. /**
  30829. * Sets the submesh BoundingInfo
  30830. * @param boundingInfo defines the new bounding info to use
  30831. * @returns the SubMesh
  30832. */
  30833. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30834. /**
  30835. * Returns the mesh of the current submesh
  30836. * @return the parent mesh
  30837. */
  30838. getMesh(): AbstractMesh;
  30839. /**
  30840. * Returns the rendering mesh of the submesh
  30841. * @returns the rendering mesh (could be different from parent mesh)
  30842. */
  30843. getRenderingMesh(): Mesh;
  30844. /**
  30845. * Returns the replacement mesh of the submesh
  30846. * @returns the replacement mesh (could be different from parent mesh)
  30847. */
  30848. getReplacementMesh(): Nullable<AbstractMesh>;
  30849. /**
  30850. * Returns the effective mesh of the submesh
  30851. * @returns the effective mesh (could be different from parent mesh)
  30852. */
  30853. getEffectiveMesh(): AbstractMesh;
  30854. /**
  30855. * Returns the submesh material
  30856. * @returns null or the current material
  30857. */
  30858. getMaterial(): Nullable<Material>;
  30859. private _IsMultiMaterial;
  30860. /**
  30861. * Sets a new updated BoundingInfo object to the submesh
  30862. * @param data defines an optional position array to use to determine the bounding info
  30863. * @returns the SubMesh
  30864. */
  30865. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30866. /** @hidden */
  30867. _checkCollision(collider: Collider): boolean;
  30868. /**
  30869. * Updates the submesh BoundingInfo
  30870. * @param world defines the world matrix to use to update the bounding info
  30871. * @returns the submesh
  30872. */
  30873. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30874. /**
  30875. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30876. * @param frustumPlanes defines the frustum planes
  30877. * @returns true if the submesh is intersecting with the frustum
  30878. */
  30879. isInFrustum(frustumPlanes: Plane[]): boolean;
  30880. /**
  30881. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30882. * @param frustumPlanes defines the frustum planes
  30883. * @returns true if the submesh is inside the frustum
  30884. */
  30885. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30886. /**
  30887. * Renders the submesh
  30888. * @param enableAlphaMode defines if alpha needs to be used
  30889. * @returns the submesh
  30890. */
  30891. render(enableAlphaMode: boolean): SubMesh;
  30892. /**
  30893. * @hidden
  30894. */
  30895. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30896. /**
  30897. * Checks if the submesh intersects with a ray
  30898. * @param ray defines the ray to test
  30899. * @returns true is the passed ray intersects the submesh bounding box
  30900. */
  30901. canIntersects(ray: Ray): boolean;
  30902. /**
  30903. * Intersects current submesh with a ray
  30904. * @param ray defines the ray to test
  30905. * @param positions defines mesh's positions array
  30906. * @param indices defines mesh's indices array
  30907. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30909. * @returns intersection info or null if no intersection
  30910. */
  30911. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30912. /** @hidden */
  30913. private _intersectLines;
  30914. /** @hidden */
  30915. private _intersectUnIndexedLines;
  30916. /** @hidden */
  30917. private _intersectTriangles;
  30918. /** @hidden */
  30919. private _intersectUnIndexedTriangles;
  30920. /** @hidden */
  30921. _rebuild(): void;
  30922. /**
  30923. * Creates a new submesh from the passed mesh
  30924. * @param newMesh defines the new hosting mesh
  30925. * @param newRenderingMesh defines an optional rendering mesh
  30926. * @returns the new submesh
  30927. */
  30928. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30929. /**
  30930. * Release associated resources
  30931. */
  30932. dispose(): void;
  30933. /**
  30934. * Gets the class name
  30935. * @returns the string "SubMesh".
  30936. */
  30937. getClassName(): string;
  30938. /**
  30939. * Creates a new submesh from indices data
  30940. * @param materialIndex the index of the main mesh material
  30941. * @param startIndex the index where to start the copy in the mesh indices array
  30942. * @param indexCount the number of indices to copy then from the startIndex
  30943. * @param mesh the main mesh to create the submesh from
  30944. * @param renderingMesh the optional rendering mesh
  30945. * @returns a new submesh
  30946. */
  30947. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30948. }
  30949. }
  30950. declare module "babylonjs/Loading/sceneLoaderFlags" {
  30951. /**
  30952. * Class used to represent data loading progression
  30953. */
  30954. export class SceneLoaderFlags {
  30955. private static _ForceFullSceneLoadingForIncremental;
  30956. private static _ShowLoadingScreen;
  30957. private static _CleanBoneMatrixWeights;
  30958. private static _loggingLevel;
  30959. /**
  30960. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30961. */
  30962. static get ForceFullSceneLoadingForIncremental(): boolean;
  30963. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30964. /**
  30965. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30966. */
  30967. static get ShowLoadingScreen(): boolean;
  30968. static set ShowLoadingScreen(value: boolean);
  30969. /**
  30970. * Defines the current logging level (while loading the scene)
  30971. * @ignorenaming
  30972. */
  30973. static get loggingLevel(): number;
  30974. static set loggingLevel(value: number);
  30975. /**
  30976. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30977. */
  30978. static get CleanBoneMatrixWeights(): boolean;
  30979. static set CleanBoneMatrixWeights(value: boolean);
  30980. }
  30981. }
  30982. declare module "babylonjs/Meshes/geometry" {
  30983. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30984. import { Scene } from "babylonjs/scene";
  30985. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  30986. import { Engine } from "babylonjs/Engines/engine";
  30987. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  30988. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30989. import { Effect } from "babylonjs/Materials/effect";
  30990. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30992. import { Mesh } from "babylonjs/Meshes/mesh";
  30993. /**
  30994. * Class used to store geometry data (vertex buffers + index buffer)
  30995. */
  30996. export class Geometry implements IGetSetVerticesData {
  30997. /**
  30998. * Gets or sets the ID of the geometry
  30999. */
  31000. id: string;
  31001. /**
  31002. * Gets or sets the unique ID of the geometry
  31003. */
  31004. uniqueId: number;
  31005. /**
  31006. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31007. */
  31008. delayLoadState: number;
  31009. /**
  31010. * Gets the file containing the data to load when running in delay load state
  31011. */
  31012. delayLoadingFile: Nullable<string>;
  31013. /**
  31014. * Callback called when the geometry is updated
  31015. */
  31016. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31017. private _scene;
  31018. private _engine;
  31019. private _meshes;
  31020. private _totalVertices;
  31021. /** @hidden */
  31022. _indices: IndicesArray;
  31023. /** @hidden */
  31024. _vertexBuffers: {
  31025. [key: string]: VertexBuffer;
  31026. };
  31027. private _isDisposed;
  31028. private _extend;
  31029. private _boundingBias;
  31030. /** @hidden */
  31031. _delayInfo: Array<string>;
  31032. private _indexBuffer;
  31033. private _indexBufferIsUpdatable;
  31034. /** @hidden */
  31035. _boundingInfo: Nullable<BoundingInfo>;
  31036. /** @hidden */
  31037. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31038. /** @hidden */
  31039. _softwareSkinningFrameId: number;
  31040. private _vertexArrayObjects;
  31041. private _updatable;
  31042. /** @hidden */
  31043. _positions: Nullable<Vector3[]>;
  31044. /**
  31045. * 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
  31046. */
  31047. get boundingBias(): Vector2;
  31048. /**
  31049. * 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
  31050. */
  31051. set boundingBias(value: Vector2);
  31052. /**
  31053. * Static function used to attach a new empty geometry to a mesh
  31054. * @param mesh defines the mesh to attach the geometry to
  31055. * @returns the new Geometry
  31056. */
  31057. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31058. /** Get the list of meshes using this geometry */
  31059. get meshes(): Mesh[];
  31060. /**
  31061. * 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
  31062. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31063. */
  31064. useBoundingInfoFromGeometry: boolean;
  31065. /**
  31066. * Creates a new geometry
  31067. * @param id defines the unique ID
  31068. * @param scene defines the hosting scene
  31069. * @param vertexData defines the VertexData used to get geometry data
  31070. * @param updatable defines if geometry must be updatable (false by default)
  31071. * @param mesh defines the mesh that will be associated with the geometry
  31072. */
  31073. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31074. /**
  31075. * Gets the current extend of the geometry
  31076. */
  31077. get extend(): {
  31078. minimum: Vector3;
  31079. maximum: Vector3;
  31080. };
  31081. /**
  31082. * Gets the hosting scene
  31083. * @returns the hosting Scene
  31084. */
  31085. getScene(): Scene;
  31086. /**
  31087. * Gets the hosting engine
  31088. * @returns the hosting Engine
  31089. */
  31090. getEngine(): Engine;
  31091. /**
  31092. * Defines if the geometry is ready to use
  31093. * @returns true if the geometry is ready to be used
  31094. */
  31095. isReady(): boolean;
  31096. /**
  31097. * Gets a value indicating that the geometry should not be serialized
  31098. */
  31099. get doNotSerialize(): boolean;
  31100. /** @hidden */
  31101. _rebuild(): void;
  31102. /**
  31103. * Affects all geometry data in one call
  31104. * @param vertexData defines the geometry data
  31105. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31106. */
  31107. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31108. /**
  31109. * Set specific vertex data
  31110. * @param kind defines the data kind (Position, normal, etc...)
  31111. * @param data defines the vertex data to use
  31112. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31113. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31114. */
  31115. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31116. /**
  31117. * Removes a specific vertex data
  31118. * @param kind defines the data kind (Position, normal, etc...)
  31119. */
  31120. removeVerticesData(kind: string): void;
  31121. /**
  31122. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31123. * @param buffer defines the vertex buffer to use
  31124. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31125. */
  31126. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31127. /**
  31128. * Update a specific vertex buffer
  31129. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31130. * It will do nothing if the buffer is not updatable
  31131. * @param kind defines the data kind (Position, normal, etc...)
  31132. * @param data defines the data to use
  31133. * @param offset defines the offset in the target buffer where to store the data
  31134. * @param useBytes set to true if the offset is in bytes
  31135. */
  31136. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31137. /**
  31138. * Update a specific vertex buffer
  31139. * This function will create a new buffer if the current one is not updatable
  31140. * @param kind defines the data kind (Position, normal, etc...)
  31141. * @param data defines the data to use
  31142. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31143. */
  31144. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31145. private _updateBoundingInfo;
  31146. /** @hidden */
  31147. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31148. /**
  31149. * Gets total number of vertices
  31150. * @returns the total number of vertices
  31151. */
  31152. getTotalVertices(): number;
  31153. /**
  31154. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31155. * @param kind defines the data kind (Position, normal, etc...)
  31156. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31157. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31158. * @returns a float array containing vertex data
  31159. */
  31160. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31161. /**
  31162. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31163. * @param kind defines the data kind (Position, normal, etc...)
  31164. * @returns true if the vertex buffer with the specified kind is updatable
  31165. */
  31166. isVertexBufferUpdatable(kind: string): boolean;
  31167. /**
  31168. * Gets a specific vertex buffer
  31169. * @param kind defines the data kind (Position, normal, etc...)
  31170. * @returns a VertexBuffer
  31171. */
  31172. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31173. /**
  31174. * Returns all vertex buffers
  31175. * @return an object holding all vertex buffers indexed by kind
  31176. */
  31177. getVertexBuffers(): Nullable<{
  31178. [key: string]: VertexBuffer;
  31179. }>;
  31180. /**
  31181. * Gets a boolean indicating if specific vertex buffer is present
  31182. * @param kind defines the data kind (Position, normal, etc...)
  31183. * @returns true if data is present
  31184. */
  31185. isVerticesDataPresent(kind: string): boolean;
  31186. /**
  31187. * Gets a list of all attached data kinds (Position, normal, etc...)
  31188. * @returns a list of string containing all kinds
  31189. */
  31190. getVerticesDataKinds(): string[];
  31191. /**
  31192. * Update index buffer
  31193. * @param indices defines the indices to store in the index buffer
  31194. * @param offset defines the offset in the target buffer where to store the data
  31195. * @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)
  31196. */
  31197. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31198. /**
  31199. * Creates a new index buffer
  31200. * @param indices defines the indices to store in the index buffer
  31201. * @param totalVertices defines the total number of vertices (could be null)
  31202. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31203. */
  31204. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31205. /**
  31206. * Return the total number of indices
  31207. * @returns the total number of indices
  31208. */
  31209. getTotalIndices(): number;
  31210. /**
  31211. * Gets the index buffer array
  31212. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31213. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31214. * @returns the index buffer array
  31215. */
  31216. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31217. /**
  31218. * Gets the index buffer
  31219. * @return the index buffer
  31220. */
  31221. getIndexBuffer(): Nullable<DataBuffer>;
  31222. /** @hidden */
  31223. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31224. /**
  31225. * Release the associated resources for a specific mesh
  31226. * @param mesh defines the source mesh
  31227. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31228. */
  31229. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31230. /**
  31231. * Apply current geometry to a given mesh
  31232. * @param mesh defines the mesh to apply geometry to
  31233. */
  31234. applyToMesh(mesh: Mesh): void;
  31235. private _updateExtend;
  31236. private _applyToMesh;
  31237. private notifyUpdate;
  31238. /**
  31239. * Load the geometry if it was flagged as delay loaded
  31240. * @param scene defines the hosting scene
  31241. * @param onLoaded defines a callback called when the geometry is loaded
  31242. */
  31243. load(scene: Scene, onLoaded?: () => void): void;
  31244. private _queueLoad;
  31245. /**
  31246. * Invert the geometry to move from a right handed system to a left handed one.
  31247. */
  31248. toLeftHanded(): void;
  31249. /** @hidden */
  31250. _resetPointsArrayCache(): void;
  31251. /** @hidden */
  31252. _generatePointsArray(): boolean;
  31253. /**
  31254. * Gets a value indicating if the geometry is disposed
  31255. * @returns true if the geometry was disposed
  31256. */
  31257. isDisposed(): boolean;
  31258. private _disposeVertexArrayObjects;
  31259. /**
  31260. * Free all associated resources
  31261. */
  31262. dispose(): void;
  31263. /**
  31264. * Clone the current geometry into a new geometry
  31265. * @param id defines the unique ID of the new geometry
  31266. * @returns a new geometry object
  31267. */
  31268. copy(id: string): Geometry;
  31269. /**
  31270. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31271. * @return a JSON representation of the current geometry data (without the vertices data)
  31272. */
  31273. serialize(): any;
  31274. private toNumberArray;
  31275. /**
  31276. * Serialize all vertices data into a JSON oject
  31277. * @returns a JSON representation of the current geometry data
  31278. */
  31279. serializeVerticeData(): any;
  31280. /**
  31281. * Extracts a clone of a mesh geometry
  31282. * @param mesh defines the source mesh
  31283. * @param id defines the unique ID of the new geometry object
  31284. * @returns the new geometry object
  31285. */
  31286. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31287. /**
  31288. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31289. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31290. * Be aware Math.random() could cause collisions, but:
  31291. * "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"
  31292. * @returns a string containing a new GUID
  31293. */
  31294. static RandomId(): string;
  31295. /** @hidden */
  31296. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31297. private static _CleanMatricesWeights;
  31298. /**
  31299. * Create a new geometry from persisted data (Using .babylon file format)
  31300. * @param parsedVertexData defines the persisted data
  31301. * @param scene defines the hosting scene
  31302. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31303. * @returns the new geometry object
  31304. */
  31305. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31306. }
  31307. }
  31308. declare module "babylonjs/Meshes/mesh.vertexData" {
  31309. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31310. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31311. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31312. import { Geometry } from "babylonjs/Meshes/geometry";
  31313. import { Mesh } from "babylonjs/Meshes/mesh";
  31314. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31315. /**
  31316. * Define an interface for all classes that will get and set the data on vertices
  31317. */
  31318. export interface IGetSetVerticesData {
  31319. /**
  31320. * Gets a boolean indicating if specific vertex data is present
  31321. * @param kind defines the vertex data kind to use
  31322. * @returns true is data kind is present
  31323. */
  31324. isVerticesDataPresent(kind: string): boolean;
  31325. /**
  31326. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31327. * @param kind defines the data kind (Position, normal, etc...)
  31328. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31329. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31330. * @returns a float array containing vertex data
  31331. */
  31332. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31333. /**
  31334. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31335. * @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.
  31336. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31337. * @returns the indices array or an empty array if the mesh has no geometry
  31338. */
  31339. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31340. /**
  31341. * Set specific vertex data
  31342. * @param kind defines the data kind (Position, normal, etc...)
  31343. * @param data defines the vertex data to use
  31344. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31345. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31346. */
  31347. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31348. /**
  31349. * Update a specific associated vertex buffer
  31350. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31351. * - VertexBuffer.PositionKind
  31352. * - VertexBuffer.UVKind
  31353. * - VertexBuffer.UV2Kind
  31354. * - VertexBuffer.UV3Kind
  31355. * - VertexBuffer.UV4Kind
  31356. * - VertexBuffer.UV5Kind
  31357. * - VertexBuffer.UV6Kind
  31358. * - VertexBuffer.ColorKind
  31359. * - VertexBuffer.MatricesIndicesKind
  31360. * - VertexBuffer.MatricesIndicesExtraKind
  31361. * - VertexBuffer.MatricesWeightsKind
  31362. * - VertexBuffer.MatricesWeightsExtraKind
  31363. * @param data defines the data source
  31364. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31365. * @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)
  31366. */
  31367. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31368. /**
  31369. * Creates a new index buffer
  31370. * @param indices defines the indices to store in the index buffer
  31371. * @param totalVertices defines the total number of vertices (could be null)
  31372. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31373. */
  31374. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31375. }
  31376. /**
  31377. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31378. */
  31379. export class VertexData {
  31380. /**
  31381. * Mesh side orientation : usually the external or front surface
  31382. */
  31383. static readonly FRONTSIDE: number;
  31384. /**
  31385. * Mesh side orientation : usually the internal or back surface
  31386. */
  31387. static readonly BACKSIDE: number;
  31388. /**
  31389. * Mesh side orientation : both internal and external or front and back surfaces
  31390. */
  31391. static readonly DOUBLESIDE: number;
  31392. /**
  31393. * Mesh side orientation : by default, `FRONTSIDE`
  31394. */
  31395. static readonly DEFAULTSIDE: number;
  31396. /**
  31397. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31398. */
  31399. positions: Nullable<FloatArray>;
  31400. /**
  31401. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31402. */
  31403. normals: Nullable<FloatArray>;
  31404. /**
  31405. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31406. */
  31407. tangents: Nullable<FloatArray>;
  31408. /**
  31409. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31410. */
  31411. uvs: Nullable<FloatArray>;
  31412. /**
  31413. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31414. */
  31415. uvs2: Nullable<FloatArray>;
  31416. /**
  31417. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31418. */
  31419. uvs3: Nullable<FloatArray>;
  31420. /**
  31421. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31422. */
  31423. uvs4: Nullable<FloatArray>;
  31424. /**
  31425. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31426. */
  31427. uvs5: Nullable<FloatArray>;
  31428. /**
  31429. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31430. */
  31431. uvs6: Nullable<FloatArray>;
  31432. /**
  31433. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31434. */
  31435. colors: Nullable<FloatArray>;
  31436. /**
  31437. * 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).
  31438. */
  31439. matricesIndices: Nullable<FloatArray>;
  31440. /**
  31441. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31442. */
  31443. matricesWeights: Nullable<FloatArray>;
  31444. /**
  31445. * An array extending the number of possible indices
  31446. */
  31447. matricesIndicesExtra: Nullable<FloatArray>;
  31448. /**
  31449. * An array extending the number of possible weights when the number of indices is extended
  31450. */
  31451. matricesWeightsExtra: Nullable<FloatArray>;
  31452. /**
  31453. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31454. */
  31455. indices: Nullable<IndicesArray>;
  31456. /**
  31457. * Uses the passed data array to set the set the values for the specified kind of data
  31458. * @param data a linear array of floating numbers
  31459. * @param kind the type of data that is being set, eg positions, colors etc
  31460. */
  31461. set(data: FloatArray, kind: string): void;
  31462. /**
  31463. * Associates the vertexData to the passed Mesh.
  31464. * Sets it as updatable or not (default `false`)
  31465. * @param mesh the mesh the vertexData is applied to
  31466. * @param updatable when used and having the value true allows new data to update the vertexData
  31467. * @returns the VertexData
  31468. */
  31469. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31470. /**
  31471. * Associates the vertexData to the passed Geometry.
  31472. * Sets it as updatable or not (default `false`)
  31473. * @param geometry the geometry the vertexData is applied to
  31474. * @param updatable when used and having the value true allows new data to update the vertexData
  31475. * @returns VertexData
  31476. */
  31477. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31478. /**
  31479. * Updates the associated mesh
  31480. * @param mesh the mesh to be updated
  31481. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31482. * @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
  31483. * @returns VertexData
  31484. */
  31485. updateMesh(mesh: Mesh): VertexData;
  31486. /**
  31487. * Updates the associated geometry
  31488. * @param geometry the geometry to be updated
  31489. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31490. * @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
  31491. * @returns VertexData.
  31492. */
  31493. updateGeometry(geometry: Geometry): VertexData;
  31494. private _applyTo;
  31495. private _update;
  31496. /**
  31497. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31498. * @param matrix the transforming matrix
  31499. * @returns the VertexData
  31500. */
  31501. transform(matrix: Matrix): VertexData;
  31502. /**
  31503. * Merges the passed VertexData into the current one
  31504. * @param other the VertexData to be merged into the current one
  31505. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31506. * @returns the modified VertexData
  31507. */
  31508. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31509. private _mergeElement;
  31510. private _validate;
  31511. /**
  31512. * Serializes the VertexData
  31513. * @returns a serialized object
  31514. */
  31515. serialize(): any;
  31516. /**
  31517. * Extracts the vertexData from a mesh
  31518. * @param mesh the mesh from which to extract the VertexData
  31519. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31520. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31521. * @returns the object VertexData associated to the passed mesh
  31522. */
  31523. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31524. /**
  31525. * Extracts the vertexData from the geometry
  31526. * @param geometry the geometry from which to extract the VertexData
  31527. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31528. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31529. * @returns the object VertexData associated to the passed mesh
  31530. */
  31531. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31532. private static _ExtractFrom;
  31533. /**
  31534. * Creates the VertexData for a Ribbon
  31535. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31536. * * pathArray array of paths, each of which an array of successive Vector3
  31537. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31538. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31539. * * 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
  31540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31541. * * 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)
  31542. * * 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)
  31543. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31544. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31545. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31546. * @returns the VertexData of the ribbon
  31547. */
  31548. static CreateRibbon(options: {
  31549. pathArray: Vector3[][];
  31550. closeArray?: boolean;
  31551. closePath?: boolean;
  31552. offset?: number;
  31553. sideOrientation?: number;
  31554. frontUVs?: Vector4;
  31555. backUVs?: Vector4;
  31556. invertUV?: boolean;
  31557. uvs?: Vector2[];
  31558. colors?: Color4[];
  31559. }): VertexData;
  31560. /**
  31561. * Creates the VertexData for a box
  31562. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31563. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31564. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31565. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31566. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31567. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31568. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31569. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31570. * * 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)
  31571. * * 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)
  31572. * @returns the VertexData of the box
  31573. */
  31574. static CreateBox(options: {
  31575. size?: number;
  31576. width?: number;
  31577. height?: number;
  31578. depth?: number;
  31579. faceUV?: Vector4[];
  31580. faceColors?: Color4[];
  31581. sideOrientation?: number;
  31582. frontUVs?: Vector4;
  31583. backUVs?: Vector4;
  31584. }): VertexData;
  31585. /**
  31586. * Creates the VertexData for a tiled box
  31587. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31588. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31589. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31590. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31592. * @returns the VertexData of the box
  31593. */
  31594. static CreateTiledBox(options: {
  31595. pattern?: number;
  31596. width?: number;
  31597. height?: number;
  31598. depth?: number;
  31599. tileSize?: number;
  31600. tileWidth?: number;
  31601. tileHeight?: number;
  31602. alignHorizontal?: number;
  31603. alignVertical?: number;
  31604. faceUV?: Vector4[];
  31605. faceColors?: Color4[];
  31606. sideOrientation?: number;
  31607. }): VertexData;
  31608. /**
  31609. * Creates the VertexData for a tiled plane
  31610. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31611. * * pattern a limited pattern arrangement depending on the number
  31612. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31613. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31614. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31616. * * 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)
  31617. * * 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)
  31618. * @returns the VertexData of the tiled plane
  31619. */
  31620. static CreateTiledPlane(options: {
  31621. pattern?: number;
  31622. tileSize?: number;
  31623. tileWidth?: number;
  31624. tileHeight?: number;
  31625. size?: number;
  31626. width?: number;
  31627. height?: number;
  31628. alignHorizontal?: number;
  31629. alignVertical?: number;
  31630. sideOrientation?: number;
  31631. frontUVs?: Vector4;
  31632. backUVs?: Vector4;
  31633. }): VertexData;
  31634. /**
  31635. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31636. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31637. * * segments sets the number of horizontal strips optional, default 32
  31638. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31639. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31640. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31641. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31642. * * 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
  31643. * * 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
  31644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31645. * * 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)
  31646. * * 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)
  31647. * @returns the VertexData of the ellipsoid
  31648. */
  31649. static CreateSphere(options: {
  31650. segments?: number;
  31651. diameter?: number;
  31652. diameterX?: number;
  31653. diameterY?: number;
  31654. diameterZ?: number;
  31655. arc?: number;
  31656. slice?: number;
  31657. sideOrientation?: number;
  31658. frontUVs?: Vector4;
  31659. backUVs?: Vector4;
  31660. }): VertexData;
  31661. /**
  31662. * Creates the VertexData for a cylinder, cone or prism
  31663. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31664. * * height sets the height (y direction) of the cylinder, optional, default 2
  31665. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31666. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31667. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31668. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31669. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31670. * * 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
  31671. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31672. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31673. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31674. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31675. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31676. * * 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)
  31677. * * 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)
  31678. * @returns the VertexData of the cylinder, cone or prism
  31679. */
  31680. static CreateCylinder(options: {
  31681. height?: number;
  31682. diameterTop?: number;
  31683. diameterBottom?: number;
  31684. diameter?: number;
  31685. tessellation?: number;
  31686. subdivisions?: number;
  31687. arc?: number;
  31688. faceColors?: Color4[];
  31689. faceUV?: Vector4[];
  31690. hasRings?: boolean;
  31691. enclose?: boolean;
  31692. sideOrientation?: number;
  31693. frontUVs?: Vector4;
  31694. backUVs?: Vector4;
  31695. }): VertexData;
  31696. /**
  31697. * Creates the VertexData for a torus
  31698. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31699. * * diameter the diameter of the torus, optional default 1
  31700. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31701. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31702. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31703. * * 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)
  31704. * * 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)
  31705. * @returns the VertexData of the torus
  31706. */
  31707. static CreateTorus(options: {
  31708. diameter?: number;
  31709. thickness?: number;
  31710. tessellation?: number;
  31711. sideOrientation?: number;
  31712. frontUVs?: Vector4;
  31713. backUVs?: Vector4;
  31714. }): VertexData;
  31715. /**
  31716. * Creates the VertexData of the LineSystem
  31717. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31718. * - lines an array of lines, each line being an array of successive Vector3
  31719. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31720. * @returns the VertexData of the LineSystem
  31721. */
  31722. static CreateLineSystem(options: {
  31723. lines: Vector3[][];
  31724. colors?: Nullable<Color4[][]>;
  31725. }): VertexData;
  31726. /**
  31727. * Create the VertexData for a DashedLines
  31728. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31729. * - points an array successive Vector3
  31730. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31731. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31732. * - dashNb the intended total number of dashes, optional, default 200
  31733. * @returns the VertexData for the DashedLines
  31734. */
  31735. static CreateDashedLines(options: {
  31736. points: Vector3[];
  31737. dashSize?: number;
  31738. gapSize?: number;
  31739. dashNb?: number;
  31740. }): VertexData;
  31741. /**
  31742. * Creates the VertexData for a Ground
  31743. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31744. * - width the width (x direction) of the ground, optional, default 1
  31745. * - height the height (z direction) of the ground, optional, default 1
  31746. * - subdivisions the number of subdivisions per side, optional, default 1
  31747. * @returns the VertexData of the Ground
  31748. */
  31749. static CreateGround(options: {
  31750. width?: number;
  31751. height?: number;
  31752. subdivisions?: number;
  31753. subdivisionsX?: number;
  31754. subdivisionsY?: number;
  31755. }): VertexData;
  31756. /**
  31757. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31758. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31759. * * xmin the ground minimum X coordinate, optional, default -1
  31760. * * zmin the ground minimum Z coordinate, optional, default -1
  31761. * * xmax the ground maximum X coordinate, optional, default 1
  31762. * * zmax the ground maximum Z coordinate, optional, default 1
  31763. * * 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}
  31764. * * 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}
  31765. * @returns the VertexData of the TiledGround
  31766. */
  31767. static CreateTiledGround(options: {
  31768. xmin: number;
  31769. zmin: number;
  31770. xmax: number;
  31771. zmax: number;
  31772. subdivisions?: {
  31773. w: number;
  31774. h: number;
  31775. };
  31776. precision?: {
  31777. w: number;
  31778. h: number;
  31779. };
  31780. }): VertexData;
  31781. /**
  31782. * Creates the VertexData of the Ground designed from a heightmap
  31783. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31784. * * width the width (x direction) of the ground
  31785. * * height the height (z direction) of the ground
  31786. * * subdivisions the number of subdivisions per side
  31787. * * minHeight the minimum altitude on the ground, optional, default 0
  31788. * * maxHeight the maximum altitude on the ground, optional default 1
  31789. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31790. * * buffer the array holding the image color data
  31791. * * bufferWidth the width of image
  31792. * * bufferHeight the height of image
  31793. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31794. * @returns the VertexData of the Ground designed from a heightmap
  31795. */
  31796. static CreateGroundFromHeightMap(options: {
  31797. width: number;
  31798. height: number;
  31799. subdivisions: number;
  31800. minHeight: number;
  31801. maxHeight: number;
  31802. colorFilter: Color3;
  31803. buffer: Uint8Array;
  31804. bufferWidth: number;
  31805. bufferHeight: number;
  31806. alphaFilter: number;
  31807. }): VertexData;
  31808. /**
  31809. * Creates the VertexData for a Plane
  31810. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31811. * * size sets the width and height of the plane to the value of size, optional default 1
  31812. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31813. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31815. * * 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)
  31816. * * 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)
  31817. * @returns the VertexData of the box
  31818. */
  31819. static CreatePlane(options: {
  31820. size?: number;
  31821. width?: number;
  31822. height?: number;
  31823. sideOrientation?: number;
  31824. frontUVs?: Vector4;
  31825. backUVs?: Vector4;
  31826. }): VertexData;
  31827. /**
  31828. * Creates the VertexData of the Disc or regular Polygon
  31829. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31830. * * radius the radius of the disc, optional default 0.5
  31831. * * tessellation the number of polygon sides, optional, default 64
  31832. * * 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
  31833. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31834. * * 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)
  31835. * * 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)
  31836. * @returns the VertexData of the box
  31837. */
  31838. static CreateDisc(options: {
  31839. radius?: number;
  31840. tessellation?: number;
  31841. arc?: number;
  31842. sideOrientation?: number;
  31843. frontUVs?: Vector4;
  31844. backUVs?: Vector4;
  31845. }): VertexData;
  31846. /**
  31847. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31848. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31849. * @param polygon a mesh built from polygonTriangulation.build()
  31850. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31851. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31852. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31853. * @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)
  31854. * @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)
  31855. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31856. * @returns the VertexData of the Polygon
  31857. */
  31858. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31859. /**
  31860. * Creates the VertexData of the IcoSphere
  31861. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31862. * * radius the radius of the IcoSphere, optional default 1
  31863. * * radiusX allows stretching in the x direction, optional, default radius
  31864. * * radiusY allows stretching in the y direction, optional, default radius
  31865. * * radiusZ allows stretching in the z direction, optional, default radius
  31866. * * flat when true creates a flat shaded mesh, optional, default true
  31867. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31868. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31869. * * 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)
  31870. * * 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)
  31871. * @returns the VertexData of the IcoSphere
  31872. */
  31873. static CreateIcoSphere(options: {
  31874. radius?: number;
  31875. radiusX?: number;
  31876. radiusY?: number;
  31877. radiusZ?: number;
  31878. flat?: boolean;
  31879. subdivisions?: number;
  31880. sideOrientation?: number;
  31881. frontUVs?: Vector4;
  31882. backUVs?: Vector4;
  31883. }): VertexData;
  31884. /**
  31885. * Creates the VertexData for a Polyhedron
  31886. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31887. * * type provided types are:
  31888. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31889. * * 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)
  31890. * * size the size of the IcoSphere, optional default 1
  31891. * * sizeX allows stretching in the x direction, optional, default size
  31892. * * sizeY allows stretching in the y direction, optional, default size
  31893. * * sizeZ allows stretching in the z direction, optional, default size
  31894. * * 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
  31895. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31896. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31897. * * flat when true creates a flat shaded mesh, optional, default true
  31898. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31899. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31900. * * 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)
  31901. * * 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)
  31902. * @returns the VertexData of the Polyhedron
  31903. */
  31904. static CreatePolyhedron(options: {
  31905. type?: number;
  31906. size?: number;
  31907. sizeX?: number;
  31908. sizeY?: number;
  31909. sizeZ?: number;
  31910. custom?: any;
  31911. faceUV?: Vector4[];
  31912. faceColors?: Color4[];
  31913. flat?: boolean;
  31914. sideOrientation?: number;
  31915. frontUVs?: Vector4;
  31916. backUVs?: Vector4;
  31917. }): VertexData;
  31918. /**
  31919. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31920. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31921. * @returns the VertexData of the Capsule
  31922. */
  31923. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31924. /**
  31925. * Creates the VertexData for a TorusKnot
  31926. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31927. * * radius the radius of the torus knot, optional, default 2
  31928. * * tube the thickness of the tube, optional, default 0.5
  31929. * * radialSegments the number of sides on each tube segments, optional, default 32
  31930. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31931. * * p the number of windings around the z axis, optional, default 2
  31932. * * q the number of windings around the x axis, optional, default 3
  31933. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31934. * * 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)
  31935. * * 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)
  31936. * @returns the VertexData of the Torus Knot
  31937. */
  31938. static CreateTorusKnot(options: {
  31939. radius?: number;
  31940. tube?: number;
  31941. radialSegments?: number;
  31942. tubularSegments?: number;
  31943. p?: number;
  31944. q?: number;
  31945. sideOrientation?: number;
  31946. frontUVs?: Vector4;
  31947. backUVs?: Vector4;
  31948. }): VertexData;
  31949. /**
  31950. * Compute normals for given positions and indices
  31951. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31952. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31953. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31954. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31955. * * facetNormals : optional array of facet normals (vector3)
  31956. * * facetPositions : optional array of facet positions (vector3)
  31957. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31958. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31959. * * bInfo : optional bounding info, required for facetPartitioning computation
  31960. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31961. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31962. * * useRightHandedSystem: optional boolean to for right handed system computation
  31963. * * depthSort : optional boolean to enable the facet depth sort computation
  31964. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31965. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31966. */
  31967. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31968. facetNormals?: any;
  31969. facetPositions?: any;
  31970. facetPartitioning?: any;
  31971. ratio?: number;
  31972. bInfo?: any;
  31973. bbSize?: Vector3;
  31974. subDiv?: any;
  31975. useRightHandedSystem?: boolean;
  31976. depthSort?: boolean;
  31977. distanceTo?: Vector3;
  31978. depthSortedFacets?: any;
  31979. }): void;
  31980. /** @hidden */
  31981. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31982. /**
  31983. * Applies VertexData created from the imported parameters to the geometry
  31984. * @param parsedVertexData the parsed data from an imported file
  31985. * @param geometry the geometry to apply the VertexData to
  31986. */
  31987. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31988. }
  31989. }
  31990. declare module "babylonjs/Morph/morphTarget" {
  31991. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31992. import { Observable } from "babylonjs/Misc/observable";
  31993. import { Nullable, FloatArray } from "babylonjs/types";
  31994. import { Scene } from "babylonjs/scene";
  31995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31996. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31997. /**
  31998. * Defines a target to use with MorphTargetManager
  31999. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32000. */
  32001. export class MorphTarget implements IAnimatable {
  32002. /** defines the name of the target */
  32003. name: string;
  32004. /**
  32005. * Gets or sets the list of animations
  32006. */
  32007. animations: import("babylonjs/Animations/animation").Animation[];
  32008. private _scene;
  32009. private _positions;
  32010. private _normals;
  32011. private _tangents;
  32012. private _uvs;
  32013. private _influence;
  32014. private _uniqueId;
  32015. /**
  32016. * Observable raised when the influence changes
  32017. */
  32018. onInfluenceChanged: Observable<boolean>;
  32019. /** @hidden */
  32020. _onDataLayoutChanged: Observable<void>;
  32021. /**
  32022. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32023. */
  32024. get influence(): number;
  32025. set influence(influence: number);
  32026. /**
  32027. * Gets or sets the id of the morph Target
  32028. */
  32029. id: string;
  32030. private _animationPropertiesOverride;
  32031. /**
  32032. * Gets or sets the animation properties override
  32033. */
  32034. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32035. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32036. /**
  32037. * Creates a new MorphTarget
  32038. * @param name defines the name of the target
  32039. * @param influence defines the influence to use
  32040. * @param scene defines the scene the morphtarget belongs to
  32041. */
  32042. constructor(
  32043. /** defines the name of the target */
  32044. name: string, influence?: number, scene?: Nullable<Scene>);
  32045. /**
  32046. * Gets the unique ID of this manager
  32047. */
  32048. get uniqueId(): number;
  32049. /**
  32050. * Gets a boolean defining if the target contains position data
  32051. */
  32052. get hasPositions(): boolean;
  32053. /**
  32054. * Gets a boolean defining if the target contains normal data
  32055. */
  32056. get hasNormals(): boolean;
  32057. /**
  32058. * Gets a boolean defining if the target contains tangent data
  32059. */
  32060. get hasTangents(): boolean;
  32061. /**
  32062. * Gets a boolean defining if the target contains texture coordinates data
  32063. */
  32064. get hasUVs(): boolean;
  32065. /**
  32066. * Affects position data to this target
  32067. * @param data defines the position data to use
  32068. */
  32069. setPositions(data: Nullable<FloatArray>): void;
  32070. /**
  32071. * Gets the position data stored in this target
  32072. * @returns a FloatArray containing the position data (or null if not present)
  32073. */
  32074. getPositions(): Nullable<FloatArray>;
  32075. /**
  32076. * Affects normal data to this target
  32077. * @param data defines the normal data to use
  32078. */
  32079. setNormals(data: Nullable<FloatArray>): void;
  32080. /**
  32081. * Gets the normal data stored in this target
  32082. * @returns a FloatArray containing the normal data (or null if not present)
  32083. */
  32084. getNormals(): Nullable<FloatArray>;
  32085. /**
  32086. * Affects tangent data to this target
  32087. * @param data defines the tangent data to use
  32088. */
  32089. setTangents(data: Nullable<FloatArray>): void;
  32090. /**
  32091. * Gets the tangent data stored in this target
  32092. * @returns a FloatArray containing the tangent data (or null if not present)
  32093. */
  32094. getTangents(): Nullable<FloatArray>;
  32095. /**
  32096. * Affects texture coordinates data to this target
  32097. * @param data defines the texture coordinates data to use
  32098. */
  32099. setUVs(data: Nullable<FloatArray>): void;
  32100. /**
  32101. * Gets the texture coordinates data stored in this target
  32102. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32103. */
  32104. getUVs(): Nullable<FloatArray>;
  32105. /**
  32106. * Clone the current target
  32107. * @returns a new MorphTarget
  32108. */
  32109. clone(): MorphTarget;
  32110. /**
  32111. * Serializes the current target into a Serialization object
  32112. * @returns the serialized object
  32113. */
  32114. serialize(): any;
  32115. /**
  32116. * Returns the string "MorphTarget"
  32117. * @returns "MorphTarget"
  32118. */
  32119. getClassName(): string;
  32120. /**
  32121. * Creates a new target from serialized data
  32122. * @param serializationObject defines the serialized data to use
  32123. * @returns a new MorphTarget
  32124. */
  32125. static Parse(serializationObject: any): MorphTarget;
  32126. /**
  32127. * Creates a MorphTarget from mesh data
  32128. * @param mesh defines the source mesh
  32129. * @param name defines the name to use for the new target
  32130. * @param influence defines the influence to attach to the target
  32131. * @returns a new MorphTarget
  32132. */
  32133. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32134. }
  32135. }
  32136. declare module "babylonjs/Morph/morphTargetManager" {
  32137. import { Nullable } from "babylonjs/types";
  32138. import { Scene } from "babylonjs/scene";
  32139. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32140. /**
  32141. * This class is used to deform meshes using morphing between different targets
  32142. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32143. */
  32144. export class MorphTargetManager {
  32145. private _targets;
  32146. private _targetInfluenceChangedObservers;
  32147. private _targetDataLayoutChangedObservers;
  32148. private _activeTargets;
  32149. private _scene;
  32150. private _influences;
  32151. private _supportsNormals;
  32152. private _supportsTangents;
  32153. private _supportsUVs;
  32154. private _vertexCount;
  32155. private _uniqueId;
  32156. private _tempInfluences;
  32157. /**
  32158. * Gets or sets a boolean indicating if normals must be morphed
  32159. */
  32160. enableNormalMorphing: boolean;
  32161. /**
  32162. * Gets or sets a boolean indicating if tangents must be morphed
  32163. */
  32164. enableTangentMorphing: boolean;
  32165. /**
  32166. * Gets or sets a boolean indicating if UV must be morphed
  32167. */
  32168. enableUVMorphing: boolean;
  32169. /**
  32170. * Creates a new MorphTargetManager
  32171. * @param scene defines the current scene
  32172. */
  32173. constructor(scene?: Nullable<Scene>);
  32174. /**
  32175. * Gets the unique ID of this manager
  32176. */
  32177. get uniqueId(): number;
  32178. /**
  32179. * Gets the number of vertices handled by this manager
  32180. */
  32181. get vertexCount(): number;
  32182. /**
  32183. * Gets a boolean indicating if this manager supports morphing of normals
  32184. */
  32185. get supportsNormals(): boolean;
  32186. /**
  32187. * Gets a boolean indicating if this manager supports morphing of tangents
  32188. */
  32189. get supportsTangents(): boolean;
  32190. /**
  32191. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32192. */
  32193. get supportsUVs(): boolean;
  32194. /**
  32195. * Gets the number of targets stored in this manager
  32196. */
  32197. get numTargets(): number;
  32198. /**
  32199. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32200. */
  32201. get numInfluencers(): number;
  32202. /**
  32203. * Gets the list of influences (one per target)
  32204. */
  32205. get influences(): Float32Array;
  32206. /**
  32207. * Gets the active target at specified index. An active target is a target with an influence > 0
  32208. * @param index defines the index to check
  32209. * @returns the requested target
  32210. */
  32211. getActiveTarget(index: number): MorphTarget;
  32212. /**
  32213. * Gets the target at specified index
  32214. * @param index defines the index to check
  32215. * @returns the requested target
  32216. */
  32217. getTarget(index: number): MorphTarget;
  32218. /**
  32219. * Add a new target to this manager
  32220. * @param target defines the target to add
  32221. */
  32222. addTarget(target: MorphTarget): void;
  32223. /**
  32224. * Removes a target from the manager
  32225. * @param target defines the target to remove
  32226. */
  32227. removeTarget(target: MorphTarget): void;
  32228. /**
  32229. * Clone the current manager
  32230. * @returns a new MorphTargetManager
  32231. */
  32232. clone(): MorphTargetManager;
  32233. /**
  32234. * Serializes the current manager into a Serialization object
  32235. * @returns the serialized object
  32236. */
  32237. serialize(): any;
  32238. private _syncActiveTargets;
  32239. /**
  32240. * Syncrhonize the targets with all the meshes using this morph target manager
  32241. */
  32242. synchronize(): void;
  32243. /**
  32244. * Creates a new MorphTargetManager from serialized data
  32245. * @param serializationObject defines the serialized data
  32246. * @param scene defines the hosting scene
  32247. * @returns the new MorphTargetManager
  32248. */
  32249. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32250. }
  32251. }
  32252. declare module "babylonjs/Meshes/meshLODLevel" {
  32253. import { Mesh } from "babylonjs/Meshes/mesh";
  32254. import { Nullable } from "babylonjs/types";
  32255. /**
  32256. * Class used to represent a specific level of detail of a mesh
  32257. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32258. */
  32259. export class MeshLODLevel {
  32260. /** Defines the distance where this level should start being displayed */
  32261. distance: number;
  32262. /** Defines the mesh to use to render this level */
  32263. mesh: Nullable<Mesh>;
  32264. /**
  32265. * Creates a new LOD level
  32266. * @param distance defines the distance where this level should star being displayed
  32267. * @param mesh defines the mesh to use to render this level
  32268. */
  32269. constructor(
  32270. /** Defines the distance where this level should start being displayed */
  32271. distance: number,
  32272. /** Defines the mesh to use to render this level */
  32273. mesh: Nullable<Mesh>);
  32274. }
  32275. }
  32276. declare module "babylonjs/Misc/canvasGenerator" {
  32277. /**
  32278. * Helper class used to generate a canvas to manipulate images
  32279. */
  32280. export class CanvasGenerator {
  32281. /**
  32282. * Create a new canvas (or offscreen canvas depending on the context)
  32283. * @param width defines the expected width
  32284. * @param height defines the expected height
  32285. * @return a new canvas or offscreen canvas
  32286. */
  32287. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32288. }
  32289. }
  32290. declare module "babylonjs/Meshes/groundMesh" {
  32291. import { Scene } from "babylonjs/scene";
  32292. import { Vector3 } from "babylonjs/Maths/math.vector";
  32293. import { Mesh } from "babylonjs/Meshes/mesh";
  32294. /**
  32295. * Mesh representing the gorund
  32296. */
  32297. export class GroundMesh extends Mesh {
  32298. /** If octree should be generated */
  32299. generateOctree: boolean;
  32300. private _heightQuads;
  32301. /** @hidden */
  32302. _subdivisionsX: number;
  32303. /** @hidden */
  32304. _subdivisionsY: number;
  32305. /** @hidden */
  32306. _width: number;
  32307. /** @hidden */
  32308. _height: number;
  32309. /** @hidden */
  32310. _minX: number;
  32311. /** @hidden */
  32312. _maxX: number;
  32313. /** @hidden */
  32314. _minZ: number;
  32315. /** @hidden */
  32316. _maxZ: number;
  32317. constructor(name: string, scene: Scene);
  32318. /**
  32319. * "GroundMesh"
  32320. * @returns "GroundMesh"
  32321. */
  32322. getClassName(): string;
  32323. /**
  32324. * The minimum of x and y subdivisions
  32325. */
  32326. get subdivisions(): number;
  32327. /**
  32328. * X subdivisions
  32329. */
  32330. get subdivisionsX(): number;
  32331. /**
  32332. * Y subdivisions
  32333. */
  32334. get subdivisionsY(): number;
  32335. /**
  32336. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32337. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32338. * @param chunksCount the number of subdivisions for x and y
  32339. * @param octreeBlocksSize (Default: 32)
  32340. */
  32341. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32342. /**
  32343. * Returns a height (y) value in the Worl system :
  32344. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32345. * @param x x coordinate
  32346. * @param z z coordinate
  32347. * @returns the ground y position if (x, z) are outside the ground surface.
  32348. */
  32349. getHeightAtCoordinates(x: number, z: number): number;
  32350. /**
  32351. * Returns a normalized vector (Vector3) orthogonal to the ground
  32352. * at the ground coordinates (x, z) expressed in the World system.
  32353. * @param x x coordinate
  32354. * @param z z coordinate
  32355. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32356. */
  32357. getNormalAtCoordinates(x: number, z: number): Vector3;
  32358. /**
  32359. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32360. * at the ground coordinates (x, z) expressed in the World system.
  32361. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32362. * @param x x coordinate
  32363. * @param z z coordinate
  32364. * @param ref vector to store the result
  32365. * @returns the GroundMesh.
  32366. */
  32367. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32368. /**
  32369. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32370. * if the ground has been updated.
  32371. * This can be used in the render loop.
  32372. * @returns the GroundMesh.
  32373. */
  32374. updateCoordinateHeights(): GroundMesh;
  32375. private _getFacetAt;
  32376. private _initHeightQuads;
  32377. private _computeHeightQuads;
  32378. /**
  32379. * Serializes this ground mesh
  32380. * @param serializationObject object to write serialization to
  32381. */
  32382. serialize(serializationObject: any): void;
  32383. /**
  32384. * Parses a serialized ground mesh
  32385. * @param parsedMesh the serialized mesh
  32386. * @param scene the scene to create the ground mesh in
  32387. * @returns the created ground mesh
  32388. */
  32389. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32390. }
  32391. }
  32392. declare module "babylonjs/Physics/physicsJoint" {
  32393. import { Vector3 } from "babylonjs/Maths/math.vector";
  32394. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32395. /**
  32396. * Interface for Physics-Joint data
  32397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32398. */
  32399. export interface PhysicsJointData {
  32400. /**
  32401. * The main pivot of the joint
  32402. */
  32403. mainPivot?: Vector3;
  32404. /**
  32405. * The connected pivot of the joint
  32406. */
  32407. connectedPivot?: Vector3;
  32408. /**
  32409. * The main axis of the joint
  32410. */
  32411. mainAxis?: Vector3;
  32412. /**
  32413. * The connected axis of the joint
  32414. */
  32415. connectedAxis?: Vector3;
  32416. /**
  32417. * The collision of the joint
  32418. */
  32419. collision?: boolean;
  32420. /**
  32421. * Native Oimo/Cannon/Energy data
  32422. */
  32423. nativeParams?: any;
  32424. }
  32425. /**
  32426. * This is a holder class for the physics joint created by the physics plugin
  32427. * It holds a set of functions to control the underlying joint
  32428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32429. */
  32430. export class PhysicsJoint {
  32431. /**
  32432. * The type of the physics joint
  32433. */
  32434. type: number;
  32435. /**
  32436. * The data for the physics joint
  32437. */
  32438. jointData: PhysicsJointData;
  32439. private _physicsJoint;
  32440. protected _physicsPlugin: IPhysicsEnginePlugin;
  32441. /**
  32442. * Initializes the physics joint
  32443. * @param type The type of the physics joint
  32444. * @param jointData The data for the physics joint
  32445. */
  32446. constructor(
  32447. /**
  32448. * The type of the physics joint
  32449. */
  32450. type: number,
  32451. /**
  32452. * The data for the physics joint
  32453. */
  32454. jointData: PhysicsJointData);
  32455. /**
  32456. * Gets the physics joint
  32457. */
  32458. get physicsJoint(): any;
  32459. /**
  32460. * Sets the physics joint
  32461. */
  32462. set physicsJoint(newJoint: any);
  32463. /**
  32464. * Sets the physics plugin
  32465. */
  32466. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32467. /**
  32468. * Execute a function that is physics-plugin specific.
  32469. * @param {Function} func the function that will be executed.
  32470. * It accepts two parameters: the physics world and the physics joint
  32471. */
  32472. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32473. /**
  32474. * Distance-Joint type
  32475. */
  32476. static DistanceJoint: number;
  32477. /**
  32478. * Hinge-Joint type
  32479. */
  32480. static HingeJoint: number;
  32481. /**
  32482. * Ball-and-Socket joint type
  32483. */
  32484. static BallAndSocketJoint: number;
  32485. /**
  32486. * Wheel-Joint type
  32487. */
  32488. static WheelJoint: number;
  32489. /**
  32490. * Slider-Joint type
  32491. */
  32492. static SliderJoint: number;
  32493. /**
  32494. * Prismatic-Joint type
  32495. */
  32496. static PrismaticJoint: number;
  32497. /**
  32498. * Universal-Joint type
  32499. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32500. */
  32501. static UniversalJoint: number;
  32502. /**
  32503. * Hinge-Joint 2 type
  32504. */
  32505. static Hinge2Joint: number;
  32506. /**
  32507. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32508. */
  32509. static PointToPointJoint: number;
  32510. /**
  32511. * Spring-Joint type
  32512. */
  32513. static SpringJoint: number;
  32514. /**
  32515. * Lock-Joint type
  32516. */
  32517. static LockJoint: number;
  32518. }
  32519. /**
  32520. * A class representing a physics distance joint
  32521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32522. */
  32523. export class DistanceJoint extends PhysicsJoint {
  32524. /**
  32525. *
  32526. * @param jointData The data for the Distance-Joint
  32527. */
  32528. constructor(jointData: DistanceJointData);
  32529. /**
  32530. * Update the predefined distance.
  32531. * @param maxDistance The maximum preferred distance
  32532. * @param minDistance The minimum preferred distance
  32533. */
  32534. updateDistance(maxDistance: number, minDistance?: number): void;
  32535. }
  32536. /**
  32537. * Represents a Motor-Enabled Joint
  32538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32539. */
  32540. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32541. /**
  32542. * Initializes the Motor-Enabled Joint
  32543. * @param type The type of the joint
  32544. * @param jointData The physica joint data for the joint
  32545. */
  32546. constructor(type: number, jointData: PhysicsJointData);
  32547. /**
  32548. * Set the motor values.
  32549. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32550. * @param force the force to apply
  32551. * @param maxForce max force for this motor.
  32552. */
  32553. setMotor(force?: number, maxForce?: number): void;
  32554. /**
  32555. * Set the motor's limits.
  32556. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32557. * @param upperLimit The upper limit of the motor
  32558. * @param lowerLimit The lower limit of the motor
  32559. */
  32560. setLimit(upperLimit: number, lowerLimit?: number): void;
  32561. }
  32562. /**
  32563. * This class represents a single physics Hinge-Joint
  32564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32565. */
  32566. export class HingeJoint extends MotorEnabledJoint {
  32567. /**
  32568. * Initializes the Hinge-Joint
  32569. * @param jointData The joint data for the Hinge-Joint
  32570. */
  32571. constructor(jointData: PhysicsJointData);
  32572. /**
  32573. * Set the motor values.
  32574. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32575. * @param {number} force the force to apply
  32576. * @param {number} maxForce max force for this motor.
  32577. */
  32578. setMotor(force?: number, maxForce?: number): void;
  32579. /**
  32580. * Set the motor's limits.
  32581. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32582. * @param upperLimit The upper limit of the motor
  32583. * @param lowerLimit The lower limit of the motor
  32584. */
  32585. setLimit(upperLimit: number, lowerLimit?: number): void;
  32586. }
  32587. /**
  32588. * This class represents a dual hinge physics joint (same as wheel joint)
  32589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32590. */
  32591. export class Hinge2Joint extends MotorEnabledJoint {
  32592. /**
  32593. * Initializes the Hinge2-Joint
  32594. * @param jointData The joint data for the Hinge2-Joint
  32595. */
  32596. constructor(jointData: PhysicsJointData);
  32597. /**
  32598. * Set the motor values.
  32599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32600. * @param {number} targetSpeed the speed the motor is to reach
  32601. * @param {number} maxForce max force for this motor.
  32602. * @param {motorIndex} the motor's index, 0 or 1.
  32603. */
  32604. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32605. /**
  32606. * Set the motor limits.
  32607. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32608. * @param {number} upperLimit the upper limit
  32609. * @param {number} lowerLimit lower limit
  32610. * @param {motorIndex} the motor's index, 0 or 1.
  32611. */
  32612. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32613. }
  32614. /**
  32615. * Interface for a motor enabled joint
  32616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32617. */
  32618. export interface IMotorEnabledJoint {
  32619. /**
  32620. * Physics joint
  32621. */
  32622. physicsJoint: any;
  32623. /**
  32624. * Sets the motor of the motor-enabled joint
  32625. * @param force The force of the motor
  32626. * @param maxForce The maximum force of the motor
  32627. * @param motorIndex The index of the motor
  32628. */
  32629. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32630. /**
  32631. * Sets the limit of the motor
  32632. * @param upperLimit The upper limit of the motor
  32633. * @param lowerLimit The lower limit of the motor
  32634. * @param motorIndex The index of the motor
  32635. */
  32636. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32637. }
  32638. /**
  32639. * Joint data for a Distance-Joint
  32640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32641. */
  32642. export interface DistanceJointData extends PhysicsJointData {
  32643. /**
  32644. * Max distance the 2 joint objects can be apart
  32645. */
  32646. maxDistance: number;
  32647. }
  32648. /**
  32649. * Joint data from a spring joint
  32650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32651. */
  32652. export interface SpringJointData extends PhysicsJointData {
  32653. /**
  32654. * Length of the spring
  32655. */
  32656. length: number;
  32657. /**
  32658. * Stiffness of the spring
  32659. */
  32660. stiffness: number;
  32661. /**
  32662. * Damping of the spring
  32663. */
  32664. damping: number;
  32665. /** this callback will be called when applying the force to the impostors. */
  32666. forceApplicationCallback: () => void;
  32667. }
  32668. }
  32669. declare module "babylonjs/Physics/physicsRaycastResult" {
  32670. import { Vector3 } from "babylonjs/Maths/math.vector";
  32671. /**
  32672. * Holds the data for the raycast result
  32673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32674. */
  32675. export class PhysicsRaycastResult {
  32676. private _hasHit;
  32677. private _hitDistance;
  32678. private _hitNormalWorld;
  32679. private _hitPointWorld;
  32680. private _rayFromWorld;
  32681. private _rayToWorld;
  32682. /**
  32683. * Gets if there was a hit
  32684. */
  32685. get hasHit(): boolean;
  32686. /**
  32687. * Gets the distance from the hit
  32688. */
  32689. get hitDistance(): number;
  32690. /**
  32691. * Gets the hit normal/direction in the world
  32692. */
  32693. get hitNormalWorld(): Vector3;
  32694. /**
  32695. * Gets the hit point in the world
  32696. */
  32697. get hitPointWorld(): Vector3;
  32698. /**
  32699. * Gets the ray "start point" of the ray in the world
  32700. */
  32701. get rayFromWorld(): Vector3;
  32702. /**
  32703. * Gets the ray "end point" of the ray in the world
  32704. */
  32705. get rayToWorld(): Vector3;
  32706. /**
  32707. * Sets the hit data (normal & point in world space)
  32708. * @param hitNormalWorld defines the normal in world space
  32709. * @param hitPointWorld defines the point in world space
  32710. */
  32711. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32712. /**
  32713. * Sets the distance from the start point to the hit point
  32714. * @param distance
  32715. */
  32716. setHitDistance(distance: number): void;
  32717. /**
  32718. * Calculates the distance manually
  32719. */
  32720. calculateHitDistance(): void;
  32721. /**
  32722. * Resets all the values to default
  32723. * @param from The from point on world space
  32724. * @param to The to point on world space
  32725. */
  32726. reset(from?: Vector3, to?: Vector3): void;
  32727. }
  32728. /**
  32729. * Interface for the size containing width and height
  32730. */
  32731. interface IXYZ {
  32732. /**
  32733. * X
  32734. */
  32735. x: number;
  32736. /**
  32737. * Y
  32738. */
  32739. y: number;
  32740. /**
  32741. * Z
  32742. */
  32743. z: number;
  32744. }
  32745. }
  32746. declare module "babylonjs/Physics/IPhysicsEngine" {
  32747. import { Nullable } from "babylonjs/types";
  32748. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32750. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32751. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32752. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32753. /**
  32754. * Interface used to describe a physics joint
  32755. */
  32756. export interface PhysicsImpostorJoint {
  32757. /** Defines the main impostor to which the joint is linked */
  32758. mainImpostor: PhysicsImpostor;
  32759. /** Defines the impostor that is connected to the main impostor using this joint */
  32760. connectedImpostor: PhysicsImpostor;
  32761. /** Defines the joint itself */
  32762. joint: PhysicsJoint;
  32763. }
  32764. /** @hidden */
  32765. export interface IPhysicsEnginePlugin {
  32766. world: any;
  32767. name: string;
  32768. setGravity(gravity: Vector3): void;
  32769. setTimeStep(timeStep: number): void;
  32770. getTimeStep(): number;
  32771. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32772. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32773. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32774. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32775. removePhysicsBody(impostor: PhysicsImpostor): void;
  32776. generateJoint(joint: PhysicsImpostorJoint): void;
  32777. removeJoint(joint: PhysicsImpostorJoint): void;
  32778. isSupported(): boolean;
  32779. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32780. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32781. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32782. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32783. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32784. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32785. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32786. getBodyMass(impostor: PhysicsImpostor): number;
  32787. getBodyFriction(impostor: PhysicsImpostor): number;
  32788. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32789. getBodyRestitution(impostor: PhysicsImpostor): number;
  32790. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32791. getBodyPressure?(impostor: PhysicsImpostor): number;
  32792. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32793. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32794. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32795. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32796. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32797. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32798. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32799. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32800. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32801. sleepBody(impostor: PhysicsImpostor): void;
  32802. wakeUpBody(impostor: PhysicsImpostor): void;
  32803. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32804. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32805. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32806. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32807. getRadius(impostor: PhysicsImpostor): number;
  32808. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32809. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32810. dispose(): void;
  32811. }
  32812. /**
  32813. * Interface used to define a physics engine
  32814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32815. */
  32816. export interface IPhysicsEngine {
  32817. /**
  32818. * Gets the gravity vector used by the simulation
  32819. */
  32820. gravity: Vector3;
  32821. /**
  32822. * Sets the gravity vector used by the simulation
  32823. * @param gravity defines the gravity vector to use
  32824. */
  32825. setGravity(gravity: Vector3): void;
  32826. /**
  32827. * Set the time step of the physics engine.
  32828. * Default is 1/60.
  32829. * To slow it down, enter 1/600 for example.
  32830. * To speed it up, 1/30
  32831. * @param newTimeStep the new timestep to apply to this world.
  32832. */
  32833. setTimeStep(newTimeStep: number): void;
  32834. /**
  32835. * Get the time step of the physics engine.
  32836. * @returns the current time step
  32837. */
  32838. getTimeStep(): number;
  32839. /**
  32840. * Set the sub time step of the physics engine.
  32841. * Default is 0 meaning there is no sub steps
  32842. * To increase physics resolution precision, set a small value (like 1 ms)
  32843. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32844. */
  32845. setSubTimeStep(subTimeStep: number): void;
  32846. /**
  32847. * Get the sub time step of the physics engine.
  32848. * @returns the current sub time step
  32849. */
  32850. getSubTimeStep(): number;
  32851. /**
  32852. * Release all resources
  32853. */
  32854. dispose(): void;
  32855. /**
  32856. * Gets the name of the current physics plugin
  32857. * @returns the name of the plugin
  32858. */
  32859. getPhysicsPluginName(): string;
  32860. /**
  32861. * Adding a new impostor for the impostor tracking.
  32862. * This will be done by the impostor itself.
  32863. * @param impostor the impostor to add
  32864. */
  32865. addImpostor(impostor: PhysicsImpostor): void;
  32866. /**
  32867. * Remove an impostor from the engine.
  32868. * This impostor and its mesh will not longer be updated by the physics engine.
  32869. * @param impostor the impostor to remove
  32870. */
  32871. removeImpostor(impostor: PhysicsImpostor): void;
  32872. /**
  32873. * Add a joint to the physics engine
  32874. * @param mainImpostor defines the main impostor to which the joint is added.
  32875. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32876. * @param joint defines the joint that will connect both impostors.
  32877. */
  32878. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32879. /**
  32880. * Removes a joint from the simulation
  32881. * @param mainImpostor defines the impostor used with the joint
  32882. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32883. * @param joint defines the joint to remove
  32884. */
  32885. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32886. /**
  32887. * Gets the current plugin used to run the simulation
  32888. * @returns current plugin
  32889. */
  32890. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32891. /**
  32892. * Gets the list of physic impostors
  32893. * @returns an array of PhysicsImpostor
  32894. */
  32895. getImpostors(): Array<PhysicsImpostor>;
  32896. /**
  32897. * Gets the impostor for a physics enabled object
  32898. * @param object defines the object impersonated by the impostor
  32899. * @returns the PhysicsImpostor or null if not found
  32900. */
  32901. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32902. /**
  32903. * Gets the impostor for a physics body object
  32904. * @param body defines physics body used by the impostor
  32905. * @returns the PhysicsImpostor or null if not found
  32906. */
  32907. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32908. /**
  32909. * Does a raycast in the physics world
  32910. * @param from when should the ray start?
  32911. * @param to when should the ray end?
  32912. * @returns PhysicsRaycastResult
  32913. */
  32914. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32915. /**
  32916. * Called by the scene. No need to call it.
  32917. * @param delta defines the timespam between frames
  32918. */
  32919. _step(delta: number): void;
  32920. }
  32921. }
  32922. declare module "babylonjs/Physics/physicsImpostor" {
  32923. import { Nullable, IndicesArray } from "babylonjs/types";
  32924. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32925. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32927. import { Scene } from "babylonjs/scene";
  32928. import { Bone } from "babylonjs/Bones/bone";
  32929. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32930. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32931. import { Space } from "babylonjs/Maths/math.axis";
  32932. /**
  32933. * The interface for the physics imposter parameters
  32934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32935. */
  32936. export interface PhysicsImpostorParameters {
  32937. /**
  32938. * The mass of the physics imposter
  32939. */
  32940. mass: number;
  32941. /**
  32942. * The friction of the physics imposter
  32943. */
  32944. friction?: number;
  32945. /**
  32946. * The coefficient of restitution of the physics imposter
  32947. */
  32948. restitution?: number;
  32949. /**
  32950. * The native options of the physics imposter
  32951. */
  32952. nativeOptions?: any;
  32953. /**
  32954. * Specifies if the parent should be ignored
  32955. */
  32956. ignoreParent?: boolean;
  32957. /**
  32958. * Specifies if bi-directional transformations should be disabled
  32959. */
  32960. disableBidirectionalTransformation?: boolean;
  32961. /**
  32962. * The pressure inside the physics imposter, soft object only
  32963. */
  32964. pressure?: number;
  32965. /**
  32966. * The stiffness the physics imposter, soft object only
  32967. */
  32968. stiffness?: number;
  32969. /**
  32970. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32971. */
  32972. velocityIterations?: number;
  32973. /**
  32974. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32975. */
  32976. positionIterations?: number;
  32977. /**
  32978. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32979. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32980. * Add to fix multiple points
  32981. */
  32982. fixedPoints?: number;
  32983. /**
  32984. * The collision margin around a soft object
  32985. */
  32986. margin?: number;
  32987. /**
  32988. * The collision margin around a soft object
  32989. */
  32990. damping?: number;
  32991. /**
  32992. * The path for a rope based on an extrusion
  32993. */
  32994. path?: any;
  32995. /**
  32996. * The shape of an extrusion used for a rope based on an extrusion
  32997. */
  32998. shape?: any;
  32999. }
  33000. /**
  33001. * Interface for a physics-enabled object
  33002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33003. */
  33004. export interface IPhysicsEnabledObject {
  33005. /**
  33006. * The position of the physics-enabled object
  33007. */
  33008. position: Vector3;
  33009. /**
  33010. * The rotation of the physics-enabled object
  33011. */
  33012. rotationQuaternion: Nullable<Quaternion>;
  33013. /**
  33014. * The scale of the physics-enabled object
  33015. */
  33016. scaling: Vector3;
  33017. /**
  33018. * The rotation of the physics-enabled object
  33019. */
  33020. rotation?: Vector3;
  33021. /**
  33022. * The parent of the physics-enabled object
  33023. */
  33024. parent?: any;
  33025. /**
  33026. * The bounding info of the physics-enabled object
  33027. * @returns The bounding info of the physics-enabled object
  33028. */
  33029. getBoundingInfo(): BoundingInfo;
  33030. /**
  33031. * Computes the world matrix
  33032. * @param force Specifies if the world matrix should be computed by force
  33033. * @returns A world matrix
  33034. */
  33035. computeWorldMatrix(force: boolean): Matrix;
  33036. /**
  33037. * Gets the world matrix
  33038. * @returns A world matrix
  33039. */
  33040. getWorldMatrix?(): Matrix;
  33041. /**
  33042. * Gets the child meshes
  33043. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33044. * @returns An array of abstract meshes
  33045. */
  33046. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33047. /**
  33048. * Gets the vertex data
  33049. * @param kind The type of vertex data
  33050. * @returns A nullable array of numbers, or a float32 array
  33051. */
  33052. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33053. /**
  33054. * Gets the indices from the mesh
  33055. * @returns A nullable array of index arrays
  33056. */
  33057. getIndices?(): Nullable<IndicesArray>;
  33058. /**
  33059. * Gets the scene from the mesh
  33060. * @returns the indices array or null
  33061. */
  33062. getScene?(): Scene;
  33063. /**
  33064. * Gets the absolute position from the mesh
  33065. * @returns the absolute position
  33066. */
  33067. getAbsolutePosition(): Vector3;
  33068. /**
  33069. * Gets the absolute pivot point from the mesh
  33070. * @returns the absolute pivot point
  33071. */
  33072. getAbsolutePivotPoint(): Vector3;
  33073. /**
  33074. * Rotates the mesh
  33075. * @param axis The axis of rotation
  33076. * @param amount The amount of rotation
  33077. * @param space The space of the rotation
  33078. * @returns The rotation transform node
  33079. */
  33080. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33081. /**
  33082. * Translates the mesh
  33083. * @param axis The axis of translation
  33084. * @param distance The distance of translation
  33085. * @param space The space of the translation
  33086. * @returns The transform node
  33087. */
  33088. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33089. /**
  33090. * Sets the absolute position of the mesh
  33091. * @param absolutePosition The absolute position of the mesh
  33092. * @returns The transform node
  33093. */
  33094. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33095. /**
  33096. * Gets the class name of the mesh
  33097. * @returns The class name
  33098. */
  33099. getClassName(): string;
  33100. }
  33101. /**
  33102. * Represents a physics imposter
  33103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33104. */
  33105. export class PhysicsImpostor {
  33106. /**
  33107. * The physics-enabled object used as the physics imposter
  33108. */
  33109. object: IPhysicsEnabledObject;
  33110. /**
  33111. * The type of the physics imposter
  33112. */
  33113. type: number;
  33114. private _options;
  33115. private _scene?;
  33116. /**
  33117. * The default object size of the imposter
  33118. */
  33119. static DEFAULT_OBJECT_SIZE: Vector3;
  33120. /**
  33121. * The identity quaternion of the imposter
  33122. */
  33123. static IDENTITY_QUATERNION: Quaternion;
  33124. /** @hidden */
  33125. _pluginData: any;
  33126. private _physicsEngine;
  33127. private _physicsBody;
  33128. private _bodyUpdateRequired;
  33129. private _onBeforePhysicsStepCallbacks;
  33130. private _onAfterPhysicsStepCallbacks;
  33131. /** @hidden */
  33132. _onPhysicsCollideCallbacks: Array<{
  33133. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33134. otherImpostors: Array<PhysicsImpostor>;
  33135. }>;
  33136. private _deltaPosition;
  33137. private _deltaRotation;
  33138. private _deltaRotationConjugated;
  33139. /** @hidden */
  33140. _isFromLine: boolean;
  33141. private _parent;
  33142. private _isDisposed;
  33143. private static _tmpVecs;
  33144. private static _tmpQuat;
  33145. /**
  33146. * Specifies if the physics imposter is disposed
  33147. */
  33148. get isDisposed(): boolean;
  33149. /**
  33150. * Gets the mass of the physics imposter
  33151. */
  33152. get mass(): number;
  33153. set mass(value: number);
  33154. /**
  33155. * Gets the coefficient of friction
  33156. */
  33157. get friction(): number;
  33158. /**
  33159. * Sets the coefficient of friction
  33160. */
  33161. set friction(value: number);
  33162. /**
  33163. * Gets the coefficient of restitution
  33164. */
  33165. get restitution(): number;
  33166. /**
  33167. * Sets the coefficient of restitution
  33168. */
  33169. set restitution(value: number);
  33170. /**
  33171. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33172. */
  33173. get pressure(): number;
  33174. /**
  33175. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33176. */
  33177. set pressure(value: number);
  33178. /**
  33179. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33180. */
  33181. get stiffness(): number;
  33182. /**
  33183. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33184. */
  33185. set stiffness(value: number);
  33186. /**
  33187. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33188. */
  33189. get velocityIterations(): number;
  33190. /**
  33191. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33192. */
  33193. set velocityIterations(value: number);
  33194. /**
  33195. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33196. */
  33197. get positionIterations(): number;
  33198. /**
  33199. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33200. */
  33201. set positionIterations(value: number);
  33202. /**
  33203. * The unique id of the physics imposter
  33204. * set by the physics engine when adding this impostor to the array
  33205. */
  33206. uniqueId: number;
  33207. /**
  33208. * @hidden
  33209. */
  33210. soft: boolean;
  33211. /**
  33212. * @hidden
  33213. */
  33214. segments: number;
  33215. private _joints;
  33216. /**
  33217. * Initializes the physics imposter
  33218. * @param object The physics-enabled object used as the physics imposter
  33219. * @param type The type of the physics imposter
  33220. * @param _options The options for the physics imposter
  33221. * @param _scene The Babylon scene
  33222. */
  33223. constructor(
  33224. /**
  33225. * The physics-enabled object used as the physics imposter
  33226. */
  33227. object: IPhysicsEnabledObject,
  33228. /**
  33229. * The type of the physics imposter
  33230. */
  33231. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33232. /**
  33233. * This function will completly initialize this impostor.
  33234. * It will create a new body - but only if this mesh has no parent.
  33235. * If it has, this impostor will not be used other than to define the impostor
  33236. * of the child mesh.
  33237. * @hidden
  33238. */
  33239. _init(): void;
  33240. private _getPhysicsParent;
  33241. /**
  33242. * Should a new body be generated.
  33243. * @returns boolean specifying if body initialization is required
  33244. */
  33245. isBodyInitRequired(): boolean;
  33246. /**
  33247. * Sets the updated scaling
  33248. * @param updated Specifies if the scaling is updated
  33249. */
  33250. setScalingUpdated(): void;
  33251. /**
  33252. * Force a regeneration of this or the parent's impostor's body.
  33253. * Use under cautious - This will remove all joints already implemented.
  33254. */
  33255. forceUpdate(): void;
  33256. /**
  33257. * Gets the body that holds this impostor. Either its own, or its parent.
  33258. */
  33259. get physicsBody(): any;
  33260. /**
  33261. * Get the parent of the physics imposter
  33262. * @returns Physics imposter or null
  33263. */
  33264. get parent(): Nullable<PhysicsImpostor>;
  33265. /**
  33266. * Sets the parent of the physics imposter
  33267. */
  33268. set parent(value: Nullable<PhysicsImpostor>);
  33269. /**
  33270. * Set the physics body. Used mainly by the physics engine/plugin
  33271. */
  33272. set physicsBody(physicsBody: any);
  33273. /**
  33274. * Resets the update flags
  33275. */
  33276. resetUpdateFlags(): void;
  33277. /**
  33278. * Gets the object extend size
  33279. * @returns the object extend size
  33280. */
  33281. getObjectExtendSize(): Vector3;
  33282. /**
  33283. * Gets the object center
  33284. * @returns The object center
  33285. */
  33286. getObjectCenter(): Vector3;
  33287. /**
  33288. * Get a specific parameter from the options parameters
  33289. * @param paramName The object parameter name
  33290. * @returns The object parameter
  33291. */
  33292. getParam(paramName: string): any;
  33293. /**
  33294. * Sets a specific parameter in the options given to the physics plugin
  33295. * @param paramName The parameter name
  33296. * @param value The value of the parameter
  33297. */
  33298. setParam(paramName: string, value: number): void;
  33299. /**
  33300. * Specifically change the body's mass option. Won't recreate the physics body object
  33301. * @param mass The mass of the physics imposter
  33302. */
  33303. setMass(mass: number): void;
  33304. /**
  33305. * Gets the linear velocity
  33306. * @returns linear velocity or null
  33307. */
  33308. getLinearVelocity(): Nullable<Vector3>;
  33309. /**
  33310. * Sets the linear velocity
  33311. * @param velocity linear velocity or null
  33312. */
  33313. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33314. /**
  33315. * Gets the angular velocity
  33316. * @returns angular velocity or null
  33317. */
  33318. getAngularVelocity(): Nullable<Vector3>;
  33319. /**
  33320. * Sets the angular velocity
  33321. * @param velocity The velocity or null
  33322. */
  33323. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33324. /**
  33325. * Execute a function with the physics plugin native code
  33326. * Provide a function the will have two variables - the world object and the physics body object
  33327. * @param func The function to execute with the physics plugin native code
  33328. */
  33329. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33330. /**
  33331. * Register a function that will be executed before the physics world is stepping forward
  33332. * @param func The function to execute before the physics world is stepped forward
  33333. */
  33334. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33335. /**
  33336. * Unregister a function that will be executed before the physics world is stepping forward
  33337. * @param func The function to execute before the physics world is stepped forward
  33338. */
  33339. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33340. /**
  33341. * Register a function that will be executed after the physics step
  33342. * @param func The function to execute after physics step
  33343. */
  33344. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33345. /**
  33346. * Unregisters a function that will be executed after the physics step
  33347. * @param func The function to execute after physics step
  33348. */
  33349. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33350. /**
  33351. * register a function that will be executed when this impostor collides against a different body
  33352. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33353. * @param func Callback that is executed on collision
  33354. */
  33355. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33356. /**
  33357. * Unregisters the physics imposter on contact
  33358. * @param collideAgainst The physics object to collide against
  33359. * @param func Callback to execute on collision
  33360. */
  33361. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33362. private _tmpQuat;
  33363. private _tmpQuat2;
  33364. /**
  33365. * Get the parent rotation
  33366. * @returns The parent rotation
  33367. */
  33368. getParentsRotation(): Quaternion;
  33369. /**
  33370. * this function is executed by the physics engine.
  33371. */
  33372. beforeStep: () => void;
  33373. /**
  33374. * this function is executed by the physics engine
  33375. */
  33376. afterStep: () => void;
  33377. /**
  33378. * Legacy collision detection event support
  33379. */
  33380. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33381. /**
  33382. * event and body object due to cannon's event-based architecture.
  33383. */
  33384. onCollide: (e: {
  33385. body: any;
  33386. }) => void;
  33387. /**
  33388. * Apply a force
  33389. * @param force The force to apply
  33390. * @param contactPoint The contact point for the force
  33391. * @returns The physics imposter
  33392. */
  33393. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33394. /**
  33395. * Apply an impulse
  33396. * @param force The impulse force
  33397. * @param contactPoint The contact point for the impulse force
  33398. * @returns The physics imposter
  33399. */
  33400. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33401. /**
  33402. * A help function to create a joint
  33403. * @param otherImpostor A physics imposter used to create a joint
  33404. * @param jointType The type of joint
  33405. * @param jointData The data for the joint
  33406. * @returns The physics imposter
  33407. */
  33408. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33409. /**
  33410. * Add a joint to this impostor with a different impostor
  33411. * @param otherImpostor A physics imposter used to add a joint
  33412. * @param joint The joint to add
  33413. * @returns The physics imposter
  33414. */
  33415. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33416. /**
  33417. * Add an anchor to a cloth impostor
  33418. * @param otherImpostor rigid impostor to anchor to
  33419. * @param width ratio across width from 0 to 1
  33420. * @param height ratio up height from 0 to 1
  33421. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33422. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33423. * @returns impostor the soft imposter
  33424. */
  33425. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33426. /**
  33427. * Add a hook to a rope impostor
  33428. * @param otherImpostor rigid impostor to anchor to
  33429. * @param length ratio across rope from 0 to 1
  33430. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33431. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33432. * @returns impostor the rope imposter
  33433. */
  33434. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33435. /**
  33436. * Will keep this body still, in a sleep mode.
  33437. * @returns the physics imposter
  33438. */
  33439. sleep(): PhysicsImpostor;
  33440. /**
  33441. * Wake the body up.
  33442. * @returns The physics imposter
  33443. */
  33444. wakeUp(): PhysicsImpostor;
  33445. /**
  33446. * Clones the physics imposter
  33447. * @param newObject The physics imposter clones to this physics-enabled object
  33448. * @returns A nullable physics imposter
  33449. */
  33450. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33451. /**
  33452. * Disposes the physics imposter
  33453. */
  33454. dispose(): void;
  33455. /**
  33456. * Sets the delta position
  33457. * @param position The delta position amount
  33458. */
  33459. setDeltaPosition(position: Vector3): void;
  33460. /**
  33461. * Sets the delta rotation
  33462. * @param rotation The delta rotation amount
  33463. */
  33464. setDeltaRotation(rotation: Quaternion): void;
  33465. /**
  33466. * Gets the box size of the physics imposter and stores the result in the input parameter
  33467. * @param result Stores the box size
  33468. * @returns The physics imposter
  33469. */
  33470. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33471. /**
  33472. * Gets the radius of the physics imposter
  33473. * @returns Radius of the physics imposter
  33474. */
  33475. getRadius(): number;
  33476. /**
  33477. * Sync a bone with this impostor
  33478. * @param bone The bone to sync to the impostor.
  33479. * @param boneMesh The mesh that the bone is influencing.
  33480. * @param jointPivot The pivot of the joint / bone in local space.
  33481. * @param distToJoint Optional distance from the impostor to the joint.
  33482. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33483. */
  33484. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33485. /**
  33486. * Sync impostor to a bone
  33487. * @param bone The bone that the impostor will be synced to.
  33488. * @param boneMesh The mesh that the bone is influencing.
  33489. * @param jointPivot The pivot of the joint / bone in local space.
  33490. * @param distToJoint Optional distance from the impostor to the joint.
  33491. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33492. * @param boneAxis Optional vector3 axis the bone is aligned with
  33493. */
  33494. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33495. /**
  33496. * No-Imposter type
  33497. */
  33498. static NoImpostor: number;
  33499. /**
  33500. * Sphere-Imposter type
  33501. */
  33502. static SphereImpostor: number;
  33503. /**
  33504. * Box-Imposter type
  33505. */
  33506. static BoxImpostor: number;
  33507. /**
  33508. * Plane-Imposter type
  33509. */
  33510. static PlaneImpostor: number;
  33511. /**
  33512. * Mesh-imposter type
  33513. */
  33514. static MeshImpostor: number;
  33515. /**
  33516. * Capsule-Impostor type (Ammo.js plugin only)
  33517. */
  33518. static CapsuleImpostor: number;
  33519. /**
  33520. * Cylinder-Imposter type
  33521. */
  33522. static CylinderImpostor: number;
  33523. /**
  33524. * Particle-Imposter type
  33525. */
  33526. static ParticleImpostor: number;
  33527. /**
  33528. * Heightmap-Imposter type
  33529. */
  33530. static HeightmapImpostor: number;
  33531. /**
  33532. * ConvexHull-Impostor type (Ammo.js plugin only)
  33533. */
  33534. static ConvexHullImpostor: number;
  33535. /**
  33536. * Custom-Imposter type (Ammo.js plugin only)
  33537. */
  33538. static CustomImpostor: number;
  33539. /**
  33540. * Rope-Imposter type
  33541. */
  33542. static RopeImpostor: number;
  33543. /**
  33544. * Cloth-Imposter type
  33545. */
  33546. static ClothImpostor: number;
  33547. /**
  33548. * Softbody-Imposter type
  33549. */
  33550. static SoftbodyImpostor: number;
  33551. }
  33552. }
  33553. declare module "babylonjs/Meshes/mesh" {
  33554. import { Observable } from "babylonjs/Misc/observable";
  33555. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33556. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33557. import { Camera } from "babylonjs/Cameras/camera";
  33558. import { Scene } from "babylonjs/scene";
  33559. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33560. import { Color4 } from "babylonjs/Maths/math.color";
  33561. import { Engine } from "babylonjs/Engines/engine";
  33562. import { Node } from "babylonjs/node";
  33563. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33564. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33565. import { Buffer } from "babylonjs/Meshes/buffer";
  33566. import { Geometry } from "babylonjs/Meshes/geometry";
  33567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33569. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33570. import { Effect } from "babylonjs/Materials/effect";
  33571. import { Material } from "babylonjs/Materials/material";
  33572. import { Skeleton } from "babylonjs/Bones/skeleton";
  33573. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33574. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33575. import { Path3D } from "babylonjs/Maths/math.path";
  33576. import { Plane } from "babylonjs/Maths/math.plane";
  33577. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33578. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33579. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33580. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33581. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33582. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33583. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33584. /**
  33585. * @hidden
  33586. **/
  33587. export class _CreationDataStorage {
  33588. closePath?: boolean;
  33589. closeArray?: boolean;
  33590. idx: number[];
  33591. dashSize: number;
  33592. gapSize: number;
  33593. path3D: Path3D;
  33594. pathArray: Vector3[][];
  33595. arc: number;
  33596. radius: number;
  33597. cap: number;
  33598. tessellation: number;
  33599. }
  33600. /**
  33601. * @hidden
  33602. **/
  33603. class _InstanceDataStorage {
  33604. visibleInstances: any;
  33605. batchCache: _InstancesBatch;
  33606. instancesBufferSize: number;
  33607. instancesBuffer: Nullable<Buffer>;
  33608. instancesData: Float32Array;
  33609. overridenInstanceCount: number;
  33610. isFrozen: boolean;
  33611. previousBatch: Nullable<_InstancesBatch>;
  33612. hardwareInstancedRendering: boolean;
  33613. sideOrientation: number;
  33614. manualUpdate: boolean;
  33615. previousRenderId: number;
  33616. }
  33617. /**
  33618. * @hidden
  33619. **/
  33620. export class _InstancesBatch {
  33621. mustReturn: boolean;
  33622. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33623. renderSelf: boolean[];
  33624. hardwareInstancedRendering: boolean[];
  33625. }
  33626. /**
  33627. * @hidden
  33628. **/
  33629. class _ThinInstanceDataStorage {
  33630. instancesCount: number;
  33631. matrixBuffer: Nullable<Buffer>;
  33632. matrixBufferSize: number;
  33633. matrixData: Nullable<Float32Array>;
  33634. boundingVectors: Array<Vector3>;
  33635. worldMatrices: Nullable<Matrix[]>;
  33636. }
  33637. /**
  33638. * Class used to represent renderable models
  33639. */
  33640. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33641. /**
  33642. * Mesh side orientation : usually the external or front surface
  33643. */
  33644. static readonly FRONTSIDE: number;
  33645. /**
  33646. * Mesh side orientation : usually the internal or back surface
  33647. */
  33648. static readonly BACKSIDE: number;
  33649. /**
  33650. * Mesh side orientation : both internal and external or front and back surfaces
  33651. */
  33652. static readonly DOUBLESIDE: number;
  33653. /**
  33654. * Mesh side orientation : by default, `FRONTSIDE`
  33655. */
  33656. static readonly DEFAULTSIDE: number;
  33657. /**
  33658. * Mesh cap setting : no cap
  33659. */
  33660. static readonly NO_CAP: number;
  33661. /**
  33662. * Mesh cap setting : one cap at the beginning of the mesh
  33663. */
  33664. static readonly CAP_START: number;
  33665. /**
  33666. * Mesh cap setting : one cap at the end of the mesh
  33667. */
  33668. static readonly CAP_END: number;
  33669. /**
  33670. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33671. */
  33672. static readonly CAP_ALL: number;
  33673. /**
  33674. * Mesh pattern setting : no flip or rotate
  33675. */
  33676. static readonly NO_FLIP: number;
  33677. /**
  33678. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33679. */
  33680. static readonly FLIP_TILE: number;
  33681. /**
  33682. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33683. */
  33684. static readonly ROTATE_TILE: number;
  33685. /**
  33686. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33687. */
  33688. static readonly FLIP_ROW: number;
  33689. /**
  33690. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33691. */
  33692. static readonly ROTATE_ROW: number;
  33693. /**
  33694. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33695. */
  33696. static readonly FLIP_N_ROTATE_TILE: number;
  33697. /**
  33698. * Mesh pattern setting : rotate pattern and rotate
  33699. */
  33700. static readonly FLIP_N_ROTATE_ROW: number;
  33701. /**
  33702. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33703. */
  33704. static readonly CENTER: number;
  33705. /**
  33706. * Mesh tile positioning : part tiles on left
  33707. */
  33708. static readonly LEFT: number;
  33709. /**
  33710. * Mesh tile positioning : part tiles on right
  33711. */
  33712. static readonly RIGHT: number;
  33713. /**
  33714. * Mesh tile positioning : part tiles on top
  33715. */
  33716. static readonly TOP: number;
  33717. /**
  33718. * Mesh tile positioning : part tiles on bottom
  33719. */
  33720. static readonly BOTTOM: number;
  33721. /**
  33722. * Gets the default side orientation.
  33723. * @param orientation the orientation to value to attempt to get
  33724. * @returns the default orientation
  33725. * @hidden
  33726. */
  33727. static _GetDefaultSideOrientation(orientation?: number): number;
  33728. private _internalMeshDataInfo;
  33729. get computeBonesUsingShaders(): boolean;
  33730. set computeBonesUsingShaders(value: boolean);
  33731. /**
  33732. * An event triggered before rendering the mesh
  33733. */
  33734. get onBeforeRenderObservable(): Observable<Mesh>;
  33735. /**
  33736. * An event triggered before binding the mesh
  33737. */
  33738. get onBeforeBindObservable(): Observable<Mesh>;
  33739. /**
  33740. * An event triggered after rendering the mesh
  33741. */
  33742. get onAfterRenderObservable(): Observable<Mesh>;
  33743. /**
  33744. * An event triggered before drawing the mesh
  33745. */
  33746. get onBeforeDrawObservable(): Observable<Mesh>;
  33747. private _onBeforeDrawObserver;
  33748. /**
  33749. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33750. */
  33751. set onBeforeDraw(callback: () => void);
  33752. get hasInstances(): boolean;
  33753. get hasThinInstances(): boolean;
  33754. /**
  33755. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33756. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33757. */
  33758. delayLoadState: number;
  33759. /**
  33760. * Gets the list of instances created from this mesh
  33761. * it is not supposed to be modified manually.
  33762. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33763. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33764. */
  33765. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33766. /**
  33767. * Gets the file containing delay loading data for this mesh
  33768. */
  33769. delayLoadingFile: string;
  33770. /** @hidden */
  33771. _binaryInfo: any;
  33772. /**
  33773. * User defined function used to change how LOD level selection is done
  33774. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33775. */
  33776. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33777. /**
  33778. * Gets or sets the morph target manager
  33779. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33780. */
  33781. get morphTargetManager(): Nullable<MorphTargetManager>;
  33782. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33783. /** @hidden */
  33784. _creationDataStorage: Nullable<_CreationDataStorage>;
  33785. /** @hidden */
  33786. _geometry: Nullable<Geometry>;
  33787. /** @hidden */
  33788. _delayInfo: Array<string>;
  33789. /** @hidden */
  33790. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33791. /** @hidden */
  33792. _instanceDataStorage: _InstanceDataStorage;
  33793. /** @hidden */
  33794. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33795. private _effectiveMaterial;
  33796. /** @hidden */
  33797. _shouldGenerateFlatShading: boolean;
  33798. /** @hidden */
  33799. _originalBuilderSideOrientation: number;
  33800. /**
  33801. * Use this property to change the original side orientation defined at construction time
  33802. */
  33803. overrideMaterialSideOrientation: Nullable<number>;
  33804. /**
  33805. * Gets the source mesh (the one used to clone this one from)
  33806. */
  33807. get source(): Nullable<Mesh>;
  33808. /**
  33809. * Gets the list of clones of this mesh
  33810. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33811. * Note that useClonedMeshMap=true is the default setting
  33812. */
  33813. get cloneMeshMap(): Nullable<{
  33814. [id: string]: Mesh | undefined;
  33815. }>;
  33816. /**
  33817. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33818. */
  33819. get isUnIndexed(): boolean;
  33820. set isUnIndexed(value: boolean);
  33821. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33822. get worldMatrixInstancedBuffer(): Float32Array;
  33823. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33824. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33825. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33826. /**
  33827. * @constructor
  33828. * @param name The value used by scene.getMeshByName() to do a lookup.
  33829. * @param scene The scene to add this mesh to.
  33830. * @param parent The parent of this mesh, if it has one
  33831. * @param source An optional Mesh from which geometry is shared, cloned.
  33832. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33833. * When false, achieved by calling a clone(), also passing False.
  33834. * This will make creation of children, recursive.
  33835. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33836. */
  33837. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33838. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33839. doNotInstantiate: boolean;
  33840. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33841. /**
  33842. * Gets the class name
  33843. * @returns the string "Mesh".
  33844. */
  33845. getClassName(): string;
  33846. /** @hidden */
  33847. get _isMesh(): boolean;
  33848. /**
  33849. * Returns a description of this mesh
  33850. * @param fullDetails define if full details about this mesh must be used
  33851. * @returns a descriptive string representing this mesh
  33852. */
  33853. toString(fullDetails?: boolean): string;
  33854. /** @hidden */
  33855. _unBindEffect(): void;
  33856. /**
  33857. * Gets a boolean indicating if this mesh has LOD
  33858. */
  33859. get hasLODLevels(): boolean;
  33860. /**
  33861. * Gets the list of MeshLODLevel associated with the current mesh
  33862. * @returns an array of MeshLODLevel
  33863. */
  33864. getLODLevels(): MeshLODLevel[];
  33865. private _sortLODLevels;
  33866. /**
  33867. * Add a mesh as LOD level triggered at the given distance.
  33868. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33869. * @param distance The distance from the center of the object to show this level
  33870. * @param mesh The mesh to be added as LOD level (can be null)
  33871. * @return This mesh (for chaining)
  33872. */
  33873. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33874. /**
  33875. * Returns the LOD level mesh at the passed distance or null if not found.
  33876. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33877. * @param distance The distance from the center of the object to show this level
  33878. * @returns a Mesh or `null`
  33879. */
  33880. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33881. /**
  33882. * Remove a mesh from the LOD array
  33883. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33884. * @param mesh defines the mesh to be removed
  33885. * @return This mesh (for chaining)
  33886. */
  33887. removeLODLevel(mesh: Mesh): Mesh;
  33888. /**
  33889. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33890. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33891. * @param camera defines the camera to use to compute distance
  33892. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33893. * @return This mesh (for chaining)
  33894. */
  33895. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33896. /**
  33897. * Gets the mesh internal Geometry object
  33898. */
  33899. get geometry(): Nullable<Geometry>;
  33900. /**
  33901. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33902. * @returns the total number of vertices
  33903. */
  33904. getTotalVertices(): number;
  33905. /**
  33906. * Returns the content of an associated vertex buffer
  33907. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33908. * - VertexBuffer.PositionKind
  33909. * - VertexBuffer.UVKind
  33910. * - VertexBuffer.UV2Kind
  33911. * - VertexBuffer.UV3Kind
  33912. * - VertexBuffer.UV4Kind
  33913. * - VertexBuffer.UV5Kind
  33914. * - VertexBuffer.UV6Kind
  33915. * - VertexBuffer.ColorKind
  33916. * - VertexBuffer.MatricesIndicesKind
  33917. * - VertexBuffer.MatricesIndicesExtraKind
  33918. * - VertexBuffer.MatricesWeightsKind
  33919. * - VertexBuffer.MatricesWeightsExtraKind
  33920. * @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
  33921. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33922. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33923. */
  33924. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33925. /**
  33926. * Returns the mesh VertexBuffer object from the requested `kind`
  33927. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33928. * - VertexBuffer.PositionKind
  33929. * - VertexBuffer.NormalKind
  33930. * - VertexBuffer.UVKind
  33931. * - VertexBuffer.UV2Kind
  33932. * - VertexBuffer.UV3Kind
  33933. * - VertexBuffer.UV4Kind
  33934. * - VertexBuffer.UV5Kind
  33935. * - VertexBuffer.UV6Kind
  33936. * - VertexBuffer.ColorKind
  33937. * - VertexBuffer.MatricesIndicesKind
  33938. * - VertexBuffer.MatricesIndicesExtraKind
  33939. * - VertexBuffer.MatricesWeightsKind
  33940. * - VertexBuffer.MatricesWeightsExtraKind
  33941. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33942. */
  33943. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33944. /**
  33945. * Tests if a specific vertex buffer is associated with this mesh
  33946. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33947. * - VertexBuffer.PositionKind
  33948. * - VertexBuffer.NormalKind
  33949. * - VertexBuffer.UVKind
  33950. * - VertexBuffer.UV2Kind
  33951. * - VertexBuffer.UV3Kind
  33952. * - VertexBuffer.UV4Kind
  33953. * - VertexBuffer.UV5Kind
  33954. * - VertexBuffer.UV6Kind
  33955. * - VertexBuffer.ColorKind
  33956. * - VertexBuffer.MatricesIndicesKind
  33957. * - VertexBuffer.MatricesIndicesExtraKind
  33958. * - VertexBuffer.MatricesWeightsKind
  33959. * - VertexBuffer.MatricesWeightsExtraKind
  33960. * @returns a boolean
  33961. */
  33962. isVerticesDataPresent(kind: string): boolean;
  33963. /**
  33964. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33965. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33966. * - VertexBuffer.PositionKind
  33967. * - VertexBuffer.UVKind
  33968. * - VertexBuffer.UV2Kind
  33969. * - VertexBuffer.UV3Kind
  33970. * - VertexBuffer.UV4Kind
  33971. * - VertexBuffer.UV5Kind
  33972. * - VertexBuffer.UV6Kind
  33973. * - VertexBuffer.ColorKind
  33974. * - VertexBuffer.MatricesIndicesKind
  33975. * - VertexBuffer.MatricesIndicesExtraKind
  33976. * - VertexBuffer.MatricesWeightsKind
  33977. * - VertexBuffer.MatricesWeightsExtraKind
  33978. * @returns a boolean
  33979. */
  33980. isVertexBufferUpdatable(kind: string): boolean;
  33981. /**
  33982. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33983. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33984. * - VertexBuffer.PositionKind
  33985. * - VertexBuffer.NormalKind
  33986. * - VertexBuffer.UVKind
  33987. * - VertexBuffer.UV2Kind
  33988. * - VertexBuffer.UV3Kind
  33989. * - VertexBuffer.UV4Kind
  33990. * - VertexBuffer.UV5Kind
  33991. * - VertexBuffer.UV6Kind
  33992. * - VertexBuffer.ColorKind
  33993. * - VertexBuffer.MatricesIndicesKind
  33994. * - VertexBuffer.MatricesIndicesExtraKind
  33995. * - VertexBuffer.MatricesWeightsKind
  33996. * - VertexBuffer.MatricesWeightsExtraKind
  33997. * @returns an array of strings
  33998. */
  33999. getVerticesDataKinds(): string[];
  34000. /**
  34001. * Returns a positive integer : the total number of indices in this mesh geometry.
  34002. * @returns the numner of indices or zero if the mesh has no geometry.
  34003. */
  34004. getTotalIndices(): number;
  34005. /**
  34006. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34007. * @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.
  34008. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34009. * @returns the indices array or an empty array if the mesh has no geometry
  34010. */
  34011. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34012. get isBlocked(): boolean;
  34013. /**
  34014. * Determine if the current mesh is ready to be rendered
  34015. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34016. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34017. * @returns true if all associated assets are ready (material, textures, shaders)
  34018. */
  34019. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34020. /**
  34021. * 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.
  34022. */
  34023. get areNormalsFrozen(): boolean;
  34024. /**
  34025. * 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.
  34026. * @returns the current mesh
  34027. */
  34028. freezeNormals(): Mesh;
  34029. /**
  34030. * 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
  34031. * @returns the current mesh
  34032. */
  34033. unfreezeNormals(): Mesh;
  34034. /**
  34035. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34036. */
  34037. set overridenInstanceCount(count: number);
  34038. /** @hidden */
  34039. _preActivate(): Mesh;
  34040. /** @hidden */
  34041. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34042. /** @hidden */
  34043. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34044. protected _afterComputeWorldMatrix(): void;
  34045. /** @hidden */
  34046. _postActivate(): void;
  34047. /**
  34048. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34049. * This means the mesh underlying bounding box and sphere are recomputed.
  34050. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34051. * @returns the current mesh
  34052. */
  34053. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34054. /** @hidden */
  34055. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34056. /**
  34057. * This function will subdivide the mesh into multiple submeshes
  34058. * @param count defines the expected number of submeshes
  34059. */
  34060. subdivide(count: number): void;
  34061. /**
  34062. * Copy a FloatArray into a specific associated vertex buffer
  34063. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34064. * - VertexBuffer.PositionKind
  34065. * - VertexBuffer.UVKind
  34066. * - VertexBuffer.UV2Kind
  34067. * - VertexBuffer.UV3Kind
  34068. * - VertexBuffer.UV4Kind
  34069. * - VertexBuffer.UV5Kind
  34070. * - VertexBuffer.UV6Kind
  34071. * - VertexBuffer.ColorKind
  34072. * - VertexBuffer.MatricesIndicesKind
  34073. * - VertexBuffer.MatricesIndicesExtraKind
  34074. * - VertexBuffer.MatricesWeightsKind
  34075. * - VertexBuffer.MatricesWeightsExtraKind
  34076. * @param data defines the data source
  34077. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34078. * @param stride defines the data stride size (can be null)
  34079. * @returns the current mesh
  34080. */
  34081. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34082. /**
  34083. * Delete a vertex buffer associated with this mesh
  34084. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34085. * - VertexBuffer.PositionKind
  34086. * - VertexBuffer.UVKind
  34087. * - VertexBuffer.UV2Kind
  34088. * - VertexBuffer.UV3Kind
  34089. * - VertexBuffer.UV4Kind
  34090. * - VertexBuffer.UV5Kind
  34091. * - VertexBuffer.UV6Kind
  34092. * - VertexBuffer.ColorKind
  34093. * - VertexBuffer.MatricesIndicesKind
  34094. * - VertexBuffer.MatricesIndicesExtraKind
  34095. * - VertexBuffer.MatricesWeightsKind
  34096. * - VertexBuffer.MatricesWeightsExtraKind
  34097. */
  34098. removeVerticesData(kind: string): void;
  34099. /**
  34100. * Flags an associated vertex buffer as updatable
  34101. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34102. * - VertexBuffer.PositionKind
  34103. * - VertexBuffer.UVKind
  34104. * - VertexBuffer.UV2Kind
  34105. * - VertexBuffer.UV3Kind
  34106. * - VertexBuffer.UV4Kind
  34107. * - VertexBuffer.UV5Kind
  34108. * - VertexBuffer.UV6Kind
  34109. * - VertexBuffer.ColorKind
  34110. * - VertexBuffer.MatricesIndicesKind
  34111. * - VertexBuffer.MatricesIndicesExtraKind
  34112. * - VertexBuffer.MatricesWeightsKind
  34113. * - VertexBuffer.MatricesWeightsExtraKind
  34114. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34115. */
  34116. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34117. /**
  34118. * Sets the mesh global Vertex Buffer
  34119. * @param buffer defines the buffer to use
  34120. * @returns the current mesh
  34121. */
  34122. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34123. /**
  34124. * Update a specific associated vertex buffer
  34125. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34126. * - VertexBuffer.PositionKind
  34127. * - VertexBuffer.UVKind
  34128. * - VertexBuffer.UV2Kind
  34129. * - VertexBuffer.UV3Kind
  34130. * - VertexBuffer.UV4Kind
  34131. * - VertexBuffer.UV5Kind
  34132. * - VertexBuffer.UV6Kind
  34133. * - VertexBuffer.ColorKind
  34134. * - VertexBuffer.MatricesIndicesKind
  34135. * - VertexBuffer.MatricesIndicesExtraKind
  34136. * - VertexBuffer.MatricesWeightsKind
  34137. * - VertexBuffer.MatricesWeightsExtraKind
  34138. * @param data defines the data source
  34139. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34140. * @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)
  34141. * @returns the current mesh
  34142. */
  34143. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34144. /**
  34145. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34146. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34147. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34148. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34149. * @returns the current mesh
  34150. */
  34151. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34152. /**
  34153. * Creates a un-shared specific occurence of the geometry for the mesh.
  34154. * @returns the current mesh
  34155. */
  34156. makeGeometryUnique(): Mesh;
  34157. /**
  34158. * Set the index buffer of this mesh
  34159. * @param indices defines the source data
  34160. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34161. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34162. * @returns the current mesh
  34163. */
  34164. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34165. /**
  34166. * Update the current index buffer
  34167. * @param indices defines the source data
  34168. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34169. * @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)
  34170. * @returns the current mesh
  34171. */
  34172. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34173. /**
  34174. * Invert the geometry to move from a right handed system to a left handed one.
  34175. * @returns the current mesh
  34176. */
  34177. toLeftHanded(): Mesh;
  34178. /** @hidden */
  34179. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34180. /** @hidden */
  34181. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34182. /**
  34183. * Registers for this mesh a javascript function called just before the rendering process
  34184. * @param func defines the function to call before rendering this mesh
  34185. * @returns the current mesh
  34186. */
  34187. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34188. /**
  34189. * Disposes a previously registered javascript function called before the rendering
  34190. * @param func defines the function to remove
  34191. * @returns the current mesh
  34192. */
  34193. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34194. /**
  34195. * Registers for this mesh a javascript function called just after the rendering is complete
  34196. * @param func defines the function to call after rendering this mesh
  34197. * @returns the current mesh
  34198. */
  34199. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34200. /**
  34201. * Disposes a previously registered javascript function called after the rendering.
  34202. * @param func defines the function to remove
  34203. * @returns the current mesh
  34204. */
  34205. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34206. /** @hidden */
  34207. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34208. /** @hidden */
  34209. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34210. /** @hidden */
  34211. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34212. /** @hidden */
  34213. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34214. /** @hidden */
  34215. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34216. /** @hidden */
  34217. _rebuild(): void;
  34218. /** @hidden */
  34219. _freeze(): void;
  34220. /** @hidden */
  34221. _unFreeze(): void;
  34222. /**
  34223. * 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
  34224. * @param subMesh defines the subMesh to render
  34225. * @param enableAlphaMode defines if alpha mode can be changed
  34226. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34227. * @returns the current mesh
  34228. */
  34229. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34230. private _onBeforeDraw;
  34231. /**
  34232. * Renormalize the mesh and patch it up if there are no weights
  34233. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34234. * However in the case of zero weights then we set just a single influence to 1.
  34235. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34236. */
  34237. cleanMatrixWeights(): void;
  34238. private normalizeSkinFourWeights;
  34239. private normalizeSkinWeightsAndExtra;
  34240. /**
  34241. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34242. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34243. * the user know there was an issue with importing the mesh
  34244. * @returns a validation object with skinned, valid and report string
  34245. */
  34246. validateSkinning(): {
  34247. skinned: boolean;
  34248. valid: boolean;
  34249. report: string;
  34250. };
  34251. /** @hidden */
  34252. _checkDelayState(): Mesh;
  34253. private _queueLoad;
  34254. /**
  34255. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34256. * A mesh is in the frustum if its bounding box intersects the frustum
  34257. * @param frustumPlanes defines the frustum to test
  34258. * @returns true if the mesh is in the frustum planes
  34259. */
  34260. isInFrustum(frustumPlanes: Plane[]): boolean;
  34261. /**
  34262. * Sets the mesh material by the material or multiMaterial `id` property
  34263. * @param id is a string identifying the material or the multiMaterial
  34264. * @returns the current mesh
  34265. */
  34266. setMaterialByID(id: string): Mesh;
  34267. /**
  34268. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34269. * @returns an array of IAnimatable
  34270. */
  34271. getAnimatables(): IAnimatable[];
  34272. /**
  34273. * Modifies the mesh geometry according to the passed transformation matrix.
  34274. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34275. * The mesh normals are modified using the same transformation.
  34276. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34277. * @param transform defines the transform matrix to use
  34278. * @see https://doc.babylonjs.com/resources/baking_transformations
  34279. * @returns the current mesh
  34280. */
  34281. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34282. /**
  34283. * Modifies the mesh geometry according to its own current World Matrix.
  34284. * The mesh World Matrix is then reset.
  34285. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34286. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34287. * @see https://doc.babylonjs.com/resources/baking_transformations
  34288. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34289. * @returns the current mesh
  34290. */
  34291. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34292. /** @hidden */
  34293. get _positions(): Nullable<Vector3[]>;
  34294. /** @hidden */
  34295. _resetPointsArrayCache(): Mesh;
  34296. /** @hidden */
  34297. _generatePointsArray(): boolean;
  34298. /**
  34299. * Returns a new Mesh object generated from the current mesh properties.
  34300. * This method must not get confused with createInstance()
  34301. * @param name is a string, the name given to the new mesh
  34302. * @param newParent can be any Node object (default `null`)
  34303. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34304. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34305. * @returns a new mesh
  34306. */
  34307. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34308. /**
  34309. * Releases resources associated with this mesh.
  34310. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34311. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34312. */
  34313. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34314. /** @hidden */
  34315. _disposeInstanceSpecificData(): void;
  34316. /** @hidden */
  34317. _disposeThinInstanceSpecificData(): void;
  34318. /**
  34319. * Modifies the mesh geometry according to a displacement map.
  34320. * 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.
  34321. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34322. * @param url is a string, the URL from the image file is to be downloaded.
  34323. * @param minHeight is the lower limit of the displacement.
  34324. * @param maxHeight is the upper limit of the displacement.
  34325. * @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.
  34326. * @param uvOffset is an optional vector2 used to offset UV.
  34327. * @param uvScale is an optional vector2 used to scale UV.
  34328. * @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.
  34329. * @returns the Mesh.
  34330. */
  34331. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34332. /**
  34333. * Modifies the mesh geometry according to a displacementMap buffer.
  34334. * 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.
  34335. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34336. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34337. * @param heightMapWidth is the width of the buffer image.
  34338. * @param heightMapHeight is the height of the buffer image.
  34339. * @param minHeight is the lower limit of the displacement.
  34340. * @param maxHeight is the upper limit of the displacement.
  34341. * @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.
  34342. * @param uvOffset is an optional vector2 used to offset UV.
  34343. * @param uvScale is an optional vector2 used to scale UV.
  34344. * @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.
  34345. * @returns the Mesh.
  34346. */
  34347. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34348. /**
  34349. * Modify the mesh to get a flat shading rendering.
  34350. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34351. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34352. * @returns current mesh
  34353. */
  34354. convertToFlatShadedMesh(): Mesh;
  34355. /**
  34356. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34357. * In other words, more vertices, no more indices and a single bigger VBO.
  34358. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34359. * @returns current mesh
  34360. */
  34361. convertToUnIndexedMesh(): Mesh;
  34362. /**
  34363. * Inverses facet orientations.
  34364. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34365. * @param flipNormals will also inverts the normals
  34366. * @returns current mesh
  34367. */
  34368. flipFaces(flipNormals?: boolean): Mesh;
  34369. /**
  34370. * Increase the number of facets and hence vertices in a mesh
  34371. * Vertex normals are interpolated from existing vertex normals
  34372. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34373. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34374. */
  34375. increaseVertices(numberPerEdge: number): void;
  34376. /**
  34377. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34378. * This will undo any application of covertToFlatShadedMesh
  34379. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34380. */
  34381. forceSharedVertices(): void;
  34382. /** @hidden */
  34383. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34384. /** @hidden */
  34385. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34386. /**
  34387. * Creates a new InstancedMesh object from the mesh model.
  34388. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34389. * @param name defines the name of the new instance
  34390. * @returns a new InstancedMesh
  34391. */
  34392. createInstance(name: string): InstancedMesh;
  34393. /**
  34394. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34395. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34396. * @returns the current mesh
  34397. */
  34398. synchronizeInstances(): Mesh;
  34399. /**
  34400. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34401. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34402. * This should be used together with the simplification to avoid disappearing triangles.
  34403. * @param successCallback an optional success callback to be called after the optimization finished.
  34404. * @returns the current mesh
  34405. */
  34406. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34407. /**
  34408. * Serialize current mesh
  34409. * @param serializationObject defines the object which will receive the serialization data
  34410. */
  34411. serialize(serializationObject: any): void;
  34412. /** @hidden */
  34413. _syncGeometryWithMorphTargetManager(): void;
  34414. /** @hidden */
  34415. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34416. /**
  34417. * Returns a new Mesh object parsed from the source provided.
  34418. * @param parsedMesh is the source
  34419. * @param scene defines the hosting scene
  34420. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34421. * @returns a new Mesh
  34422. */
  34423. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34424. /**
  34425. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34427. * @param name defines the name of the mesh to create
  34428. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34429. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34430. * @param closePath creates a seam between the first and the last points of each path of the path array
  34431. * @param offset is taken in account only if the `pathArray` is containing a single path
  34432. * @param scene defines the hosting scene
  34433. * @param updatable defines if the mesh must be flagged as updatable
  34434. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34435. * @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)
  34436. * @returns a new Mesh
  34437. */
  34438. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34439. /**
  34440. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34441. * @param name defines the name of the mesh to create
  34442. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34443. * @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
  34444. * @param scene defines the hosting scene
  34445. * @param updatable defines if the mesh must be flagged as updatable
  34446. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34447. * @returns a new Mesh
  34448. */
  34449. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34450. /**
  34451. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34452. * @param name defines the name of the mesh to create
  34453. * @param size sets the size (float) of each box side (default 1)
  34454. * @param scene defines the hosting scene
  34455. * @param updatable defines if the mesh must be flagged as updatable
  34456. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34457. * @returns a new Mesh
  34458. */
  34459. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34460. /**
  34461. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34462. * @param name defines the name of the mesh to create
  34463. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34464. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34465. * @param scene defines the hosting scene
  34466. * @param updatable defines if the mesh must be flagged as updatable
  34467. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34468. * @returns a new Mesh
  34469. */
  34470. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34471. /**
  34472. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34473. * @param name defines the name of the mesh to create
  34474. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34475. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34476. * @param scene defines the hosting scene
  34477. * @returns a new Mesh
  34478. */
  34479. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34480. /**
  34481. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34482. * @param name defines the name of the mesh to create
  34483. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34484. * @param diameterTop set the top cap diameter (floats, default 1)
  34485. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34486. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34487. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34488. * @param scene defines the hosting scene
  34489. * @param updatable defines if the mesh must be flagged as updatable
  34490. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34491. * @returns a new Mesh
  34492. */
  34493. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34494. /**
  34495. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34496. * @param name defines the name of the mesh to create
  34497. * @param diameter sets the diameter size (float) of the torus (default 1)
  34498. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34499. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34500. * @param scene defines the hosting scene
  34501. * @param updatable defines if the mesh must be flagged as updatable
  34502. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34503. * @returns a new Mesh
  34504. */
  34505. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34506. /**
  34507. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34508. * @param name defines the name of the mesh to create
  34509. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34510. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34511. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34512. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34513. * @param p the number of windings on X axis (positive integers, default 2)
  34514. * @param q the number of windings on Y axis (positive integers, default 3)
  34515. * @param scene defines the hosting scene
  34516. * @param updatable defines if the mesh must be flagged as updatable
  34517. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34518. * @returns a new Mesh
  34519. */
  34520. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34521. /**
  34522. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34523. * @param name defines the name of the mesh to create
  34524. * @param points is an array successive Vector3
  34525. * @param scene defines the hosting scene
  34526. * @param updatable defines if the mesh must be flagged as updatable
  34527. * @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).
  34528. * @returns a new Mesh
  34529. */
  34530. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34531. /**
  34532. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34533. * @param name defines the name of the mesh to create
  34534. * @param points is an array successive Vector3
  34535. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34536. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34537. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34538. * @param scene defines the hosting scene
  34539. * @param updatable defines if the mesh must be flagged as updatable
  34540. * @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)
  34541. * @returns a new Mesh
  34542. */
  34543. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34544. /**
  34545. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34546. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34547. * 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.
  34548. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34549. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34550. * Remember you can only change the shape positions, not their number when updating a polygon.
  34551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34552. * @param name defines the name of the mesh to create
  34553. * @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
  34554. * @param scene defines the hosting scene
  34555. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34556. * @param updatable defines if the mesh must be flagged as updatable
  34557. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34558. * @param earcutInjection can be used to inject your own earcut reference
  34559. * @returns a new Mesh
  34560. */
  34561. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34562. /**
  34563. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34565. * @param name defines the name of the mesh to create
  34566. * @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
  34567. * @param depth defines the height of extrusion
  34568. * @param scene defines the hosting scene
  34569. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34570. * @param updatable defines if the mesh must be flagged as updatable
  34571. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34572. * @param earcutInjection can be used to inject your own earcut reference
  34573. * @returns a new Mesh
  34574. */
  34575. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34576. /**
  34577. * Creates an extruded shape mesh.
  34578. * 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
  34579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34581. * @param name defines the name of the mesh to create
  34582. * @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
  34583. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34584. * @param scale is the value to scale the shape
  34585. * @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
  34586. * @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
  34587. * @param scene defines the hosting scene
  34588. * @param updatable defines if the mesh must be flagged as updatable
  34589. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34590. * @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)
  34591. * @returns a new Mesh
  34592. */
  34593. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34594. /**
  34595. * Creates an custom extruded shape mesh.
  34596. * The custom extrusion is a parametric shape.
  34597. * It has no predefined shape. Its final shape will depend on the input parameters.
  34598. * Please consider using the same method from the MeshBuilder class instead
  34599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34600. * @param name defines the name of the mesh to create
  34601. * @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
  34602. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34603. * @param scaleFunction is a custom Javascript function called on each path point
  34604. * @param rotationFunction is a custom Javascript function called on each path point
  34605. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34606. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34607. * @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
  34608. * @param scene defines the hosting scene
  34609. * @param updatable defines if the mesh must be flagged as updatable
  34610. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34611. * @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)
  34612. * @returns a new Mesh
  34613. */
  34614. 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;
  34615. /**
  34616. * Creates lathe mesh.
  34617. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34618. * Please consider using the same method from the MeshBuilder class instead
  34619. * @param name defines the name of the mesh to create
  34620. * @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
  34621. * @param radius is the radius value of the lathe
  34622. * @param tessellation is the side number of the lathe.
  34623. * @param scene defines the hosting scene
  34624. * @param updatable defines if the mesh must be flagged as updatable
  34625. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34626. * @returns a new Mesh
  34627. */
  34628. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34629. /**
  34630. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34631. * @param name defines the name of the mesh to create
  34632. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34633. * @param scene defines the hosting scene
  34634. * @param updatable defines if the mesh must be flagged as updatable
  34635. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34636. * @returns a new Mesh
  34637. */
  34638. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34639. /**
  34640. * Creates a ground mesh.
  34641. * Please consider using the same method from the MeshBuilder class instead
  34642. * @param name defines the name of the mesh to create
  34643. * @param width set the width of the ground
  34644. * @param height set the height of the ground
  34645. * @param subdivisions sets the number of subdivisions per side
  34646. * @param scene defines the hosting scene
  34647. * @param updatable defines if the mesh must be flagged as updatable
  34648. * @returns a new Mesh
  34649. */
  34650. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34651. /**
  34652. * Creates a tiled ground mesh.
  34653. * Please consider using the same method from the MeshBuilder class instead
  34654. * @param name defines the name of the mesh to create
  34655. * @param xmin set the ground minimum X coordinate
  34656. * @param zmin set the ground minimum Y coordinate
  34657. * @param xmax set the ground maximum X coordinate
  34658. * @param zmax set the ground maximum Z coordinate
  34659. * @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
  34660. * @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
  34661. * @param scene defines the hosting scene
  34662. * @param updatable defines if the mesh must be flagged as updatable
  34663. * @returns a new Mesh
  34664. */
  34665. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34666. w: number;
  34667. h: number;
  34668. }, precision: {
  34669. w: number;
  34670. h: number;
  34671. }, scene: Scene, updatable?: boolean): Mesh;
  34672. /**
  34673. * Creates a ground mesh from a height map.
  34674. * Please consider using the same method from the MeshBuilder class instead
  34675. * @see https://doc.babylonjs.com/babylon101/height_map
  34676. * @param name defines the name of the mesh to create
  34677. * @param url sets the URL of the height map image resource
  34678. * @param width set the ground width size
  34679. * @param height set the ground height size
  34680. * @param subdivisions sets the number of subdivision per side
  34681. * @param minHeight is the minimum altitude on the ground
  34682. * @param maxHeight is the maximum altitude on the ground
  34683. * @param scene defines the hosting scene
  34684. * @param updatable defines if the mesh must be flagged as updatable
  34685. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34686. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34687. * @returns a new Mesh
  34688. */
  34689. 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;
  34690. /**
  34691. * Creates a tube mesh.
  34692. * The tube is a parametric shape.
  34693. * It has no predefined shape. Its final shape will depend on the input parameters.
  34694. * Please consider using the same method from the MeshBuilder class instead
  34695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34696. * @param name defines the name of the mesh to create
  34697. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34698. * @param radius sets the tube radius size
  34699. * @param tessellation is the number of sides on the tubular surface
  34700. * @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
  34701. * @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
  34702. * @param scene defines the hosting scene
  34703. * @param updatable defines if the mesh must be flagged as updatable
  34704. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34705. * @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)
  34706. * @returns a new Mesh
  34707. */
  34708. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34709. (i: number, distance: number): number;
  34710. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34711. /**
  34712. * Creates a polyhedron mesh.
  34713. * Please consider using the same method from the MeshBuilder class instead.
  34714. * * 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
  34715. * * The parameter `size` (positive float, default 1) sets the polygon size
  34716. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34717. * * 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`
  34718. * * 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
  34719. * * 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)`)
  34720. * * 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
  34721. * * 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
  34722. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34725. * @param name defines the name of the mesh to create
  34726. * @param options defines the options used to create the mesh
  34727. * @param scene defines the hosting scene
  34728. * @returns a new Mesh
  34729. */
  34730. static CreatePolyhedron(name: string, options: {
  34731. type?: number;
  34732. size?: number;
  34733. sizeX?: number;
  34734. sizeY?: number;
  34735. sizeZ?: number;
  34736. custom?: any;
  34737. faceUV?: Vector4[];
  34738. faceColors?: Color4[];
  34739. updatable?: boolean;
  34740. sideOrientation?: number;
  34741. }, scene: Scene): Mesh;
  34742. /**
  34743. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34744. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34745. * * 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`)
  34746. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34747. * * 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
  34748. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34751. * @param name defines the name of the mesh
  34752. * @param options defines the options used to create the mesh
  34753. * @param scene defines the hosting scene
  34754. * @returns a new Mesh
  34755. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34756. */
  34757. static CreateIcoSphere(name: string, options: {
  34758. radius?: number;
  34759. flat?: boolean;
  34760. subdivisions?: number;
  34761. sideOrientation?: number;
  34762. updatable?: boolean;
  34763. }, scene: Scene): Mesh;
  34764. /**
  34765. * Creates a decal mesh.
  34766. * Please consider using the same method from the MeshBuilder class instead.
  34767. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34768. * @param name defines the name of the mesh
  34769. * @param sourceMesh defines the mesh receiving the decal
  34770. * @param position sets the position of the decal in world coordinates
  34771. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34772. * @param size sets the decal scaling
  34773. * @param angle sets the angle to rotate the decal
  34774. * @returns a new Mesh
  34775. */
  34776. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34777. /** Creates a Capsule Mesh
  34778. * @param name defines the name of the mesh.
  34779. * @param options the constructors options used to shape the mesh.
  34780. * @param scene defines the scene the mesh is scoped to.
  34781. * @returns the capsule mesh
  34782. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34783. */
  34784. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34785. /**
  34786. * Prepare internal position array for software CPU skinning
  34787. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34788. */
  34789. setPositionsForCPUSkinning(): Float32Array;
  34790. /**
  34791. * Prepare internal normal array for software CPU skinning
  34792. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34793. */
  34794. setNormalsForCPUSkinning(): Float32Array;
  34795. /**
  34796. * Updates the vertex buffer by applying transformation from the bones
  34797. * @param skeleton defines the skeleton to apply to current mesh
  34798. * @returns the current mesh
  34799. */
  34800. applySkeleton(skeleton: Skeleton): Mesh;
  34801. /**
  34802. * 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
  34803. * @param meshes defines the list of meshes to scan
  34804. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34805. */
  34806. static MinMax(meshes: AbstractMesh[]): {
  34807. min: Vector3;
  34808. max: Vector3;
  34809. };
  34810. /**
  34811. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34812. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34813. * @returns a vector3
  34814. */
  34815. static Center(meshesOrMinMaxVector: {
  34816. min: Vector3;
  34817. max: Vector3;
  34818. } | AbstractMesh[]): Vector3;
  34819. /**
  34820. * Merge the array of meshes into a single mesh for performance reasons.
  34821. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34822. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34823. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34824. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34825. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34826. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34827. * @returns a new mesh
  34828. */
  34829. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34830. /** @hidden */
  34831. addInstance(instance: InstancedMesh): void;
  34832. /** @hidden */
  34833. removeInstance(instance: InstancedMesh): void;
  34834. }
  34835. }
  34836. declare module "babylonjs/Cameras/camera" {
  34837. import { SmartArray } from "babylonjs/Misc/smartArray";
  34838. import { Observable } from "babylonjs/Misc/observable";
  34839. import { Nullable } from "babylonjs/types";
  34840. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34841. import { Scene } from "babylonjs/scene";
  34842. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34843. import { Node } from "babylonjs/node";
  34844. import { Mesh } from "babylonjs/Meshes/mesh";
  34845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34846. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34847. import { Viewport } from "babylonjs/Maths/math.viewport";
  34848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34850. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34851. import { Ray } from "babylonjs/Culling/ray";
  34852. /**
  34853. * This is the base class of all the camera used in the application.
  34854. * @see https://doc.babylonjs.com/features/cameras
  34855. */
  34856. export class Camera extends Node {
  34857. /** @hidden */
  34858. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34859. /**
  34860. * This is the default projection mode used by the cameras.
  34861. * It helps recreating a feeling of perspective and better appreciate depth.
  34862. * This is the best way to simulate real life cameras.
  34863. */
  34864. static readonly PERSPECTIVE_CAMERA: number;
  34865. /**
  34866. * This helps creating camera with an orthographic mode.
  34867. * 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.
  34868. */
  34869. static readonly ORTHOGRAPHIC_CAMERA: number;
  34870. /**
  34871. * This is the default FOV mode for perspective cameras.
  34872. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34873. */
  34874. static readonly FOVMODE_VERTICAL_FIXED: number;
  34875. /**
  34876. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34877. */
  34878. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34879. /**
  34880. * This specifies ther is no need for a camera rig.
  34881. * Basically only one eye is rendered corresponding to the camera.
  34882. */
  34883. static readonly RIG_MODE_NONE: number;
  34884. /**
  34885. * Simulates a camera Rig with one blue eye and one red eye.
  34886. * This can be use with 3d blue and red glasses.
  34887. */
  34888. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34889. /**
  34890. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34891. */
  34892. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34893. /**
  34894. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34895. */
  34896. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34897. /**
  34898. * Defines that both eyes of the camera will be rendered over under each other.
  34899. */
  34900. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34901. /**
  34902. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34903. */
  34904. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34905. /**
  34906. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  34907. */
  34908. static readonly RIG_MODE_VR: number;
  34909. /**
  34910. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  34911. */
  34912. static readonly RIG_MODE_WEBVR: number;
  34913. /**
  34914. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  34915. */
  34916. static readonly RIG_MODE_CUSTOM: number;
  34917. /**
  34918. * Defines if by default attaching controls should prevent the default javascript event to continue.
  34919. */
  34920. static ForceAttachControlToAlwaysPreventDefault: boolean;
  34921. /**
  34922. * Define the input manager associated with the camera.
  34923. */
  34924. inputs: CameraInputsManager<Camera>;
  34925. /** @hidden */
  34926. _position: Vector3;
  34927. /**
  34928. * Define the current local position of the camera in the scene
  34929. */
  34930. get position(): Vector3;
  34931. set position(newPosition: Vector3);
  34932. protected _upVector: Vector3;
  34933. /**
  34934. * The vector the camera should consider as up.
  34935. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34936. */
  34937. set upVector(vec: Vector3);
  34938. get upVector(): Vector3;
  34939. /**
  34940. * Define the current limit on the left side for an orthographic camera
  34941. * In scene unit
  34942. */
  34943. orthoLeft: Nullable<number>;
  34944. /**
  34945. * Define the current limit on the right side for an orthographic camera
  34946. * In scene unit
  34947. */
  34948. orthoRight: Nullable<number>;
  34949. /**
  34950. * Define the current limit on the bottom side for an orthographic camera
  34951. * In scene unit
  34952. */
  34953. orthoBottom: Nullable<number>;
  34954. /**
  34955. * Define the current limit on the top side for an orthographic camera
  34956. * In scene unit
  34957. */
  34958. orthoTop: Nullable<number>;
  34959. /**
  34960. * Field Of View is set in Radians. (default is 0.8)
  34961. */
  34962. fov: number;
  34963. /**
  34964. * Define the minimum distance the camera can see from.
  34965. * This is important to note that the depth buffer are not infinite and the closer it starts
  34966. * the more your scene might encounter depth fighting issue.
  34967. */
  34968. minZ: number;
  34969. /**
  34970. * Define the maximum distance the camera can see to.
  34971. * This is important to note that the depth buffer are not infinite and the further it end
  34972. * the more your scene might encounter depth fighting issue.
  34973. */
  34974. maxZ: number;
  34975. /**
  34976. * Define the default inertia of the camera.
  34977. * This helps giving a smooth feeling to the camera movement.
  34978. */
  34979. inertia: number;
  34980. /**
  34981. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34982. */
  34983. mode: number;
  34984. /**
  34985. * Define whether the camera is intermediate.
  34986. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34987. */
  34988. isIntermediate: boolean;
  34989. /**
  34990. * Define the viewport of the camera.
  34991. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34992. */
  34993. viewport: Viewport;
  34994. /**
  34995. * Restricts the camera to viewing objects with the same layerMask.
  34996. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34997. */
  34998. layerMask: number;
  34999. /**
  35000. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35001. */
  35002. fovMode: number;
  35003. /**
  35004. * Rig mode of the camera.
  35005. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35006. * This is normally controlled byt the camera themselves as internal use.
  35007. */
  35008. cameraRigMode: number;
  35009. /**
  35010. * Defines the distance between both "eyes" in case of a RIG
  35011. */
  35012. interaxialDistance: number;
  35013. /**
  35014. * Defines if stereoscopic rendering is done side by side or over under.
  35015. */
  35016. isStereoscopicSideBySide: boolean;
  35017. /**
  35018. * 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
  35019. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35020. * else in the scene. (Eg. security camera)
  35021. *
  35022. * 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)
  35023. */
  35024. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35025. /**
  35026. * When set, the camera will render to this render target instead of the default canvas
  35027. *
  35028. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35029. */
  35030. outputRenderTarget: Nullable<RenderTargetTexture>;
  35031. /**
  35032. * Observable triggered when the camera view matrix has changed.
  35033. */
  35034. onViewMatrixChangedObservable: Observable<Camera>;
  35035. /**
  35036. * Observable triggered when the camera Projection matrix has changed.
  35037. */
  35038. onProjectionMatrixChangedObservable: Observable<Camera>;
  35039. /**
  35040. * Observable triggered when the inputs have been processed.
  35041. */
  35042. onAfterCheckInputsObservable: Observable<Camera>;
  35043. /**
  35044. * Observable triggered when reset has been called and applied to the camera.
  35045. */
  35046. onRestoreStateObservable: Observable<Camera>;
  35047. /**
  35048. * Is this camera a part of a rig system?
  35049. */
  35050. isRigCamera: boolean;
  35051. /**
  35052. * If isRigCamera set to true this will be set with the parent camera.
  35053. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35054. */
  35055. rigParent?: Camera;
  35056. /** @hidden */
  35057. _cameraRigParams: any;
  35058. /** @hidden */
  35059. _rigCameras: Camera[];
  35060. /** @hidden */
  35061. _rigPostProcess: Nullable<PostProcess>;
  35062. protected _webvrViewMatrix: Matrix;
  35063. /** @hidden */
  35064. _skipRendering: boolean;
  35065. /** @hidden */
  35066. _projectionMatrix: Matrix;
  35067. /** @hidden */
  35068. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35069. /** @hidden */
  35070. _activeMeshes: SmartArray<AbstractMesh>;
  35071. protected _globalPosition: Vector3;
  35072. /** @hidden */
  35073. _computedViewMatrix: Matrix;
  35074. private _doNotComputeProjectionMatrix;
  35075. private _transformMatrix;
  35076. private _frustumPlanes;
  35077. private _refreshFrustumPlanes;
  35078. private _storedFov;
  35079. private _stateStored;
  35080. /**
  35081. * Instantiates a new camera object.
  35082. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35083. * @see https://doc.babylonjs.com/features/cameras
  35084. * @param name Defines the name of the camera in the scene
  35085. * @param position Defines the position of the camera
  35086. * @param scene Defines the scene the camera belongs too
  35087. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35088. */
  35089. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35090. /**
  35091. * Store current camera state (fov, position, etc..)
  35092. * @returns the camera
  35093. */
  35094. storeState(): Camera;
  35095. /**
  35096. * Restores the camera state values if it has been stored. You must call storeState() first
  35097. */
  35098. protected _restoreStateValues(): boolean;
  35099. /**
  35100. * Restored camera state. You must call storeState() first.
  35101. * @returns true if restored and false otherwise
  35102. */
  35103. restoreState(): boolean;
  35104. /**
  35105. * Gets the class name of the camera.
  35106. * @returns the class name
  35107. */
  35108. getClassName(): string;
  35109. /** @hidden */
  35110. readonly _isCamera: boolean;
  35111. /**
  35112. * Gets a string representation of the camera useful for debug purpose.
  35113. * @param fullDetails Defines that a more verboe level of logging is required
  35114. * @returns the string representation
  35115. */
  35116. toString(fullDetails?: boolean): string;
  35117. /**
  35118. * Gets the current world space position of the camera.
  35119. */
  35120. get globalPosition(): Vector3;
  35121. /**
  35122. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35123. * @returns the active meshe list
  35124. */
  35125. getActiveMeshes(): SmartArray<AbstractMesh>;
  35126. /**
  35127. * Check whether a mesh is part of the current active mesh list of the camera
  35128. * @param mesh Defines the mesh to check
  35129. * @returns true if active, false otherwise
  35130. */
  35131. isActiveMesh(mesh: Mesh): boolean;
  35132. /**
  35133. * Is this camera ready to be used/rendered
  35134. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35135. * @return true if the camera is ready
  35136. */
  35137. isReady(completeCheck?: boolean): boolean;
  35138. /** @hidden */
  35139. _initCache(): void;
  35140. /** @hidden */
  35141. _updateCache(ignoreParentClass?: boolean): void;
  35142. /** @hidden */
  35143. _isSynchronized(): boolean;
  35144. /** @hidden */
  35145. _isSynchronizedViewMatrix(): boolean;
  35146. /** @hidden */
  35147. _isSynchronizedProjectionMatrix(): boolean;
  35148. /**
  35149. * Attach the input controls to a specific dom element to get the input from.
  35150. * @param element Defines the element the controls should be listened from
  35151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35152. */
  35153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35154. /**
  35155. * Detach the current controls from the specified dom element.
  35156. * @param element Defines the element to stop listening the inputs from
  35157. */
  35158. detachControl(element: HTMLElement): void;
  35159. /**
  35160. * Update the camera state according to the different inputs gathered during the frame.
  35161. */
  35162. update(): void;
  35163. /** @hidden */
  35164. _checkInputs(): void;
  35165. /** @hidden */
  35166. get rigCameras(): Camera[];
  35167. /**
  35168. * Gets the post process used by the rig cameras
  35169. */
  35170. get rigPostProcess(): Nullable<PostProcess>;
  35171. /**
  35172. * Internal, gets the first post proces.
  35173. * @returns the first post process to be run on this camera.
  35174. */
  35175. _getFirstPostProcess(): Nullable<PostProcess>;
  35176. private _cascadePostProcessesToRigCams;
  35177. /**
  35178. * Attach a post process to the camera.
  35179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35180. * @param postProcess The post process to attach to the camera
  35181. * @param insertAt The position of the post process in case several of them are in use in the scene
  35182. * @returns the position the post process has been inserted at
  35183. */
  35184. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35185. /**
  35186. * Detach a post process to the camera.
  35187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35188. * @param postProcess The post process to detach from the camera
  35189. */
  35190. detachPostProcess(postProcess: PostProcess): void;
  35191. /**
  35192. * Gets the current world matrix of the camera
  35193. */
  35194. getWorldMatrix(): Matrix;
  35195. /** @hidden */
  35196. _getViewMatrix(): Matrix;
  35197. /**
  35198. * Gets the current view matrix of the camera.
  35199. * @param force forces the camera to recompute the matrix without looking at the cached state
  35200. * @returns the view matrix
  35201. */
  35202. getViewMatrix(force?: boolean): Matrix;
  35203. /**
  35204. * Freeze the projection matrix.
  35205. * It will prevent the cache check of the camera projection compute and can speed up perf
  35206. * if no parameter of the camera are meant to change
  35207. * @param projection Defines manually a projection if necessary
  35208. */
  35209. freezeProjectionMatrix(projection?: Matrix): void;
  35210. /**
  35211. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35212. */
  35213. unfreezeProjectionMatrix(): void;
  35214. /**
  35215. * Gets the current projection matrix of the camera.
  35216. * @param force forces the camera to recompute the matrix without looking at the cached state
  35217. * @returns the projection matrix
  35218. */
  35219. getProjectionMatrix(force?: boolean): Matrix;
  35220. /**
  35221. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35222. * @returns a Matrix
  35223. */
  35224. getTransformationMatrix(): Matrix;
  35225. private _updateFrustumPlanes;
  35226. /**
  35227. * Checks if a cullable object (mesh...) is in the camera frustum
  35228. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35229. * @param target The object to check
  35230. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35231. * @returns true if the object is in frustum otherwise false
  35232. */
  35233. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35234. /**
  35235. * Checks if a cullable object (mesh...) is in the camera frustum
  35236. * Unlike isInFrustum this cheks the full bounding box
  35237. * @param target The object to check
  35238. * @returns true if the object is in frustum otherwise false
  35239. */
  35240. isCompletelyInFrustum(target: ICullable): boolean;
  35241. /**
  35242. * Gets a ray in the forward direction from the camera.
  35243. * @param length Defines the length of the ray to create
  35244. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35245. * @param origin Defines the start point of the ray which defaults to the camera position
  35246. * @returns the forward ray
  35247. */
  35248. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35249. /**
  35250. * Gets a ray in the forward direction from the camera.
  35251. * @param refRay the ray to (re)use when setting the values
  35252. * @param length Defines the length of the ray to create
  35253. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35254. * @param origin Defines the start point of the ray which defaults to the camera position
  35255. * @returns the forward ray
  35256. */
  35257. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35258. /**
  35259. * Releases resources associated with this node.
  35260. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35261. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35262. */
  35263. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35264. /** @hidden */
  35265. _isLeftCamera: boolean;
  35266. /**
  35267. * Gets the left camera of a rig setup in case of Rigged Camera
  35268. */
  35269. get isLeftCamera(): boolean;
  35270. /** @hidden */
  35271. _isRightCamera: boolean;
  35272. /**
  35273. * Gets the right camera of a rig setup in case of Rigged Camera
  35274. */
  35275. get isRightCamera(): boolean;
  35276. /**
  35277. * Gets the left camera of a rig setup in case of Rigged Camera
  35278. */
  35279. get leftCamera(): Nullable<FreeCamera>;
  35280. /**
  35281. * Gets the right camera of a rig setup in case of Rigged Camera
  35282. */
  35283. get rightCamera(): Nullable<FreeCamera>;
  35284. /**
  35285. * Gets the left camera target of a rig setup in case of Rigged Camera
  35286. * @returns the target position
  35287. */
  35288. getLeftTarget(): Nullable<Vector3>;
  35289. /**
  35290. * Gets the right camera target of a rig setup in case of Rigged Camera
  35291. * @returns the target position
  35292. */
  35293. getRightTarget(): Nullable<Vector3>;
  35294. /**
  35295. * @hidden
  35296. */
  35297. setCameraRigMode(mode: number, rigParams: any): void;
  35298. /** @hidden */
  35299. static _setStereoscopicRigMode(camera: Camera): void;
  35300. /** @hidden */
  35301. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35302. /** @hidden */
  35303. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35304. /** @hidden */
  35305. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35306. /** @hidden */
  35307. _getVRProjectionMatrix(): Matrix;
  35308. protected _updateCameraRotationMatrix(): void;
  35309. protected _updateWebVRCameraRotationMatrix(): void;
  35310. /**
  35311. * This function MUST be overwritten by the different WebVR cameras available.
  35312. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35313. * @hidden
  35314. */
  35315. _getWebVRProjectionMatrix(): Matrix;
  35316. /**
  35317. * This function MUST be overwritten by the different WebVR cameras available.
  35318. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35319. * @hidden
  35320. */
  35321. _getWebVRViewMatrix(): Matrix;
  35322. /** @hidden */
  35323. setCameraRigParameter(name: string, value: any): void;
  35324. /**
  35325. * needs to be overridden by children so sub has required properties to be copied
  35326. * @hidden
  35327. */
  35328. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35329. /**
  35330. * May need to be overridden by children
  35331. * @hidden
  35332. */
  35333. _updateRigCameras(): void;
  35334. /** @hidden */
  35335. _setupInputs(): void;
  35336. /**
  35337. * Serialiaze the camera setup to a json represention
  35338. * @returns the JSON representation
  35339. */
  35340. serialize(): any;
  35341. /**
  35342. * Clones the current camera.
  35343. * @param name The cloned camera name
  35344. * @returns the cloned camera
  35345. */
  35346. clone(name: string): Camera;
  35347. /**
  35348. * Gets the direction of the camera relative to a given local axis.
  35349. * @param localAxis Defines the reference axis to provide a relative direction.
  35350. * @return the direction
  35351. */
  35352. getDirection(localAxis: Vector3): Vector3;
  35353. /**
  35354. * Returns the current camera absolute rotation
  35355. */
  35356. get absoluteRotation(): Quaternion;
  35357. /**
  35358. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35359. * @param localAxis Defines the reference axis to provide a relative direction.
  35360. * @param result Defines the vector to store the result in
  35361. */
  35362. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35363. /**
  35364. * Gets a camera constructor for a given camera type
  35365. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35366. * @param name The name of the camera the result will be able to instantiate
  35367. * @param scene The scene the result will construct the camera in
  35368. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35369. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35370. * @returns a factory method to construc the camera
  35371. */
  35372. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35373. /**
  35374. * Compute the world matrix of the camera.
  35375. * @returns the camera world matrix
  35376. */
  35377. computeWorldMatrix(): Matrix;
  35378. /**
  35379. * Parse a JSON and creates the camera from the parsed information
  35380. * @param parsedCamera The JSON to parse
  35381. * @param scene The scene to instantiate the camera in
  35382. * @returns the newly constructed camera
  35383. */
  35384. static Parse(parsedCamera: any, scene: Scene): Camera;
  35385. }
  35386. }
  35387. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35388. import { Nullable } from "babylonjs/types";
  35389. import { Scene } from "babylonjs/scene";
  35390. import { Vector4 } from "babylonjs/Maths/math.vector";
  35391. import { Mesh } from "babylonjs/Meshes/mesh";
  35392. /**
  35393. * Class containing static functions to help procedurally build meshes
  35394. */
  35395. export class DiscBuilder {
  35396. /**
  35397. * Creates a plane polygonal mesh. By default, this is a disc
  35398. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35399. * * 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
  35400. * * 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
  35401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35404. * @param name defines the name of the mesh
  35405. * @param options defines the options used to create the mesh
  35406. * @param scene defines the hosting scene
  35407. * @returns the plane polygonal mesh
  35408. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35409. */
  35410. static CreateDisc(name: string, options: {
  35411. radius?: number;
  35412. tessellation?: number;
  35413. arc?: number;
  35414. updatable?: boolean;
  35415. sideOrientation?: number;
  35416. frontUVs?: Vector4;
  35417. backUVs?: Vector4;
  35418. }, scene?: Nullable<Scene>): Mesh;
  35419. }
  35420. }
  35421. declare module "babylonjs/Particles/solidParticleSystem" {
  35422. import { Nullable } from "babylonjs/types";
  35423. import { Mesh } from "babylonjs/Meshes/mesh";
  35424. import { Scene, IDisposable } from "babylonjs/scene";
  35425. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35426. import { Material } from "babylonjs/Materials/material";
  35427. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35428. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35429. /**
  35430. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35431. *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.
  35432. * The SPS is also a particle system. It provides some methods to manage the particles.
  35433. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35434. *
  35435. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35436. */
  35437. export class SolidParticleSystem implements IDisposable {
  35438. /**
  35439. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35440. * Example : var p = SPS.particles[i];
  35441. */
  35442. particles: SolidParticle[];
  35443. /**
  35444. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35445. */
  35446. nbParticles: number;
  35447. /**
  35448. * If the particles must ever face the camera (default false). Useful for planar particles.
  35449. */
  35450. billboard: boolean;
  35451. /**
  35452. * Recompute normals when adding a shape
  35453. */
  35454. recomputeNormals: boolean;
  35455. /**
  35456. * This a counter ofr your own usage. It's not set by any SPS functions.
  35457. */
  35458. counter: number;
  35459. /**
  35460. * The SPS name. This name is also given to the underlying mesh.
  35461. */
  35462. name: string;
  35463. /**
  35464. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35465. */
  35466. mesh: Mesh;
  35467. /**
  35468. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35469. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35470. */
  35471. vars: any;
  35472. /**
  35473. * This array is populated when the SPS is set as 'pickable'.
  35474. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35475. * Each element of this array is an object `{idx: int, faceId: int}`.
  35476. * `idx` is the picked particle index in the `SPS.particles` array
  35477. * `faceId` is the picked face index counted within this particle.
  35478. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35479. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35480. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35481. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35482. */
  35483. pickedParticles: {
  35484. idx: number;
  35485. faceId: number;
  35486. }[];
  35487. /**
  35488. * This array is populated when the SPS is set as 'pickable'
  35489. * Each key of this array is a submesh index.
  35490. * Each element of this array is a second array defined like this :
  35491. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35492. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35493. * `idx` is the picked particle index in the `SPS.particles` array
  35494. * `faceId` is the picked face index counted within this particle.
  35495. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35496. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35497. */
  35498. pickedBySubMesh: {
  35499. idx: number;
  35500. faceId: number;
  35501. }[][];
  35502. /**
  35503. * This array is populated when `enableDepthSort` is set to true.
  35504. * Each element of this array is an instance of the class DepthSortedParticle.
  35505. */
  35506. depthSortedParticles: DepthSortedParticle[];
  35507. /**
  35508. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35509. * @hidden
  35510. */
  35511. _bSphereOnly: boolean;
  35512. /**
  35513. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35514. * @hidden
  35515. */
  35516. _bSphereRadiusFactor: number;
  35517. private _scene;
  35518. private _positions;
  35519. private _indices;
  35520. private _normals;
  35521. private _colors;
  35522. private _uvs;
  35523. private _indices32;
  35524. private _positions32;
  35525. private _normals32;
  35526. private _fixedNormal32;
  35527. private _colors32;
  35528. private _uvs32;
  35529. private _index;
  35530. private _updatable;
  35531. private _pickable;
  35532. private _isVisibilityBoxLocked;
  35533. private _alwaysVisible;
  35534. private _depthSort;
  35535. private _expandable;
  35536. private _shapeCounter;
  35537. private _copy;
  35538. private _color;
  35539. private _computeParticleColor;
  35540. private _computeParticleTexture;
  35541. private _computeParticleRotation;
  35542. private _computeParticleVertex;
  35543. private _computeBoundingBox;
  35544. private _depthSortParticles;
  35545. private _camera;
  35546. private _mustUnrotateFixedNormals;
  35547. private _particlesIntersect;
  35548. private _needs32Bits;
  35549. private _isNotBuilt;
  35550. private _lastParticleId;
  35551. private _idxOfId;
  35552. private _multimaterialEnabled;
  35553. private _useModelMaterial;
  35554. private _indicesByMaterial;
  35555. private _materialIndexes;
  35556. private _depthSortFunction;
  35557. private _materialSortFunction;
  35558. private _materials;
  35559. private _multimaterial;
  35560. private _materialIndexesById;
  35561. private _defaultMaterial;
  35562. private _autoUpdateSubMeshes;
  35563. private _tmpVertex;
  35564. /**
  35565. * Creates a SPS (Solid Particle System) object.
  35566. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35567. * @param scene (Scene) is the scene in which the SPS is added.
  35568. * @param options defines the options of the sps e.g.
  35569. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35570. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35571. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35572. * * 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.
  35573. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35574. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35575. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35576. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35577. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35578. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35579. */
  35580. constructor(name: string, scene: Scene, options?: {
  35581. updatable?: boolean;
  35582. isPickable?: boolean;
  35583. enableDepthSort?: boolean;
  35584. particleIntersection?: boolean;
  35585. boundingSphereOnly?: boolean;
  35586. bSphereRadiusFactor?: number;
  35587. expandable?: boolean;
  35588. useModelMaterial?: boolean;
  35589. enableMultiMaterial?: boolean;
  35590. });
  35591. /**
  35592. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35593. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35594. * @returns the created mesh
  35595. */
  35596. buildMesh(): Mesh;
  35597. /**
  35598. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35599. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35600. * Thus the particles generated from `digest()` have their property `position` set yet.
  35601. * @param mesh ( Mesh ) is the mesh to be digested
  35602. * @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
  35603. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35604. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35605. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35606. * @returns the current SPS
  35607. */
  35608. digest(mesh: Mesh, options?: {
  35609. facetNb?: number;
  35610. number?: number;
  35611. delta?: number;
  35612. storage?: [];
  35613. }): SolidParticleSystem;
  35614. /**
  35615. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35616. * @hidden
  35617. */
  35618. private _unrotateFixedNormals;
  35619. /**
  35620. * Resets the temporary working copy particle
  35621. * @hidden
  35622. */
  35623. private _resetCopy;
  35624. /**
  35625. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35626. * @param p the current index in the positions array to be updated
  35627. * @param ind the current index in the indices array
  35628. * @param shape a Vector3 array, the shape geometry
  35629. * @param positions the positions array to be updated
  35630. * @param meshInd the shape indices array
  35631. * @param indices the indices array to be updated
  35632. * @param meshUV the shape uv array
  35633. * @param uvs the uv array to be updated
  35634. * @param meshCol the shape color array
  35635. * @param colors the color array to be updated
  35636. * @param meshNor the shape normals array
  35637. * @param normals the normals array to be updated
  35638. * @param idx the particle index
  35639. * @param idxInShape the particle index in its shape
  35640. * @param options the addShape() method passed options
  35641. * @model the particle model
  35642. * @hidden
  35643. */
  35644. private _meshBuilder;
  35645. /**
  35646. * Returns a shape Vector3 array from positions float array
  35647. * @param positions float array
  35648. * @returns a vector3 array
  35649. * @hidden
  35650. */
  35651. private _posToShape;
  35652. /**
  35653. * Returns a shapeUV array from a float uvs (array deep copy)
  35654. * @param uvs as a float array
  35655. * @returns a shapeUV array
  35656. * @hidden
  35657. */
  35658. private _uvsToShapeUV;
  35659. /**
  35660. * Adds a new particle object in the particles array
  35661. * @param idx particle index in particles array
  35662. * @param id particle id
  35663. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35664. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35665. * @param model particle ModelShape object
  35666. * @param shapeId model shape identifier
  35667. * @param idxInShape index of the particle in the current model
  35668. * @param bInfo model bounding info object
  35669. * @param storage target storage array, if any
  35670. * @hidden
  35671. */
  35672. private _addParticle;
  35673. /**
  35674. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35675. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35676. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35677. * @param nb (positive integer) the number of particles to be created from this model
  35678. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35679. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35680. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35681. * @returns the number of shapes in the system
  35682. */
  35683. addShape(mesh: Mesh, nb: number, options?: {
  35684. positionFunction?: any;
  35685. vertexFunction?: any;
  35686. storage?: [];
  35687. }): number;
  35688. /**
  35689. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35690. * @hidden
  35691. */
  35692. private _rebuildParticle;
  35693. /**
  35694. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35695. * @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.
  35696. * @returns the SPS.
  35697. */
  35698. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35699. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35700. * Returns an array with the removed particles.
  35701. * 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.
  35702. * The SPS can't be empty so at least one particle needs to remain in place.
  35703. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35704. * @param start index of the first particle to remove
  35705. * @param end index of the last particle to remove (included)
  35706. * @returns an array populated with the removed particles
  35707. */
  35708. removeParticles(start: number, end: number): SolidParticle[];
  35709. /**
  35710. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35711. * @param solidParticleArray an array populated with Solid Particles objects
  35712. * @returns the SPS
  35713. */
  35714. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35715. /**
  35716. * Creates a new particle and modifies the SPS mesh geometry :
  35717. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35718. * - calls _addParticle() to populate the particle array
  35719. * factorized code from addShape() and insertParticlesFromArray()
  35720. * @param idx particle index in the particles array
  35721. * @param i particle index in its shape
  35722. * @param modelShape particle ModelShape object
  35723. * @param shape shape vertex array
  35724. * @param meshInd shape indices array
  35725. * @param meshUV shape uv array
  35726. * @param meshCol shape color array
  35727. * @param meshNor shape normals array
  35728. * @param bbInfo shape bounding info
  35729. * @param storage target particle storage
  35730. * @options addShape() passed options
  35731. * @hidden
  35732. */
  35733. private _insertNewParticle;
  35734. /**
  35735. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35736. * This method calls `updateParticle()` for each particle of the SPS.
  35737. * For an animated SPS, it is usually called within the render loop.
  35738. * 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.
  35739. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35740. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35741. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35742. * @returns the SPS.
  35743. */
  35744. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35745. /**
  35746. * Disposes the SPS.
  35747. */
  35748. dispose(): void;
  35749. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35750. * idx is the particle index in the SPS
  35751. * faceId is the picked face index counted within this particle.
  35752. * Returns null if the pickInfo can't identify a picked particle.
  35753. * @param pickingInfo (PickingInfo object)
  35754. * @returns {idx: number, faceId: number} or null
  35755. */
  35756. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35757. idx: number;
  35758. faceId: number;
  35759. }>;
  35760. /**
  35761. * Returns a SolidParticle object from its identifier : particle.id
  35762. * @param id (integer) the particle Id
  35763. * @returns the searched particle or null if not found in the SPS.
  35764. */
  35765. getParticleById(id: number): Nullable<SolidParticle>;
  35766. /**
  35767. * Returns a new array populated with the particles having the passed shapeId.
  35768. * @param shapeId (integer) the shape identifier
  35769. * @returns a new solid particle array
  35770. */
  35771. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35772. /**
  35773. * Populates the passed array "ref" with the particles having the passed shapeId.
  35774. * @param shapeId the shape identifier
  35775. * @returns the SPS
  35776. * @param ref
  35777. */
  35778. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35779. /**
  35780. * Computes the required SubMeshes according the materials assigned to the particles.
  35781. * @returns the solid particle system.
  35782. * Does nothing if called before the SPS mesh is built.
  35783. */
  35784. computeSubMeshes(): SolidParticleSystem;
  35785. /**
  35786. * Sorts the solid particles by material when MultiMaterial is enabled.
  35787. * Updates the indices32 array.
  35788. * Updates the indicesByMaterial array.
  35789. * Updates the mesh indices array.
  35790. * @returns the SPS
  35791. * @hidden
  35792. */
  35793. private _sortParticlesByMaterial;
  35794. /**
  35795. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35796. * @hidden
  35797. */
  35798. private _setMaterialIndexesById;
  35799. /**
  35800. * Returns an array with unique values of Materials from the passed array
  35801. * @param array the material array to be checked and filtered
  35802. * @hidden
  35803. */
  35804. private _filterUniqueMaterialId;
  35805. /**
  35806. * Sets a new Standard Material as _defaultMaterial if not already set.
  35807. * @hidden
  35808. */
  35809. private _setDefaultMaterial;
  35810. /**
  35811. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35812. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35813. * @returns the SPS.
  35814. */
  35815. refreshVisibleSize(): SolidParticleSystem;
  35816. /**
  35817. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35818. * @param size the size (float) of the visibility box
  35819. * note : this doesn't lock the SPS mesh bounding box.
  35820. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35821. */
  35822. setVisibilityBox(size: number): void;
  35823. /**
  35824. * Gets whether the SPS as always visible or not
  35825. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35826. */
  35827. get isAlwaysVisible(): boolean;
  35828. /**
  35829. * Sets the SPS as always visible or not
  35830. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35831. */
  35832. set isAlwaysVisible(val: boolean);
  35833. /**
  35834. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35835. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35836. */
  35837. set isVisibilityBoxLocked(val: boolean);
  35838. /**
  35839. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35840. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35841. */
  35842. get isVisibilityBoxLocked(): boolean;
  35843. /**
  35844. * Tells to `setParticles()` to compute the particle rotations or not.
  35845. * Default value : true. The SPS is faster when it's set to false.
  35846. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35847. */
  35848. set computeParticleRotation(val: boolean);
  35849. /**
  35850. * Tells to `setParticles()` to compute the particle colors or not.
  35851. * Default value : true. The SPS is faster when it's set to false.
  35852. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35853. */
  35854. set computeParticleColor(val: boolean);
  35855. set computeParticleTexture(val: boolean);
  35856. /**
  35857. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35858. * Default value : false. The SPS is faster when it's set to false.
  35859. * Note : the particle custom vertex positions aren't stored values.
  35860. */
  35861. set computeParticleVertex(val: boolean);
  35862. /**
  35863. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35864. */
  35865. set computeBoundingBox(val: boolean);
  35866. /**
  35867. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35868. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35869. * Default : `true`
  35870. */
  35871. set depthSortParticles(val: boolean);
  35872. /**
  35873. * Gets if `setParticles()` computes the particle rotations or not.
  35874. * Default value : true. The SPS is faster when it's set to false.
  35875. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35876. */
  35877. get computeParticleRotation(): boolean;
  35878. /**
  35879. * Gets if `setParticles()` computes the particle colors or not.
  35880. * Default value : true. The SPS is faster when it's set to false.
  35881. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35882. */
  35883. get computeParticleColor(): boolean;
  35884. /**
  35885. * Gets if `setParticles()` computes the particle textures or not.
  35886. * Default value : true. The SPS is faster when it's set to false.
  35887. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35888. */
  35889. get computeParticleTexture(): boolean;
  35890. /**
  35891. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35892. * Default value : false. The SPS is faster when it's set to false.
  35893. * Note : the particle custom vertex positions aren't stored values.
  35894. */
  35895. get computeParticleVertex(): boolean;
  35896. /**
  35897. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35898. */
  35899. get computeBoundingBox(): boolean;
  35900. /**
  35901. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35902. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35903. * Default : `true`
  35904. */
  35905. get depthSortParticles(): boolean;
  35906. /**
  35907. * Gets if the SPS is created as expandable at construction time.
  35908. * Default : `false`
  35909. */
  35910. get expandable(): boolean;
  35911. /**
  35912. * Gets if the SPS supports the Multi Materials
  35913. */
  35914. get multimaterialEnabled(): boolean;
  35915. /**
  35916. * Gets if the SPS uses the model materials for its own multimaterial.
  35917. */
  35918. get useModelMaterial(): boolean;
  35919. /**
  35920. * The SPS used material array.
  35921. */
  35922. get materials(): Material[];
  35923. /**
  35924. * Sets the SPS MultiMaterial from the passed materials.
  35925. * Note : the passed array is internally copied and not used then by reference.
  35926. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35927. */
  35928. setMultiMaterial(materials: Material[]): void;
  35929. /**
  35930. * The SPS computed multimaterial object
  35931. */
  35932. get multimaterial(): MultiMaterial;
  35933. set multimaterial(mm: MultiMaterial);
  35934. /**
  35935. * If the subMeshes must be updated on the next call to setParticles()
  35936. */
  35937. get autoUpdateSubMeshes(): boolean;
  35938. set autoUpdateSubMeshes(val: boolean);
  35939. /**
  35940. * This function does nothing. It may be overwritten to set all the particle first values.
  35941. * The SPS doesn't call this function, you may have to call it by your own.
  35942. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35943. */
  35944. initParticles(): void;
  35945. /**
  35946. * This function does nothing. It may be overwritten to recycle a particle.
  35947. * The SPS doesn't call this function, you may have to call it by your own.
  35948. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35949. * @param particle The particle to recycle
  35950. * @returns the recycled particle
  35951. */
  35952. recycleParticle(particle: SolidParticle): SolidParticle;
  35953. /**
  35954. * Updates a particle : this function should be overwritten by the user.
  35955. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35956. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35957. * @example : just set a particle position or velocity and recycle conditions
  35958. * @param particle The particle to update
  35959. * @returns the updated particle
  35960. */
  35961. updateParticle(particle: SolidParticle): SolidParticle;
  35962. /**
  35963. * Updates a vertex of a particle : it can be overwritten by the user.
  35964. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35965. * @param particle the current particle
  35966. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35967. * @param pt the index of the current vertex in the particle shape
  35968. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35969. * @example : just set a vertex particle position or color
  35970. * @returns the sps
  35971. */
  35972. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35973. /**
  35974. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35975. * This does nothing and may be overwritten by the user.
  35976. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35977. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35978. * @param update the boolean update value actually passed to setParticles()
  35979. */
  35980. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35981. /**
  35982. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35983. * This will be passed three parameters.
  35984. * This does nothing and may be overwritten by the user.
  35985. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35986. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35987. * @param update the boolean update value actually passed to setParticles()
  35988. */
  35989. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35990. }
  35991. }
  35992. declare module "babylonjs/Particles/solidParticle" {
  35993. import { Nullable } from "babylonjs/types";
  35994. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  35995. import { Color4 } from "babylonjs/Maths/math.color";
  35996. import { Mesh } from "babylonjs/Meshes/mesh";
  35997. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  35998. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  35999. import { Plane } from "babylonjs/Maths/math.plane";
  36000. import { Material } from "babylonjs/Materials/material";
  36001. /**
  36002. * Represents one particle of a solid particle system.
  36003. */
  36004. export class SolidParticle {
  36005. /**
  36006. * particle global index
  36007. */
  36008. idx: number;
  36009. /**
  36010. * particle identifier
  36011. */
  36012. id: number;
  36013. /**
  36014. * The color of the particle
  36015. */
  36016. color: Nullable<Color4>;
  36017. /**
  36018. * The world space position of the particle.
  36019. */
  36020. position: Vector3;
  36021. /**
  36022. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36023. */
  36024. rotation: Vector3;
  36025. /**
  36026. * The world space rotation quaternion of the particle.
  36027. */
  36028. rotationQuaternion: Nullable<Quaternion>;
  36029. /**
  36030. * The scaling of the particle.
  36031. */
  36032. scaling: Vector3;
  36033. /**
  36034. * The uvs of the particle.
  36035. */
  36036. uvs: Vector4;
  36037. /**
  36038. * The current speed of the particle.
  36039. */
  36040. velocity: Vector3;
  36041. /**
  36042. * The pivot point in the particle local space.
  36043. */
  36044. pivot: Vector3;
  36045. /**
  36046. * Must the particle be translated from its pivot point in its local space ?
  36047. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36048. * Default : false
  36049. */
  36050. translateFromPivot: boolean;
  36051. /**
  36052. * Is the particle active or not ?
  36053. */
  36054. alive: boolean;
  36055. /**
  36056. * Is the particle visible or not ?
  36057. */
  36058. isVisible: boolean;
  36059. /**
  36060. * Index of this particle in the global "positions" array (Internal use)
  36061. * @hidden
  36062. */
  36063. _pos: number;
  36064. /**
  36065. * @hidden Index of this particle in the global "indices" array (Internal use)
  36066. */
  36067. _ind: number;
  36068. /**
  36069. * @hidden ModelShape of this particle (Internal use)
  36070. */
  36071. _model: ModelShape;
  36072. /**
  36073. * ModelShape id of this particle
  36074. */
  36075. shapeId: number;
  36076. /**
  36077. * Index of the particle in its shape id
  36078. */
  36079. idxInShape: number;
  36080. /**
  36081. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36082. */
  36083. _modelBoundingInfo: BoundingInfo;
  36084. /**
  36085. * @hidden Particle BoundingInfo object (Internal use)
  36086. */
  36087. _boundingInfo: BoundingInfo;
  36088. /**
  36089. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36090. */
  36091. _sps: SolidParticleSystem;
  36092. /**
  36093. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36094. */
  36095. _stillInvisible: boolean;
  36096. /**
  36097. * @hidden Last computed particle rotation matrix
  36098. */
  36099. _rotationMatrix: number[];
  36100. /**
  36101. * Parent particle Id, if any.
  36102. * Default null.
  36103. */
  36104. parentId: Nullable<number>;
  36105. /**
  36106. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36107. */
  36108. materialIndex: Nullable<number>;
  36109. /**
  36110. * Custom object or properties.
  36111. */
  36112. props: Nullable<any>;
  36113. /**
  36114. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36115. * The possible values are :
  36116. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36117. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36118. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36119. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36120. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36121. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36122. * */
  36123. cullingStrategy: number;
  36124. /**
  36125. * @hidden Internal global position in the SPS.
  36126. */
  36127. _globalPosition: Vector3;
  36128. /**
  36129. * Creates a Solid Particle object.
  36130. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36131. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36132. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36133. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36134. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36135. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36136. * @param shapeId (integer) is the model shape identifier in the SPS.
  36137. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36138. * @param sps defines the sps it is associated to
  36139. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36140. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36141. */
  36142. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36143. /**
  36144. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36145. * @param target the particle target
  36146. * @returns the current particle
  36147. */
  36148. copyToRef(target: SolidParticle): SolidParticle;
  36149. /**
  36150. * Legacy support, changed scale to scaling
  36151. */
  36152. get scale(): Vector3;
  36153. /**
  36154. * Legacy support, changed scale to scaling
  36155. */
  36156. set scale(scale: Vector3);
  36157. /**
  36158. * Legacy support, changed quaternion to rotationQuaternion
  36159. */
  36160. get quaternion(): Nullable<Quaternion>;
  36161. /**
  36162. * Legacy support, changed quaternion to rotationQuaternion
  36163. */
  36164. set quaternion(q: Nullable<Quaternion>);
  36165. /**
  36166. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36167. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36168. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36169. * @returns true if it intersects
  36170. */
  36171. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36172. /**
  36173. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36174. * A particle is in the frustum if its bounding box intersects the frustum
  36175. * @param frustumPlanes defines the frustum to test
  36176. * @returns true if the particle is in the frustum planes
  36177. */
  36178. isInFrustum(frustumPlanes: Plane[]): boolean;
  36179. /**
  36180. * get the rotation matrix of the particle
  36181. * @hidden
  36182. */
  36183. getRotationMatrix(m: Matrix): void;
  36184. }
  36185. /**
  36186. * Represents the shape of the model used by one particle of a solid particle system.
  36187. * SPS internal tool, don't use it manually.
  36188. */
  36189. export class ModelShape {
  36190. /**
  36191. * The shape id
  36192. * @hidden
  36193. */
  36194. shapeID: number;
  36195. /**
  36196. * flat array of model positions (internal use)
  36197. * @hidden
  36198. */
  36199. _shape: Vector3[];
  36200. /**
  36201. * flat array of model UVs (internal use)
  36202. * @hidden
  36203. */
  36204. _shapeUV: number[];
  36205. /**
  36206. * color array of the model
  36207. * @hidden
  36208. */
  36209. _shapeColors: number[];
  36210. /**
  36211. * indices array of the model
  36212. * @hidden
  36213. */
  36214. _indices: number[];
  36215. /**
  36216. * normals array of the model
  36217. * @hidden
  36218. */
  36219. _normals: number[];
  36220. /**
  36221. * length of the shape in the model indices array (internal use)
  36222. * @hidden
  36223. */
  36224. _indicesLength: number;
  36225. /**
  36226. * Custom position function (internal use)
  36227. * @hidden
  36228. */
  36229. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36230. /**
  36231. * Custom vertex function (internal use)
  36232. * @hidden
  36233. */
  36234. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36235. /**
  36236. * Model material (internal use)
  36237. * @hidden
  36238. */
  36239. _material: Nullable<Material>;
  36240. /**
  36241. * 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.
  36242. * SPS internal tool, don't use it manually.
  36243. * @hidden
  36244. */
  36245. 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>);
  36246. }
  36247. /**
  36248. * Represents a Depth Sorted Particle in the solid particle system.
  36249. * @hidden
  36250. */
  36251. export class DepthSortedParticle {
  36252. /**
  36253. * Particle index
  36254. */
  36255. idx: number;
  36256. /**
  36257. * Index of the particle in the "indices" array
  36258. */
  36259. ind: number;
  36260. /**
  36261. * Length of the particle shape in the "indices" array
  36262. */
  36263. indicesLength: number;
  36264. /**
  36265. * Squared distance from the particle to the camera
  36266. */
  36267. sqDistance: number;
  36268. /**
  36269. * Material index when used with MultiMaterials
  36270. */
  36271. materialIndex: number;
  36272. /**
  36273. * Creates a new sorted particle
  36274. * @param materialIndex
  36275. */
  36276. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36277. }
  36278. /**
  36279. * Represents a solid particle vertex
  36280. */
  36281. export class SolidParticleVertex {
  36282. /**
  36283. * Vertex position
  36284. */
  36285. position: Vector3;
  36286. /**
  36287. * Vertex color
  36288. */
  36289. color: Color4;
  36290. /**
  36291. * Vertex UV
  36292. */
  36293. uv: Vector2;
  36294. /**
  36295. * Creates a new solid particle vertex
  36296. */
  36297. constructor();
  36298. /** Vertex x coordinate */
  36299. get x(): number;
  36300. set x(val: number);
  36301. /** Vertex y coordinate */
  36302. get y(): number;
  36303. set y(val: number);
  36304. /** Vertex z coordinate */
  36305. get z(): number;
  36306. set z(val: number);
  36307. }
  36308. }
  36309. declare module "babylonjs/Collisions/meshCollisionData" {
  36310. import { Collider } from "babylonjs/Collisions/collider";
  36311. import { Vector3 } from "babylonjs/Maths/math.vector";
  36312. import { Nullable } from "babylonjs/types";
  36313. import { Observer } from "babylonjs/Misc/observable";
  36314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36315. /**
  36316. * @hidden
  36317. */
  36318. export class _MeshCollisionData {
  36319. _checkCollisions: boolean;
  36320. _collisionMask: number;
  36321. _collisionGroup: number;
  36322. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36323. _collider: Nullable<Collider>;
  36324. _oldPositionForCollisions: Vector3;
  36325. _diffPositionForCollisions: Vector3;
  36326. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36327. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36328. _collisionResponse: boolean;
  36329. }
  36330. }
  36331. declare module "babylonjs/Meshes/abstractMesh" {
  36332. import { Observable } from "babylonjs/Misc/observable";
  36333. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36334. import { Camera } from "babylonjs/Cameras/camera";
  36335. import { Scene, IDisposable } from "babylonjs/scene";
  36336. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36337. import { Node } from "babylonjs/node";
  36338. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36341. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36342. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36343. import { Material } from "babylonjs/Materials/material";
  36344. import { Light } from "babylonjs/Lights/light";
  36345. import { Skeleton } from "babylonjs/Bones/skeleton";
  36346. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36347. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36348. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36349. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36350. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36351. import { Plane } from "babylonjs/Maths/math.plane";
  36352. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36353. import { Ray } from "babylonjs/Culling/ray";
  36354. import { Collider } from "babylonjs/Collisions/collider";
  36355. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36356. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36357. /** @hidden */
  36358. class _FacetDataStorage {
  36359. facetPositions: Vector3[];
  36360. facetNormals: Vector3[];
  36361. facetPartitioning: number[][];
  36362. facetNb: number;
  36363. partitioningSubdivisions: number;
  36364. partitioningBBoxRatio: number;
  36365. facetDataEnabled: boolean;
  36366. facetParameters: any;
  36367. bbSize: Vector3;
  36368. subDiv: {
  36369. max: number;
  36370. X: number;
  36371. Y: number;
  36372. Z: number;
  36373. };
  36374. facetDepthSort: boolean;
  36375. facetDepthSortEnabled: boolean;
  36376. depthSortedIndices: IndicesArray;
  36377. depthSortedFacets: {
  36378. ind: number;
  36379. sqDistance: number;
  36380. }[];
  36381. facetDepthSortFunction: (f1: {
  36382. ind: number;
  36383. sqDistance: number;
  36384. }, f2: {
  36385. ind: number;
  36386. sqDistance: number;
  36387. }) => number;
  36388. facetDepthSortFrom: Vector3;
  36389. facetDepthSortOrigin: Vector3;
  36390. invertedMatrix: Matrix;
  36391. }
  36392. /**
  36393. * @hidden
  36394. **/
  36395. class _InternalAbstractMeshDataInfo {
  36396. _hasVertexAlpha: boolean;
  36397. _useVertexColors: boolean;
  36398. _numBoneInfluencers: number;
  36399. _applyFog: boolean;
  36400. _receiveShadows: boolean;
  36401. _facetData: _FacetDataStorage;
  36402. _visibility: number;
  36403. _skeleton: Nullable<Skeleton>;
  36404. _layerMask: number;
  36405. _computeBonesUsingShaders: boolean;
  36406. _isActive: boolean;
  36407. _onlyForInstances: boolean;
  36408. _isActiveIntermediate: boolean;
  36409. _onlyForInstancesIntermediate: boolean;
  36410. _actAsRegularMesh: boolean;
  36411. }
  36412. /**
  36413. * Class used to store all common mesh properties
  36414. */
  36415. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36416. /** No occlusion */
  36417. static OCCLUSION_TYPE_NONE: number;
  36418. /** Occlusion set to optimisitic */
  36419. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36420. /** Occlusion set to strict */
  36421. static OCCLUSION_TYPE_STRICT: number;
  36422. /** Use an accurante occlusion algorithm */
  36423. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36424. /** Use a conservative occlusion algorithm */
  36425. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36426. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36427. * Test order :
  36428. * Is the bounding sphere outside the frustum ?
  36429. * If not, are the bounding box vertices outside the frustum ?
  36430. * It not, then the cullable object is in the frustum.
  36431. */
  36432. static readonly CULLINGSTRATEGY_STANDARD: number;
  36433. /** Culling strategy : Bounding Sphere Only.
  36434. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36435. * It's also less accurate than the standard because some not visible objects can still be selected.
  36436. * Test : is the bounding sphere outside the frustum ?
  36437. * If not, then the cullable object is in the frustum.
  36438. */
  36439. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36440. /** Culling strategy : Optimistic Inclusion.
  36441. * This in an inclusion test first, then the standard exclusion test.
  36442. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36443. * 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.
  36444. * Anyway, it's as accurate as the standard strategy.
  36445. * Test :
  36446. * Is the cullable object bounding sphere center in the frustum ?
  36447. * If not, apply the default culling strategy.
  36448. */
  36449. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36450. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36451. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36452. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36453. * 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.
  36454. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36455. * Test :
  36456. * Is the cullable object bounding sphere center in the frustum ?
  36457. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36458. */
  36459. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36460. /**
  36461. * No billboard
  36462. */
  36463. static get BILLBOARDMODE_NONE(): number;
  36464. /** Billboard on X axis */
  36465. static get BILLBOARDMODE_X(): number;
  36466. /** Billboard on Y axis */
  36467. static get BILLBOARDMODE_Y(): number;
  36468. /** Billboard on Z axis */
  36469. static get BILLBOARDMODE_Z(): number;
  36470. /** Billboard on all axes */
  36471. static get BILLBOARDMODE_ALL(): number;
  36472. /** Billboard on using position instead of orientation */
  36473. static get BILLBOARDMODE_USE_POSITION(): number;
  36474. /** @hidden */
  36475. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36476. /**
  36477. * The culling strategy to use to check whether the mesh must be rendered or not.
  36478. * This value can be changed at any time and will be used on the next render mesh selection.
  36479. * The possible values are :
  36480. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36481. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36482. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36483. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36484. * Please read each static variable documentation to get details about the culling process.
  36485. * */
  36486. cullingStrategy: number;
  36487. /**
  36488. * Gets the number of facets in the mesh
  36489. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36490. */
  36491. get facetNb(): number;
  36492. /**
  36493. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36494. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36495. */
  36496. get partitioningSubdivisions(): number;
  36497. set partitioningSubdivisions(nb: number);
  36498. /**
  36499. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36500. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36501. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36502. */
  36503. get partitioningBBoxRatio(): number;
  36504. set partitioningBBoxRatio(ratio: number);
  36505. /**
  36506. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36507. * Works only for updatable meshes.
  36508. * Doesn't work with multi-materials
  36509. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36510. */
  36511. get mustDepthSortFacets(): boolean;
  36512. set mustDepthSortFacets(sort: boolean);
  36513. /**
  36514. * The location (Vector3) where the facet depth sort must be computed from.
  36515. * By default, the active camera position.
  36516. * Used only when facet depth sort is enabled
  36517. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36518. */
  36519. get facetDepthSortFrom(): Vector3;
  36520. set facetDepthSortFrom(location: Vector3);
  36521. /**
  36522. * gets a boolean indicating if facetData is enabled
  36523. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36524. */
  36525. get isFacetDataEnabled(): boolean;
  36526. /** @hidden */
  36527. _updateNonUniformScalingState(value: boolean): boolean;
  36528. /**
  36529. * An event triggered when this mesh collides with another one
  36530. */
  36531. onCollideObservable: Observable<AbstractMesh>;
  36532. /** Set a function to call when this mesh collides with another one */
  36533. set onCollide(callback: () => void);
  36534. /**
  36535. * An event triggered when the collision's position changes
  36536. */
  36537. onCollisionPositionChangeObservable: Observable<Vector3>;
  36538. /** Set a function to call when the collision's position changes */
  36539. set onCollisionPositionChange(callback: () => void);
  36540. /**
  36541. * An event triggered when material is changed
  36542. */
  36543. onMaterialChangedObservable: Observable<AbstractMesh>;
  36544. /**
  36545. * Gets or sets the orientation for POV movement & rotation
  36546. */
  36547. definedFacingForward: boolean;
  36548. /** @hidden */
  36549. _occlusionQuery: Nullable<WebGLQuery>;
  36550. /** @hidden */
  36551. _renderingGroup: Nullable<RenderingGroup>;
  36552. /**
  36553. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36554. */
  36555. get visibility(): number;
  36556. /**
  36557. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36558. */
  36559. set visibility(value: number);
  36560. /** Gets or sets the alpha index used to sort transparent meshes
  36561. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36562. */
  36563. alphaIndex: number;
  36564. /**
  36565. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36566. */
  36567. isVisible: boolean;
  36568. /**
  36569. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36570. */
  36571. isPickable: boolean;
  36572. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36573. showSubMeshesBoundingBox: boolean;
  36574. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36575. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36576. */
  36577. isBlocker: boolean;
  36578. /**
  36579. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36580. */
  36581. enablePointerMoveEvents: boolean;
  36582. private _renderingGroupId;
  36583. /**
  36584. * Specifies the rendering group id for this mesh (0 by default)
  36585. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36586. */
  36587. get renderingGroupId(): number;
  36588. set renderingGroupId(value: number);
  36589. private _material;
  36590. /** Gets or sets current material */
  36591. get material(): Nullable<Material>;
  36592. set material(value: Nullable<Material>);
  36593. /**
  36594. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36595. * @see https://doc.babylonjs.com/babylon101/shadows
  36596. */
  36597. get receiveShadows(): boolean;
  36598. set receiveShadows(value: boolean);
  36599. /** Defines color to use when rendering outline */
  36600. outlineColor: Color3;
  36601. /** Define width to use when rendering outline */
  36602. outlineWidth: number;
  36603. /** Defines color to use when rendering overlay */
  36604. overlayColor: Color3;
  36605. /** Defines alpha to use when rendering overlay */
  36606. overlayAlpha: number;
  36607. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36608. get hasVertexAlpha(): boolean;
  36609. set hasVertexAlpha(value: boolean);
  36610. /** 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) */
  36611. get useVertexColors(): boolean;
  36612. set useVertexColors(value: boolean);
  36613. /**
  36614. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36615. */
  36616. get computeBonesUsingShaders(): boolean;
  36617. set computeBonesUsingShaders(value: boolean);
  36618. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36619. get numBoneInfluencers(): number;
  36620. set numBoneInfluencers(value: number);
  36621. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36622. get applyFog(): boolean;
  36623. set applyFog(value: boolean);
  36624. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36625. useOctreeForRenderingSelection: boolean;
  36626. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36627. useOctreeForPicking: boolean;
  36628. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36629. useOctreeForCollisions: boolean;
  36630. /**
  36631. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36632. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36633. */
  36634. get layerMask(): number;
  36635. set layerMask(value: number);
  36636. /**
  36637. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36638. */
  36639. alwaysSelectAsActiveMesh: boolean;
  36640. /**
  36641. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36642. */
  36643. doNotSyncBoundingInfo: boolean;
  36644. /**
  36645. * Gets or sets the current action manager
  36646. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36647. */
  36648. actionManager: Nullable<AbstractActionManager>;
  36649. private _meshCollisionData;
  36650. /**
  36651. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36652. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36653. */
  36654. ellipsoid: Vector3;
  36655. /**
  36656. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36657. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36658. */
  36659. ellipsoidOffset: Vector3;
  36660. /**
  36661. * Gets or sets a collision mask used to mask collisions (default is -1).
  36662. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36663. */
  36664. get collisionMask(): number;
  36665. set collisionMask(mask: number);
  36666. /**
  36667. * Gets or sets a collision response flag (default is true).
  36668. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36669. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36670. * to respond to the collision.
  36671. */
  36672. get collisionResponse(): boolean;
  36673. set collisionResponse(response: boolean);
  36674. /**
  36675. * Gets or sets the current collision group mask (-1 by default).
  36676. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36677. */
  36678. get collisionGroup(): number;
  36679. set collisionGroup(mask: number);
  36680. /**
  36681. * Gets or sets current surrounding meshes (null by default).
  36682. *
  36683. * By default collision detection is tested against every mesh in the scene.
  36684. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36685. * meshes will be tested for the collision.
  36686. *
  36687. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36688. */
  36689. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36690. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36691. /**
  36692. * Defines edge width used when edgesRenderer is enabled
  36693. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36694. */
  36695. edgesWidth: number;
  36696. /**
  36697. * Defines edge color used when edgesRenderer is enabled
  36698. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36699. */
  36700. edgesColor: Color4;
  36701. /** @hidden */
  36702. _edgesRenderer: Nullable<IEdgesRenderer>;
  36703. /** @hidden */
  36704. _masterMesh: Nullable<AbstractMesh>;
  36705. /** @hidden */
  36706. _boundingInfo: Nullable<BoundingInfo>;
  36707. /** @hidden */
  36708. _renderId: number;
  36709. /**
  36710. * Gets or sets the list of subMeshes
  36711. * @see https://doc.babylonjs.com/how_to/multi_materials
  36712. */
  36713. subMeshes: SubMesh[];
  36714. /** @hidden */
  36715. _intersectionsInProgress: AbstractMesh[];
  36716. /** @hidden */
  36717. _unIndexed: boolean;
  36718. /** @hidden */
  36719. _lightSources: Light[];
  36720. /** Gets the list of lights affecting that mesh */
  36721. get lightSources(): Light[];
  36722. /** @hidden */
  36723. get _positions(): Nullable<Vector3[]>;
  36724. /** @hidden */
  36725. _waitingData: {
  36726. lods: Nullable<any>;
  36727. actions: Nullable<any>;
  36728. freezeWorldMatrix: Nullable<boolean>;
  36729. };
  36730. /** @hidden */
  36731. _bonesTransformMatrices: Nullable<Float32Array>;
  36732. /** @hidden */
  36733. _transformMatrixTexture: Nullable<RawTexture>;
  36734. /**
  36735. * Gets or sets a skeleton to apply skining transformations
  36736. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36737. */
  36738. set skeleton(value: Nullable<Skeleton>);
  36739. get skeleton(): Nullable<Skeleton>;
  36740. /**
  36741. * An event triggered when the mesh is rebuilt.
  36742. */
  36743. onRebuildObservable: Observable<AbstractMesh>;
  36744. /**
  36745. * Creates a new AbstractMesh
  36746. * @param name defines the name of the mesh
  36747. * @param scene defines the hosting scene
  36748. */
  36749. constructor(name: string, scene?: Nullable<Scene>);
  36750. /**
  36751. * Returns the string "AbstractMesh"
  36752. * @returns "AbstractMesh"
  36753. */
  36754. getClassName(): string;
  36755. /**
  36756. * Gets a string representation of the current mesh
  36757. * @param fullDetails defines a boolean indicating if full details must be included
  36758. * @returns a string representation of the current mesh
  36759. */
  36760. toString(fullDetails?: boolean): string;
  36761. /**
  36762. * @hidden
  36763. */
  36764. protected _getEffectiveParent(): Nullable<Node>;
  36765. /** @hidden */
  36766. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36767. /** @hidden */
  36768. _rebuild(): void;
  36769. /** @hidden */
  36770. _resyncLightSources(): void;
  36771. /** @hidden */
  36772. _resyncLightSource(light: Light): void;
  36773. /** @hidden */
  36774. _unBindEffect(): void;
  36775. /** @hidden */
  36776. _removeLightSource(light: Light, dispose: boolean): void;
  36777. private _markSubMeshesAsDirty;
  36778. /** @hidden */
  36779. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36780. /** @hidden */
  36781. _markSubMeshesAsAttributesDirty(): void;
  36782. /** @hidden */
  36783. _markSubMeshesAsMiscDirty(): void;
  36784. /**
  36785. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36786. */
  36787. get scaling(): Vector3;
  36788. set scaling(newScaling: Vector3);
  36789. /**
  36790. * Returns true if the mesh is blocked. Implemented by child classes
  36791. */
  36792. get isBlocked(): boolean;
  36793. /**
  36794. * Returns the mesh itself by default. Implemented by child classes
  36795. * @param camera defines the camera to use to pick the right LOD level
  36796. * @returns the currentAbstractMesh
  36797. */
  36798. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36799. /**
  36800. * Returns 0 by default. Implemented by child classes
  36801. * @returns an integer
  36802. */
  36803. getTotalVertices(): number;
  36804. /**
  36805. * Returns a positive integer : the total number of indices in this mesh geometry.
  36806. * @returns the numner of indices or zero if the mesh has no geometry.
  36807. */
  36808. getTotalIndices(): number;
  36809. /**
  36810. * Returns null by default. Implemented by child classes
  36811. * @returns null
  36812. */
  36813. getIndices(): Nullable<IndicesArray>;
  36814. /**
  36815. * Returns the array of the requested vertex data kind. Implemented by child classes
  36816. * @param kind defines the vertex data kind to use
  36817. * @returns null
  36818. */
  36819. getVerticesData(kind: string): Nullable<FloatArray>;
  36820. /**
  36821. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36822. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36823. * Note that a new underlying VertexBuffer object is created each call.
  36824. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36825. * @param kind defines vertex data kind:
  36826. * * VertexBuffer.PositionKind
  36827. * * VertexBuffer.UVKind
  36828. * * VertexBuffer.UV2Kind
  36829. * * VertexBuffer.UV3Kind
  36830. * * VertexBuffer.UV4Kind
  36831. * * VertexBuffer.UV5Kind
  36832. * * VertexBuffer.UV6Kind
  36833. * * VertexBuffer.ColorKind
  36834. * * VertexBuffer.MatricesIndicesKind
  36835. * * VertexBuffer.MatricesIndicesExtraKind
  36836. * * VertexBuffer.MatricesWeightsKind
  36837. * * VertexBuffer.MatricesWeightsExtraKind
  36838. * @param data defines the data source
  36839. * @param updatable defines if the data must be flagged as updatable (or static)
  36840. * @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
  36841. * @returns the current mesh
  36842. */
  36843. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36844. /**
  36845. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36846. * If the mesh has no geometry, it is simply returned as it is.
  36847. * @param kind defines vertex data kind:
  36848. * * VertexBuffer.PositionKind
  36849. * * VertexBuffer.UVKind
  36850. * * VertexBuffer.UV2Kind
  36851. * * VertexBuffer.UV3Kind
  36852. * * VertexBuffer.UV4Kind
  36853. * * VertexBuffer.UV5Kind
  36854. * * VertexBuffer.UV6Kind
  36855. * * VertexBuffer.ColorKind
  36856. * * VertexBuffer.MatricesIndicesKind
  36857. * * VertexBuffer.MatricesIndicesExtraKind
  36858. * * VertexBuffer.MatricesWeightsKind
  36859. * * VertexBuffer.MatricesWeightsExtraKind
  36860. * @param data defines the data source
  36861. * @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
  36862. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36863. * @returns the current mesh
  36864. */
  36865. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36866. /**
  36867. * Sets the mesh indices,
  36868. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36869. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36870. * @param totalVertices Defines the total number of vertices
  36871. * @returns the current mesh
  36872. */
  36873. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36874. /**
  36875. * Gets a boolean indicating if specific vertex data is present
  36876. * @param kind defines the vertex data kind to use
  36877. * @returns true is data kind is present
  36878. */
  36879. isVerticesDataPresent(kind: string): boolean;
  36880. /**
  36881. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36882. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36883. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36884. * @returns a BoundingInfo
  36885. */
  36886. getBoundingInfo(): BoundingInfo;
  36887. /**
  36888. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36889. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36890. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36891. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36892. * @returns the current mesh
  36893. */
  36894. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36895. /**
  36896. * Overwrite the current bounding info
  36897. * @param boundingInfo defines the new bounding info
  36898. * @returns the current mesh
  36899. */
  36900. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36901. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36902. get useBones(): boolean;
  36903. /** @hidden */
  36904. _preActivate(): void;
  36905. /** @hidden */
  36906. _preActivateForIntermediateRendering(renderId: number): void;
  36907. /** @hidden */
  36908. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36909. /** @hidden */
  36910. _postActivate(): void;
  36911. /** @hidden */
  36912. _freeze(): void;
  36913. /** @hidden */
  36914. _unFreeze(): void;
  36915. /**
  36916. * Gets the current world matrix
  36917. * @returns a Matrix
  36918. */
  36919. getWorldMatrix(): Matrix;
  36920. /** @hidden */
  36921. _getWorldMatrixDeterminant(): number;
  36922. /**
  36923. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36924. */
  36925. get isAnInstance(): boolean;
  36926. /**
  36927. * Gets a boolean indicating if this mesh has instances
  36928. */
  36929. get hasInstances(): boolean;
  36930. /**
  36931. * Gets a boolean indicating if this mesh has thin instances
  36932. */
  36933. get hasThinInstances(): boolean;
  36934. /**
  36935. * Perform relative position change from the point of view of behind the front of the mesh.
  36936. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36937. * Supports definition of mesh facing forward or backward
  36938. * @param amountRight defines the distance on the right axis
  36939. * @param amountUp defines the distance on the up axis
  36940. * @param amountForward defines the distance on the forward axis
  36941. * @returns the current mesh
  36942. */
  36943. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36944. /**
  36945. * Calculate relative position change from the point of view of behind the front of the mesh.
  36946. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36947. * Supports definition of mesh facing forward or backward
  36948. * @param amountRight defines the distance on the right axis
  36949. * @param amountUp defines the distance on the up axis
  36950. * @param amountForward defines the distance on the forward axis
  36951. * @returns the new displacement vector
  36952. */
  36953. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36954. /**
  36955. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36956. * Supports definition of mesh facing forward or backward
  36957. * @param flipBack defines the flip
  36958. * @param twirlClockwise defines the twirl
  36959. * @param tiltRight defines the tilt
  36960. * @returns the current mesh
  36961. */
  36962. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36963. /**
  36964. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36965. * Supports definition of mesh facing forward or backward.
  36966. * @param flipBack defines the flip
  36967. * @param twirlClockwise defines the twirl
  36968. * @param tiltRight defines the tilt
  36969. * @returns the new rotation vector
  36970. */
  36971. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36972. /**
  36973. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36974. * This means the mesh underlying bounding box and sphere are recomputed.
  36975. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36976. * @returns the current mesh
  36977. */
  36978. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36979. /** @hidden */
  36980. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36981. /** @hidden */
  36982. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36983. /** @hidden */
  36984. _updateBoundingInfo(): AbstractMesh;
  36985. /** @hidden */
  36986. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36987. /** @hidden */
  36988. protected _afterComputeWorldMatrix(): void;
  36989. /** @hidden */
  36990. get _effectiveMesh(): AbstractMesh;
  36991. /**
  36992. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36993. * A mesh is in the frustum if its bounding box intersects the frustum
  36994. * @param frustumPlanes defines the frustum to test
  36995. * @returns true if the mesh is in the frustum planes
  36996. */
  36997. isInFrustum(frustumPlanes: Plane[]): boolean;
  36998. /**
  36999. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37000. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37001. * @param frustumPlanes defines the frustum to test
  37002. * @returns true if the mesh is completely in the frustum planes
  37003. */
  37004. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37005. /**
  37006. * True if the mesh intersects another mesh or a SolidParticle object
  37007. * @param mesh defines a target mesh or SolidParticle to test
  37008. * @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)
  37009. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37010. * @returns true if there is an intersection
  37011. */
  37012. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37013. /**
  37014. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37015. * @param point defines the point to test
  37016. * @returns true if there is an intersection
  37017. */
  37018. intersectsPoint(point: Vector3): boolean;
  37019. /**
  37020. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37021. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37022. */
  37023. get checkCollisions(): boolean;
  37024. set checkCollisions(collisionEnabled: boolean);
  37025. /**
  37026. * Gets Collider object used to compute collisions (not physics)
  37027. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37028. */
  37029. get collider(): Nullable<Collider>;
  37030. /**
  37031. * Move the mesh using collision engine
  37032. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37033. * @param displacement defines the requested displacement vector
  37034. * @returns the current mesh
  37035. */
  37036. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37037. private _onCollisionPositionChange;
  37038. /** @hidden */
  37039. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37040. /** @hidden */
  37041. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37042. /** @hidden */
  37043. _checkCollision(collider: Collider): AbstractMesh;
  37044. /** @hidden */
  37045. _generatePointsArray(): boolean;
  37046. /**
  37047. * Checks if the passed Ray intersects with the mesh
  37048. * @param ray defines the ray to use
  37049. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37050. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37051. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37052. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37053. * @returns the picking info
  37054. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37055. */
  37056. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37057. /**
  37058. * Clones the current mesh
  37059. * @param name defines the mesh name
  37060. * @param newParent defines the new mesh parent
  37061. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37062. * @returns the new mesh
  37063. */
  37064. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37065. /**
  37066. * Disposes all the submeshes of the current meshnp
  37067. * @returns the current mesh
  37068. */
  37069. releaseSubMeshes(): AbstractMesh;
  37070. /**
  37071. * Releases resources associated with this abstract mesh.
  37072. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37073. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37074. */
  37075. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37076. /**
  37077. * Adds the passed mesh as a child to the current mesh
  37078. * @param mesh defines the child mesh
  37079. * @returns the current mesh
  37080. */
  37081. addChild(mesh: AbstractMesh): AbstractMesh;
  37082. /**
  37083. * Removes the passed mesh from the current mesh children list
  37084. * @param mesh defines the child mesh
  37085. * @returns the current mesh
  37086. */
  37087. removeChild(mesh: AbstractMesh): AbstractMesh;
  37088. /** @hidden */
  37089. private _initFacetData;
  37090. /**
  37091. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37092. * This method can be called within the render loop.
  37093. * 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
  37094. * @returns the current mesh
  37095. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37096. */
  37097. updateFacetData(): AbstractMesh;
  37098. /**
  37099. * Returns the facetLocalNormals array.
  37100. * The normals are expressed in the mesh local spac
  37101. * @returns an array of Vector3
  37102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37103. */
  37104. getFacetLocalNormals(): Vector3[];
  37105. /**
  37106. * Returns the facetLocalPositions array.
  37107. * The facet positions are expressed in the mesh local space
  37108. * @returns an array of Vector3
  37109. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37110. */
  37111. getFacetLocalPositions(): Vector3[];
  37112. /**
  37113. * Returns the facetLocalPartioning array
  37114. * @returns an array of array of numbers
  37115. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37116. */
  37117. getFacetLocalPartitioning(): number[][];
  37118. /**
  37119. * Returns the i-th facet position in the world system.
  37120. * This method allocates a new Vector3 per call
  37121. * @param i defines the facet index
  37122. * @returns a new Vector3
  37123. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37124. */
  37125. getFacetPosition(i: number): Vector3;
  37126. /**
  37127. * Sets the reference Vector3 with the i-th facet position in the world system
  37128. * @param i defines the facet index
  37129. * @param ref defines the target vector
  37130. * @returns the current mesh
  37131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37132. */
  37133. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37134. /**
  37135. * Returns the i-th facet normal in the world system.
  37136. * This method allocates a new Vector3 per call
  37137. * @param i defines the facet index
  37138. * @returns a new Vector3
  37139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37140. */
  37141. getFacetNormal(i: number): Vector3;
  37142. /**
  37143. * Sets the reference Vector3 with the i-th facet normal in the world system
  37144. * @param i defines the facet index
  37145. * @param ref defines the target vector
  37146. * @returns the current mesh
  37147. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37148. */
  37149. getFacetNormalToRef(i: number, ref: Vector3): this;
  37150. /**
  37151. * 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)
  37152. * @param x defines x coordinate
  37153. * @param y defines y coordinate
  37154. * @param z defines z coordinate
  37155. * @returns the array of facet indexes
  37156. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37157. */
  37158. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37159. /**
  37160. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37161. * @param projected sets as the (x,y,z) world projection on the facet
  37162. * @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
  37163. * @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
  37164. * @param x defines x coordinate
  37165. * @param y defines y coordinate
  37166. * @param z defines z coordinate
  37167. * @returns the face index if found (or null instead)
  37168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37169. */
  37170. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37171. /**
  37172. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37173. * @param projected sets as the (x,y,z) local projection on the facet
  37174. * @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
  37175. * @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
  37176. * @param x defines x coordinate
  37177. * @param y defines y coordinate
  37178. * @param z defines z coordinate
  37179. * @returns the face index if found (or null instead)
  37180. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37181. */
  37182. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37183. /**
  37184. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37185. * @returns the parameters
  37186. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37187. */
  37188. getFacetDataParameters(): any;
  37189. /**
  37190. * Disables the feature FacetData and frees the related memory
  37191. * @returns the current mesh
  37192. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37193. */
  37194. disableFacetData(): AbstractMesh;
  37195. /**
  37196. * Updates the AbstractMesh indices array
  37197. * @param indices defines the data source
  37198. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37199. * @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)
  37200. * @returns the current mesh
  37201. */
  37202. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37203. /**
  37204. * Creates new normals data for the mesh
  37205. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37206. * @returns the current mesh
  37207. */
  37208. createNormals(updatable: boolean): AbstractMesh;
  37209. /**
  37210. * Align the mesh with a normal
  37211. * @param normal defines the normal to use
  37212. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37213. * @returns the current mesh
  37214. */
  37215. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37216. /** @hidden */
  37217. _checkOcclusionQuery(): boolean;
  37218. /**
  37219. * Disables the mesh edge rendering mode
  37220. * @returns the currentAbstractMesh
  37221. */
  37222. disableEdgesRendering(): AbstractMesh;
  37223. /**
  37224. * Enables the edge rendering mode on the mesh.
  37225. * This mode makes the mesh edges visible
  37226. * @param epsilon defines the maximal distance between two angles to detect a face
  37227. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37228. * @returns the currentAbstractMesh
  37229. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37230. */
  37231. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37232. /**
  37233. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37234. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37235. */
  37236. getConnectedParticleSystems(): IParticleSystem[];
  37237. }
  37238. }
  37239. declare module "babylonjs/Actions/actionEvent" {
  37240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37241. import { Nullable } from "babylonjs/types";
  37242. import { Sprite } from "babylonjs/Sprites/sprite";
  37243. import { Scene } from "babylonjs/scene";
  37244. import { Vector2 } from "babylonjs/Maths/math.vector";
  37245. /**
  37246. * Interface used to define ActionEvent
  37247. */
  37248. export interface IActionEvent {
  37249. /** The mesh or sprite that triggered the action */
  37250. source: any;
  37251. /** The X mouse cursor position at the time of the event */
  37252. pointerX: number;
  37253. /** The Y mouse cursor position at the time of the event */
  37254. pointerY: number;
  37255. /** The mesh that is currently pointed at (can be null) */
  37256. meshUnderPointer: Nullable<AbstractMesh>;
  37257. /** the original (browser) event that triggered the ActionEvent */
  37258. sourceEvent?: any;
  37259. /** additional data for the event */
  37260. additionalData?: any;
  37261. }
  37262. /**
  37263. * ActionEvent is the event being sent when an action is triggered.
  37264. */
  37265. export class ActionEvent implements IActionEvent {
  37266. /** The mesh or sprite that triggered the action */
  37267. source: any;
  37268. /** The X mouse cursor position at the time of the event */
  37269. pointerX: number;
  37270. /** The Y mouse cursor position at the time of the event */
  37271. pointerY: number;
  37272. /** The mesh that is currently pointed at (can be null) */
  37273. meshUnderPointer: Nullable<AbstractMesh>;
  37274. /** the original (browser) event that triggered the ActionEvent */
  37275. sourceEvent?: any;
  37276. /** additional data for the event */
  37277. additionalData?: any;
  37278. /**
  37279. * Creates a new ActionEvent
  37280. * @param source The mesh or sprite that triggered the action
  37281. * @param pointerX The X mouse cursor position at the time of the event
  37282. * @param pointerY The Y mouse cursor position at the time of the event
  37283. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37284. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37285. * @param additionalData additional data for the event
  37286. */
  37287. constructor(
  37288. /** The mesh or sprite that triggered the action */
  37289. source: any,
  37290. /** The X mouse cursor position at the time of the event */
  37291. pointerX: number,
  37292. /** The Y mouse cursor position at the time of the event */
  37293. pointerY: number,
  37294. /** The mesh that is currently pointed at (can be null) */
  37295. meshUnderPointer: Nullable<AbstractMesh>,
  37296. /** the original (browser) event that triggered the ActionEvent */
  37297. sourceEvent?: any,
  37298. /** additional data for the event */
  37299. additionalData?: any);
  37300. /**
  37301. * Helper function to auto-create an ActionEvent from a source mesh.
  37302. * @param source The source mesh that triggered the event
  37303. * @param evt The original (browser) event
  37304. * @param additionalData additional data for the event
  37305. * @returns the new ActionEvent
  37306. */
  37307. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37308. /**
  37309. * Helper function to auto-create an ActionEvent from a source sprite
  37310. * @param source The source sprite that triggered the event
  37311. * @param scene Scene associated with the sprite
  37312. * @param evt The original (browser) event
  37313. * @param additionalData additional data for the event
  37314. * @returns the new ActionEvent
  37315. */
  37316. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37317. /**
  37318. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37319. * @param scene the scene where the event occurred
  37320. * @param evt The original (browser) event
  37321. * @returns the new ActionEvent
  37322. */
  37323. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37324. /**
  37325. * Helper function to auto-create an ActionEvent from a primitive
  37326. * @param prim defines the target primitive
  37327. * @param pointerPos defines the pointer position
  37328. * @param evt The original (browser) event
  37329. * @param additionalData additional data for the event
  37330. * @returns the new ActionEvent
  37331. */
  37332. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37333. }
  37334. }
  37335. declare module "babylonjs/Actions/abstractActionManager" {
  37336. import { IDisposable } from "babylonjs/scene";
  37337. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37338. import { IAction } from "babylonjs/Actions/action";
  37339. import { Nullable } from "babylonjs/types";
  37340. /**
  37341. * Abstract class used to decouple action Manager from scene and meshes.
  37342. * Do not instantiate.
  37343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37344. */
  37345. export abstract class AbstractActionManager implements IDisposable {
  37346. /** Gets the list of active triggers */
  37347. static Triggers: {
  37348. [key: string]: number;
  37349. };
  37350. /** Gets the cursor to use when hovering items */
  37351. hoverCursor: string;
  37352. /** Gets the list of actions */
  37353. actions: IAction[];
  37354. /**
  37355. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37356. */
  37357. isRecursive: boolean;
  37358. /**
  37359. * Releases all associated resources
  37360. */
  37361. abstract dispose(): void;
  37362. /**
  37363. * Does this action manager has pointer triggers
  37364. */
  37365. abstract get hasPointerTriggers(): boolean;
  37366. /**
  37367. * Does this action manager has pick triggers
  37368. */
  37369. abstract get hasPickTriggers(): boolean;
  37370. /**
  37371. * Process a specific trigger
  37372. * @param trigger defines the trigger to process
  37373. * @param evt defines the event details to be processed
  37374. */
  37375. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37376. /**
  37377. * Does this action manager handles actions of any of the given triggers
  37378. * @param triggers defines the triggers to be tested
  37379. * @return a boolean indicating whether one (or more) of the triggers is handled
  37380. */
  37381. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37382. /**
  37383. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37384. * speed.
  37385. * @param triggerA defines the trigger to be tested
  37386. * @param triggerB defines the trigger to be tested
  37387. * @return a boolean indicating whether one (or more) of the triggers is handled
  37388. */
  37389. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37390. /**
  37391. * Does this action manager handles actions of a given trigger
  37392. * @param trigger defines the trigger to be tested
  37393. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37394. * @return whether the trigger is handled
  37395. */
  37396. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37397. /**
  37398. * Serialize this manager to a JSON object
  37399. * @param name defines the property name to store this manager
  37400. * @returns a JSON representation of this manager
  37401. */
  37402. abstract serialize(name: string): any;
  37403. /**
  37404. * Registers an action to this action manager
  37405. * @param action defines the action to be registered
  37406. * @return the action amended (prepared) after registration
  37407. */
  37408. abstract registerAction(action: IAction): Nullable<IAction>;
  37409. /**
  37410. * Unregisters an action to this action manager
  37411. * @param action defines the action to be unregistered
  37412. * @return a boolean indicating whether the action has been unregistered
  37413. */
  37414. abstract unregisterAction(action: IAction): Boolean;
  37415. /**
  37416. * Does exist one action manager with at least one trigger
  37417. **/
  37418. static get HasTriggers(): boolean;
  37419. /**
  37420. * Does exist one action manager with at least one pick trigger
  37421. **/
  37422. static get HasPickTriggers(): boolean;
  37423. /**
  37424. * Does exist one action manager that handles actions of a given trigger
  37425. * @param trigger defines the trigger to be tested
  37426. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37427. **/
  37428. static HasSpecificTrigger(trigger: number): boolean;
  37429. }
  37430. }
  37431. declare module "babylonjs/node" {
  37432. import { Scene } from "babylonjs/scene";
  37433. import { Nullable } from "babylonjs/types";
  37434. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37435. import { Engine } from "babylonjs/Engines/engine";
  37436. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37437. import { Observable } from "babylonjs/Misc/observable";
  37438. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37439. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37440. import { Animatable } from "babylonjs/Animations/animatable";
  37441. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37442. import { Animation } from "babylonjs/Animations/animation";
  37443. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37445. /**
  37446. * Defines how a node can be built from a string name.
  37447. */
  37448. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37449. /**
  37450. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37451. */
  37452. export class Node implements IBehaviorAware<Node> {
  37453. /** @hidden */
  37454. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37455. private static _NodeConstructors;
  37456. /**
  37457. * Add a new node constructor
  37458. * @param type defines the type name of the node to construct
  37459. * @param constructorFunc defines the constructor function
  37460. */
  37461. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37462. /**
  37463. * Returns a node constructor based on type name
  37464. * @param type defines the type name
  37465. * @param name defines the new node name
  37466. * @param scene defines the hosting scene
  37467. * @param options defines optional options to transmit to constructors
  37468. * @returns the new constructor or null
  37469. */
  37470. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37471. /**
  37472. * Gets or sets the name of the node
  37473. */
  37474. name: string;
  37475. /**
  37476. * Gets or sets the id of the node
  37477. */
  37478. id: string;
  37479. /**
  37480. * Gets or sets the unique id of the node
  37481. */
  37482. uniqueId: number;
  37483. /**
  37484. * Gets or sets a string used to store user defined state for the node
  37485. */
  37486. state: string;
  37487. /**
  37488. * Gets or sets an object used to store user defined information for the node
  37489. */
  37490. metadata: any;
  37491. /**
  37492. * For internal use only. Please do not use.
  37493. */
  37494. reservedDataStore: any;
  37495. /**
  37496. * List of inspectable custom properties (used by the Inspector)
  37497. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37498. */
  37499. inspectableCustomProperties: IInspectable[];
  37500. private _doNotSerialize;
  37501. /**
  37502. * Gets or sets a boolean used to define if the node must be serialized
  37503. */
  37504. get doNotSerialize(): boolean;
  37505. set doNotSerialize(value: boolean);
  37506. /** @hidden */
  37507. _isDisposed: boolean;
  37508. /**
  37509. * Gets a list of Animations associated with the node
  37510. */
  37511. animations: import("babylonjs/Animations/animation").Animation[];
  37512. protected _ranges: {
  37513. [name: string]: Nullable<AnimationRange>;
  37514. };
  37515. /**
  37516. * Callback raised when the node is ready to be used
  37517. */
  37518. onReady: Nullable<(node: Node) => void>;
  37519. private _isEnabled;
  37520. private _isParentEnabled;
  37521. private _isReady;
  37522. /** @hidden */
  37523. _currentRenderId: number;
  37524. private _parentUpdateId;
  37525. /** @hidden */
  37526. _childUpdateId: number;
  37527. /** @hidden */
  37528. _waitingParentId: Nullable<string>;
  37529. /** @hidden */
  37530. _scene: Scene;
  37531. /** @hidden */
  37532. _cache: any;
  37533. private _parentNode;
  37534. private _children;
  37535. /** @hidden */
  37536. _worldMatrix: Matrix;
  37537. /** @hidden */
  37538. _worldMatrixDeterminant: number;
  37539. /** @hidden */
  37540. _worldMatrixDeterminantIsDirty: boolean;
  37541. /** @hidden */
  37542. private _sceneRootNodesIndex;
  37543. /**
  37544. * Gets a boolean indicating if the node has been disposed
  37545. * @returns true if the node was disposed
  37546. */
  37547. isDisposed(): boolean;
  37548. /**
  37549. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37550. * @see https://doc.babylonjs.com/how_to/parenting
  37551. */
  37552. set parent(parent: Nullable<Node>);
  37553. get parent(): Nullable<Node>;
  37554. /** @hidden */
  37555. _addToSceneRootNodes(): void;
  37556. /** @hidden */
  37557. _removeFromSceneRootNodes(): void;
  37558. private _animationPropertiesOverride;
  37559. /**
  37560. * Gets or sets the animation properties override
  37561. */
  37562. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37563. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37564. /**
  37565. * Gets a string identifying the name of the class
  37566. * @returns "Node" string
  37567. */
  37568. getClassName(): string;
  37569. /** @hidden */
  37570. readonly _isNode: boolean;
  37571. /**
  37572. * An event triggered when the mesh is disposed
  37573. */
  37574. onDisposeObservable: Observable<Node>;
  37575. private _onDisposeObserver;
  37576. /**
  37577. * Sets a callback that will be raised when the node will be disposed
  37578. */
  37579. set onDispose(callback: () => void);
  37580. /**
  37581. * Creates a new Node
  37582. * @param name the name and id to be given to this node
  37583. * @param scene the scene this node will be added to
  37584. */
  37585. constructor(name: string, scene?: Nullable<Scene>);
  37586. /**
  37587. * Gets the scene of the node
  37588. * @returns a scene
  37589. */
  37590. getScene(): Scene;
  37591. /**
  37592. * Gets the engine of the node
  37593. * @returns a Engine
  37594. */
  37595. getEngine(): Engine;
  37596. private _behaviors;
  37597. /**
  37598. * Attach a behavior to the node
  37599. * @see https://doc.babylonjs.com/features/behaviour
  37600. * @param behavior defines the behavior to attach
  37601. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37602. * @returns the current Node
  37603. */
  37604. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37605. /**
  37606. * Remove an attached behavior
  37607. * @see https://doc.babylonjs.com/features/behaviour
  37608. * @param behavior defines the behavior to attach
  37609. * @returns the current Node
  37610. */
  37611. removeBehavior(behavior: Behavior<Node>): Node;
  37612. /**
  37613. * Gets the list of attached behaviors
  37614. * @see https://doc.babylonjs.com/features/behaviour
  37615. */
  37616. get behaviors(): Behavior<Node>[];
  37617. /**
  37618. * Gets an attached behavior by name
  37619. * @param name defines the name of the behavior to look for
  37620. * @see https://doc.babylonjs.com/features/behaviour
  37621. * @returns null if behavior was not found else the requested behavior
  37622. */
  37623. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37624. /**
  37625. * Returns the latest update of the World matrix
  37626. * @returns a Matrix
  37627. */
  37628. getWorldMatrix(): Matrix;
  37629. /** @hidden */
  37630. _getWorldMatrixDeterminant(): number;
  37631. /**
  37632. * Returns directly the latest state of the mesh World matrix.
  37633. * A Matrix is returned.
  37634. */
  37635. get worldMatrixFromCache(): Matrix;
  37636. /** @hidden */
  37637. _initCache(): void;
  37638. /** @hidden */
  37639. updateCache(force?: boolean): void;
  37640. /** @hidden */
  37641. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37642. /** @hidden */
  37643. _updateCache(ignoreParentClass?: boolean): void;
  37644. /** @hidden */
  37645. _isSynchronized(): boolean;
  37646. /** @hidden */
  37647. _markSyncedWithParent(): void;
  37648. /** @hidden */
  37649. isSynchronizedWithParent(): boolean;
  37650. /** @hidden */
  37651. isSynchronized(): boolean;
  37652. /**
  37653. * Is this node ready to be used/rendered
  37654. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37655. * @return true if the node is ready
  37656. */
  37657. isReady(completeCheck?: boolean): boolean;
  37658. /**
  37659. * Is this node enabled?
  37660. * 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
  37661. * @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
  37662. * @return whether this node (and its parent) is enabled
  37663. */
  37664. isEnabled(checkAncestors?: boolean): boolean;
  37665. /** @hidden */
  37666. protected _syncParentEnabledState(): void;
  37667. /**
  37668. * Set the enabled state of this node
  37669. * @param value defines the new enabled state
  37670. */
  37671. setEnabled(value: boolean): void;
  37672. /**
  37673. * Is this node a descendant of the given node?
  37674. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37675. * @param ancestor defines the parent node to inspect
  37676. * @returns a boolean indicating if this node is a descendant of the given node
  37677. */
  37678. isDescendantOf(ancestor: Node): boolean;
  37679. /** @hidden */
  37680. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37681. /**
  37682. * Will return all nodes that have this node as ascendant
  37683. * @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
  37684. * @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
  37685. * @return all children nodes of all types
  37686. */
  37687. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37688. /**
  37689. * Get all child-meshes of this node
  37690. * @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)
  37691. * @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
  37692. * @returns an array of AbstractMesh
  37693. */
  37694. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37695. /**
  37696. * Get all direct children of this node
  37697. * @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
  37698. * @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)
  37699. * @returns an array of Node
  37700. */
  37701. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37702. /** @hidden */
  37703. _setReady(state: boolean): void;
  37704. /**
  37705. * Get an animation by name
  37706. * @param name defines the name of the animation to look for
  37707. * @returns null if not found else the requested animation
  37708. */
  37709. getAnimationByName(name: string): Nullable<Animation>;
  37710. /**
  37711. * Creates an animation range for this node
  37712. * @param name defines the name of the range
  37713. * @param from defines the starting key
  37714. * @param to defines the end key
  37715. */
  37716. createAnimationRange(name: string, from: number, to: number): void;
  37717. /**
  37718. * Delete a specific animation range
  37719. * @param name defines the name of the range to delete
  37720. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37721. */
  37722. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37723. /**
  37724. * Get an animation range by name
  37725. * @param name defines the name of the animation range to look for
  37726. * @returns null if not found else the requested animation range
  37727. */
  37728. getAnimationRange(name: string): Nullable<AnimationRange>;
  37729. /**
  37730. * Gets the list of all animation ranges defined on this node
  37731. * @returns an array
  37732. */
  37733. getAnimationRanges(): Nullable<AnimationRange>[];
  37734. /**
  37735. * Will start the animation sequence
  37736. * @param name defines the range frames for animation sequence
  37737. * @param loop defines if the animation should loop (false by default)
  37738. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37739. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37740. * @returns the object created for this animation. If range does not exist, it will return null
  37741. */
  37742. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37743. /**
  37744. * Serialize animation ranges into a JSON compatible object
  37745. * @returns serialization object
  37746. */
  37747. serializeAnimationRanges(): any;
  37748. /**
  37749. * Computes the world matrix of the node
  37750. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37751. * @returns the world matrix
  37752. */
  37753. computeWorldMatrix(force?: boolean): Matrix;
  37754. /**
  37755. * Releases resources associated with this node.
  37756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37758. */
  37759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37760. /**
  37761. * Parse animation range data from a serialization object and store them into a given node
  37762. * @param node defines where to store the animation ranges
  37763. * @param parsedNode defines the serialization object to read data from
  37764. * @param scene defines the hosting scene
  37765. */
  37766. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37767. /**
  37768. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37769. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37770. * @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
  37771. * @returns the new bounding vectors
  37772. */
  37773. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37774. min: Vector3;
  37775. max: Vector3;
  37776. };
  37777. }
  37778. }
  37779. declare module "babylonjs/Animations/animation" {
  37780. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37781. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37782. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37783. import { Nullable } from "babylonjs/types";
  37784. import { Scene } from "babylonjs/scene";
  37785. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37786. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37787. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37788. import { Node } from "babylonjs/node";
  37789. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37790. import { Size } from "babylonjs/Maths/math.size";
  37791. import { Animatable } from "babylonjs/Animations/animatable";
  37792. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37793. /**
  37794. * @hidden
  37795. */
  37796. export class _IAnimationState {
  37797. key: number;
  37798. repeatCount: number;
  37799. workValue?: any;
  37800. loopMode?: number;
  37801. offsetValue?: any;
  37802. highLimitValue?: any;
  37803. }
  37804. /**
  37805. * Class used to store any kind of animation
  37806. */
  37807. export class Animation {
  37808. /**Name of the animation */
  37809. name: string;
  37810. /**Property to animate */
  37811. targetProperty: string;
  37812. /**The frames per second of the animation */
  37813. framePerSecond: number;
  37814. /**The data type of the animation */
  37815. dataType: number;
  37816. /**The loop mode of the animation */
  37817. loopMode?: number | undefined;
  37818. /**Specifies if blending should be enabled */
  37819. enableBlending?: boolean | undefined;
  37820. /**
  37821. * Use matrix interpolation instead of using direct key value when animating matrices
  37822. */
  37823. static AllowMatricesInterpolation: boolean;
  37824. /**
  37825. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37826. */
  37827. static AllowMatrixDecomposeForInterpolation: boolean;
  37828. /** Define the Url to load snippets */
  37829. static SnippetUrl: string;
  37830. /** Snippet ID if the animation was created from the snippet server */
  37831. snippetId: string;
  37832. /**
  37833. * Stores the key frames of the animation
  37834. */
  37835. private _keys;
  37836. /**
  37837. * Stores the easing function of the animation
  37838. */
  37839. private _easingFunction;
  37840. /**
  37841. * @hidden Internal use only
  37842. */
  37843. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37844. /**
  37845. * The set of event that will be linked to this animation
  37846. */
  37847. private _events;
  37848. /**
  37849. * Stores an array of target property paths
  37850. */
  37851. targetPropertyPath: string[];
  37852. /**
  37853. * Stores the blending speed of the animation
  37854. */
  37855. blendingSpeed: number;
  37856. /**
  37857. * Stores the animation ranges for the animation
  37858. */
  37859. private _ranges;
  37860. /**
  37861. * @hidden Internal use
  37862. */
  37863. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37864. /**
  37865. * Sets up an animation
  37866. * @param property The property to animate
  37867. * @param animationType The animation type to apply
  37868. * @param framePerSecond The frames per second of the animation
  37869. * @param easingFunction The easing function used in the animation
  37870. * @returns The created animation
  37871. */
  37872. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37873. /**
  37874. * Create and start an animation on a node
  37875. * @param name defines the name of the global animation that will be run on all nodes
  37876. * @param node defines the root node where the animation will take place
  37877. * @param targetProperty defines property to animate
  37878. * @param framePerSecond defines the number of frame per second yo use
  37879. * @param totalFrame defines the number of frames in total
  37880. * @param from defines the initial value
  37881. * @param to defines the final value
  37882. * @param loopMode defines which loop mode you want to use (off by default)
  37883. * @param easingFunction defines the easing function to use (linear by default)
  37884. * @param onAnimationEnd defines the callback to call when animation end
  37885. * @returns the animatable created for this animation
  37886. */
  37887. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37888. /**
  37889. * Create and start an animation on a node and its descendants
  37890. * @param name defines the name of the global animation that will be run on all nodes
  37891. * @param node defines the root node where the animation will take place
  37892. * @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
  37893. * @param targetProperty defines property to animate
  37894. * @param framePerSecond defines the number of frame per second to use
  37895. * @param totalFrame defines the number of frames in total
  37896. * @param from defines the initial value
  37897. * @param to defines the final value
  37898. * @param loopMode defines which loop mode you want to use (off by default)
  37899. * @param easingFunction defines the easing function to use (linear by default)
  37900. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37901. * @returns the list of animatables created for all nodes
  37902. * @example https://www.babylonjs-playground.com/#MH0VLI
  37903. */
  37904. 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[]>;
  37905. /**
  37906. * Creates a new animation, merges it with the existing animations and starts it
  37907. * @param name Name of the animation
  37908. * @param node Node which contains the scene that begins the animations
  37909. * @param targetProperty Specifies which property to animate
  37910. * @param framePerSecond The frames per second of the animation
  37911. * @param totalFrame The total number of frames
  37912. * @param from The frame at the beginning of the animation
  37913. * @param to The frame at the end of the animation
  37914. * @param loopMode Specifies the loop mode of the animation
  37915. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37916. * @param onAnimationEnd Callback to run once the animation is complete
  37917. * @returns Nullable animation
  37918. */
  37919. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37920. /**
  37921. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37922. * @param sourceAnimation defines the Animation containing keyframes to convert
  37923. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37924. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37925. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37926. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37927. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37928. */
  37929. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37930. /**
  37931. * Transition property of an host to the target Value
  37932. * @param property The property to transition
  37933. * @param targetValue The target Value of the property
  37934. * @param host The object where the property to animate belongs
  37935. * @param scene Scene used to run the animation
  37936. * @param frameRate Framerate (in frame/s) to use
  37937. * @param transition The transition type we want to use
  37938. * @param duration The duration of the animation, in milliseconds
  37939. * @param onAnimationEnd Callback trigger at the end of the animation
  37940. * @returns Nullable animation
  37941. */
  37942. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37943. /**
  37944. * Return the array of runtime animations currently using this animation
  37945. */
  37946. get runtimeAnimations(): RuntimeAnimation[];
  37947. /**
  37948. * Specifies if any of the runtime animations are currently running
  37949. */
  37950. get hasRunningRuntimeAnimations(): boolean;
  37951. /**
  37952. * Initializes the animation
  37953. * @param name Name of the animation
  37954. * @param targetProperty Property to animate
  37955. * @param framePerSecond The frames per second of the animation
  37956. * @param dataType The data type of the animation
  37957. * @param loopMode The loop mode of the animation
  37958. * @param enableBlending Specifies if blending should be enabled
  37959. */
  37960. constructor(
  37961. /**Name of the animation */
  37962. name: string,
  37963. /**Property to animate */
  37964. targetProperty: string,
  37965. /**The frames per second of the animation */
  37966. framePerSecond: number,
  37967. /**The data type of the animation */
  37968. dataType: number,
  37969. /**The loop mode of the animation */
  37970. loopMode?: number | undefined,
  37971. /**Specifies if blending should be enabled */
  37972. enableBlending?: boolean | undefined);
  37973. /**
  37974. * Converts the animation to a string
  37975. * @param fullDetails support for multiple levels of logging within scene loading
  37976. * @returns String form of the animation
  37977. */
  37978. toString(fullDetails?: boolean): string;
  37979. /**
  37980. * Add an event to this animation
  37981. * @param event Event to add
  37982. */
  37983. addEvent(event: AnimationEvent): void;
  37984. /**
  37985. * Remove all events found at the given frame
  37986. * @param frame The frame to remove events from
  37987. */
  37988. removeEvents(frame: number): void;
  37989. /**
  37990. * Retrieves all the events from the animation
  37991. * @returns Events from the animation
  37992. */
  37993. getEvents(): AnimationEvent[];
  37994. /**
  37995. * Creates an animation range
  37996. * @param name Name of the animation range
  37997. * @param from Starting frame of the animation range
  37998. * @param to Ending frame of the animation
  37999. */
  38000. createRange(name: string, from: number, to: number): void;
  38001. /**
  38002. * Deletes an animation range by name
  38003. * @param name Name of the animation range to delete
  38004. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38005. */
  38006. deleteRange(name: string, deleteFrames?: boolean): void;
  38007. /**
  38008. * Gets the animation range by name, or null if not defined
  38009. * @param name Name of the animation range
  38010. * @returns Nullable animation range
  38011. */
  38012. getRange(name: string): Nullable<AnimationRange>;
  38013. /**
  38014. * Gets the key frames from the animation
  38015. * @returns The key frames of the animation
  38016. */
  38017. getKeys(): Array<IAnimationKey>;
  38018. /**
  38019. * Gets the highest frame rate of the animation
  38020. * @returns Highest frame rate of the animation
  38021. */
  38022. getHighestFrame(): number;
  38023. /**
  38024. * Gets the easing function of the animation
  38025. * @returns Easing function of the animation
  38026. */
  38027. getEasingFunction(): IEasingFunction;
  38028. /**
  38029. * Sets the easing function of the animation
  38030. * @param easingFunction A custom mathematical formula for animation
  38031. */
  38032. setEasingFunction(easingFunction: EasingFunction): void;
  38033. /**
  38034. * Interpolates a scalar linearly
  38035. * @param startValue Start value of the animation curve
  38036. * @param endValue End value of the animation curve
  38037. * @param gradient Scalar amount to interpolate
  38038. * @returns Interpolated scalar value
  38039. */
  38040. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38041. /**
  38042. * Interpolates a scalar cubically
  38043. * @param startValue Start value of the animation curve
  38044. * @param outTangent End tangent of the animation
  38045. * @param endValue End value of the animation curve
  38046. * @param inTangent Start tangent of the animation curve
  38047. * @param gradient Scalar amount to interpolate
  38048. * @returns Interpolated scalar value
  38049. */
  38050. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38051. /**
  38052. * Interpolates a quaternion using a spherical linear interpolation
  38053. * @param startValue Start value of the animation curve
  38054. * @param endValue End value of the animation curve
  38055. * @param gradient Scalar amount to interpolate
  38056. * @returns Interpolated quaternion value
  38057. */
  38058. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38059. /**
  38060. * Interpolates a quaternion cubically
  38061. * @param startValue Start value of the animation curve
  38062. * @param outTangent End tangent of the animation curve
  38063. * @param endValue End value of the animation curve
  38064. * @param inTangent Start tangent of the animation curve
  38065. * @param gradient Scalar amount to interpolate
  38066. * @returns Interpolated quaternion value
  38067. */
  38068. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38069. /**
  38070. * Interpolates a Vector3 linearl
  38071. * @param startValue Start value of the animation curve
  38072. * @param endValue End value of the animation curve
  38073. * @param gradient Scalar amount to interpolate
  38074. * @returns Interpolated scalar value
  38075. */
  38076. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38077. /**
  38078. * Interpolates a Vector3 cubically
  38079. * @param startValue Start value of the animation curve
  38080. * @param outTangent End tangent of the animation
  38081. * @param endValue End value of the animation curve
  38082. * @param inTangent Start tangent of the animation curve
  38083. * @param gradient Scalar amount to interpolate
  38084. * @returns InterpolatedVector3 value
  38085. */
  38086. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38087. /**
  38088. * Interpolates a Vector2 linearly
  38089. * @param startValue Start value of the animation curve
  38090. * @param endValue End value of the animation curve
  38091. * @param gradient Scalar amount to interpolate
  38092. * @returns Interpolated Vector2 value
  38093. */
  38094. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38095. /**
  38096. * Interpolates a Vector2 cubically
  38097. * @param startValue Start value of the animation curve
  38098. * @param outTangent End tangent of the animation
  38099. * @param endValue End value of the animation curve
  38100. * @param inTangent Start tangent of the animation curve
  38101. * @param gradient Scalar amount to interpolate
  38102. * @returns Interpolated Vector2 value
  38103. */
  38104. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38105. /**
  38106. * Interpolates a size linearly
  38107. * @param startValue Start value of the animation curve
  38108. * @param endValue End value of the animation curve
  38109. * @param gradient Scalar amount to interpolate
  38110. * @returns Interpolated Size value
  38111. */
  38112. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38113. /**
  38114. * Interpolates a Color3 linearly
  38115. * @param startValue Start value of the animation curve
  38116. * @param endValue End value of the animation curve
  38117. * @param gradient Scalar amount to interpolate
  38118. * @returns Interpolated Color3 value
  38119. */
  38120. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38121. /**
  38122. * Interpolates a Color4 linearly
  38123. * @param startValue Start value of the animation curve
  38124. * @param endValue End value of the animation curve
  38125. * @param gradient Scalar amount to interpolate
  38126. * @returns Interpolated Color3 value
  38127. */
  38128. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38129. /**
  38130. * @hidden Internal use only
  38131. */
  38132. _getKeyValue(value: any): any;
  38133. /**
  38134. * @hidden Internal use only
  38135. */
  38136. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38137. /**
  38138. * Defines the function to use to interpolate matrices
  38139. * @param startValue defines the start matrix
  38140. * @param endValue defines the end matrix
  38141. * @param gradient defines the gradient between both matrices
  38142. * @param result defines an optional target matrix where to store the interpolation
  38143. * @returns the interpolated matrix
  38144. */
  38145. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38146. /**
  38147. * Makes a copy of the animation
  38148. * @returns Cloned animation
  38149. */
  38150. clone(): Animation;
  38151. /**
  38152. * Sets the key frames of the animation
  38153. * @param values The animation key frames to set
  38154. */
  38155. setKeys(values: Array<IAnimationKey>): void;
  38156. /**
  38157. * Serializes the animation to an object
  38158. * @returns Serialized object
  38159. */
  38160. serialize(): any;
  38161. /**
  38162. * Float animation type
  38163. */
  38164. static readonly ANIMATIONTYPE_FLOAT: number;
  38165. /**
  38166. * Vector3 animation type
  38167. */
  38168. static readonly ANIMATIONTYPE_VECTOR3: number;
  38169. /**
  38170. * Quaternion animation type
  38171. */
  38172. static readonly ANIMATIONTYPE_QUATERNION: number;
  38173. /**
  38174. * Matrix animation type
  38175. */
  38176. static readonly ANIMATIONTYPE_MATRIX: number;
  38177. /**
  38178. * Color3 animation type
  38179. */
  38180. static readonly ANIMATIONTYPE_COLOR3: number;
  38181. /**
  38182. * Color3 animation type
  38183. */
  38184. static readonly ANIMATIONTYPE_COLOR4: number;
  38185. /**
  38186. * Vector2 animation type
  38187. */
  38188. static readonly ANIMATIONTYPE_VECTOR2: number;
  38189. /**
  38190. * Size animation type
  38191. */
  38192. static readonly ANIMATIONTYPE_SIZE: number;
  38193. /**
  38194. * Relative Loop Mode
  38195. */
  38196. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38197. /**
  38198. * Cycle Loop Mode
  38199. */
  38200. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38201. /**
  38202. * Constant Loop Mode
  38203. */
  38204. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38205. /** @hidden */
  38206. static _UniversalLerp(left: any, right: any, amount: number): any;
  38207. /**
  38208. * Parses an animation object and creates an animation
  38209. * @param parsedAnimation Parsed animation object
  38210. * @returns Animation object
  38211. */
  38212. static Parse(parsedAnimation: any): Animation;
  38213. /**
  38214. * Appends the serialized animations from the source animations
  38215. * @param source Source containing the animations
  38216. * @param destination Target to store the animations
  38217. */
  38218. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38219. /**
  38220. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38221. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38222. * @param url defines the url to load from
  38223. * @returns a promise that will resolve to the new animation or an array of animations
  38224. */
  38225. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38226. /**
  38227. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38228. * @param snippetId defines the snippet to load
  38229. * @returns a promise that will resolve to the new animation or a new array of animations
  38230. */
  38231. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38232. }
  38233. }
  38234. declare module "babylonjs/Animations/animatable.interface" {
  38235. import { Nullable } from "babylonjs/types";
  38236. import { Animation } from "babylonjs/Animations/animation";
  38237. /**
  38238. * Interface containing an array of animations
  38239. */
  38240. export interface IAnimatable {
  38241. /**
  38242. * Array of animations
  38243. */
  38244. animations: Nullable<Array<Animation>>;
  38245. }
  38246. }
  38247. declare module "babylonjs/Misc/decorators" {
  38248. import { Nullable } from "babylonjs/types";
  38249. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38250. import { Scene } from "babylonjs/scene";
  38251. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38252. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38253. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38255. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38256. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38257. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38258. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38259. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38260. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38261. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38262. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38263. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38264. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38265. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38266. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38267. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38268. /**
  38269. * Decorator used to define property that can be serialized as reference to a camera
  38270. * @param sourceName defines the name of the property to decorate
  38271. */
  38272. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38273. /**
  38274. * Class used to help serialization objects
  38275. */
  38276. export class SerializationHelper {
  38277. /** @hidden */
  38278. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38279. /** @hidden */
  38280. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38281. /** @hidden */
  38282. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38283. /** @hidden */
  38284. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38285. /**
  38286. * Appends the serialized animations from the source animations
  38287. * @param source Source containing the animations
  38288. * @param destination Target to store the animations
  38289. */
  38290. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38291. /**
  38292. * Static function used to serialized a specific entity
  38293. * @param entity defines the entity to serialize
  38294. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38295. * @returns a JSON compatible object representing the serialization of the entity
  38296. */
  38297. static Serialize<T>(entity: T, serializationObject?: any): any;
  38298. /**
  38299. * Creates a new entity from a serialization data object
  38300. * @param creationFunction defines a function used to instanciated the new entity
  38301. * @param source defines the source serialization data
  38302. * @param scene defines the hosting scene
  38303. * @param rootUrl defines the root url for resources
  38304. * @returns a new entity
  38305. */
  38306. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38307. /**
  38308. * Clones an object
  38309. * @param creationFunction defines the function used to instanciate the new object
  38310. * @param source defines the source object
  38311. * @returns the cloned object
  38312. */
  38313. static Clone<T>(creationFunction: () => T, source: T): T;
  38314. /**
  38315. * Instanciates a new object based on a source one (some data will be shared between both object)
  38316. * @param creationFunction defines the function used to instanciate the new object
  38317. * @param source defines the source object
  38318. * @returns the new object
  38319. */
  38320. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38321. }
  38322. }
  38323. declare module "babylonjs/Materials/Textures/baseTexture" {
  38324. import { Observable } from "babylonjs/Misc/observable";
  38325. import { Nullable } from "babylonjs/types";
  38326. import { Scene } from "babylonjs/scene";
  38327. import { Matrix } from "babylonjs/Maths/math.vector";
  38328. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38329. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38330. import { ISize } from "babylonjs/Maths/math.size";
  38331. import "babylonjs/Misc/fileTools";
  38332. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38333. /**
  38334. * Base class of all the textures in babylon.
  38335. * It groups all the common properties the materials, post process, lights... might need
  38336. * in order to make a correct use of the texture.
  38337. */
  38338. export class BaseTexture implements IAnimatable {
  38339. /**
  38340. * Default anisotropic filtering level for the application.
  38341. * It is set to 4 as a good tradeoff between perf and quality.
  38342. */
  38343. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38344. /**
  38345. * Gets or sets the unique id of the texture
  38346. */
  38347. uniqueId: number;
  38348. /**
  38349. * Define the name of the texture.
  38350. */
  38351. name: string;
  38352. /**
  38353. * Gets or sets an object used to store user defined information.
  38354. */
  38355. metadata: any;
  38356. /**
  38357. * For internal use only. Please do not use.
  38358. */
  38359. reservedDataStore: any;
  38360. private _hasAlpha;
  38361. /**
  38362. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38363. */
  38364. set hasAlpha(value: boolean);
  38365. get hasAlpha(): boolean;
  38366. /**
  38367. * Defines if the alpha value should be determined via the rgb values.
  38368. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38369. */
  38370. getAlphaFromRGB: boolean;
  38371. /**
  38372. * Intensity or strength of the texture.
  38373. * It is commonly used by materials to fine tune the intensity of the texture
  38374. */
  38375. level: number;
  38376. /**
  38377. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38378. * This is part of the texture as textures usually maps to one uv set.
  38379. */
  38380. coordinatesIndex: number;
  38381. protected _coordinatesMode: number;
  38382. /**
  38383. * How a texture is mapped.
  38384. *
  38385. * | Value | Type | Description |
  38386. * | ----- | ----------------------------------- | ----------- |
  38387. * | 0 | EXPLICIT_MODE | |
  38388. * | 1 | SPHERICAL_MODE | |
  38389. * | 2 | PLANAR_MODE | |
  38390. * | 3 | CUBIC_MODE | |
  38391. * | 4 | PROJECTION_MODE | |
  38392. * | 5 | SKYBOX_MODE | |
  38393. * | 6 | INVCUBIC_MODE | |
  38394. * | 7 | EQUIRECTANGULAR_MODE | |
  38395. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38396. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38397. */
  38398. set coordinatesMode(value: number);
  38399. get coordinatesMode(): number;
  38400. private _wrapU;
  38401. /**
  38402. * | Value | Type | Description |
  38403. * | ----- | ------------------ | ----------- |
  38404. * | 0 | CLAMP_ADDRESSMODE | |
  38405. * | 1 | WRAP_ADDRESSMODE | |
  38406. * | 2 | MIRROR_ADDRESSMODE | |
  38407. */
  38408. get wrapU(): number;
  38409. set wrapU(value: number);
  38410. private _wrapV;
  38411. /**
  38412. * | Value | Type | Description |
  38413. * | ----- | ------------------ | ----------- |
  38414. * | 0 | CLAMP_ADDRESSMODE | |
  38415. * | 1 | WRAP_ADDRESSMODE | |
  38416. * | 2 | MIRROR_ADDRESSMODE | |
  38417. */
  38418. get wrapV(): number;
  38419. set wrapV(value: number);
  38420. /**
  38421. * | Value | Type | Description |
  38422. * | ----- | ------------------ | ----------- |
  38423. * | 0 | CLAMP_ADDRESSMODE | |
  38424. * | 1 | WRAP_ADDRESSMODE | |
  38425. * | 2 | MIRROR_ADDRESSMODE | |
  38426. */
  38427. wrapR: number;
  38428. /**
  38429. * With compliant hardware and browser (supporting anisotropic filtering)
  38430. * this defines the level of anisotropic filtering in the texture.
  38431. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38432. */
  38433. anisotropicFilteringLevel: number;
  38434. /**
  38435. * Define if the texture is a cube texture or if false a 2d texture.
  38436. */
  38437. get isCube(): boolean;
  38438. set isCube(value: boolean);
  38439. /**
  38440. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38441. */
  38442. get is3D(): boolean;
  38443. set is3D(value: boolean);
  38444. /**
  38445. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38446. */
  38447. get is2DArray(): boolean;
  38448. set is2DArray(value: boolean);
  38449. private _gammaSpace;
  38450. /**
  38451. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38452. * HDR texture are usually stored in linear space.
  38453. * This only impacts the PBR and Background materials
  38454. */
  38455. get gammaSpace(): boolean;
  38456. set gammaSpace(gamma: boolean);
  38457. /**
  38458. * Gets or sets whether or not the texture contains RGBD data.
  38459. */
  38460. get isRGBD(): boolean;
  38461. set isRGBD(value: boolean);
  38462. /**
  38463. * Is Z inverted in the texture (useful in a cube texture).
  38464. */
  38465. invertZ: boolean;
  38466. /**
  38467. * Are mip maps generated for this texture or not.
  38468. */
  38469. get noMipmap(): boolean;
  38470. /**
  38471. * @hidden
  38472. */
  38473. lodLevelInAlpha: boolean;
  38474. /**
  38475. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38476. */
  38477. get lodGenerationOffset(): number;
  38478. set lodGenerationOffset(value: number);
  38479. /**
  38480. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38481. */
  38482. get lodGenerationScale(): number;
  38483. set lodGenerationScale(value: number);
  38484. /**
  38485. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38486. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38487. * average roughness values.
  38488. */
  38489. get linearSpecularLOD(): boolean;
  38490. set linearSpecularLOD(value: boolean);
  38491. /**
  38492. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38493. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38494. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38495. */
  38496. get irradianceTexture(): Nullable<BaseTexture>;
  38497. set irradianceTexture(value: Nullable<BaseTexture>);
  38498. /**
  38499. * Define if the texture is a render target.
  38500. */
  38501. isRenderTarget: boolean;
  38502. /**
  38503. * Define the unique id of the texture in the scene.
  38504. */
  38505. get uid(): string;
  38506. /** @hidden */
  38507. _prefiltered: boolean;
  38508. /**
  38509. * Return a string representation of the texture.
  38510. * @returns the texture as a string
  38511. */
  38512. toString(): string;
  38513. /**
  38514. * Get the class name of the texture.
  38515. * @returns "BaseTexture"
  38516. */
  38517. getClassName(): string;
  38518. /**
  38519. * Define the list of animation attached to the texture.
  38520. */
  38521. animations: import("babylonjs/Animations/animation").Animation[];
  38522. /**
  38523. * An event triggered when the texture is disposed.
  38524. */
  38525. onDisposeObservable: Observable<BaseTexture>;
  38526. private _onDisposeObserver;
  38527. /**
  38528. * Callback triggered when the texture has been disposed.
  38529. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38530. */
  38531. set onDispose(callback: () => void);
  38532. /**
  38533. * Define the current state of the loading sequence when in delayed load mode.
  38534. */
  38535. delayLoadState: number;
  38536. protected _scene: Nullable<Scene>;
  38537. protected _engine: Nullable<ThinEngine>;
  38538. /** @hidden */
  38539. _texture: Nullable<InternalTexture>;
  38540. private _uid;
  38541. /**
  38542. * Define if the texture is preventinga material to render or not.
  38543. * If not and the texture is not ready, the engine will use a default black texture instead.
  38544. */
  38545. get isBlocking(): boolean;
  38546. /**
  38547. * Instantiates a new BaseTexture.
  38548. * Base class of all the textures in babylon.
  38549. * It groups all the common properties the materials, post process, lights... might need
  38550. * in order to make a correct use of the texture.
  38551. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38552. */
  38553. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38554. /**
  38555. * Get the scene the texture belongs to.
  38556. * @returns the scene or null if undefined
  38557. */
  38558. getScene(): Nullable<Scene>;
  38559. /** @hidden */
  38560. protected _getEngine(): Nullable<ThinEngine>;
  38561. /**
  38562. * Get the texture transform matrix used to offset tile the texture for istance.
  38563. * @returns the transformation matrix
  38564. */
  38565. getTextureMatrix(): Matrix;
  38566. /**
  38567. * Get the texture reflection matrix used to rotate/transform the reflection.
  38568. * @returns the reflection matrix
  38569. */
  38570. getReflectionTextureMatrix(): Matrix;
  38571. /**
  38572. * Get the underlying lower level texture from Babylon.
  38573. * @returns the insternal texture
  38574. */
  38575. getInternalTexture(): Nullable<InternalTexture>;
  38576. /**
  38577. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38578. * @returns true if ready or not blocking
  38579. */
  38580. isReadyOrNotBlocking(): boolean;
  38581. /**
  38582. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38583. * @returns true if fully ready
  38584. */
  38585. isReady(): boolean;
  38586. private _cachedSize;
  38587. /**
  38588. * Get the size of the texture.
  38589. * @returns the texture size.
  38590. */
  38591. getSize(): ISize;
  38592. /**
  38593. * Get the base size of the texture.
  38594. * It can be different from the size if the texture has been resized for POT for instance
  38595. * @returns the base size
  38596. */
  38597. getBaseSize(): ISize;
  38598. /**
  38599. * Update the sampling mode of the texture.
  38600. * Default is Trilinear mode.
  38601. *
  38602. * | Value | Type | Description |
  38603. * | ----- | ------------------ | ----------- |
  38604. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38605. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38606. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38607. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38608. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38609. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38610. * | 7 | NEAREST_LINEAR | |
  38611. * | 8 | NEAREST_NEAREST | |
  38612. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38613. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38614. * | 11 | LINEAR_LINEAR | |
  38615. * | 12 | LINEAR_NEAREST | |
  38616. *
  38617. * > _mag_: magnification filter (close to the viewer)
  38618. * > _min_: minification filter (far from the viewer)
  38619. * > _mip_: filter used between mip map levels
  38620. *@param samplingMode Define the new sampling mode of the texture
  38621. */
  38622. updateSamplingMode(samplingMode: number): void;
  38623. /**
  38624. * Scales the texture if is `canRescale()`
  38625. * @param ratio the resize factor we want to use to rescale
  38626. */
  38627. scale(ratio: number): void;
  38628. /**
  38629. * Get if the texture can rescale.
  38630. */
  38631. get canRescale(): boolean;
  38632. /** @hidden */
  38633. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38634. /** @hidden */
  38635. _rebuild(): void;
  38636. /**
  38637. * Triggers the load sequence in delayed load mode.
  38638. */
  38639. delayLoad(): void;
  38640. /**
  38641. * Clones the texture.
  38642. * @returns the cloned texture
  38643. */
  38644. clone(): Nullable<BaseTexture>;
  38645. /**
  38646. * Get the texture underlying type (INT, FLOAT...)
  38647. */
  38648. get textureType(): number;
  38649. /**
  38650. * Get the texture underlying format (RGB, RGBA...)
  38651. */
  38652. get textureFormat(): number;
  38653. /**
  38654. * Indicates that textures need to be re-calculated for all materials
  38655. */
  38656. protected _markAllSubMeshesAsTexturesDirty(): void;
  38657. /**
  38658. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38659. * This will returns an RGBA array buffer containing either in values (0-255) or
  38660. * float values (0-1) depending of the underlying buffer type.
  38661. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38662. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38663. * @param buffer defines a user defined buffer to fill with data (can be null)
  38664. * @returns The Array buffer containing the pixels data.
  38665. */
  38666. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38667. /**
  38668. * Release and destroy the underlying lower level texture aka internalTexture.
  38669. */
  38670. releaseInternalTexture(): void;
  38671. /** @hidden */
  38672. get _lodTextureHigh(): Nullable<BaseTexture>;
  38673. /** @hidden */
  38674. get _lodTextureMid(): Nullable<BaseTexture>;
  38675. /** @hidden */
  38676. get _lodTextureLow(): Nullable<BaseTexture>;
  38677. /**
  38678. * Dispose the texture and release its associated resources.
  38679. */
  38680. dispose(): void;
  38681. /**
  38682. * Serialize the texture into a JSON representation that can be parsed later on.
  38683. * @returns the JSON representation of the texture
  38684. */
  38685. serialize(): any;
  38686. /**
  38687. * Helper function to be called back once a list of texture contains only ready textures.
  38688. * @param textures Define the list of textures to wait for
  38689. * @param callback Define the callback triggered once the entire list will be ready
  38690. */
  38691. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38692. private static _isScene;
  38693. }
  38694. }
  38695. declare module "babylonjs/Materials/effect" {
  38696. import { Observable } from "babylonjs/Misc/observable";
  38697. import { Nullable } from "babylonjs/types";
  38698. import { IDisposable } from "babylonjs/scene";
  38699. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38700. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38701. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38702. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38703. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38704. import { Engine } from "babylonjs/Engines/engine";
  38705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38707. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38708. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38709. /**
  38710. * Options to be used when creating an effect.
  38711. */
  38712. export interface IEffectCreationOptions {
  38713. /**
  38714. * Atrributes that will be used in the shader.
  38715. */
  38716. attributes: string[];
  38717. /**
  38718. * Uniform varible names that will be set in the shader.
  38719. */
  38720. uniformsNames: string[];
  38721. /**
  38722. * Uniform buffer variable names that will be set in the shader.
  38723. */
  38724. uniformBuffersNames: string[];
  38725. /**
  38726. * Sampler texture variable names that will be set in the shader.
  38727. */
  38728. samplers: string[];
  38729. /**
  38730. * Define statements that will be set in the shader.
  38731. */
  38732. defines: any;
  38733. /**
  38734. * Possible fallbacks for this effect to improve performance when needed.
  38735. */
  38736. fallbacks: Nullable<IEffectFallbacks>;
  38737. /**
  38738. * Callback that will be called when the shader is compiled.
  38739. */
  38740. onCompiled: Nullable<(effect: Effect) => void>;
  38741. /**
  38742. * Callback that will be called if an error occurs during shader compilation.
  38743. */
  38744. onError: Nullable<(effect: Effect, errors: string) => void>;
  38745. /**
  38746. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38747. */
  38748. indexParameters?: any;
  38749. /**
  38750. * Max number of lights that can be used in the shader.
  38751. */
  38752. maxSimultaneousLights?: number;
  38753. /**
  38754. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38755. */
  38756. transformFeedbackVaryings?: Nullable<string[]>;
  38757. /**
  38758. * 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
  38759. */
  38760. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38761. /**
  38762. * Is this effect rendering to several color attachments ?
  38763. */
  38764. multiTarget?: boolean;
  38765. }
  38766. /**
  38767. * Effect containing vertex and fragment shader that can be executed on an object.
  38768. */
  38769. export class Effect implements IDisposable {
  38770. /**
  38771. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38772. */
  38773. static ShadersRepository: string;
  38774. /**
  38775. * Enable logging of the shader code when a compilation error occurs
  38776. */
  38777. static LogShaderCodeOnCompilationError: boolean;
  38778. /**
  38779. * Name of the effect.
  38780. */
  38781. name: any;
  38782. /**
  38783. * String container all the define statements that should be set on the shader.
  38784. */
  38785. defines: string;
  38786. /**
  38787. * Callback that will be called when the shader is compiled.
  38788. */
  38789. onCompiled: Nullable<(effect: Effect) => void>;
  38790. /**
  38791. * Callback that will be called if an error occurs during shader compilation.
  38792. */
  38793. onError: Nullable<(effect: Effect, errors: string) => void>;
  38794. /**
  38795. * Callback that will be called when effect is bound.
  38796. */
  38797. onBind: Nullable<(effect: Effect) => void>;
  38798. /**
  38799. * Unique ID of the effect.
  38800. */
  38801. uniqueId: number;
  38802. /**
  38803. * Observable that will be called when the shader is compiled.
  38804. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38805. */
  38806. onCompileObservable: Observable<Effect>;
  38807. /**
  38808. * Observable that will be called if an error occurs during shader compilation.
  38809. */
  38810. onErrorObservable: Observable<Effect>;
  38811. /** @hidden */
  38812. _onBindObservable: Nullable<Observable<Effect>>;
  38813. /**
  38814. * @hidden
  38815. * Specifies if the effect was previously ready
  38816. */
  38817. _wasPreviouslyReady: boolean;
  38818. /**
  38819. * Observable that will be called when effect is bound.
  38820. */
  38821. get onBindObservable(): Observable<Effect>;
  38822. /** @hidden */
  38823. _bonesComputationForcedToCPU: boolean;
  38824. /** @hidden */
  38825. _multiTarget: boolean;
  38826. private static _uniqueIdSeed;
  38827. private _engine;
  38828. private _uniformBuffersNames;
  38829. private _uniformBuffersNamesList;
  38830. private _uniformsNames;
  38831. private _samplerList;
  38832. private _samplers;
  38833. private _isReady;
  38834. private _compilationError;
  38835. private _allFallbacksProcessed;
  38836. private _attributesNames;
  38837. private _attributes;
  38838. private _attributeLocationByName;
  38839. private _uniforms;
  38840. /**
  38841. * Key for the effect.
  38842. * @hidden
  38843. */
  38844. _key: string;
  38845. private _indexParameters;
  38846. private _fallbacks;
  38847. private _vertexSourceCode;
  38848. private _fragmentSourceCode;
  38849. private _vertexSourceCodeOverride;
  38850. private _fragmentSourceCodeOverride;
  38851. private _transformFeedbackVaryings;
  38852. /**
  38853. * Compiled shader to webGL program.
  38854. * @hidden
  38855. */
  38856. _pipelineContext: Nullable<IPipelineContext>;
  38857. private _valueCache;
  38858. private static _baseCache;
  38859. /**
  38860. * Instantiates an effect.
  38861. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38862. * @param baseName Name of the effect.
  38863. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38864. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38865. * @param samplers List of sampler variables that will be passed to the shader.
  38866. * @param engine Engine to be used to render the effect
  38867. * @param defines Define statements to be added to the shader.
  38868. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38869. * @param onCompiled Callback that will be called when the shader is compiled.
  38870. * @param onError Callback that will be called if an error occurs during shader compilation.
  38871. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38872. */
  38873. 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);
  38874. private _useFinalCode;
  38875. /**
  38876. * Unique key for this effect
  38877. */
  38878. get key(): string;
  38879. /**
  38880. * If the effect has been compiled and prepared.
  38881. * @returns if the effect is compiled and prepared.
  38882. */
  38883. isReady(): boolean;
  38884. private _isReadyInternal;
  38885. /**
  38886. * The engine the effect was initialized with.
  38887. * @returns the engine.
  38888. */
  38889. getEngine(): Engine;
  38890. /**
  38891. * The pipeline context for this effect
  38892. * @returns the associated pipeline context
  38893. */
  38894. getPipelineContext(): Nullable<IPipelineContext>;
  38895. /**
  38896. * The set of names of attribute variables for the shader.
  38897. * @returns An array of attribute names.
  38898. */
  38899. getAttributesNames(): string[];
  38900. /**
  38901. * Returns the attribute at the given index.
  38902. * @param index The index of the attribute.
  38903. * @returns The location of the attribute.
  38904. */
  38905. getAttributeLocation(index: number): number;
  38906. /**
  38907. * Returns the attribute based on the name of the variable.
  38908. * @param name of the attribute to look up.
  38909. * @returns the attribute location.
  38910. */
  38911. getAttributeLocationByName(name: string): number;
  38912. /**
  38913. * The number of attributes.
  38914. * @returns the numnber of attributes.
  38915. */
  38916. getAttributesCount(): number;
  38917. /**
  38918. * Gets the index of a uniform variable.
  38919. * @param uniformName of the uniform to look up.
  38920. * @returns the index.
  38921. */
  38922. getUniformIndex(uniformName: string): number;
  38923. /**
  38924. * Returns the attribute based on the name of the variable.
  38925. * @param uniformName of the uniform to look up.
  38926. * @returns the location of the uniform.
  38927. */
  38928. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38929. /**
  38930. * Returns an array of sampler variable names
  38931. * @returns The array of sampler variable names.
  38932. */
  38933. getSamplers(): string[];
  38934. /**
  38935. * Returns an array of uniform variable names
  38936. * @returns The array of uniform variable names.
  38937. */
  38938. getUniformNames(): string[];
  38939. /**
  38940. * Returns an array of uniform buffer variable names
  38941. * @returns The array of uniform buffer variable names.
  38942. */
  38943. getUniformBuffersNames(): string[];
  38944. /**
  38945. * Returns the index parameters used to create the effect
  38946. * @returns The index parameters object
  38947. */
  38948. getIndexParameters(): any;
  38949. /**
  38950. * The error from the last compilation.
  38951. * @returns the error string.
  38952. */
  38953. getCompilationError(): string;
  38954. /**
  38955. * Gets a boolean indicating that all fallbacks were used during compilation
  38956. * @returns true if all fallbacks were used
  38957. */
  38958. allFallbacksProcessed(): boolean;
  38959. /**
  38960. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38961. * @param func The callback to be used.
  38962. */
  38963. executeWhenCompiled(func: (effect: Effect) => void): void;
  38964. private _checkIsReady;
  38965. private _loadShader;
  38966. /**
  38967. * Gets the vertex shader source code of this effect
  38968. */
  38969. get vertexSourceCode(): string;
  38970. /**
  38971. * Gets the fragment shader source code of this effect
  38972. */
  38973. get fragmentSourceCode(): string;
  38974. /**
  38975. * Recompiles the webGL program
  38976. * @param vertexSourceCode The source code for the vertex shader.
  38977. * @param fragmentSourceCode The source code for the fragment shader.
  38978. * @param onCompiled Callback called when completed.
  38979. * @param onError Callback called on error.
  38980. * @hidden
  38981. */
  38982. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38983. /**
  38984. * Prepares the effect
  38985. * @hidden
  38986. */
  38987. _prepareEffect(): void;
  38988. private _getShaderCodeAndErrorLine;
  38989. private _processCompilationErrors;
  38990. /**
  38991. * Checks if the effect is supported. (Must be called after compilation)
  38992. */
  38993. get isSupported(): boolean;
  38994. /**
  38995. * Binds a texture to the engine to be used as output of the shader.
  38996. * @param channel Name of the output variable.
  38997. * @param texture Texture to bind.
  38998. * @hidden
  38999. */
  39000. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39001. /**
  39002. * Sets a texture on the engine to be used in the shader.
  39003. * @param channel Name of the sampler variable.
  39004. * @param texture Texture to set.
  39005. */
  39006. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39007. /**
  39008. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39009. * @param channel Name of the sampler variable.
  39010. * @param texture Texture to set.
  39011. */
  39012. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39013. /**
  39014. * Sets an array of textures on the engine to be used in the shader.
  39015. * @param channel Name of the variable.
  39016. * @param textures Textures to set.
  39017. */
  39018. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39019. /**
  39020. * 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)
  39021. * @param channel Name of the sampler variable.
  39022. * @param postProcess Post process to get the input texture from.
  39023. */
  39024. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39025. /**
  39026. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39027. * 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)
  39028. * @param channel Name of the sampler variable.
  39029. * @param postProcess Post process to get the output texture from.
  39030. */
  39031. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39032. /** @hidden */
  39033. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39034. /** @hidden */
  39035. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39036. /** @hidden */
  39037. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39038. /** @hidden */
  39039. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39040. /**
  39041. * Binds a buffer to a uniform.
  39042. * @param buffer Buffer to bind.
  39043. * @param name Name of the uniform variable to bind to.
  39044. */
  39045. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39046. /**
  39047. * Binds block to a uniform.
  39048. * @param blockName Name of the block to bind.
  39049. * @param index Index to bind.
  39050. */
  39051. bindUniformBlock(blockName: string, index: number): void;
  39052. /**
  39053. * Sets an interger value on a uniform variable.
  39054. * @param uniformName Name of the variable.
  39055. * @param value Value to be set.
  39056. * @returns this effect.
  39057. */
  39058. setInt(uniformName: string, value: number): Effect;
  39059. /**
  39060. * Sets an int array on a uniform variable.
  39061. * @param uniformName Name of the variable.
  39062. * @param array array to be set.
  39063. * @returns this effect.
  39064. */
  39065. setIntArray(uniformName: string, array: Int32Array): Effect;
  39066. /**
  39067. * 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)
  39068. * @param uniformName Name of the variable.
  39069. * @param array array to be set.
  39070. * @returns this effect.
  39071. */
  39072. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39073. /**
  39074. * 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)
  39075. * @param uniformName Name of the variable.
  39076. * @param array array to be set.
  39077. * @returns this effect.
  39078. */
  39079. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39080. /**
  39081. * 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)
  39082. * @param uniformName Name of the variable.
  39083. * @param array array to be set.
  39084. * @returns this effect.
  39085. */
  39086. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39087. /**
  39088. * Sets an float array on a uniform variable.
  39089. * @param uniformName Name of the variable.
  39090. * @param array array to be set.
  39091. * @returns this effect.
  39092. */
  39093. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39094. /**
  39095. * 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)
  39096. * @param uniformName Name of the variable.
  39097. * @param array array to be set.
  39098. * @returns this effect.
  39099. */
  39100. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39101. /**
  39102. * 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)
  39103. * @param uniformName Name of the variable.
  39104. * @param array array to be set.
  39105. * @returns this effect.
  39106. */
  39107. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39108. /**
  39109. * 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)
  39110. * @param uniformName Name of the variable.
  39111. * @param array array to be set.
  39112. * @returns this effect.
  39113. */
  39114. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39115. /**
  39116. * Sets an array on a uniform variable.
  39117. * @param uniformName Name of the variable.
  39118. * @param array array to be set.
  39119. * @returns this effect.
  39120. */
  39121. setArray(uniformName: string, array: number[]): Effect;
  39122. /**
  39123. * 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)
  39124. * @param uniformName Name of the variable.
  39125. * @param array array to be set.
  39126. * @returns this effect.
  39127. */
  39128. setArray2(uniformName: string, array: number[]): Effect;
  39129. /**
  39130. * 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)
  39131. * @param uniformName Name of the variable.
  39132. * @param array array to be set.
  39133. * @returns this effect.
  39134. */
  39135. setArray3(uniformName: string, array: number[]): Effect;
  39136. /**
  39137. * 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)
  39138. * @param uniformName Name of the variable.
  39139. * @param array array to be set.
  39140. * @returns this effect.
  39141. */
  39142. setArray4(uniformName: string, array: number[]): Effect;
  39143. /**
  39144. * Sets matrices on a uniform variable.
  39145. * @param uniformName Name of the variable.
  39146. * @param matrices matrices to be set.
  39147. * @returns this effect.
  39148. */
  39149. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39150. /**
  39151. * Sets matrix on a uniform variable.
  39152. * @param uniformName Name of the variable.
  39153. * @param matrix matrix to be set.
  39154. * @returns this effect.
  39155. */
  39156. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39157. /**
  39158. * 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)
  39159. * @param uniformName Name of the variable.
  39160. * @param matrix matrix to be set.
  39161. * @returns this effect.
  39162. */
  39163. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39164. /**
  39165. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39166. * @param uniformName Name of the variable.
  39167. * @param matrix matrix to be set.
  39168. * @returns this effect.
  39169. */
  39170. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39171. /**
  39172. * Sets a float on a uniform variable.
  39173. * @param uniformName Name of the variable.
  39174. * @param value value to be set.
  39175. * @returns this effect.
  39176. */
  39177. setFloat(uniformName: string, value: number): Effect;
  39178. /**
  39179. * Sets a boolean on a uniform variable.
  39180. * @param uniformName Name of the variable.
  39181. * @param bool value to be set.
  39182. * @returns this effect.
  39183. */
  39184. setBool(uniformName: string, bool: boolean): Effect;
  39185. /**
  39186. * Sets a Vector2 on a uniform variable.
  39187. * @param uniformName Name of the variable.
  39188. * @param vector2 vector2 to be set.
  39189. * @returns this effect.
  39190. */
  39191. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39192. /**
  39193. * Sets a float2 on a uniform variable.
  39194. * @param uniformName Name of the variable.
  39195. * @param x First float in float2.
  39196. * @param y Second float in float2.
  39197. * @returns this effect.
  39198. */
  39199. setFloat2(uniformName: string, x: number, y: number): Effect;
  39200. /**
  39201. * Sets a Vector3 on a uniform variable.
  39202. * @param uniformName Name of the variable.
  39203. * @param vector3 Value to be set.
  39204. * @returns this effect.
  39205. */
  39206. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39207. /**
  39208. * Sets a float3 on a uniform variable.
  39209. * @param uniformName Name of the variable.
  39210. * @param x First float in float3.
  39211. * @param y Second float in float3.
  39212. * @param z Third float in float3.
  39213. * @returns this effect.
  39214. */
  39215. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39216. /**
  39217. * Sets a Vector4 on a uniform variable.
  39218. * @param uniformName Name of the variable.
  39219. * @param vector4 Value to be set.
  39220. * @returns this effect.
  39221. */
  39222. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39223. /**
  39224. * Sets a float4 on a uniform variable.
  39225. * @param uniformName Name of the variable.
  39226. * @param x First float in float4.
  39227. * @param y Second float in float4.
  39228. * @param z Third float in float4.
  39229. * @param w Fourth float in float4.
  39230. * @returns this effect.
  39231. */
  39232. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39233. /**
  39234. * Sets a Color3 on a uniform variable.
  39235. * @param uniformName Name of the variable.
  39236. * @param color3 Value to be set.
  39237. * @returns this effect.
  39238. */
  39239. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39240. /**
  39241. * Sets a Color4 on a uniform variable.
  39242. * @param uniformName Name of the variable.
  39243. * @param color3 Value to be set.
  39244. * @param alpha Alpha value to be set.
  39245. * @returns this effect.
  39246. */
  39247. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39248. /**
  39249. * Sets a Color4 on a uniform variable
  39250. * @param uniformName defines the name of the variable
  39251. * @param color4 defines the value to be set
  39252. * @returns this effect.
  39253. */
  39254. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39255. /** Release all associated resources */
  39256. dispose(): void;
  39257. /**
  39258. * This function will add a new shader to the shader store
  39259. * @param name the name of the shader
  39260. * @param pixelShader optional pixel shader content
  39261. * @param vertexShader optional vertex shader content
  39262. */
  39263. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39264. /**
  39265. * Store of each shader (The can be looked up using effect.key)
  39266. */
  39267. static ShadersStore: {
  39268. [key: string]: string;
  39269. };
  39270. /**
  39271. * Store of each included file for a shader (The can be looked up using effect.key)
  39272. */
  39273. static IncludesShadersStore: {
  39274. [key: string]: string;
  39275. };
  39276. /**
  39277. * Resets the cache of effects.
  39278. */
  39279. static ResetCache(): void;
  39280. }
  39281. }
  39282. declare module "babylonjs/Engines/engineCapabilities" {
  39283. /**
  39284. * Interface used to describe the capabilities of the engine relatively to the current browser
  39285. */
  39286. export interface EngineCapabilities {
  39287. /** Maximum textures units per fragment shader */
  39288. maxTexturesImageUnits: number;
  39289. /** Maximum texture units per vertex shader */
  39290. maxVertexTextureImageUnits: number;
  39291. /** Maximum textures units in the entire pipeline */
  39292. maxCombinedTexturesImageUnits: number;
  39293. /** Maximum texture size */
  39294. maxTextureSize: number;
  39295. /** Maximum texture samples */
  39296. maxSamples?: number;
  39297. /** Maximum cube texture size */
  39298. maxCubemapTextureSize: number;
  39299. /** Maximum render texture size */
  39300. maxRenderTextureSize: number;
  39301. /** Maximum number of vertex attributes */
  39302. maxVertexAttribs: number;
  39303. /** Maximum number of varyings */
  39304. maxVaryingVectors: number;
  39305. /** Maximum number of uniforms per vertex shader */
  39306. maxVertexUniformVectors: number;
  39307. /** Maximum number of uniforms per fragment shader */
  39308. maxFragmentUniformVectors: number;
  39309. /** Defines if standard derivates (dx/dy) are supported */
  39310. standardDerivatives: boolean;
  39311. /** Defines if s3tc texture compression is supported */
  39312. s3tc?: WEBGL_compressed_texture_s3tc;
  39313. /** Defines if pvrtc texture compression is supported */
  39314. pvrtc: any;
  39315. /** Defines if etc1 texture compression is supported */
  39316. etc1: any;
  39317. /** Defines if etc2 texture compression is supported */
  39318. etc2: any;
  39319. /** Defines if astc texture compression is supported */
  39320. astc: any;
  39321. /** Defines if bptc texture compression is supported */
  39322. bptc: any;
  39323. /** Defines if float textures are supported */
  39324. textureFloat: boolean;
  39325. /** Defines if vertex array objects are supported */
  39326. vertexArrayObject: boolean;
  39327. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39328. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39329. /** Gets the maximum level of anisotropy supported */
  39330. maxAnisotropy: number;
  39331. /** Defines if instancing is supported */
  39332. instancedArrays: boolean;
  39333. /** Defines if 32 bits indices are supported */
  39334. uintIndices: boolean;
  39335. /** Defines if high precision shaders are supported */
  39336. highPrecisionShaderSupported: boolean;
  39337. /** Defines if depth reading in the fragment shader is supported */
  39338. fragmentDepthSupported: boolean;
  39339. /** Defines if float texture linear filtering is supported*/
  39340. textureFloatLinearFiltering: boolean;
  39341. /** Defines if rendering to float textures is supported */
  39342. textureFloatRender: boolean;
  39343. /** Defines if half float textures are supported*/
  39344. textureHalfFloat: boolean;
  39345. /** Defines if half float texture linear filtering is supported*/
  39346. textureHalfFloatLinearFiltering: boolean;
  39347. /** Defines if rendering to half float textures is supported */
  39348. textureHalfFloatRender: boolean;
  39349. /** Defines if textureLOD shader command is supported */
  39350. textureLOD: boolean;
  39351. /** Defines if draw buffers extension is supported */
  39352. drawBuffersExtension: boolean;
  39353. /** Defines if depth textures are supported */
  39354. depthTextureExtension: boolean;
  39355. /** Defines if float color buffer are supported */
  39356. colorBufferFloat: boolean;
  39357. /** Gets disjoint timer query extension (null if not supported) */
  39358. timerQuery?: EXT_disjoint_timer_query;
  39359. /** Defines if timestamp can be used with timer query */
  39360. canUseTimestampForTimerQuery: boolean;
  39361. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39362. multiview?: any;
  39363. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39364. oculusMultiview?: any;
  39365. /** Function used to let the system compiles shaders in background */
  39366. parallelShaderCompile?: {
  39367. COMPLETION_STATUS_KHR: number;
  39368. };
  39369. /** Max number of texture samples for MSAA */
  39370. maxMSAASamples: number;
  39371. /** Defines if the blend min max extension is supported */
  39372. blendMinMax: boolean;
  39373. }
  39374. }
  39375. declare module "babylonjs/States/depthCullingState" {
  39376. import { Nullable } from "babylonjs/types";
  39377. /**
  39378. * @hidden
  39379. **/
  39380. export class DepthCullingState {
  39381. private _isDepthTestDirty;
  39382. private _isDepthMaskDirty;
  39383. private _isDepthFuncDirty;
  39384. private _isCullFaceDirty;
  39385. private _isCullDirty;
  39386. private _isZOffsetDirty;
  39387. private _isFrontFaceDirty;
  39388. private _depthTest;
  39389. private _depthMask;
  39390. private _depthFunc;
  39391. private _cull;
  39392. private _cullFace;
  39393. private _zOffset;
  39394. private _frontFace;
  39395. /**
  39396. * Initializes the state.
  39397. */
  39398. constructor();
  39399. get isDirty(): boolean;
  39400. get zOffset(): number;
  39401. set zOffset(value: number);
  39402. get cullFace(): Nullable<number>;
  39403. set cullFace(value: Nullable<number>);
  39404. get cull(): Nullable<boolean>;
  39405. set cull(value: Nullable<boolean>);
  39406. get depthFunc(): Nullable<number>;
  39407. set depthFunc(value: Nullable<number>);
  39408. get depthMask(): boolean;
  39409. set depthMask(value: boolean);
  39410. get depthTest(): boolean;
  39411. set depthTest(value: boolean);
  39412. get frontFace(): Nullable<number>;
  39413. set frontFace(value: Nullable<number>);
  39414. reset(): void;
  39415. apply(gl: WebGLRenderingContext): void;
  39416. }
  39417. }
  39418. declare module "babylonjs/States/stencilState" {
  39419. /**
  39420. * @hidden
  39421. **/
  39422. export class StencilState {
  39423. /** 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 */
  39424. static readonly ALWAYS: number;
  39425. /** Passed to stencilOperation to specify that stencil value must be kept */
  39426. static readonly KEEP: number;
  39427. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39428. static readonly REPLACE: number;
  39429. private _isStencilTestDirty;
  39430. private _isStencilMaskDirty;
  39431. private _isStencilFuncDirty;
  39432. private _isStencilOpDirty;
  39433. private _stencilTest;
  39434. private _stencilMask;
  39435. private _stencilFunc;
  39436. private _stencilFuncRef;
  39437. private _stencilFuncMask;
  39438. private _stencilOpStencilFail;
  39439. private _stencilOpDepthFail;
  39440. private _stencilOpStencilDepthPass;
  39441. get isDirty(): boolean;
  39442. get stencilFunc(): number;
  39443. set stencilFunc(value: number);
  39444. get stencilFuncRef(): number;
  39445. set stencilFuncRef(value: number);
  39446. get stencilFuncMask(): number;
  39447. set stencilFuncMask(value: number);
  39448. get stencilOpStencilFail(): number;
  39449. set stencilOpStencilFail(value: number);
  39450. get stencilOpDepthFail(): number;
  39451. set stencilOpDepthFail(value: number);
  39452. get stencilOpStencilDepthPass(): number;
  39453. set stencilOpStencilDepthPass(value: number);
  39454. get stencilMask(): number;
  39455. set stencilMask(value: number);
  39456. get stencilTest(): boolean;
  39457. set stencilTest(value: boolean);
  39458. constructor();
  39459. reset(): void;
  39460. apply(gl: WebGLRenderingContext): void;
  39461. }
  39462. }
  39463. declare module "babylonjs/States/alphaCullingState" {
  39464. /**
  39465. * @hidden
  39466. **/
  39467. export class AlphaState {
  39468. private _isAlphaBlendDirty;
  39469. private _isBlendFunctionParametersDirty;
  39470. private _isBlendEquationParametersDirty;
  39471. private _isBlendConstantsDirty;
  39472. private _alphaBlend;
  39473. private _blendFunctionParameters;
  39474. private _blendEquationParameters;
  39475. private _blendConstants;
  39476. /**
  39477. * Initializes the state.
  39478. */
  39479. constructor();
  39480. get isDirty(): boolean;
  39481. get alphaBlend(): boolean;
  39482. set alphaBlend(value: boolean);
  39483. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39484. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39485. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39486. reset(): void;
  39487. apply(gl: WebGLRenderingContext): void;
  39488. }
  39489. }
  39490. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39491. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39492. /** @hidden */
  39493. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39494. attributeProcessor(attribute: string): string;
  39495. varyingProcessor(varying: string, isFragment: boolean): string;
  39496. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39497. }
  39498. }
  39499. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39500. /**
  39501. * Interface for attribute information associated with buffer instanciation
  39502. */
  39503. export interface InstancingAttributeInfo {
  39504. /**
  39505. * Name of the GLSL attribute
  39506. * if attribute index is not specified, this is used to retrieve the index from the effect
  39507. */
  39508. attributeName: string;
  39509. /**
  39510. * Index/offset of the attribute in the vertex shader
  39511. * if not specified, this will be computes from the name.
  39512. */
  39513. index?: number;
  39514. /**
  39515. * size of the attribute, 1, 2, 3 or 4
  39516. */
  39517. attributeSize: number;
  39518. /**
  39519. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39520. */
  39521. offset: number;
  39522. /**
  39523. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39524. * default to 1
  39525. */
  39526. divisor?: number;
  39527. /**
  39528. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39529. * default is FLOAT
  39530. */
  39531. attributeType?: number;
  39532. /**
  39533. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39534. */
  39535. normalized?: boolean;
  39536. }
  39537. }
  39538. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39540. import { Nullable } from "babylonjs/types";
  39541. module "babylonjs/Engines/thinEngine" {
  39542. interface ThinEngine {
  39543. /**
  39544. * Update a video texture
  39545. * @param texture defines the texture to update
  39546. * @param video defines the video element to use
  39547. * @param invertY defines if data must be stored with Y axis inverted
  39548. */
  39549. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39550. }
  39551. }
  39552. }
  39553. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39554. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39555. import { Nullable } from "babylonjs/types";
  39556. module "babylonjs/Engines/thinEngine" {
  39557. interface ThinEngine {
  39558. /**
  39559. * Creates a dynamic texture
  39560. * @param width defines the width of the texture
  39561. * @param height defines the height of the texture
  39562. * @param generateMipMaps defines if the engine should generate the mip levels
  39563. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39564. * @returns the dynamic texture inside an InternalTexture
  39565. */
  39566. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39567. /**
  39568. * Update the content of a dynamic texture
  39569. * @param texture defines the texture to update
  39570. * @param canvas defines the canvas containing the source
  39571. * @param invertY defines if data must be stored with Y axis inverted
  39572. * @param premulAlpha defines if alpha is stored as premultiplied
  39573. * @param format defines the format of the data
  39574. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39575. */
  39576. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39577. }
  39578. }
  39579. }
  39580. declare module "babylonjs/Materials/Textures/videoTexture" {
  39581. import { Observable } from "babylonjs/Misc/observable";
  39582. import { Nullable } from "babylonjs/types";
  39583. import { Scene } from "babylonjs/scene";
  39584. import { Texture } from "babylonjs/Materials/Textures/texture";
  39585. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39586. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39587. /**
  39588. * Settings for finer control over video usage
  39589. */
  39590. export interface VideoTextureSettings {
  39591. /**
  39592. * Applies `autoplay` to video, if specified
  39593. */
  39594. autoPlay?: boolean;
  39595. /**
  39596. * Applies `muted` to video, if specified
  39597. */
  39598. muted?: boolean;
  39599. /**
  39600. * Applies `loop` to video, if specified
  39601. */
  39602. loop?: boolean;
  39603. /**
  39604. * Automatically updates internal texture from video at every frame in the render loop
  39605. */
  39606. autoUpdateTexture: boolean;
  39607. /**
  39608. * Image src displayed during the video loading or until the user interacts with the video.
  39609. */
  39610. poster?: string;
  39611. }
  39612. /**
  39613. * If you want to display a video in your scene, this is the special texture for that.
  39614. * This special texture works similar to other textures, with the exception of a few parameters.
  39615. * @see https://doc.babylonjs.com/how_to/video_texture
  39616. */
  39617. export class VideoTexture extends Texture {
  39618. /**
  39619. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39620. */
  39621. readonly autoUpdateTexture: boolean;
  39622. /**
  39623. * The video instance used by the texture internally
  39624. */
  39625. readonly video: HTMLVideoElement;
  39626. private _onUserActionRequestedObservable;
  39627. /**
  39628. * Event triggerd when a dom action is required by the user to play the video.
  39629. * This happens due to recent changes in browser policies preventing video to auto start.
  39630. */
  39631. get onUserActionRequestedObservable(): Observable<Texture>;
  39632. private _generateMipMaps;
  39633. private _stillImageCaptured;
  39634. private _displayingPosterTexture;
  39635. private _settings;
  39636. private _createInternalTextureOnEvent;
  39637. private _frameId;
  39638. private _currentSrc;
  39639. /**
  39640. * Creates a video texture.
  39641. * If you want to display a video in your scene, this is the special texture for that.
  39642. * This special texture works similar to other textures, with the exception of a few parameters.
  39643. * @see https://doc.babylonjs.com/how_to/video_texture
  39644. * @param name optional name, will detect from video source, if not defined
  39645. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39646. * @param scene is obviously the current scene.
  39647. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39648. * @param invertY is false by default but can be used to invert video on Y axis
  39649. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39650. * @param settings allows finer control over video usage
  39651. */
  39652. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39653. private _getName;
  39654. private _getVideo;
  39655. private _createInternalTexture;
  39656. private reset;
  39657. /**
  39658. * @hidden Internal method to initiate `update`.
  39659. */
  39660. _rebuild(): void;
  39661. /**
  39662. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39663. */
  39664. update(): void;
  39665. /**
  39666. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39667. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39668. */
  39669. updateTexture(isVisible: boolean): void;
  39670. protected _updateInternalTexture: () => void;
  39671. /**
  39672. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39673. * @param url New url.
  39674. */
  39675. updateURL(url: string): void;
  39676. /**
  39677. * Clones the texture.
  39678. * @returns the cloned texture
  39679. */
  39680. clone(): VideoTexture;
  39681. /**
  39682. * Dispose the texture and release its associated resources.
  39683. */
  39684. dispose(): void;
  39685. /**
  39686. * Creates a video texture straight from a stream.
  39687. * @param scene Define the scene the texture should be created in
  39688. * @param stream Define the stream the texture should be created from
  39689. * @returns The created video texture as a promise
  39690. */
  39691. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39692. /**
  39693. * Creates a video texture straight from your WebCam video feed.
  39694. * @param scene Define the scene the texture should be created in
  39695. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39696. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39697. * @returns The created video texture as a promise
  39698. */
  39699. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39700. minWidth: number;
  39701. maxWidth: number;
  39702. minHeight: number;
  39703. maxHeight: number;
  39704. deviceId: string;
  39705. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39706. /**
  39707. * Creates a video texture straight from your WebCam video feed.
  39708. * @param scene Define the scene the texture should be created in
  39709. * @param onReady Define a callback to triggered once the texture will be ready
  39710. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39711. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39712. */
  39713. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39714. minWidth: number;
  39715. maxWidth: number;
  39716. minHeight: number;
  39717. maxHeight: number;
  39718. deviceId: string;
  39719. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39720. }
  39721. }
  39722. declare module "babylonjs/Engines/thinEngine" {
  39723. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39724. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39725. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39726. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39727. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39728. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39729. import { Observable } from "babylonjs/Misc/observable";
  39730. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39731. import { StencilState } from "babylonjs/States/stencilState";
  39732. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39734. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39735. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39736. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39737. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39738. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39739. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39740. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39742. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39743. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39744. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39745. import { WebRequest } from "babylonjs/Misc/webRequest";
  39746. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39747. /**
  39748. * Defines the interface used by objects working like Scene
  39749. * @hidden
  39750. */
  39751. export interface ISceneLike {
  39752. _addPendingData(data: any): void;
  39753. _removePendingData(data: any): void;
  39754. offlineProvider: IOfflineProvider;
  39755. }
  39756. /**
  39757. * Information about the current host
  39758. */
  39759. export interface HostInformation {
  39760. /**
  39761. * Defines if the current host is a mobile
  39762. */
  39763. isMobile: boolean;
  39764. }
  39765. /** Interface defining initialization parameters for Engine class */
  39766. export interface EngineOptions extends WebGLContextAttributes {
  39767. /**
  39768. * Defines if the engine should no exceed a specified device ratio
  39769. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39770. */
  39771. limitDeviceRatio?: number;
  39772. /**
  39773. * Defines if webvr should be enabled automatically
  39774. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39775. */
  39776. autoEnableWebVR?: boolean;
  39777. /**
  39778. * Defines if webgl2 should be turned off even if supported
  39779. * @see https://doc.babylonjs.com/features/webgl2
  39780. */
  39781. disableWebGL2Support?: boolean;
  39782. /**
  39783. * Defines if webaudio should be initialized as well
  39784. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39785. */
  39786. audioEngine?: boolean;
  39787. /**
  39788. * Defines if animations should run using a deterministic lock step
  39789. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39790. */
  39791. deterministicLockstep?: boolean;
  39792. /** Defines the maximum steps to use with deterministic lock step mode */
  39793. lockstepMaxSteps?: number;
  39794. /** Defines the seconds between each deterministic lock step */
  39795. timeStep?: number;
  39796. /**
  39797. * Defines that engine should ignore context lost events
  39798. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39799. */
  39800. doNotHandleContextLost?: boolean;
  39801. /**
  39802. * Defines that engine should ignore modifying touch action attribute and style
  39803. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39804. */
  39805. doNotHandleTouchAction?: boolean;
  39806. /**
  39807. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39808. */
  39809. useHighPrecisionFloats?: boolean;
  39810. /**
  39811. * Make the canvas XR Compatible for XR sessions
  39812. */
  39813. xrCompatible?: boolean;
  39814. /**
  39815. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39816. */
  39817. useHighPrecisionMatrix?: boolean;
  39818. /**
  39819. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39820. */
  39821. failIfMajorPerformanceCaveat?: boolean;
  39822. }
  39823. /**
  39824. * The base engine class (root of all engines)
  39825. */
  39826. export class ThinEngine {
  39827. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39828. static ExceptionList: ({
  39829. key: string;
  39830. capture: string;
  39831. captureConstraint: number;
  39832. targets: string[];
  39833. } | {
  39834. key: string;
  39835. capture: null;
  39836. captureConstraint: null;
  39837. targets: string[];
  39838. })[];
  39839. /** @hidden */
  39840. static _TextureLoaders: IInternalTextureLoader[];
  39841. /**
  39842. * Returns the current npm package of the sdk
  39843. */
  39844. static get NpmPackage(): string;
  39845. /**
  39846. * Returns the current version of the framework
  39847. */
  39848. static get Version(): string;
  39849. /**
  39850. * Returns a string describing the current engine
  39851. */
  39852. get description(): string;
  39853. /**
  39854. * Gets or sets the epsilon value used by collision engine
  39855. */
  39856. static CollisionsEpsilon: number;
  39857. /**
  39858. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39859. */
  39860. static get ShadersRepository(): string;
  39861. static set ShadersRepository(value: string);
  39862. /** @hidden */
  39863. _shaderProcessor: IShaderProcessor;
  39864. /**
  39865. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39866. */
  39867. forcePOTTextures: boolean;
  39868. /**
  39869. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39870. */
  39871. isFullscreen: boolean;
  39872. /**
  39873. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39874. */
  39875. cullBackFaces: boolean;
  39876. /**
  39877. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39878. */
  39879. renderEvenInBackground: boolean;
  39880. /**
  39881. * Gets or sets a boolean indicating that cache can be kept between frames
  39882. */
  39883. preventCacheWipeBetweenFrames: boolean;
  39884. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39885. validateShaderPrograms: boolean;
  39886. /**
  39887. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39888. * This can provide greater z depth for distant objects.
  39889. */
  39890. useReverseDepthBuffer: boolean;
  39891. /**
  39892. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39893. */
  39894. disableUniformBuffers: boolean;
  39895. /** @hidden */
  39896. _uniformBuffers: UniformBuffer[];
  39897. /**
  39898. * Gets a boolean indicating that the engine supports uniform buffers
  39899. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39900. */
  39901. get supportsUniformBuffers(): boolean;
  39902. /** @hidden */
  39903. _gl: WebGLRenderingContext;
  39904. /** @hidden */
  39905. _webGLVersion: number;
  39906. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39907. protected _windowIsBackground: boolean;
  39908. protected _creationOptions: EngineOptions;
  39909. protected _highPrecisionShadersAllowed: boolean;
  39910. /** @hidden */
  39911. get _shouldUseHighPrecisionShader(): boolean;
  39912. /**
  39913. * Gets a boolean indicating that only power of 2 textures are supported
  39914. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39915. */
  39916. get needPOTTextures(): boolean;
  39917. /** @hidden */
  39918. _badOS: boolean;
  39919. /** @hidden */
  39920. _badDesktopOS: boolean;
  39921. private _hardwareScalingLevel;
  39922. /** @hidden */
  39923. _caps: EngineCapabilities;
  39924. private _isStencilEnable;
  39925. private _glVersion;
  39926. private _glRenderer;
  39927. private _glVendor;
  39928. /** @hidden */
  39929. _videoTextureSupported: boolean;
  39930. protected _renderingQueueLaunched: boolean;
  39931. protected _activeRenderLoops: (() => void)[];
  39932. /**
  39933. * Observable signaled when a context lost event is raised
  39934. */
  39935. onContextLostObservable: Observable<ThinEngine>;
  39936. /**
  39937. * Observable signaled when a context restored event is raised
  39938. */
  39939. onContextRestoredObservable: Observable<ThinEngine>;
  39940. private _onContextLost;
  39941. private _onContextRestored;
  39942. protected _contextWasLost: boolean;
  39943. /** @hidden */
  39944. _doNotHandleContextLost: boolean;
  39945. /**
  39946. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39947. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39948. */
  39949. get doNotHandleContextLost(): boolean;
  39950. set doNotHandleContextLost(value: boolean);
  39951. /**
  39952. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39953. */
  39954. disableVertexArrayObjects: boolean;
  39955. /** @hidden */
  39956. protected _colorWrite: boolean;
  39957. /** @hidden */
  39958. protected _colorWriteChanged: boolean;
  39959. /** @hidden */
  39960. protected _depthCullingState: DepthCullingState;
  39961. /** @hidden */
  39962. protected _stencilState: StencilState;
  39963. /** @hidden */
  39964. _alphaState: AlphaState;
  39965. /** @hidden */
  39966. _alphaMode: number;
  39967. /** @hidden */
  39968. _alphaEquation: number;
  39969. /** @hidden */
  39970. _internalTexturesCache: InternalTexture[];
  39971. /** @hidden */
  39972. protected _activeChannel: number;
  39973. private _currentTextureChannel;
  39974. /** @hidden */
  39975. protected _boundTexturesCache: {
  39976. [key: string]: Nullable<InternalTexture>;
  39977. };
  39978. /** @hidden */
  39979. protected _currentEffect: Nullable<Effect>;
  39980. /** @hidden */
  39981. protected _currentProgram: Nullable<WebGLProgram>;
  39982. private _compiledEffects;
  39983. private _vertexAttribArraysEnabled;
  39984. /** @hidden */
  39985. protected _cachedViewport: Nullable<IViewportLike>;
  39986. private _cachedVertexArrayObject;
  39987. /** @hidden */
  39988. protected _cachedVertexBuffers: any;
  39989. /** @hidden */
  39990. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39991. /** @hidden */
  39992. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39993. /** @hidden */
  39994. _currentRenderTarget: Nullable<InternalTexture>;
  39995. private _uintIndicesCurrentlySet;
  39996. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39997. /** @hidden */
  39998. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39999. /** @hidden */
  40000. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40001. private _currentBufferPointers;
  40002. private _currentInstanceLocations;
  40003. private _currentInstanceBuffers;
  40004. private _textureUnits;
  40005. /** @hidden */
  40006. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40007. /** @hidden */
  40008. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40009. /** @hidden */
  40010. _boundRenderFunction: any;
  40011. private _vaoRecordInProgress;
  40012. private _mustWipeVertexAttributes;
  40013. private _emptyTexture;
  40014. private _emptyCubeTexture;
  40015. private _emptyTexture3D;
  40016. private _emptyTexture2DArray;
  40017. /** @hidden */
  40018. _frameHandler: number;
  40019. private _nextFreeTextureSlots;
  40020. private _maxSimultaneousTextures;
  40021. private _activeRequests;
  40022. /** @hidden */
  40023. _transformTextureUrl: Nullable<(url: string) => string>;
  40024. /**
  40025. * Gets information about the current host
  40026. */
  40027. hostInformation: HostInformation;
  40028. protected get _supportsHardwareTextureRescaling(): boolean;
  40029. private _framebufferDimensionsObject;
  40030. /**
  40031. * sets the object from which width and height will be taken from when getting render width and height
  40032. * Will fallback to the gl object
  40033. * @param dimensions the framebuffer width and height that will be used.
  40034. */
  40035. set framebufferDimensionsObject(dimensions: Nullable<{
  40036. framebufferWidth: number;
  40037. framebufferHeight: number;
  40038. }>);
  40039. /**
  40040. * Gets the current viewport
  40041. */
  40042. get currentViewport(): Nullable<IViewportLike>;
  40043. /**
  40044. * Gets the default empty texture
  40045. */
  40046. get emptyTexture(): InternalTexture;
  40047. /**
  40048. * Gets the default empty 3D texture
  40049. */
  40050. get emptyTexture3D(): InternalTexture;
  40051. /**
  40052. * Gets the default empty 2D array texture
  40053. */
  40054. get emptyTexture2DArray(): InternalTexture;
  40055. /**
  40056. * Gets the default empty cube texture
  40057. */
  40058. get emptyCubeTexture(): InternalTexture;
  40059. /**
  40060. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40061. */
  40062. readonly premultipliedAlpha: boolean;
  40063. /**
  40064. * Observable event triggered before each texture is initialized
  40065. */
  40066. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40067. /**
  40068. * Creates a new engine
  40069. * @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
  40070. * @param antialias defines enable antialiasing (default: false)
  40071. * @param options defines further options to be sent to the getContext() function
  40072. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40073. */
  40074. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40075. private _rebuildInternalTextures;
  40076. private _rebuildEffects;
  40077. /**
  40078. * Gets a boolean indicating if all created effects are ready
  40079. * @returns true if all effects are ready
  40080. */
  40081. areAllEffectsReady(): boolean;
  40082. protected _rebuildBuffers(): void;
  40083. protected _initGLContext(): void;
  40084. /**
  40085. * Gets version of the current webGL context
  40086. */
  40087. get webGLVersion(): number;
  40088. /**
  40089. * Gets a string identifying the name of the class
  40090. * @returns "Engine" string
  40091. */
  40092. getClassName(): string;
  40093. /**
  40094. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40095. */
  40096. get isStencilEnable(): boolean;
  40097. /** @hidden */
  40098. _prepareWorkingCanvas(): void;
  40099. /**
  40100. * Reset the texture cache to empty state
  40101. */
  40102. resetTextureCache(): void;
  40103. /**
  40104. * Gets an object containing information about the current webGL context
  40105. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40106. */
  40107. getGlInfo(): {
  40108. vendor: string;
  40109. renderer: string;
  40110. version: string;
  40111. };
  40112. /**
  40113. * Defines the hardware scaling level.
  40114. * By default the hardware scaling level is computed from the window device ratio.
  40115. * 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.
  40116. * @param level defines the level to use
  40117. */
  40118. setHardwareScalingLevel(level: number): void;
  40119. /**
  40120. * Gets the current hardware scaling level.
  40121. * By default the hardware scaling level is computed from the window device ratio.
  40122. * 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.
  40123. * @returns a number indicating the current hardware scaling level
  40124. */
  40125. getHardwareScalingLevel(): number;
  40126. /**
  40127. * Gets the list of loaded textures
  40128. * @returns an array containing all loaded textures
  40129. */
  40130. getLoadedTexturesCache(): InternalTexture[];
  40131. /**
  40132. * Gets the object containing all engine capabilities
  40133. * @returns the EngineCapabilities object
  40134. */
  40135. getCaps(): EngineCapabilities;
  40136. /**
  40137. * stop executing a render loop function and remove it from the execution array
  40138. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40139. */
  40140. stopRenderLoop(renderFunction?: () => void): void;
  40141. /** @hidden */
  40142. _renderLoop(): void;
  40143. /**
  40144. * Gets the HTML canvas attached with the current webGL context
  40145. * @returns a HTML canvas
  40146. */
  40147. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40148. /**
  40149. * Gets host window
  40150. * @returns the host window object
  40151. */
  40152. getHostWindow(): Nullable<Window>;
  40153. /**
  40154. * Gets the current render width
  40155. * @param useScreen defines if screen size must be used (or the current render target if any)
  40156. * @returns a number defining the current render width
  40157. */
  40158. getRenderWidth(useScreen?: boolean): number;
  40159. /**
  40160. * Gets the current render height
  40161. * @param useScreen defines if screen size must be used (or the current render target if any)
  40162. * @returns a number defining the current render height
  40163. */
  40164. getRenderHeight(useScreen?: boolean): number;
  40165. /**
  40166. * Can be used to override the current requestAnimationFrame requester.
  40167. * @hidden
  40168. */
  40169. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40170. /**
  40171. * Register and execute a render loop. The engine can have more than one render function
  40172. * @param renderFunction defines the function to continuously execute
  40173. */
  40174. runRenderLoop(renderFunction: () => void): void;
  40175. /**
  40176. * Clear the current render buffer or the current render target (if any is set up)
  40177. * @param color defines the color to use
  40178. * @param backBuffer defines if the back buffer must be cleared
  40179. * @param depth defines if the depth buffer must be cleared
  40180. * @param stencil defines if the stencil buffer must be cleared
  40181. */
  40182. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40183. private _viewportCached;
  40184. /** @hidden */
  40185. _viewport(x: number, y: number, width: number, height: number): void;
  40186. /**
  40187. * Set the WebGL's viewport
  40188. * @param viewport defines the viewport element to be used
  40189. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40190. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40191. */
  40192. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40193. /**
  40194. * Begin a new frame
  40195. */
  40196. beginFrame(): void;
  40197. /**
  40198. * Enf the current frame
  40199. */
  40200. endFrame(): void;
  40201. /**
  40202. * Resize the view according to the canvas' size
  40203. */
  40204. resize(): void;
  40205. /**
  40206. * Force a specific size of the canvas
  40207. * @param width defines the new canvas' width
  40208. * @param height defines the new canvas' height
  40209. * @returns true if the size was changed
  40210. */
  40211. setSize(width: number, height: number): boolean;
  40212. /**
  40213. * Binds the frame buffer to the specified texture.
  40214. * @param texture The texture to render to or null for the default canvas
  40215. * @param faceIndex The face of the texture to render to in case of cube texture
  40216. * @param requiredWidth The width of the target to render to
  40217. * @param requiredHeight The height of the target to render to
  40218. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40219. * @param lodLevel defines the lod level to bind to the frame buffer
  40220. * @param layer defines the 2d array index to bind to frame buffer to
  40221. */
  40222. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40223. /** @hidden */
  40224. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40225. /**
  40226. * Unbind the current render target texture from the webGL context
  40227. * @param texture defines the render target texture to unbind
  40228. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40229. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40230. */
  40231. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40232. /**
  40233. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40234. */
  40235. flushFramebuffer(): void;
  40236. /**
  40237. * Unbind the current render target and bind the default framebuffer
  40238. */
  40239. restoreDefaultFramebuffer(): void;
  40240. /** @hidden */
  40241. protected _resetVertexBufferBinding(): void;
  40242. /**
  40243. * Creates a vertex buffer
  40244. * @param data the data for the vertex buffer
  40245. * @returns the new WebGL static buffer
  40246. */
  40247. createVertexBuffer(data: DataArray): DataBuffer;
  40248. private _createVertexBuffer;
  40249. /**
  40250. * Creates a dynamic vertex buffer
  40251. * @param data the data for the dynamic vertex buffer
  40252. * @returns the new WebGL dynamic buffer
  40253. */
  40254. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40255. protected _resetIndexBufferBinding(): void;
  40256. /**
  40257. * Creates a new index buffer
  40258. * @param indices defines the content of the index buffer
  40259. * @param updatable defines if the index buffer must be updatable
  40260. * @returns a new webGL buffer
  40261. */
  40262. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40263. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40264. /**
  40265. * Bind a webGL buffer to the webGL context
  40266. * @param buffer defines the buffer to bind
  40267. */
  40268. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40269. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40270. private bindBuffer;
  40271. /**
  40272. * update the bound buffer with the given data
  40273. * @param data defines the data to update
  40274. */
  40275. updateArrayBuffer(data: Float32Array): void;
  40276. private _vertexAttribPointer;
  40277. /** @hidden */
  40278. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40279. private _bindVertexBuffersAttributes;
  40280. /**
  40281. * Records a vertex array object
  40282. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40283. * @param vertexBuffers defines the list of vertex buffers to store
  40284. * @param indexBuffer defines the index buffer to store
  40285. * @param effect defines the effect to store
  40286. * @returns the new vertex array object
  40287. */
  40288. recordVertexArrayObject(vertexBuffers: {
  40289. [key: string]: VertexBuffer;
  40290. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40291. /**
  40292. * Bind a specific vertex array object
  40293. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40294. * @param vertexArrayObject defines the vertex array object to bind
  40295. * @param indexBuffer defines the index buffer to bind
  40296. */
  40297. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40298. /**
  40299. * Bind webGl buffers directly to the webGL context
  40300. * @param vertexBuffer defines the vertex buffer to bind
  40301. * @param indexBuffer defines the index buffer to bind
  40302. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40303. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40304. * @param effect defines the effect associated with the vertex buffer
  40305. */
  40306. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40307. private _unbindVertexArrayObject;
  40308. /**
  40309. * Bind a list of vertex buffers to the webGL context
  40310. * @param vertexBuffers defines the list of vertex buffers to bind
  40311. * @param indexBuffer defines the index buffer to bind
  40312. * @param effect defines the effect associated with the vertex buffers
  40313. */
  40314. bindBuffers(vertexBuffers: {
  40315. [key: string]: Nullable<VertexBuffer>;
  40316. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40317. /**
  40318. * Unbind all instance attributes
  40319. */
  40320. unbindInstanceAttributes(): void;
  40321. /**
  40322. * Release and free the memory of a vertex array object
  40323. * @param vao defines the vertex array object to delete
  40324. */
  40325. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40326. /** @hidden */
  40327. _releaseBuffer(buffer: DataBuffer): boolean;
  40328. protected _deleteBuffer(buffer: DataBuffer): void;
  40329. /**
  40330. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40331. * @param instancesBuffer defines the webGL buffer to update and bind
  40332. * @param data defines the data to store in the buffer
  40333. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40334. */
  40335. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40336. /**
  40337. * Bind the content of a webGL buffer used with instantiation
  40338. * @param instancesBuffer defines the webGL buffer to bind
  40339. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40340. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40341. */
  40342. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40343. /**
  40344. * Disable the instance attribute corresponding to the name in parameter
  40345. * @param name defines the name of the attribute to disable
  40346. */
  40347. disableInstanceAttributeByName(name: string): void;
  40348. /**
  40349. * Disable the instance attribute corresponding to the location in parameter
  40350. * @param attributeLocation defines the attribute location of the attribute to disable
  40351. */
  40352. disableInstanceAttribute(attributeLocation: number): void;
  40353. /**
  40354. * Disable the attribute corresponding to the location in parameter
  40355. * @param attributeLocation defines the attribute location of the attribute to disable
  40356. */
  40357. disableAttributeByIndex(attributeLocation: number): void;
  40358. /**
  40359. * Send a draw order
  40360. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40361. * @param indexStart defines the starting index
  40362. * @param indexCount defines the number of index to draw
  40363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40364. */
  40365. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40366. /**
  40367. * Draw a list of points
  40368. * @param verticesStart defines the index of first vertex to draw
  40369. * @param verticesCount defines the count of vertices to draw
  40370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40371. */
  40372. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40373. /**
  40374. * Draw a list of unindexed primitives
  40375. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40376. * @param verticesStart defines the index of first vertex to draw
  40377. * @param verticesCount defines the count of vertices to draw
  40378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40379. */
  40380. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40381. /**
  40382. * Draw a list of indexed primitives
  40383. * @param fillMode defines the primitive to use
  40384. * @param indexStart defines the starting index
  40385. * @param indexCount defines the number of index to draw
  40386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40387. */
  40388. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40389. /**
  40390. * Draw a list of unindexed primitives
  40391. * @param fillMode defines the primitive to use
  40392. * @param verticesStart defines the index of first vertex to draw
  40393. * @param verticesCount defines the count of vertices to draw
  40394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40395. */
  40396. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40397. private _drawMode;
  40398. /** @hidden */
  40399. protected _reportDrawCall(): void;
  40400. /** @hidden */
  40401. _releaseEffect(effect: Effect): void;
  40402. /** @hidden */
  40403. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40404. /**
  40405. * Create a new effect (used to store vertex/fragment shaders)
  40406. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40407. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40408. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40409. * @param samplers defines an array of string used to represent textures
  40410. * @param defines defines the string containing the defines to use to compile the shaders
  40411. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40412. * @param onCompiled defines a function to call when the effect creation is successful
  40413. * @param onError defines a function to call when the effect creation has failed
  40414. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40415. * @returns the new Effect
  40416. */
  40417. 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;
  40418. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40419. private _compileShader;
  40420. private _compileRawShader;
  40421. /** @hidden */
  40422. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40423. /**
  40424. * Directly creates a webGL program
  40425. * @param pipelineContext defines the pipeline context to attach to
  40426. * @param vertexCode defines the vertex shader code to use
  40427. * @param fragmentCode defines the fragment shader code to use
  40428. * @param context defines the webGL context to use (if not set, the current one will be used)
  40429. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40430. * @returns the new webGL program
  40431. */
  40432. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40433. /**
  40434. * Creates a webGL program
  40435. * @param pipelineContext defines the pipeline context to attach to
  40436. * @param vertexCode defines the vertex shader code to use
  40437. * @param fragmentCode defines the fragment shader code to use
  40438. * @param defines defines the string containing the defines to use to compile the shaders
  40439. * @param context defines the webGL context to use (if not set, the current one will be used)
  40440. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40441. * @returns the new webGL program
  40442. */
  40443. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40444. /**
  40445. * Creates a new pipeline context
  40446. * @returns the new pipeline
  40447. */
  40448. createPipelineContext(): IPipelineContext;
  40449. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40450. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40451. /** @hidden */
  40452. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40453. /** @hidden */
  40454. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40455. /** @hidden */
  40456. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40457. /**
  40458. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40459. * @param pipelineContext defines the pipeline context to use
  40460. * @param uniformsNames defines the list of uniform names
  40461. * @returns an array of webGL uniform locations
  40462. */
  40463. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40464. /**
  40465. * Gets the lsit of active attributes for a given webGL program
  40466. * @param pipelineContext defines the pipeline context to use
  40467. * @param attributesNames defines the list of attribute names to get
  40468. * @returns an array of indices indicating the offset of each attribute
  40469. */
  40470. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40471. /**
  40472. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40473. * @param effect defines the effect to activate
  40474. */
  40475. enableEffect(effect: Nullable<Effect>): void;
  40476. /**
  40477. * Set the value of an uniform to a number (int)
  40478. * @param uniform defines the webGL uniform location where to store the value
  40479. * @param value defines the int number to store
  40480. * @returns true if the value was set
  40481. */
  40482. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40483. /**
  40484. * Set the value of an uniform to an array of int32
  40485. * @param uniform defines the webGL uniform location where to store the value
  40486. * @param array defines the array of int32 to store
  40487. * @returns true if the value was set
  40488. */
  40489. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40490. /**
  40491. * Set the value of an uniform to an array of int32 (stored as vec2)
  40492. * @param uniform defines the webGL uniform location where to store the value
  40493. * @param array defines the array of int32 to store
  40494. * @returns true if the value was set
  40495. */
  40496. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40497. /**
  40498. * Set the value of an uniform to an array of int32 (stored as vec3)
  40499. * @param uniform defines the webGL uniform location where to store the value
  40500. * @param array defines the array of int32 to store
  40501. * @returns true if the value was set
  40502. */
  40503. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40504. /**
  40505. * Set the value of an uniform to an array of int32 (stored as vec4)
  40506. * @param uniform defines the webGL uniform location where to store the value
  40507. * @param array defines the array of int32 to store
  40508. * @returns true if the value was set
  40509. */
  40510. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40511. /**
  40512. * Set the value of an uniform to an array of number
  40513. * @param uniform defines the webGL uniform location where to store the value
  40514. * @param array defines the array of number to store
  40515. * @returns true if the value was set
  40516. */
  40517. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40518. /**
  40519. * Set the value of an uniform to an array of number (stored as vec2)
  40520. * @param uniform defines the webGL uniform location where to store the value
  40521. * @param array defines the array of number to store
  40522. * @returns true if the value was set
  40523. */
  40524. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40525. /**
  40526. * Set the value of an uniform to an array of number (stored as vec3)
  40527. * @param uniform defines the webGL uniform location where to store the value
  40528. * @param array defines the array of number to store
  40529. * @returns true if the value was set
  40530. */
  40531. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40532. /**
  40533. * Set the value of an uniform to an array of number (stored as vec4)
  40534. * @param uniform defines the webGL uniform location where to store the value
  40535. * @param array defines the array of number to store
  40536. * @returns true if the value was set
  40537. */
  40538. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40539. /**
  40540. * Set the value of an uniform to an array of float32 (stored as matrices)
  40541. * @param uniform defines the webGL uniform location where to store the value
  40542. * @param matrices defines the array of float32 to store
  40543. * @returns true if the value was set
  40544. */
  40545. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40546. /**
  40547. * Set the value of an uniform to a matrix (3x3)
  40548. * @param uniform defines the webGL uniform location where to store the value
  40549. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40550. * @returns true if the value was set
  40551. */
  40552. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40553. /**
  40554. * Set the value of an uniform to a matrix (2x2)
  40555. * @param uniform defines the webGL uniform location where to store the value
  40556. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40557. * @returns true if the value was set
  40558. */
  40559. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40560. /**
  40561. * Set the value of an uniform to a number (float)
  40562. * @param uniform defines the webGL uniform location where to store the value
  40563. * @param value defines the float number to store
  40564. * @returns true if the value was transfered
  40565. */
  40566. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40567. /**
  40568. * Set the value of an uniform to a vec2
  40569. * @param uniform defines the webGL uniform location where to store the value
  40570. * @param x defines the 1st component of the value
  40571. * @param y defines the 2nd component of the value
  40572. * @returns true if the value was set
  40573. */
  40574. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40575. /**
  40576. * Set the value of an uniform to a vec3
  40577. * @param uniform defines the webGL uniform location where to store the value
  40578. * @param x defines the 1st component of the value
  40579. * @param y defines the 2nd component of the value
  40580. * @param z defines the 3rd component of the value
  40581. * @returns true if the value was set
  40582. */
  40583. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40584. /**
  40585. * Set the value of an uniform to a vec4
  40586. * @param uniform defines the webGL uniform location where to store the value
  40587. * @param x defines the 1st component of the value
  40588. * @param y defines the 2nd component of the value
  40589. * @param z defines the 3rd component of the value
  40590. * @param w defines the 4th component of the value
  40591. * @returns true if the value was set
  40592. */
  40593. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40594. /**
  40595. * Apply all cached states (depth, culling, stencil and alpha)
  40596. */
  40597. applyStates(): void;
  40598. /**
  40599. * Enable or disable color writing
  40600. * @param enable defines the state to set
  40601. */
  40602. setColorWrite(enable: boolean): void;
  40603. /**
  40604. * Gets a boolean indicating if color writing is enabled
  40605. * @returns the current color writing state
  40606. */
  40607. getColorWrite(): boolean;
  40608. /**
  40609. * Gets the depth culling state manager
  40610. */
  40611. get depthCullingState(): DepthCullingState;
  40612. /**
  40613. * Gets the alpha state manager
  40614. */
  40615. get alphaState(): AlphaState;
  40616. /**
  40617. * Gets the stencil state manager
  40618. */
  40619. get stencilState(): StencilState;
  40620. /**
  40621. * Clears the list of texture accessible through engine.
  40622. * This can help preventing texture load conflict due to name collision.
  40623. */
  40624. clearInternalTexturesCache(): void;
  40625. /**
  40626. * Force the entire cache to be cleared
  40627. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40628. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40629. */
  40630. wipeCaches(bruteForce?: boolean): void;
  40631. /** @hidden */
  40632. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40633. min: number;
  40634. mag: number;
  40635. };
  40636. /** @hidden */
  40637. _createTexture(): WebGLTexture;
  40638. /**
  40639. * Usually called from Texture.ts.
  40640. * Passed information to create a WebGLTexture
  40641. * @param url defines a value which contains one of the following:
  40642. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40643. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40644. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40646. * @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)
  40647. * @param scene needed for loading to the correct scene
  40648. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40649. * @param onLoad optional callback to be called upon successful completion
  40650. * @param onError optional callback to be called upon failure
  40651. * @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
  40652. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40653. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40654. * @param forcedExtension defines the extension to use to pick the right loader
  40655. * @param mimeType defines an optional mime type
  40656. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40657. */
  40658. 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;
  40659. /**
  40660. * Loads an image as an HTMLImageElement.
  40661. * @param input url string, ArrayBuffer, or Blob to load
  40662. * @param onLoad callback called when the image successfully loads
  40663. * @param onError callback called when the image fails to load
  40664. * @param offlineProvider offline provider for caching
  40665. * @param mimeType optional mime type
  40666. * @returns the HTMLImageElement of the loaded image
  40667. * @hidden
  40668. */
  40669. 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>;
  40670. /**
  40671. * @hidden
  40672. */
  40673. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40674. private _unpackFlipYCached;
  40675. /**
  40676. * In case you are sharing the context with other applications, it might
  40677. * be interested to not cache the unpack flip y state to ensure a consistent
  40678. * value would be set.
  40679. */
  40680. enableUnpackFlipYCached: boolean;
  40681. /** @hidden */
  40682. _unpackFlipY(value: boolean): void;
  40683. /** @hidden */
  40684. _getUnpackAlignement(): number;
  40685. private _getTextureTarget;
  40686. /**
  40687. * Update the sampling mode of a given texture
  40688. * @param samplingMode defines the required sampling mode
  40689. * @param texture defines the texture to update
  40690. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40691. */
  40692. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40693. /**
  40694. * Update the sampling mode of a given texture
  40695. * @param texture defines the texture to update
  40696. * @param wrapU defines the texture wrap mode of the u coordinates
  40697. * @param wrapV defines the texture wrap mode of the v coordinates
  40698. * @param wrapR defines the texture wrap mode of the r coordinates
  40699. */
  40700. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40701. /** @hidden */
  40702. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40703. width: number;
  40704. height: number;
  40705. layers?: number;
  40706. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40707. /** @hidden */
  40708. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40709. /** @hidden */
  40710. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40711. /**
  40712. * Update a portion of an internal texture
  40713. * @param texture defines the texture to update
  40714. * @param imageData defines the data to store into the texture
  40715. * @param xOffset defines the x coordinates of the update rectangle
  40716. * @param yOffset defines the y coordinates of the update rectangle
  40717. * @param width defines the width of the update rectangle
  40718. * @param height defines the height of the update rectangle
  40719. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40720. * @param lod defines the lod level to update (0 by default)
  40721. */
  40722. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40723. /** @hidden */
  40724. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40725. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40726. private _prepareWebGLTexture;
  40727. /** @hidden */
  40728. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40729. private _getDepthStencilBuffer;
  40730. /** @hidden */
  40731. _releaseFramebufferObjects(texture: InternalTexture): void;
  40732. /** @hidden */
  40733. _releaseTexture(texture: InternalTexture): void;
  40734. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40735. protected _setProgram(program: WebGLProgram): void;
  40736. protected _boundUniforms: {
  40737. [key: number]: WebGLUniformLocation;
  40738. };
  40739. /**
  40740. * Binds an effect to the webGL context
  40741. * @param effect defines the effect to bind
  40742. */
  40743. bindSamplers(effect: Effect): void;
  40744. private _activateCurrentTexture;
  40745. /** @hidden */
  40746. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40747. /** @hidden */
  40748. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40749. /**
  40750. * Unbind all textures from the webGL context
  40751. */
  40752. unbindAllTextures(): void;
  40753. /**
  40754. * Sets a texture to the according uniform.
  40755. * @param channel The texture channel
  40756. * @param uniform The uniform to set
  40757. * @param texture The texture to apply
  40758. */
  40759. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40760. private _bindSamplerUniformToChannel;
  40761. private _getTextureWrapMode;
  40762. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40763. /**
  40764. * Sets an array of texture to the webGL context
  40765. * @param channel defines the channel where the texture array must be set
  40766. * @param uniform defines the associated uniform location
  40767. * @param textures defines the array of textures to bind
  40768. */
  40769. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40770. /** @hidden */
  40771. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40772. private _setTextureParameterFloat;
  40773. private _setTextureParameterInteger;
  40774. /**
  40775. * Unbind all vertex attributes from the webGL context
  40776. */
  40777. unbindAllAttributes(): void;
  40778. /**
  40779. * 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
  40780. */
  40781. releaseEffects(): void;
  40782. /**
  40783. * Dispose and release all associated resources
  40784. */
  40785. dispose(): void;
  40786. /**
  40787. * Attach a new callback raised when context lost event is fired
  40788. * @param callback defines the callback to call
  40789. */
  40790. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40791. /**
  40792. * Attach a new callback raised when context restored event is fired
  40793. * @param callback defines the callback to call
  40794. */
  40795. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40796. /**
  40797. * Get the current error code of the webGL context
  40798. * @returns the error code
  40799. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40800. */
  40801. getError(): number;
  40802. private _canRenderToFloatFramebuffer;
  40803. private _canRenderToHalfFloatFramebuffer;
  40804. private _canRenderToFramebuffer;
  40805. /** @hidden */
  40806. _getWebGLTextureType(type: number): number;
  40807. /** @hidden */
  40808. _getInternalFormat(format: number): number;
  40809. /** @hidden */
  40810. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40811. /** @hidden */
  40812. _getRGBAMultiSampleBufferFormat(type: number): number;
  40813. /** @hidden */
  40814. _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;
  40815. /**
  40816. * Loads a file from a url
  40817. * @param url url to load
  40818. * @param onSuccess callback called when the file successfully loads
  40819. * @param onProgress callback called while file is loading (if the server supports this mode)
  40820. * @param offlineProvider defines the offline provider for caching
  40821. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40822. * @param onError callback called when the file fails to load
  40823. * @returns a file request object
  40824. * @hidden
  40825. */
  40826. 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;
  40827. /**
  40828. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40829. * @param x defines the x coordinate of the rectangle where pixels must be read
  40830. * @param y defines the y coordinate of the rectangle where pixels must be read
  40831. * @param width defines the width of the rectangle where pixels must be read
  40832. * @param height defines the height of the rectangle where pixels must be read
  40833. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40834. * @returns a Uint8Array containing RGBA colors
  40835. */
  40836. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40837. private static _IsSupported;
  40838. private static _HasMajorPerformanceCaveat;
  40839. /**
  40840. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40841. */
  40842. static get IsSupported(): boolean;
  40843. /**
  40844. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40845. * @returns true if the engine can be created
  40846. * @ignorenaming
  40847. */
  40848. static isSupported(): boolean;
  40849. /**
  40850. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  40851. */
  40852. static get HasMajorPerformanceCaveat(): boolean;
  40853. /**
  40854. * Find the next highest power of two.
  40855. * @param x Number to start search from.
  40856. * @return Next highest power of two.
  40857. */
  40858. static CeilingPOT(x: number): number;
  40859. /**
  40860. * Find the next lowest power of two.
  40861. * @param x Number to start search from.
  40862. * @return Next lowest power of two.
  40863. */
  40864. static FloorPOT(x: number): number;
  40865. /**
  40866. * Find the nearest power of two.
  40867. * @param x Number to start search from.
  40868. * @return Next nearest power of two.
  40869. */
  40870. static NearestPOT(x: number): number;
  40871. /**
  40872. * Get the closest exponent of two
  40873. * @param value defines the value to approximate
  40874. * @param max defines the maximum value to return
  40875. * @param mode defines how to define the closest value
  40876. * @returns closest exponent of two of the given value
  40877. */
  40878. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40879. /**
  40880. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40881. * @param func - the function to be called
  40882. * @param requester - the object that will request the next frame. Falls back to window.
  40883. * @returns frame number
  40884. */
  40885. static QueueNewFrame(func: () => void, requester?: any): number;
  40886. /**
  40887. * Gets host document
  40888. * @returns the host document object
  40889. */
  40890. getHostDocument(): Nullable<Document>;
  40891. }
  40892. }
  40893. declare module "babylonjs/Materials/Textures/internalTexture" {
  40894. import { Observable } from "babylonjs/Misc/observable";
  40895. import { Nullable, int } from "babylonjs/types";
  40896. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40898. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  40899. /**
  40900. * Defines the source of the internal texture
  40901. */
  40902. export enum InternalTextureSource {
  40903. /**
  40904. * The source of the texture data is unknown
  40905. */
  40906. Unknown = 0,
  40907. /**
  40908. * Texture data comes from an URL
  40909. */
  40910. Url = 1,
  40911. /**
  40912. * Texture data is only used for temporary storage
  40913. */
  40914. Temp = 2,
  40915. /**
  40916. * Texture data comes from raw data (ArrayBuffer)
  40917. */
  40918. Raw = 3,
  40919. /**
  40920. * Texture content is dynamic (video or dynamic texture)
  40921. */
  40922. Dynamic = 4,
  40923. /**
  40924. * Texture content is generated by rendering to it
  40925. */
  40926. RenderTarget = 5,
  40927. /**
  40928. * Texture content is part of a multi render target process
  40929. */
  40930. MultiRenderTarget = 6,
  40931. /**
  40932. * Texture data comes from a cube data file
  40933. */
  40934. Cube = 7,
  40935. /**
  40936. * Texture data comes from a raw cube data
  40937. */
  40938. CubeRaw = 8,
  40939. /**
  40940. * Texture data come from a prefiltered cube data file
  40941. */
  40942. CubePrefiltered = 9,
  40943. /**
  40944. * Texture content is raw 3D data
  40945. */
  40946. Raw3D = 10,
  40947. /**
  40948. * Texture content is raw 2D array data
  40949. */
  40950. Raw2DArray = 11,
  40951. /**
  40952. * Texture content is a depth texture
  40953. */
  40954. Depth = 12,
  40955. /**
  40956. * Texture data comes from a raw cube data encoded with RGBD
  40957. */
  40958. CubeRawRGBD = 13
  40959. }
  40960. /**
  40961. * Class used to store data associated with WebGL texture data for the engine
  40962. * This class should not be used directly
  40963. */
  40964. export class InternalTexture {
  40965. /** @hidden */
  40966. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40967. /**
  40968. * Defines if the texture is ready
  40969. */
  40970. isReady: boolean;
  40971. /**
  40972. * Defines if the texture is a cube texture
  40973. */
  40974. isCube: boolean;
  40975. /**
  40976. * Defines if the texture contains 3D data
  40977. */
  40978. is3D: boolean;
  40979. /**
  40980. * Defines if the texture contains 2D array data
  40981. */
  40982. is2DArray: boolean;
  40983. /**
  40984. * Defines if the texture contains multiview data
  40985. */
  40986. isMultiview: boolean;
  40987. /**
  40988. * Gets the URL used to load this texture
  40989. */
  40990. url: string;
  40991. /**
  40992. * Gets the sampling mode of the texture
  40993. */
  40994. samplingMode: number;
  40995. /**
  40996. * Gets a boolean indicating if the texture needs mipmaps generation
  40997. */
  40998. generateMipMaps: boolean;
  40999. /**
  41000. * Gets the number of samples used by the texture (WebGL2+ only)
  41001. */
  41002. samples: number;
  41003. /**
  41004. * Gets the type of the texture (int, float...)
  41005. */
  41006. type: number;
  41007. /**
  41008. * Gets the format of the texture (RGB, RGBA...)
  41009. */
  41010. format: number;
  41011. /**
  41012. * Observable called when the texture is loaded
  41013. */
  41014. onLoadedObservable: Observable<InternalTexture>;
  41015. /**
  41016. * Gets the width of the texture
  41017. */
  41018. width: number;
  41019. /**
  41020. * Gets the height of the texture
  41021. */
  41022. height: number;
  41023. /**
  41024. * Gets the depth of the texture
  41025. */
  41026. depth: number;
  41027. /**
  41028. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41029. */
  41030. baseWidth: number;
  41031. /**
  41032. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41033. */
  41034. baseHeight: number;
  41035. /**
  41036. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41037. */
  41038. baseDepth: number;
  41039. /**
  41040. * Gets a boolean indicating if the texture is inverted on Y axis
  41041. */
  41042. invertY: boolean;
  41043. /** @hidden */
  41044. _invertVScale: boolean;
  41045. /** @hidden */
  41046. _associatedChannel: number;
  41047. /** @hidden */
  41048. _source: InternalTextureSource;
  41049. /** @hidden */
  41050. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41051. /** @hidden */
  41052. _bufferView: Nullable<ArrayBufferView>;
  41053. /** @hidden */
  41054. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41055. /** @hidden */
  41056. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41057. /** @hidden */
  41058. _size: number;
  41059. /** @hidden */
  41060. _extension: string;
  41061. /** @hidden */
  41062. _files: Nullable<string[]>;
  41063. /** @hidden */
  41064. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41065. /** @hidden */
  41066. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41067. /** @hidden */
  41068. _framebuffer: Nullable<WebGLFramebuffer>;
  41069. /** @hidden */
  41070. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41071. /** @hidden */
  41072. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41073. /** @hidden */
  41074. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41075. /** @hidden */
  41076. _attachments: Nullable<number[]>;
  41077. /** @hidden */
  41078. _textureArray: Nullable<InternalTexture[]>;
  41079. /** @hidden */
  41080. _cachedCoordinatesMode: Nullable<number>;
  41081. /** @hidden */
  41082. _cachedWrapU: Nullable<number>;
  41083. /** @hidden */
  41084. _cachedWrapV: Nullable<number>;
  41085. /** @hidden */
  41086. _cachedWrapR: Nullable<number>;
  41087. /** @hidden */
  41088. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41089. /** @hidden */
  41090. _isDisabled: boolean;
  41091. /** @hidden */
  41092. _compression: Nullable<string>;
  41093. /** @hidden */
  41094. _generateStencilBuffer: boolean;
  41095. /** @hidden */
  41096. _generateDepthBuffer: boolean;
  41097. /** @hidden */
  41098. _comparisonFunction: number;
  41099. /** @hidden */
  41100. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41101. /** @hidden */
  41102. _lodGenerationScale: number;
  41103. /** @hidden */
  41104. _lodGenerationOffset: number;
  41105. /** @hidden */
  41106. _depthStencilTexture: Nullable<InternalTexture>;
  41107. /** @hidden */
  41108. _colorTextureArray: Nullable<WebGLTexture>;
  41109. /** @hidden */
  41110. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41111. /** @hidden */
  41112. _lodTextureHigh: Nullable<BaseTexture>;
  41113. /** @hidden */
  41114. _lodTextureMid: Nullable<BaseTexture>;
  41115. /** @hidden */
  41116. _lodTextureLow: Nullable<BaseTexture>;
  41117. /** @hidden */
  41118. _isRGBD: boolean;
  41119. /** @hidden */
  41120. _linearSpecularLOD: boolean;
  41121. /** @hidden */
  41122. _irradianceTexture: Nullable<BaseTexture>;
  41123. /** @hidden */
  41124. _webGLTexture: Nullable<WebGLTexture>;
  41125. /** @hidden */
  41126. _references: number;
  41127. /** @hidden */
  41128. _gammaSpace: Nullable<boolean>;
  41129. private _engine;
  41130. /**
  41131. * Gets the Engine the texture belongs to.
  41132. * @returns The babylon engine
  41133. */
  41134. getEngine(): ThinEngine;
  41135. /**
  41136. * Gets the data source type of the texture
  41137. */
  41138. get source(): InternalTextureSource;
  41139. /**
  41140. * Creates a new InternalTexture
  41141. * @param engine defines the engine to use
  41142. * @param source defines the type of data that will be used
  41143. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41144. */
  41145. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41146. /**
  41147. * Increments the number of references (ie. the number of Texture that point to it)
  41148. */
  41149. incrementReferences(): void;
  41150. /**
  41151. * Change the size of the texture (not the size of the content)
  41152. * @param width defines the new width
  41153. * @param height defines the new height
  41154. * @param depth defines the new depth (1 by default)
  41155. */
  41156. updateSize(width: int, height: int, depth?: int): void;
  41157. /** @hidden */
  41158. _rebuild(): void;
  41159. /** @hidden */
  41160. _swapAndDie(target: InternalTexture): void;
  41161. /**
  41162. * Dispose the current allocated resources
  41163. */
  41164. dispose(): void;
  41165. }
  41166. }
  41167. declare module "babylonjs/Audio/analyser" {
  41168. import { Scene } from "babylonjs/scene";
  41169. /**
  41170. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41171. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41172. */
  41173. export class Analyser {
  41174. /**
  41175. * Gets or sets the smoothing
  41176. * @ignorenaming
  41177. */
  41178. SMOOTHING: number;
  41179. /**
  41180. * Gets or sets the FFT table size
  41181. * @ignorenaming
  41182. */
  41183. FFT_SIZE: number;
  41184. /**
  41185. * Gets or sets the bar graph amplitude
  41186. * @ignorenaming
  41187. */
  41188. BARGRAPHAMPLITUDE: number;
  41189. /**
  41190. * Gets or sets the position of the debug canvas
  41191. * @ignorenaming
  41192. */
  41193. DEBUGCANVASPOS: {
  41194. x: number;
  41195. y: number;
  41196. };
  41197. /**
  41198. * Gets or sets the debug canvas size
  41199. * @ignorenaming
  41200. */
  41201. DEBUGCANVASSIZE: {
  41202. width: number;
  41203. height: number;
  41204. };
  41205. private _byteFreqs;
  41206. private _byteTime;
  41207. private _floatFreqs;
  41208. private _webAudioAnalyser;
  41209. private _debugCanvas;
  41210. private _debugCanvasContext;
  41211. private _scene;
  41212. private _registerFunc;
  41213. private _audioEngine;
  41214. /**
  41215. * Creates a new analyser
  41216. * @param scene defines hosting scene
  41217. */
  41218. constructor(scene: Scene);
  41219. /**
  41220. * Get the number of data values you will have to play with for the visualization
  41221. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41222. * @returns a number
  41223. */
  41224. getFrequencyBinCount(): number;
  41225. /**
  41226. * Gets the current frequency data as a byte array
  41227. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41228. * @returns a Uint8Array
  41229. */
  41230. getByteFrequencyData(): Uint8Array;
  41231. /**
  41232. * Gets the current waveform as a byte array
  41233. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41234. * @returns a Uint8Array
  41235. */
  41236. getByteTimeDomainData(): Uint8Array;
  41237. /**
  41238. * Gets the current frequency data as a float array
  41239. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41240. * @returns a Float32Array
  41241. */
  41242. getFloatFrequencyData(): Float32Array;
  41243. /**
  41244. * Renders the debug canvas
  41245. */
  41246. drawDebugCanvas(): void;
  41247. /**
  41248. * Stops rendering the debug canvas and removes it
  41249. */
  41250. stopDebugCanvas(): void;
  41251. /**
  41252. * Connects two audio nodes
  41253. * @param inputAudioNode defines first node to connect
  41254. * @param outputAudioNode defines second node to connect
  41255. */
  41256. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41257. /**
  41258. * Releases all associated resources
  41259. */
  41260. dispose(): void;
  41261. }
  41262. }
  41263. declare module "babylonjs/Audio/audioEngine" {
  41264. import { IDisposable } from "babylonjs/scene";
  41265. import { Analyser } from "babylonjs/Audio/analyser";
  41266. import { Nullable } from "babylonjs/types";
  41267. import { Observable } from "babylonjs/Misc/observable";
  41268. /**
  41269. * This represents an audio engine and it is responsible
  41270. * to play, synchronize and analyse sounds throughout the application.
  41271. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41272. */
  41273. export interface IAudioEngine extends IDisposable {
  41274. /**
  41275. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41276. */
  41277. readonly canUseWebAudio: boolean;
  41278. /**
  41279. * Gets the current AudioContext if available.
  41280. */
  41281. readonly audioContext: Nullable<AudioContext>;
  41282. /**
  41283. * The master gain node defines the global audio volume of your audio engine.
  41284. */
  41285. readonly masterGain: GainNode;
  41286. /**
  41287. * Gets whether or not mp3 are supported by your browser.
  41288. */
  41289. readonly isMP3supported: boolean;
  41290. /**
  41291. * Gets whether or not ogg are supported by your browser.
  41292. */
  41293. readonly isOGGsupported: boolean;
  41294. /**
  41295. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41296. * @ignoreNaming
  41297. */
  41298. WarnedWebAudioUnsupported: boolean;
  41299. /**
  41300. * Defines if the audio engine relies on a custom unlocked button.
  41301. * In this case, the embedded button will not be displayed.
  41302. */
  41303. useCustomUnlockedButton: boolean;
  41304. /**
  41305. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41306. */
  41307. readonly unlocked: boolean;
  41308. /**
  41309. * Event raised when audio has been unlocked on the browser.
  41310. */
  41311. onAudioUnlockedObservable: Observable<AudioEngine>;
  41312. /**
  41313. * Event raised when audio has been locked on the browser.
  41314. */
  41315. onAudioLockedObservable: Observable<AudioEngine>;
  41316. /**
  41317. * Flags the audio engine in Locked state.
  41318. * This happens due to new browser policies preventing audio to autoplay.
  41319. */
  41320. lock(): void;
  41321. /**
  41322. * Unlocks the audio engine once a user action has been done on the dom.
  41323. * This is helpful to resume play once browser policies have been satisfied.
  41324. */
  41325. unlock(): void;
  41326. /**
  41327. * Gets the global volume sets on the master gain.
  41328. * @returns the global volume if set or -1 otherwise
  41329. */
  41330. getGlobalVolume(): number;
  41331. /**
  41332. * Sets the global volume of your experience (sets on the master gain).
  41333. * @param newVolume Defines the new global volume of the application
  41334. */
  41335. setGlobalVolume(newVolume: number): void;
  41336. /**
  41337. * Connect the audio engine to an audio analyser allowing some amazing
  41338. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41339. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41340. * @param analyser The analyser to connect to the engine
  41341. */
  41342. connectToAnalyser(analyser: Analyser): void;
  41343. }
  41344. /**
  41345. * This represents the default audio engine used in babylon.
  41346. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41347. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41348. */
  41349. export class AudioEngine implements IAudioEngine {
  41350. private _audioContext;
  41351. private _audioContextInitialized;
  41352. private _muteButton;
  41353. private _hostElement;
  41354. /**
  41355. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41356. */
  41357. canUseWebAudio: boolean;
  41358. /**
  41359. * The master gain node defines the global audio volume of your audio engine.
  41360. */
  41361. masterGain: GainNode;
  41362. /**
  41363. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41364. * @ignoreNaming
  41365. */
  41366. WarnedWebAudioUnsupported: boolean;
  41367. /**
  41368. * Gets whether or not mp3 are supported by your browser.
  41369. */
  41370. isMP3supported: boolean;
  41371. /**
  41372. * Gets whether or not ogg are supported by your browser.
  41373. */
  41374. isOGGsupported: boolean;
  41375. /**
  41376. * Gets whether audio has been unlocked on the device.
  41377. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41378. * a user interaction has happened.
  41379. */
  41380. unlocked: boolean;
  41381. /**
  41382. * Defines if the audio engine relies on a custom unlocked button.
  41383. * In this case, the embedded button will not be displayed.
  41384. */
  41385. useCustomUnlockedButton: boolean;
  41386. /**
  41387. * Event raised when audio has been unlocked on the browser.
  41388. */
  41389. onAudioUnlockedObservable: Observable<AudioEngine>;
  41390. /**
  41391. * Event raised when audio has been locked on the browser.
  41392. */
  41393. onAudioLockedObservable: Observable<AudioEngine>;
  41394. /**
  41395. * Gets the current AudioContext if available.
  41396. */
  41397. get audioContext(): Nullable<AudioContext>;
  41398. private _connectedAnalyser;
  41399. /**
  41400. * Instantiates a new audio engine.
  41401. *
  41402. * There should be only one per page as some browsers restrict the number
  41403. * of audio contexts you can create.
  41404. * @param hostElement defines the host element where to display the mute icon if necessary
  41405. */
  41406. constructor(hostElement?: Nullable<HTMLElement>);
  41407. /**
  41408. * Flags the audio engine in Locked state.
  41409. * This happens due to new browser policies preventing audio to autoplay.
  41410. */
  41411. lock(): void;
  41412. /**
  41413. * Unlocks the audio engine once a user action has been done on the dom.
  41414. * This is helpful to resume play once browser policies have been satisfied.
  41415. */
  41416. unlock(): void;
  41417. private _resumeAudioContext;
  41418. private _initializeAudioContext;
  41419. private _tryToRun;
  41420. private _triggerRunningState;
  41421. private _triggerSuspendedState;
  41422. private _displayMuteButton;
  41423. private _moveButtonToTopLeft;
  41424. private _onResize;
  41425. private _hideMuteButton;
  41426. /**
  41427. * Destroy and release the resources associated with the audio ccontext.
  41428. */
  41429. dispose(): void;
  41430. /**
  41431. * Gets the global volume sets on the master gain.
  41432. * @returns the global volume if set or -1 otherwise
  41433. */
  41434. getGlobalVolume(): number;
  41435. /**
  41436. * Sets the global volume of your experience (sets on the master gain).
  41437. * @param newVolume Defines the new global volume of the application
  41438. */
  41439. setGlobalVolume(newVolume: number): void;
  41440. /**
  41441. * Connect the audio engine to an audio analyser allowing some amazing
  41442. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41443. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41444. * @param analyser The analyser to connect to the engine
  41445. */
  41446. connectToAnalyser(analyser: Analyser): void;
  41447. }
  41448. }
  41449. declare module "babylonjs/Loading/loadingScreen" {
  41450. /**
  41451. * Interface used to present a loading screen while loading a scene
  41452. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41453. */
  41454. export interface ILoadingScreen {
  41455. /**
  41456. * Function called to display the loading screen
  41457. */
  41458. displayLoadingUI: () => void;
  41459. /**
  41460. * Function called to hide the loading screen
  41461. */
  41462. hideLoadingUI: () => void;
  41463. /**
  41464. * Gets or sets the color to use for the background
  41465. */
  41466. loadingUIBackgroundColor: string;
  41467. /**
  41468. * Gets or sets the text to display while loading
  41469. */
  41470. loadingUIText: string;
  41471. }
  41472. /**
  41473. * Class used for the default loading screen
  41474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41475. */
  41476. export class DefaultLoadingScreen implements ILoadingScreen {
  41477. private _renderingCanvas;
  41478. private _loadingText;
  41479. private _loadingDivBackgroundColor;
  41480. private _loadingDiv;
  41481. private _loadingTextDiv;
  41482. /** Gets or sets the logo url to use for the default loading screen */
  41483. static DefaultLogoUrl: string;
  41484. /** Gets or sets the spinner url to use for the default loading screen */
  41485. static DefaultSpinnerUrl: string;
  41486. /**
  41487. * Creates a new default loading screen
  41488. * @param _renderingCanvas defines the canvas used to render the scene
  41489. * @param _loadingText defines the default text to display
  41490. * @param _loadingDivBackgroundColor defines the default background color
  41491. */
  41492. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41493. /**
  41494. * Function called to display the loading screen
  41495. */
  41496. displayLoadingUI(): void;
  41497. /**
  41498. * Function called to hide the loading screen
  41499. */
  41500. hideLoadingUI(): void;
  41501. /**
  41502. * Gets or sets the text to display while loading
  41503. */
  41504. set loadingUIText(text: string);
  41505. get loadingUIText(): string;
  41506. /**
  41507. * Gets or sets the color to use for the background
  41508. */
  41509. get loadingUIBackgroundColor(): string;
  41510. set loadingUIBackgroundColor(color: string);
  41511. private _resizeLoadingUI;
  41512. }
  41513. }
  41514. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41515. /**
  41516. * Interface for any object that can request an animation frame
  41517. */
  41518. export interface ICustomAnimationFrameRequester {
  41519. /**
  41520. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41521. */
  41522. renderFunction?: Function;
  41523. /**
  41524. * Called to request the next frame to render to
  41525. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41526. */
  41527. requestAnimationFrame: Function;
  41528. /**
  41529. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41530. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41531. */
  41532. requestID?: number;
  41533. }
  41534. }
  41535. declare module "babylonjs/Misc/performanceMonitor" {
  41536. /**
  41537. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41538. */
  41539. export class PerformanceMonitor {
  41540. private _enabled;
  41541. private _rollingFrameTime;
  41542. private _lastFrameTimeMs;
  41543. /**
  41544. * constructor
  41545. * @param frameSampleSize The number of samples required to saturate the sliding window
  41546. */
  41547. constructor(frameSampleSize?: number);
  41548. /**
  41549. * Samples current frame
  41550. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41551. */
  41552. sampleFrame(timeMs?: number): void;
  41553. /**
  41554. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41555. */
  41556. get averageFrameTime(): number;
  41557. /**
  41558. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41559. */
  41560. get averageFrameTimeVariance(): number;
  41561. /**
  41562. * Returns the frame time of the most recent frame
  41563. */
  41564. get instantaneousFrameTime(): number;
  41565. /**
  41566. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41567. */
  41568. get averageFPS(): number;
  41569. /**
  41570. * Returns the average framerate in frames per second using the most recent frame time
  41571. */
  41572. get instantaneousFPS(): number;
  41573. /**
  41574. * Returns true if enough samples have been taken to completely fill the sliding window
  41575. */
  41576. get isSaturated(): boolean;
  41577. /**
  41578. * Enables contributions to the sliding window sample set
  41579. */
  41580. enable(): void;
  41581. /**
  41582. * Disables contributions to the sliding window sample set
  41583. * Samples will not be interpolated over the disabled period
  41584. */
  41585. disable(): void;
  41586. /**
  41587. * Returns true if sampling is enabled
  41588. */
  41589. get isEnabled(): boolean;
  41590. /**
  41591. * Resets performance monitor
  41592. */
  41593. reset(): void;
  41594. }
  41595. /**
  41596. * RollingAverage
  41597. *
  41598. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41599. */
  41600. export class RollingAverage {
  41601. /**
  41602. * Current average
  41603. */
  41604. average: number;
  41605. /**
  41606. * Current variance
  41607. */
  41608. variance: number;
  41609. protected _samples: Array<number>;
  41610. protected _sampleCount: number;
  41611. protected _pos: number;
  41612. protected _m2: number;
  41613. /**
  41614. * constructor
  41615. * @param length The number of samples required to saturate the sliding window
  41616. */
  41617. constructor(length: number);
  41618. /**
  41619. * Adds a sample to the sample set
  41620. * @param v The sample value
  41621. */
  41622. add(v: number): void;
  41623. /**
  41624. * Returns previously added values or null if outside of history or outside the sliding window domain
  41625. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41626. * @return Value previously recorded with add() or null if outside of range
  41627. */
  41628. history(i: number): number;
  41629. /**
  41630. * Returns true if enough samples have been taken to completely fill the sliding window
  41631. * @return true if sample-set saturated
  41632. */
  41633. isSaturated(): boolean;
  41634. /**
  41635. * Resets the rolling average (equivalent to 0 samples taken so far)
  41636. */
  41637. reset(): void;
  41638. /**
  41639. * Wraps a value around the sample range boundaries
  41640. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41641. * @return Wrapped position in sample range
  41642. */
  41643. protected _wrapPosition(i: number): number;
  41644. }
  41645. }
  41646. declare module "babylonjs/Misc/perfCounter" {
  41647. /**
  41648. * This class is used to track a performance counter which is number based.
  41649. * The user has access to many properties which give statistics of different nature.
  41650. *
  41651. * The implementer can track two kinds of Performance Counter: time and count.
  41652. * 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.
  41653. * 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.
  41654. */
  41655. export class PerfCounter {
  41656. /**
  41657. * Gets or sets a global boolean to turn on and off all the counters
  41658. */
  41659. static Enabled: boolean;
  41660. /**
  41661. * Returns the smallest value ever
  41662. */
  41663. get min(): number;
  41664. /**
  41665. * Returns the biggest value ever
  41666. */
  41667. get max(): number;
  41668. /**
  41669. * Returns the average value since the performance counter is running
  41670. */
  41671. get average(): number;
  41672. /**
  41673. * Returns the average value of the last second the counter was monitored
  41674. */
  41675. get lastSecAverage(): number;
  41676. /**
  41677. * Returns the current value
  41678. */
  41679. get current(): number;
  41680. /**
  41681. * Gets the accumulated total
  41682. */
  41683. get total(): number;
  41684. /**
  41685. * Gets the total value count
  41686. */
  41687. get count(): number;
  41688. /**
  41689. * Creates a new counter
  41690. */
  41691. constructor();
  41692. /**
  41693. * Call this method to start monitoring a new frame.
  41694. * 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.
  41695. */
  41696. fetchNewFrame(): void;
  41697. /**
  41698. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41699. * @param newCount the count value to add to the monitored count
  41700. * @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.
  41701. */
  41702. addCount(newCount: number, fetchResult: boolean): void;
  41703. /**
  41704. * Start monitoring this performance counter
  41705. */
  41706. beginMonitoring(): void;
  41707. /**
  41708. * Compute the time lapsed since the previous beginMonitoring() call.
  41709. * @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
  41710. */
  41711. endMonitoring(newFrame?: boolean): void;
  41712. private _fetchResult;
  41713. private _startMonitoringTime;
  41714. private _min;
  41715. private _max;
  41716. private _average;
  41717. private _current;
  41718. private _totalValueCount;
  41719. private _totalAccumulated;
  41720. private _lastSecAverage;
  41721. private _lastSecAccumulated;
  41722. private _lastSecTime;
  41723. private _lastSecValueCount;
  41724. }
  41725. }
  41726. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41728. import { Nullable } from "babylonjs/types";
  41729. module "babylonjs/Engines/thinEngine" {
  41730. interface ThinEngine {
  41731. /** @hidden */
  41732. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41733. }
  41734. }
  41735. }
  41736. declare module "babylonjs/Engines/engine" {
  41737. import { Observable } from "babylonjs/Misc/observable";
  41738. import { Nullable } from "babylonjs/types";
  41739. import { Scene } from "babylonjs/scene";
  41740. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41741. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41742. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41743. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41744. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41745. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41746. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41747. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41748. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41749. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41750. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41751. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41752. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41753. import "babylonjs/Engines/Extensions/engine.alpha";
  41754. import "babylonjs/Engines/Extensions/engine.readTexture";
  41755. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41756. import { Material } from "babylonjs/Materials/material";
  41757. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41758. /**
  41759. * Defines the interface used by display changed events
  41760. */
  41761. export interface IDisplayChangedEventArgs {
  41762. /** Gets the vrDisplay object (if any) */
  41763. vrDisplay: Nullable<any>;
  41764. /** Gets a boolean indicating if webVR is supported */
  41765. vrSupported: boolean;
  41766. }
  41767. /**
  41768. * Defines the interface used by objects containing a viewport (like a camera)
  41769. */
  41770. interface IViewportOwnerLike {
  41771. /**
  41772. * Gets or sets the viewport
  41773. */
  41774. viewport: IViewportLike;
  41775. }
  41776. /**
  41777. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41778. */
  41779. export class Engine extends ThinEngine {
  41780. /** Defines that alpha blending is disabled */
  41781. static readonly ALPHA_DISABLE: number;
  41782. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41783. static readonly ALPHA_ADD: number;
  41784. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41785. static readonly ALPHA_COMBINE: number;
  41786. /** Defines that alpha blending to DEST - SRC * DEST */
  41787. static readonly ALPHA_SUBTRACT: number;
  41788. /** Defines that alpha blending to SRC * DEST */
  41789. static readonly ALPHA_MULTIPLY: number;
  41790. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41791. static readonly ALPHA_MAXIMIZED: number;
  41792. /** Defines that alpha blending to SRC + DEST */
  41793. static readonly ALPHA_ONEONE: number;
  41794. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41795. static readonly ALPHA_PREMULTIPLIED: number;
  41796. /**
  41797. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41798. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41799. */
  41800. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41801. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41802. static readonly ALPHA_INTERPOLATE: number;
  41803. /**
  41804. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41805. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41806. */
  41807. static readonly ALPHA_SCREENMODE: number;
  41808. /** Defines that the ressource is not delayed*/
  41809. static readonly DELAYLOADSTATE_NONE: number;
  41810. /** Defines that the ressource was successfully delay loaded */
  41811. static readonly DELAYLOADSTATE_LOADED: number;
  41812. /** Defines that the ressource is currently delay loading */
  41813. static readonly DELAYLOADSTATE_LOADING: number;
  41814. /** Defines that the ressource is delayed and has not started loading */
  41815. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41816. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41817. static readonly NEVER: number;
  41818. /** 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 */
  41819. static readonly ALWAYS: number;
  41820. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41821. static readonly LESS: number;
  41822. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41823. static readonly EQUAL: number;
  41824. /** 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 */
  41825. static readonly LEQUAL: number;
  41826. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41827. static readonly GREATER: number;
  41828. /** 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 */
  41829. static readonly GEQUAL: number;
  41830. /** 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 */
  41831. static readonly NOTEQUAL: number;
  41832. /** Passed to stencilOperation to specify that stencil value must be kept */
  41833. static readonly KEEP: number;
  41834. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41835. static readonly REPLACE: number;
  41836. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41837. static readonly INCR: number;
  41838. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41839. static readonly DECR: number;
  41840. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41841. static readonly INVERT: number;
  41842. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41843. static readonly INCR_WRAP: number;
  41844. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41845. static readonly DECR_WRAP: number;
  41846. /** Texture is not repeating outside of 0..1 UVs */
  41847. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41848. /** Texture is repeating outside of 0..1 UVs */
  41849. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41850. /** Texture is repeating and mirrored */
  41851. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41852. /** ALPHA */
  41853. static readonly TEXTUREFORMAT_ALPHA: number;
  41854. /** LUMINANCE */
  41855. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41856. /** LUMINANCE_ALPHA */
  41857. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41858. /** RGB */
  41859. static readonly TEXTUREFORMAT_RGB: number;
  41860. /** RGBA */
  41861. static readonly TEXTUREFORMAT_RGBA: number;
  41862. /** RED */
  41863. static readonly TEXTUREFORMAT_RED: number;
  41864. /** RED (2nd reference) */
  41865. static readonly TEXTUREFORMAT_R: number;
  41866. /** RG */
  41867. static readonly TEXTUREFORMAT_RG: number;
  41868. /** RED_INTEGER */
  41869. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41870. /** RED_INTEGER (2nd reference) */
  41871. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41872. /** RG_INTEGER */
  41873. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41874. /** RGB_INTEGER */
  41875. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41876. /** RGBA_INTEGER */
  41877. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41878. /** UNSIGNED_BYTE */
  41879. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41880. /** UNSIGNED_BYTE (2nd reference) */
  41881. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41882. /** FLOAT */
  41883. static readonly TEXTURETYPE_FLOAT: number;
  41884. /** HALF_FLOAT */
  41885. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41886. /** BYTE */
  41887. static readonly TEXTURETYPE_BYTE: number;
  41888. /** SHORT */
  41889. static readonly TEXTURETYPE_SHORT: number;
  41890. /** UNSIGNED_SHORT */
  41891. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41892. /** INT */
  41893. static readonly TEXTURETYPE_INT: number;
  41894. /** UNSIGNED_INT */
  41895. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41896. /** UNSIGNED_SHORT_4_4_4_4 */
  41897. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41898. /** UNSIGNED_SHORT_5_5_5_1 */
  41899. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41900. /** UNSIGNED_SHORT_5_6_5 */
  41901. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41902. /** UNSIGNED_INT_2_10_10_10_REV */
  41903. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41904. /** UNSIGNED_INT_24_8 */
  41905. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41906. /** UNSIGNED_INT_10F_11F_11F_REV */
  41907. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41908. /** UNSIGNED_INT_5_9_9_9_REV */
  41909. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41910. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41911. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41912. /** nearest is mag = nearest and min = nearest and mip = linear */
  41913. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41914. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41915. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41916. /** Trilinear is mag = linear and min = linear and mip = linear */
  41917. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41918. /** nearest is mag = nearest and min = nearest and mip = linear */
  41919. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41920. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41921. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41922. /** Trilinear is mag = linear and min = linear and mip = linear */
  41923. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41924. /** mag = nearest and min = nearest and mip = nearest */
  41925. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41926. /** mag = nearest and min = linear and mip = nearest */
  41927. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41928. /** mag = nearest and min = linear and mip = linear */
  41929. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41930. /** mag = nearest and min = linear and mip = none */
  41931. static readonly TEXTURE_NEAREST_LINEAR: number;
  41932. /** mag = nearest and min = nearest and mip = none */
  41933. static readonly TEXTURE_NEAREST_NEAREST: number;
  41934. /** mag = linear and min = nearest and mip = nearest */
  41935. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41936. /** mag = linear and min = nearest and mip = linear */
  41937. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41938. /** mag = linear and min = linear and mip = none */
  41939. static readonly TEXTURE_LINEAR_LINEAR: number;
  41940. /** mag = linear and min = nearest and mip = none */
  41941. static readonly TEXTURE_LINEAR_NEAREST: number;
  41942. /** Explicit coordinates mode */
  41943. static readonly TEXTURE_EXPLICIT_MODE: number;
  41944. /** Spherical coordinates mode */
  41945. static readonly TEXTURE_SPHERICAL_MODE: number;
  41946. /** Planar coordinates mode */
  41947. static readonly TEXTURE_PLANAR_MODE: number;
  41948. /** Cubic coordinates mode */
  41949. static readonly TEXTURE_CUBIC_MODE: number;
  41950. /** Projection coordinates mode */
  41951. static readonly TEXTURE_PROJECTION_MODE: number;
  41952. /** Skybox coordinates mode */
  41953. static readonly TEXTURE_SKYBOX_MODE: number;
  41954. /** Inverse Cubic coordinates mode */
  41955. static readonly TEXTURE_INVCUBIC_MODE: number;
  41956. /** Equirectangular coordinates mode */
  41957. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41958. /** Equirectangular Fixed coordinates mode */
  41959. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41960. /** Equirectangular Fixed Mirrored coordinates mode */
  41961. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41962. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41963. static readonly SCALEMODE_FLOOR: number;
  41964. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41965. static readonly SCALEMODE_NEAREST: number;
  41966. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41967. static readonly SCALEMODE_CEILING: number;
  41968. /**
  41969. * Returns the current npm package of the sdk
  41970. */
  41971. static get NpmPackage(): string;
  41972. /**
  41973. * Returns the current version of the framework
  41974. */
  41975. static get Version(): string;
  41976. /** Gets the list of created engines */
  41977. static get Instances(): Engine[];
  41978. /**
  41979. * Gets the latest created engine
  41980. */
  41981. static get LastCreatedEngine(): Nullable<Engine>;
  41982. /**
  41983. * Gets the latest created scene
  41984. */
  41985. static get LastCreatedScene(): Nullable<Scene>;
  41986. /**
  41987. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41988. * @param flag defines which part of the materials must be marked as dirty
  41989. * @param predicate defines a predicate used to filter which materials should be affected
  41990. */
  41991. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41992. /**
  41993. * Method called to create the default loading screen.
  41994. * This can be overriden in your own app.
  41995. * @param canvas The rendering canvas element
  41996. * @returns The loading screen
  41997. */
  41998. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41999. /**
  42000. * Method called to create the default rescale post process on each engine.
  42001. */
  42002. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42003. /**
  42004. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42005. **/
  42006. enableOfflineSupport: boolean;
  42007. /**
  42008. * 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)
  42009. **/
  42010. disableManifestCheck: boolean;
  42011. /**
  42012. * Gets the list of created scenes
  42013. */
  42014. scenes: Scene[];
  42015. /**
  42016. * Event raised when a new scene is created
  42017. */
  42018. onNewSceneAddedObservable: Observable<Scene>;
  42019. /**
  42020. * Gets the list of created postprocesses
  42021. */
  42022. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42023. /**
  42024. * Gets a boolean indicating if the pointer is currently locked
  42025. */
  42026. isPointerLock: boolean;
  42027. /**
  42028. * Observable event triggered each time the rendering canvas is resized
  42029. */
  42030. onResizeObservable: Observable<Engine>;
  42031. /**
  42032. * Observable event triggered each time the canvas loses focus
  42033. */
  42034. onCanvasBlurObservable: Observable<Engine>;
  42035. /**
  42036. * Observable event triggered each time the canvas gains focus
  42037. */
  42038. onCanvasFocusObservable: Observable<Engine>;
  42039. /**
  42040. * Observable event triggered each time the canvas receives pointerout event
  42041. */
  42042. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42043. /**
  42044. * Observable raised when the engine begins a new frame
  42045. */
  42046. onBeginFrameObservable: Observable<Engine>;
  42047. /**
  42048. * If set, will be used to request the next animation frame for the render loop
  42049. */
  42050. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42051. /**
  42052. * Observable raised when the engine ends the current frame
  42053. */
  42054. onEndFrameObservable: Observable<Engine>;
  42055. /**
  42056. * Observable raised when the engine is about to compile a shader
  42057. */
  42058. onBeforeShaderCompilationObservable: Observable<Engine>;
  42059. /**
  42060. * Observable raised when the engine has jsut compiled a shader
  42061. */
  42062. onAfterShaderCompilationObservable: Observable<Engine>;
  42063. /**
  42064. * Gets the audio engine
  42065. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42066. * @ignorenaming
  42067. */
  42068. static audioEngine: IAudioEngine;
  42069. /**
  42070. * Default AudioEngine factory responsible of creating the Audio Engine.
  42071. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42072. */
  42073. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42074. /**
  42075. * Default offline support factory responsible of creating a tool used to store data locally.
  42076. * By default, this will create a Database object if the workload has been embedded.
  42077. */
  42078. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42079. private _loadingScreen;
  42080. private _pointerLockRequested;
  42081. private _rescalePostProcess;
  42082. private _deterministicLockstep;
  42083. private _lockstepMaxSteps;
  42084. private _timeStep;
  42085. protected get _supportsHardwareTextureRescaling(): boolean;
  42086. private _fps;
  42087. private _deltaTime;
  42088. /** @hidden */
  42089. _drawCalls: PerfCounter;
  42090. /** 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 */
  42091. canvasTabIndex: number;
  42092. /**
  42093. * Turn this value on if you want to pause FPS computation when in background
  42094. */
  42095. disablePerformanceMonitorInBackground: boolean;
  42096. private _performanceMonitor;
  42097. /**
  42098. * Gets the performance monitor attached to this engine
  42099. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42100. */
  42101. get performanceMonitor(): PerformanceMonitor;
  42102. private _onFocus;
  42103. private _onBlur;
  42104. private _onCanvasPointerOut;
  42105. private _onCanvasBlur;
  42106. private _onCanvasFocus;
  42107. private _onFullscreenChange;
  42108. private _onPointerLockChange;
  42109. /**
  42110. * Gets the HTML element used to attach event listeners
  42111. * @returns a HTML element
  42112. */
  42113. getInputElement(): Nullable<HTMLElement>;
  42114. /**
  42115. * Creates a new engine
  42116. * @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
  42117. * @param antialias defines enable antialiasing (default: false)
  42118. * @param options defines further options to be sent to the getContext() function
  42119. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42120. */
  42121. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42122. /**
  42123. * Gets current aspect ratio
  42124. * @param viewportOwner defines the camera to use to get the aspect ratio
  42125. * @param useScreen defines if screen size must be used (or the current render target if any)
  42126. * @returns a number defining the aspect ratio
  42127. */
  42128. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42129. /**
  42130. * Gets current screen aspect ratio
  42131. * @returns a number defining the aspect ratio
  42132. */
  42133. getScreenAspectRatio(): number;
  42134. /**
  42135. * Gets the client rect of the HTML canvas attached with the current webGL context
  42136. * @returns a client rectanglee
  42137. */
  42138. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42139. /**
  42140. * Gets the client rect of the HTML element used for events
  42141. * @returns a client rectanglee
  42142. */
  42143. getInputElementClientRect(): Nullable<ClientRect>;
  42144. /**
  42145. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42146. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42147. * @returns true if engine is in deterministic lock step mode
  42148. */
  42149. isDeterministicLockStep(): boolean;
  42150. /**
  42151. * Gets the max steps when engine is running in deterministic lock step
  42152. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42153. * @returns the max steps
  42154. */
  42155. getLockstepMaxSteps(): number;
  42156. /**
  42157. * Returns the time in ms between steps when using deterministic lock step.
  42158. * @returns time step in (ms)
  42159. */
  42160. getTimeStep(): number;
  42161. /**
  42162. * Force the mipmap generation for the given render target texture
  42163. * @param texture defines the render target texture to use
  42164. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42165. */
  42166. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42167. /** States */
  42168. /**
  42169. * Set various states to the webGL context
  42170. * @param culling defines backface culling state
  42171. * @param zOffset defines the value to apply to zOffset (0 by default)
  42172. * @param force defines if states must be applied even if cache is up to date
  42173. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42174. */
  42175. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42176. /**
  42177. * Set the z offset to apply to current rendering
  42178. * @param value defines the offset to apply
  42179. */
  42180. setZOffset(value: number): void;
  42181. /**
  42182. * Gets the current value of the zOffset
  42183. * @returns the current zOffset state
  42184. */
  42185. getZOffset(): number;
  42186. /**
  42187. * Enable or disable depth buffering
  42188. * @param enable defines the state to set
  42189. */
  42190. setDepthBuffer(enable: boolean): void;
  42191. /**
  42192. * Gets a boolean indicating if depth writing is enabled
  42193. * @returns the current depth writing state
  42194. */
  42195. getDepthWrite(): boolean;
  42196. /**
  42197. * Enable or disable depth writing
  42198. * @param enable defines the state to set
  42199. */
  42200. setDepthWrite(enable: boolean): void;
  42201. /**
  42202. * Gets a boolean indicating if stencil buffer is enabled
  42203. * @returns the current stencil buffer state
  42204. */
  42205. getStencilBuffer(): boolean;
  42206. /**
  42207. * Enable or disable the stencil buffer
  42208. * @param enable defines if the stencil buffer must be enabled or disabled
  42209. */
  42210. setStencilBuffer(enable: boolean): void;
  42211. /**
  42212. * Gets the current stencil mask
  42213. * @returns a number defining the new stencil mask to use
  42214. */
  42215. getStencilMask(): number;
  42216. /**
  42217. * Sets the current stencil mask
  42218. * @param mask defines the new stencil mask to use
  42219. */
  42220. setStencilMask(mask: number): void;
  42221. /**
  42222. * Gets the current stencil function
  42223. * @returns a number defining the stencil function to use
  42224. */
  42225. getStencilFunction(): number;
  42226. /**
  42227. * Gets the current stencil reference value
  42228. * @returns a number defining the stencil reference value to use
  42229. */
  42230. getStencilFunctionReference(): number;
  42231. /**
  42232. * Gets the current stencil mask
  42233. * @returns a number defining the stencil mask to use
  42234. */
  42235. getStencilFunctionMask(): number;
  42236. /**
  42237. * Sets the current stencil function
  42238. * @param stencilFunc defines the new stencil function to use
  42239. */
  42240. setStencilFunction(stencilFunc: number): void;
  42241. /**
  42242. * Sets the current stencil reference
  42243. * @param reference defines the new stencil reference to use
  42244. */
  42245. setStencilFunctionReference(reference: number): void;
  42246. /**
  42247. * Sets the current stencil mask
  42248. * @param mask defines the new stencil mask to use
  42249. */
  42250. setStencilFunctionMask(mask: number): void;
  42251. /**
  42252. * Gets the current stencil operation when stencil fails
  42253. * @returns a number defining stencil operation to use when stencil fails
  42254. */
  42255. getStencilOperationFail(): number;
  42256. /**
  42257. * Gets the current stencil operation when depth fails
  42258. * @returns a number defining stencil operation to use when depth fails
  42259. */
  42260. getStencilOperationDepthFail(): number;
  42261. /**
  42262. * Gets the current stencil operation when stencil passes
  42263. * @returns a number defining stencil operation to use when stencil passes
  42264. */
  42265. getStencilOperationPass(): number;
  42266. /**
  42267. * Sets the stencil operation to use when stencil fails
  42268. * @param operation defines the stencil operation to use when stencil fails
  42269. */
  42270. setStencilOperationFail(operation: number): void;
  42271. /**
  42272. * Sets the stencil operation to use when depth fails
  42273. * @param operation defines the stencil operation to use when depth fails
  42274. */
  42275. setStencilOperationDepthFail(operation: number): void;
  42276. /**
  42277. * Sets the stencil operation to use when stencil passes
  42278. * @param operation defines the stencil operation to use when stencil passes
  42279. */
  42280. setStencilOperationPass(operation: number): void;
  42281. /**
  42282. * Sets a boolean indicating if the dithering state is enabled or disabled
  42283. * @param value defines the dithering state
  42284. */
  42285. setDitheringState(value: boolean): void;
  42286. /**
  42287. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42288. * @param value defines the rasterizer state
  42289. */
  42290. setRasterizerState(value: boolean): void;
  42291. /**
  42292. * Gets the current depth function
  42293. * @returns a number defining the depth function
  42294. */
  42295. getDepthFunction(): Nullable<number>;
  42296. /**
  42297. * Sets the current depth function
  42298. * @param depthFunc defines the function to use
  42299. */
  42300. setDepthFunction(depthFunc: number): void;
  42301. /**
  42302. * Sets the current depth function to GREATER
  42303. */
  42304. setDepthFunctionToGreater(): void;
  42305. /**
  42306. * Sets the current depth function to GEQUAL
  42307. */
  42308. setDepthFunctionToGreaterOrEqual(): void;
  42309. /**
  42310. * Sets the current depth function to LESS
  42311. */
  42312. setDepthFunctionToLess(): void;
  42313. /**
  42314. * Sets the current depth function to LEQUAL
  42315. */
  42316. setDepthFunctionToLessOrEqual(): void;
  42317. private _cachedStencilBuffer;
  42318. private _cachedStencilFunction;
  42319. private _cachedStencilMask;
  42320. private _cachedStencilOperationPass;
  42321. private _cachedStencilOperationFail;
  42322. private _cachedStencilOperationDepthFail;
  42323. private _cachedStencilReference;
  42324. /**
  42325. * Caches the the state of the stencil buffer
  42326. */
  42327. cacheStencilState(): void;
  42328. /**
  42329. * Restores the state of the stencil buffer
  42330. */
  42331. restoreStencilState(): void;
  42332. /**
  42333. * Directly set the WebGL Viewport
  42334. * @param x defines the x coordinate of the viewport (in screen space)
  42335. * @param y defines the y coordinate of the viewport (in screen space)
  42336. * @param width defines the width of the viewport (in screen space)
  42337. * @param height defines the height of the viewport (in screen space)
  42338. * @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
  42339. */
  42340. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42341. /**
  42342. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42343. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42344. * @param y defines the y-coordinate of the corner of the clear rectangle
  42345. * @param width defines the width of the clear rectangle
  42346. * @param height defines the height of the clear rectangle
  42347. * @param clearColor defines the clear color
  42348. */
  42349. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42350. /**
  42351. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42352. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42353. * @param y defines the y-coordinate of the corner of the clear rectangle
  42354. * @param width defines the width of the clear rectangle
  42355. * @param height defines the height of the clear rectangle
  42356. */
  42357. enableScissor(x: number, y: number, width: number, height: number): void;
  42358. /**
  42359. * Disable previously set scissor test rectangle
  42360. */
  42361. disableScissor(): void;
  42362. protected _reportDrawCall(): void;
  42363. /**
  42364. * Initializes a webVR display and starts listening to display change events
  42365. * The onVRDisplayChangedObservable will be notified upon these changes
  42366. * @returns The onVRDisplayChangedObservable
  42367. */
  42368. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42369. /** @hidden */
  42370. _prepareVRComponent(): void;
  42371. /** @hidden */
  42372. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42373. /** @hidden */
  42374. _submitVRFrame(): void;
  42375. /**
  42376. * Call this function to leave webVR mode
  42377. * Will do nothing if webVR is not supported or if there is no webVR device
  42378. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42379. */
  42380. disableVR(): void;
  42381. /**
  42382. * Gets a boolean indicating that the system is in VR mode and is presenting
  42383. * @returns true if VR mode is engaged
  42384. */
  42385. isVRPresenting(): boolean;
  42386. /** @hidden */
  42387. _requestVRFrame(): void;
  42388. /** @hidden */
  42389. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42390. /**
  42391. * Gets the source code of the vertex shader associated with a specific webGL program
  42392. * @param program defines the program to use
  42393. * @returns a string containing the source code of the vertex shader associated with the program
  42394. */
  42395. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42396. /**
  42397. * Gets the source code of the fragment shader associated with a specific webGL program
  42398. * @param program defines the program to use
  42399. * @returns a string containing the source code of the fragment shader associated with the program
  42400. */
  42401. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42402. /**
  42403. * Sets a depth stencil texture from a render target to the according uniform.
  42404. * @param channel The texture channel
  42405. * @param uniform The uniform to set
  42406. * @param texture The render target texture containing the depth stencil texture to apply
  42407. */
  42408. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42409. /**
  42410. * Sets a texture to the webGL context from a postprocess
  42411. * @param channel defines the channel to use
  42412. * @param postProcess defines the source postprocess
  42413. */
  42414. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42415. /**
  42416. * Binds the output of the passed in post process to the texture channel specified
  42417. * @param channel The channel the texture should be bound to
  42418. * @param postProcess The post process which's output should be bound
  42419. */
  42420. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42421. protected _rebuildBuffers(): void;
  42422. /** @hidden */
  42423. _renderFrame(): void;
  42424. _renderLoop(): void;
  42425. /** @hidden */
  42426. _renderViews(): boolean;
  42427. /**
  42428. * Toggle full screen mode
  42429. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42430. */
  42431. switchFullscreen(requestPointerLock: boolean): void;
  42432. /**
  42433. * Enters full screen mode
  42434. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42435. */
  42436. enterFullscreen(requestPointerLock: boolean): void;
  42437. /**
  42438. * Exits full screen mode
  42439. */
  42440. exitFullscreen(): void;
  42441. /**
  42442. * Enters Pointerlock mode
  42443. */
  42444. enterPointerlock(): void;
  42445. /**
  42446. * Exits Pointerlock mode
  42447. */
  42448. exitPointerlock(): void;
  42449. /**
  42450. * Begin a new frame
  42451. */
  42452. beginFrame(): void;
  42453. /**
  42454. * Enf the current frame
  42455. */
  42456. endFrame(): void;
  42457. resize(): void;
  42458. /**
  42459. * Force a specific size of the canvas
  42460. * @param width defines the new canvas' width
  42461. * @param height defines the new canvas' height
  42462. * @returns true if the size was changed
  42463. */
  42464. setSize(width: number, height: number): boolean;
  42465. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42466. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42467. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42468. _releaseTexture(texture: InternalTexture): void;
  42469. /**
  42470. * @hidden
  42471. * Rescales a texture
  42472. * @param source input texutre
  42473. * @param destination destination texture
  42474. * @param scene scene to use to render the resize
  42475. * @param internalFormat format to use when resizing
  42476. * @param onComplete callback to be called when resize has completed
  42477. */
  42478. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42479. /**
  42480. * Gets the current framerate
  42481. * @returns a number representing the framerate
  42482. */
  42483. getFps(): number;
  42484. /**
  42485. * Gets the time spent between current and previous frame
  42486. * @returns a number representing the delta time in ms
  42487. */
  42488. getDeltaTime(): number;
  42489. private _measureFps;
  42490. /** @hidden */
  42491. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42492. /**
  42493. * Updates the sample count of a render target texture
  42494. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42495. * @param texture defines the texture to update
  42496. * @param samples defines the sample count to set
  42497. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42498. */
  42499. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42500. /**
  42501. * Updates a depth texture Comparison Mode and Function.
  42502. * If the comparison Function is equal to 0, the mode will be set to none.
  42503. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42504. * @param texture The texture to set the comparison function for
  42505. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42506. */
  42507. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42508. /**
  42509. * Creates a webGL buffer to use with instanciation
  42510. * @param capacity defines the size of the buffer
  42511. * @returns the webGL buffer
  42512. */
  42513. createInstancesBuffer(capacity: number): DataBuffer;
  42514. /**
  42515. * Delete a webGL buffer used with instanciation
  42516. * @param buffer defines the webGL buffer to delete
  42517. */
  42518. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42519. private _clientWaitAsync;
  42520. /** @hidden */
  42521. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42522. dispose(): void;
  42523. private _disableTouchAction;
  42524. /**
  42525. * Display the loading screen
  42526. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42527. */
  42528. displayLoadingUI(): void;
  42529. /**
  42530. * Hide the loading screen
  42531. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42532. */
  42533. hideLoadingUI(): void;
  42534. /**
  42535. * Gets the current loading screen object
  42536. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42537. */
  42538. get loadingScreen(): ILoadingScreen;
  42539. /**
  42540. * Sets the current loading screen object
  42541. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42542. */
  42543. set loadingScreen(loadingScreen: ILoadingScreen);
  42544. /**
  42545. * Sets the current loading screen text
  42546. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42547. */
  42548. set loadingUIText(text: string);
  42549. /**
  42550. * Sets the current loading screen background color
  42551. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42552. */
  42553. set loadingUIBackgroundColor(color: string);
  42554. /** Pointerlock and fullscreen */
  42555. /**
  42556. * Ask the browser to promote the current element to pointerlock mode
  42557. * @param element defines the DOM element to promote
  42558. */
  42559. static _RequestPointerlock(element: HTMLElement): void;
  42560. /**
  42561. * Asks the browser to exit pointerlock mode
  42562. */
  42563. static _ExitPointerlock(): void;
  42564. /**
  42565. * Ask the browser to promote the current element to fullscreen rendering mode
  42566. * @param element defines the DOM element to promote
  42567. */
  42568. static _RequestFullscreen(element: HTMLElement): void;
  42569. /**
  42570. * Asks the browser to exit fullscreen mode
  42571. */
  42572. static _ExitFullscreen(): void;
  42573. }
  42574. }
  42575. declare module "babylonjs/Engines/engineStore" {
  42576. import { Nullable } from "babylonjs/types";
  42577. import { Engine } from "babylonjs/Engines/engine";
  42578. import { Scene } from "babylonjs/scene";
  42579. /**
  42580. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42581. * during the life time of the application.
  42582. */
  42583. export class EngineStore {
  42584. /** Gets the list of created engines */
  42585. static Instances: import("babylonjs/Engines/engine").Engine[];
  42586. /** @hidden */
  42587. static _LastCreatedScene: Nullable<Scene>;
  42588. /**
  42589. * Gets the latest created engine
  42590. */
  42591. static get LastCreatedEngine(): Nullable<Engine>;
  42592. /**
  42593. * Gets the latest created scene
  42594. */
  42595. static get LastCreatedScene(): Nullable<Scene>;
  42596. /**
  42597. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42598. * @ignorenaming
  42599. */
  42600. static UseFallbackTexture: boolean;
  42601. /**
  42602. * Texture content used if a texture cannot loaded
  42603. * @ignorenaming
  42604. */
  42605. static FallbackTexture: string;
  42606. }
  42607. }
  42608. declare module "babylonjs/Misc/promise" {
  42609. /**
  42610. * Helper class that provides a small promise polyfill
  42611. */
  42612. export class PromisePolyfill {
  42613. /**
  42614. * Static function used to check if the polyfill is required
  42615. * If this is the case then the function will inject the polyfill to window.Promise
  42616. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42617. */
  42618. static Apply(force?: boolean): void;
  42619. }
  42620. }
  42621. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42622. /**
  42623. * Interface for screenshot methods with describe argument called `size` as object with options
  42624. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42625. */
  42626. export interface IScreenshotSize {
  42627. /**
  42628. * number in pixels for canvas height
  42629. */
  42630. height?: number;
  42631. /**
  42632. * multiplier allowing render at a higher or lower resolution
  42633. * If value is defined then height and width will be ignored and taken from camera
  42634. */
  42635. precision?: number;
  42636. /**
  42637. * number in pixels for canvas width
  42638. */
  42639. width?: number;
  42640. }
  42641. }
  42642. declare module "babylonjs/Misc/tools" {
  42643. import { Nullable, float } from "babylonjs/types";
  42644. import { DomManagement } from "babylonjs/Misc/domManagement";
  42645. import { WebRequest } from "babylonjs/Misc/webRequest";
  42646. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42647. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42648. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42649. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42650. import { Camera } from "babylonjs/Cameras/camera";
  42651. import { Engine } from "babylonjs/Engines/engine";
  42652. interface IColor4Like {
  42653. r: float;
  42654. g: float;
  42655. b: float;
  42656. a: float;
  42657. }
  42658. /**
  42659. * Class containing a set of static utilities functions
  42660. */
  42661. export class Tools {
  42662. /**
  42663. * Gets or sets the base URL to use to load assets
  42664. */
  42665. static get BaseUrl(): string;
  42666. static set BaseUrl(value: string);
  42667. /**
  42668. * Enable/Disable Custom HTTP Request Headers globally.
  42669. * default = false
  42670. * @see CustomRequestHeaders
  42671. */
  42672. static UseCustomRequestHeaders: boolean;
  42673. /**
  42674. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42675. * i.e. when loading files, where the server/service expects an Authorization header
  42676. */
  42677. static CustomRequestHeaders: {
  42678. [key: string]: string;
  42679. };
  42680. /**
  42681. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42682. */
  42683. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42684. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42685. /**
  42686. * Default behaviour for cors in the application.
  42687. * It can be a string if the expected behavior is identical in the entire app.
  42688. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42689. */
  42690. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42691. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42692. /**
  42693. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42694. * @ignorenaming
  42695. */
  42696. static get UseFallbackTexture(): boolean;
  42697. static set UseFallbackTexture(value: boolean);
  42698. /**
  42699. * Use this object to register external classes like custom textures or material
  42700. * to allow the laoders to instantiate them
  42701. */
  42702. static get RegisteredExternalClasses(): {
  42703. [key: string]: Object;
  42704. };
  42705. static set RegisteredExternalClasses(classes: {
  42706. [key: string]: Object;
  42707. });
  42708. /**
  42709. * Texture content used if a texture cannot loaded
  42710. * @ignorenaming
  42711. */
  42712. static get fallbackTexture(): string;
  42713. static set fallbackTexture(value: string);
  42714. /**
  42715. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42716. * @param u defines the coordinate on X axis
  42717. * @param v defines the coordinate on Y axis
  42718. * @param width defines the width of the source data
  42719. * @param height defines the height of the source data
  42720. * @param pixels defines the source byte array
  42721. * @param color defines the output color
  42722. */
  42723. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42724. /**
  42725. * Interpolates between a and b via alpha
  42726. * @param a The lower value (returned when alpha = 0)
  42727. * @param b The upper value (returned when alpha = 1)
  42728. * @param alpha The interpolation-factor
  42729. * @return The mixed value
  42730. */
  42731. static Mix(a: number, b: number, alpha: number): number;
  42732. /**
  42733. * Tries to instantiate a new object from a given class name
  42734. * @param className defines the class name to instantiate
  42735. * @returns the new object or null if the system was not able to do the instantiation
  42736. */
  42737. static Instantiate(className: string): any;
  42738. /**
  42739. * Provides a slice function that will work even on IE
  42740. * @param data defines the array to slice
  42741. * @param start defines the start of the data (optional)
  42742. * @param end defines the end of the data (optional)
  42743. * @returns the new sliced array
  42744. */
  42745. static Slice<T>(data: T, start?: number, end?: number): T;
  42746. /**
  42747. * Polyfill for setImmediate
  42748. * @param action defines the action to execute after the current execution block
  42749. */
  42750. static SetImmediate(action: () => void): void;
  42751. /**
  42752. * Function indicating if a number is an exponent of 2
  42753. * @param value defines the value to test
  42754. * @returns true if the value is an exponent of 2
  42755. */
  42756. static IsExponentOfTwo(value: number): boolean;
  42757. private static _tmpFloatArray;
  42758. /**
  42759. * Returns the nearest 32-bit single precision float representation of a Number
  42760. * @param value A Number. If the parameter is of a different type, it will get converted
  42761. * to a number or to NaN if it cannot be converted
  42762. * @returns number
  42763. */
  42764. static FloatRound(value: number): number;
  42765. /**
  42766. * Extracts the filename from a path
  42767. * @param path defines the path to use
  42768. * @returns the filename
  42769. */
  42770. static GetFilename(path: string): string;
  42771. /**
  42772. * Extracts the "folder" part of a path (everything before the filename).
  42773. * @param uri The URI to extract the info from
  42774. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42775. * @returns The "folder" part of the path
  42776. */
  42777. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42778. /**
  42779. * Extracts text content from a DOM element hierarchy
  42780. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42781. */
  42782. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42783. /**
  42784. * Convert an angle in radians to degrees
  42785. * @param angle defines the angle to convert
  42786. * @returns the angle in degrees
  42787. */
  42788. static ToDegrees(angle: number): number;
  42789. /**
  42790. * Convert an angle in degrees to radians
  42791. * @param angle defines the angle to convert
  42792. * @returns the angle in radians
  42793. */
  42794. static ToRadians(angle: number): number;
  42795. /**
  42796. * Returns an array if obj is not an array
  42797. * @param obj defines the object to evaluate as an array
  42798. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42799. * @returns either obj directly if obj is an array or a new array containing obj
  42800. */
  42801. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42802. /**
  42803. * Gets the pointer prefix to use
  42804. * @param engine defines the engine we are finding the prefix for
  42805. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42806. */
  42807. static GetPointerPrefix(engine: Engine): string;
  42808. /**
  42809. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42810. * @param url define the url we are trying
  42811. * @param element define the dom element where to configure the cors policy
  42812. */
  42813. static SetCorsBehavior(url: string | string[], element: {
  42814. crossOrigin: string | null;
  42815. }): void;
  42816. /**
  42817. * Removes unwanted characters from an url
  42818. * @param url defines the url to clean
  42819. * @returns the cleaned url
  42820. */
  42821. static CleanUrl(url: string): string;
  42822. /**
  42823. * Gets or sets a function used to pre-process url before using them to load assets
  42824. */
  42825. static get PreprocessUrl(): (url: string) => string;
  42826. static set PreprocessUrl(processor: (url: string) => string);
  42827. /**
  42828. * Loads an image as an HTMLImageElement.
  42829. * @param input url string, ArrayBuffer, or Blob to load
  42830. * @param onLoad callback called when the image successfully loads
  42831. * @param onError callback called when the image fails to load
  42832. * @param offlineProvider offline provider for caching
  42833. * @param mimeType optional mime type
  42834. * @returns the HTMLImageElement of the loaded image
  42835. */
  42836. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42837. /**
  42838. * Loads a file from a url
  42839. * @param url url string, ArrayBuffer, or Blob to load
  42840. * @param onSuccess callback called when the file successfully loads
  42841. * @param onProgress callback called while file is loading (if the server supports this mode)
  42842. * @param offlineProvider defines the offline provider for caching
  42843. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42844. * @param onError callback called when the file fails to load
  42845. * @returns a file request object
  42846. */
  42847. 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;
  42848. /**
  42849. * Loads a file from a url
  42850. * @param url the file url to load
  42851. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42852. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42853. */
  42854. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42855. /**
  42856. * Load a script (identified by an url). When the url returns, the
  42857. * content of this file is added into a new script element, attached to the DOM (body element)
  42858. * @param scriptUrl defines the url of the script to laod
  42859. * @param onSuccess defines the callback called when the script is loaded
  42860. * @param onError defines the callback to call if an error occurs
  42861. * @param scriptId defines the id of the script element
  42862. */
  42863. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42864. /**
  42865. * Load an asynchronous script (identified by an url). When the url returns, the
  42866. * content of this file is added into a new script element, attached to the DOM (body element)
  42867. * @param scriptUrl defines the url of the script to laod
  42868. * @param scriptId defines the id of the script element
  42869. * @returns a promise request object
  42870. */
  42871. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42872. /**
  42873. * Loads a file from a blob
  42874. * @param fileToLoad defines the blob to use
  42875. * @param callback defines the callback to call when data is loaded
  42876. * @param progressCallback defines the callback to call during loading process
  42877. * @returns a file request object
  42878. */
  42879. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42880. /**
  42881. * Reads a file from a File object
  42882. * @param file defines the file to load
  42883. * @param onSuccess defines the callback to call when data is loaded
  42884. * @param onProgress defines the callback to call during loading process
  42885. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42886. * @param onError defines the callback to call when an error occurs
  42887. * @returns a file request object
  42888. */
  42889. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42890. /**
  42891. * Creates a data url from a given string content
  42892. * @param content defines the content to convert
  42893. * @returns the new data url link
  42894. */
  42895. static FileAsURL(content: string): string;
  42896. /**
  42897. * Format the given number to a specific decimal format
  42898. * @param value defines the number to format
  42899. * @param decimals defines the number of decimals to use
  42900. * @returns the formatted string
  42901. */
  42902. static Format(value: number, decimals?: number): string;
  42903. /**
  42904. * Tries to copy an object by duplicating every property
  42905. * @param source defines the source object
  42906. * @param destination defines the target object
  42907. * @param doNotCopyList defines a list of properties to avoid
  42908. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42909. */
  42910. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42911. /**
  42912. * Gets a boolean indicating if the given object has no own property
  42913. * @param obj defines the object to test
  42914. * @returns true if object has no own property
  42915. */
  42916. static IsEmpty(obj: any): boolean;
  42917. /**
  42918. * Function used to register events at window level
  42919. * @param windowElement defines the Window object to use
  42920. * @param events defines the events to register
  42921. */
  42922. static RegisterTopRootEvents(windowElement: Window, events: {
  42923. name: string;
  42924. handler: Nullable<(e: FocusEvent) => any>;
  42925. }[]): void;
  42926. /**
  42927. * Function used to unregister events from window level
  42928. * @param windowElement defines the Window object to use
  42929. * @param events defines the events to unregister
  42930. */
  42931. static UnregisterTopRootEvents(windowElement: Window, events: {
  42932. name: string;
  42933. handler: Nullable<(e: FocusEvent) => any>;
  42934. }[]): void;
  42935. /**
  42936. * @ignore
  42937. */
  42938. static _ScreenshotCanvas: HTMLCanvasElement;
  42939. /**
  42940. * Dumps the current bound framebuffer
  42941. * @param width defines the rendering width
  42942. * @param height defines the rendering height
  42943. * @param engine defines the hosting engine
  42944. * @param successCallback defines the callback triggered once the data are available
  42945. * @param mimeType defines the mime type of the result
  42946. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42947. */
  42948. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42949. /**
  42950. * Converts the canvas data to blob.
  42951. * This acts as a polyfill for browsers not supporting the to blob function.
  42952. * @param canvas Defines the canvas to extract the data from
  42953. * @param successCallback Defines the callback triggered once the data are available
  42954. * @param mimeType Defines the mime type of the result
  42955. */
  42956. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42957. /**
  42958. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42959. * @param successCallback defines the callback triggered once the data are available
  42960. * @param mimeType defines the mime type of the result
  42961. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42962. */
  42963. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42964. /**
  42965. * Downloads a blob in the browser
  42966. * @param blob defines the blob to download
  42967. * @param fileName defines the name of the downloaded file
  42968. */
  42969. static Download(blob: Blob, fileName: string): void;
  42970. /**
  42971. * Captures a screenshot of the current rendering
  42972. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42973. * @param engine defines the rendering engine
  42974. * @param camera defines the source camera
  42975. * @param size This parameter can be set to a single number or to an object with the
  42976. * following (optional) properties: precision, width, height. If a single number is passed,
  42977. * it will be used for both width and height. If an object is passed, the screenshot size
  42978. * will be derived from the parameters. The precision property is a multiplier allowing
  42979. * rendering at a higher or lower resolution
  42980. * @param successCallback defines the callback receives a single parameter which contains the
  42981. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42982. * src parameter of an <img> to display it
  42983. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42984. * Check your browser for supported MIME types
  42985. */
  42986. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42987. /**
  42988. * Captures a screenshot of the current rendering
  42989. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42990. * @param engine defines the rendering engine
  42991. * @param camera defines the source camera
  42992. * @param size This parameter can be set to a single number or to an object with the
  42993. * following (optional) properties: precision, width, height. If a single number is passed,
  42994. * it will be used for both width and height. If an object is passed, the screenshot size
  42995. * will be derived from the parameters. The precision property is a multiplier allowing
  42996. * rendering at a higher or lower resolution
  42997. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42998. * Check your browser for supported MIME types
  42999. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43000. * to the src parameter of an <img> to display it
  43001. */
  43002. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43003. /**
  43004. * Generates an image screenshot from the specified camera.
  43005. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43006. * @param engine The engine to use for rendering
  43007. * @param camera The camera to use for rendering
  43008. * @param size This parameter can be set to a single number or to an object with the
  43009. * following (optional) properties: precision, width, height. If a single number is passed,
  43010. * it will be used for both width and height. If an object is passed, the screenshot size
  43011. * will be derived from the parameters. The precision property is a multiplier allowing
  43012. * rendering at a higher or lower resolution
  43013. * @param successCallback The callback receives a single parameter which contains the
  43014. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43015. * src parameter of an <img> to display it
  43016. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43017. * Check your browser for supported MIME types
  43018. * @param samples Texture samples (default: 1)
  43019. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43020. * @param fileName A name for for the downloaded file.
  43021. */
  43022. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43023. /**
  43024. * Generates an image screenshot from the specified camera.
  43025. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43026. * @param engine The engine to use for rendering
  43027. * @param camera The camera to use for rendering
  43028. * @param size This parameter can be set to a single number or to an object with the
  43029. * following (optional) properties: precision, width, height. If a single number is passed,
  43030. * it will be used for both width and height. If an object is passed, the screenshot size
  43031. * will be derived from the parameters. The precision property is a multiplier allowing
  43032. * rendering at a higher or lower resolution
  43033. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43034. * Check your browser for supported MIME types
  43035. * @param samples Texture samples (default: 1)
  43036. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43037. * @param fileName A name for for the downloaded file.
  43038. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43039. * to the src parameter of an <img> to display it
  43040. */
  43041. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43042. /**
  43043. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43044. * Be aware Math.random() could cause collisions, but:
  43045. * "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"
  43046. * @returns a pseudo random id
  43047. */
  43048. static RandomId(): string;
  43049. /**
  43050. * Test if the given uri is a base64 string
  43051. * @param uri The uri to test
  43052. * @return True if the uri is a base64 string or false otherwise
  43053. */
  43054. static IsBase64(uri: string): boolean;
  43055. /**
  43056. * Decode the given base64 uri.
  43057. * @param uri The uri to decode
  43058. * @return The decoded base64 data.
  43059. */
  43060. static DecodeBase64(uri: string): ArrayBuffer;
  43061. /**
  43062. * Gets the absolute url.
  43063. * @param url the input url
  43064. * @return the absolute url
  43065. */
  43066. static GetAbsoluteUrl(url: string): string;
  43067. /**
  43068. * No log
  43069. */
  43070. static readonly NoneLogLevel: number;
  43071. /**
  43072. * Only message logs
  43073. */
  43074. static readonly MessageLogLevel: number;
  43075. /**
  43076. * Only warning logs
  43077. */
  43078. static readonly WarningLogLevel: number;
  43079. /**
  43080. * Only error logs
  43081. */
  43082. static readonly ErrorLogLevel: number;
  43083. /**
  43084. * All logs
  43085. */
  43086. static readonly AllLogLevel: number;
  43087. /**
  43088. * Gets a value indicating the number of loading errors
  43089. * @ignorenaming
  43090. */
  43091. static get errorsCount(): number;
  43092. /**
  43093. * Callback called when a new log is added
  43094. */
  43095. static OnNewCacheEntry: (entry: string) => void;
  43096. /**
  43097. * Log a message to the console
  43098. * @param message defines the message to log
  43099. */
  43100. static Log(message: string): void;
  43101. /**
  43102. * Write a warning message to the console
  43103. * @param message defines the message to log
  43104. */
  43105. static Warn(message: string): void;
  43106. /**
  43107. * Write an error message to the console
  43108. * @param message defines the message to log
  43109. */
  43110. static Error(message: string): void;
  43111. /**
  43112. * Gets current log cache (list of logs)
  43113. */
  43114. static get LogCache(): string;
  43115. /**
  43116. * Clears the log cache
  43117. */
  43118. static ClearLogCache(): void;
  43119. /**
  43120. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43121. */
  43122. static set LogLevels(level: number);
  43123. /**
  43124. * Checks if the window object exists
  43125. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43126. */
  43127. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43128. /**
  43129. * No performance log
  43130. */
  43131. static readonly PerformanceNoneLogLevel: number;
  43132. /**
  43133. * Use user marks to log performance
  43134. */
  43135. static readonly PerformanceUserMarkLogLevel: number;
  43136. /**
  43137. * Log performance to the console
  43138. */
  43139. static readonly PerformanceConsoleLogLevel: number;
  43140. private static _performance;
  43141. /**
  43142. * Sets the current performance log level
  43143. */
  43144. static set PerformanceLogLevel(level: number);
  43145. private static _StartPerformanceCounterDisabled;
  43146. private static _EndPerformanceCounterDisabled;
  43147. private static _StartUserMark;
  43148. private static _EndUserMark;
  43149. private static _StartPerformanceConsole;
  43150. private static _EndPerformanceConsole;
  43151. /**
  43152. * Starts a performance counter
  43153. */
  43154. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43155. /**
  43156. * Ends a specific performance coutner
  43157. */
  43158. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43159. /**
  43160. * Gets either window.performance.now() if supported or Date.now() else
  43161. */
  43162. static get Now(): number;
  43163. /**
  43164. * This method will return the name of the class used to create the instance of the given object.
  43165. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43166. * @param object the object to get the class name from
  43167. * @param isType defines if the object is actually a type
  43168. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43169. */
  43170. static GetClassName(object: any, isType?: boolean): string;
  43171. /**
  43172. * Gets the first element of an array satisfying a given predicate
  43173. * @param array defines the array to browse
  43174. * @param predicate defines the predicate to use
  43175. * @returns null if not found or the element
  43176. */
  43177. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43178. /**
  43179. * This method will return the name of the full name of the class, including its owning module (if any).
  43180. * 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).
  43181. * @param object the object to get the class name from
  43182. * @param isType defines if the object is actually a type
  43183. * @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.
  43184. * @ignorenaming
  43185. */
  43186. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43187. /**
  43188. * Returns a promise that resolves after the given amount of time.
  43189. * @param delay Number of milliseconds to delay
  43190. * @returns Promise that resolves after the given amount of time
  43191. */
  43192. static DelayAsync(delay: number): Promise<void>;
  43193. /**
  43194. * Utility function to detect if the current user agent is Safari
  43195. * @returns whether or not the current user agent is safari
  43196. */
  43197. static IsSafari(): boolean;
  43198. }
  43199. /**
  43200. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43201. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43202. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43203. * @param name The name of the class, case should be preserved
  43204. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43205. */
  43206. export function className(name: string, module?: string): (target: Object) => void;
  43207. /**
  43208. * An implementation of a loop for asynchronous functions.
  43209. */
  43210. export class AsyncLoop {
  43211. /**
  43212. * Defines the number of iterations for the loop
  43213. */
  43214. iterations: number;
  43215. /**
  43216. * Defines the current index of the loop.
  43217. */
  43218. index: number;
  43219. private _done;
  43220. private _fn;
  43221. private _successCallback;
  43222. /**
  43223. * Constructor.
  43224. * @param iterations the number of iterations.
  43225. * @param func the function to run each iteration
  43226. * @param successCallback the callback that will be called upon succesful execution
  43227. * @param offset starting offset.
  43228. */
  43229. constructor(
  43230. /**
  43231. * Defines the number of iterations for the loop
  43232. */
  43233. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43234. /**
  43235. * Execute the next iteration. Must be called after the last iteration was finished.
  43236. */
  43237. executeNext(): void;
  43238. /**
  43239. * Break the loop and run the success callback.
  43240. */
  43241. breakLoop(): void;
  43242. /**
  43243. * Create and run an async loop.
  43244. * @param iterations the number of iterations.
  43245. * @param fn the function to run each iteration
  43246. * @param successCallback the callback that will be called upon succesful execution
  43247. * @param offset starting offset.
  43248. * @returns the created async loop object
  43249. */
  43250. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43251. /**
  43252. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43253. * @param iterations total number of iterations
  43254. * @param syncedIterations number of synchronous iterations in each async iteration.
  43255. * @param fn the function to call each iteration.
  43256. * @param callback a success call back that will be called when iterating stops.
  43257. * @param breakFunction a break condition (optional)
  43258. * @param timeout timeout settings for the setTimeout function. default - 0.
  43259. * @returns the created async loop object
  43260. */
  43261. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43262. }
  43263. }
  43264. declare module "babylonjs/Misc/stringDictionary" {
  43265. import { Nullable } from "babylonjs/types";
  43266. /**
  43267. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43268. * The underlying implementation relies on an associative array to ensure the best performances.
  43269. * The value can be anything including 'null' but except 'undefined'
  43270. */
  43271. export class StringDictionary<T> {
  43272. /**
  43273. * This will clear this dictionary and copy the content from the 'source' one.
  43274. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43275. * @param source the dictionary to take the content from and copy to this dictionary
  43276. */
  43277. copyFrom(source: StringDictionary<T>): void;
  43278. /**
  43279. * Get a value based from its key
  43280. * @param key the given key to get the matching value from
  43281. * @return the value if found, otherwise undefined is returned
  43282. */
  43283. get(key: string): T | undefined;
  43284. /**
  43285. * Get a value from its key or add it if it doesn't exist.
  43286. * This method will ensure you that a given key/data will be present in the dictionary.
  43287. * @param key the given key to get the matching value from
  43288. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43289. * The factory will only be invoked if there's no data for the given key.
  43290. * @return the value corresponding to the key.
  43291. */
  43292. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43293. /**
  43294. * Get a value from its key if present in the dictionary otherwise add it
  43295. * @param key the key to get the value from
  43296. * @param val if there's no such key/value pair in the dictionary add it with this value
  43297. * @return the value corresponding to the key
  43298. */
  43299. getOrAdd(key: string, val: T): T;
  43300. /**
  43301. * Check if there's a given key in the dictionary
  43302. * @param key the key to check for
  43303. * @return true if the key is present, false otherwise
  43304. */
  43305. contains(key: string): boolean;
  43306. /**
  43307. * Add a new key and its corresponding value
  43308. * @param key the key to add
  43309. * @param value the value corresponding to the key
  43310. * @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
  43311. */
  43312. add(key: string, value: T): boolean;
  43313. /**
  43314. * Update a specific value associated to a key
  43315. * @param key defines the key to use
  43316. * @param value defines the value to store
  43317. * @returns true if the value was updated (or false if the key was not found)
  43318. */
  43319. set(key: string, value: T): boolean;
  43320. /**
  43321. * Get the element of the given key and remove it from the dictionary
  43322. * @param key defines the key to search
  43323. * @returns the value associated with the key or null if not found
  43324. */
  43325. getAndRemove(key: string): Nullable<T>;
  43326. /**
  43327. * Remove a key/value from the dictionary.
  43328. * @param key the key to remove
  43329. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43330. */
  43331. remove(key: string): boolean;
  43332. /**
  43333. * Clear the whole content of the dictionary
  43334. */
  43335. clear(): void;
  43336. /**
  43337. * Gets the current count
  43338. */
  43339. get count(): number;
  43340. /**
  43341. * Execute a callback on each key/val of the dictionary.
  43342. * Note that you can remove any element in this dictionary in the callback implementation
  43343. * @param callback the callback to execute on a given key/value pair
  43344. */
  43345. forEach(callback: (key: string, val: T) => void): void;
  43346. /**
  43347. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43348. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43349. * Note that you can remove any element in this dictionary in the callback implementation
  43350. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43351. * @returns the first item
  43352. */
  43353. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43354. private _count;
  43355. private _data;
  43356. }
  43357. }
  43358. declare module "babylonjs/Collisions/collisionCoordinator" {
  43359. import { Nullable } from "babylonjs/types";
  43360. import { Scene } from "babylonjs/scene";
  43361. import { Vector3 } from "babylonjs/Maths/math.vector";
  43362. import { Collider } from "babylonjs/Collisions/collider";
  43363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43364. /** @hidden */
  43365. export interface ICollisionCoordinator {
  43366. createCollider(): Collider;
  43367. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43368. init(scene: Scene): void;
  43369. }
  43370. /** @hidden */
  43371. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43372. private _scene;
  43373. private _scaledPosition;
  43374. private _scaledVelocity;
  43375. private _finalPosition;
  43376. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43377. createCollider(): Collider;
  43378. init(scene: Scene): void;
  43379. private _collideWithWorld;
  43380. }
  43381. }
  43382. declare module "babylonjs/Inputs/scene.inputManager" {
  43383. import { Nullable } from "babylonjs/types";
  43384. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43385. import { Vector2 } from "babylonjs/Maths/math.vector";
  43386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43387. import { Scene } from "babylonjs/scene";
  43388. /**
  43389. * Class used to manage all inputs for the scene.
  43390. */
  43391. export class InputManager {
  43392. /** The distance in pixel that you have to move to prevent some events */
  43393. static DragMovementThreshold: number;
  43394. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43395. static LongPressDelay: number;
  43396. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43397. static DoubleClickDelay: number;
  43398. /** If you need to check double click without raising a single click at first click, enable this flag */
  43399. static ExclusiveDoubleClickMode: boolean;
  43400. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  43401. private _alreadyAttached;
  43402. private _wheelEventName;
  43403. private _onPointerMove;
  43404. private _onPointerDown;
  43405. private _onPointerUp;
  43406. private _initClickEvent;
  43407. private _initActionManager;
  43408. private _delayedSimpleClick;
  43409. private _delayedSimpleClickTimeout;
  43410. private _previousDelayedSimpleClickTimeout;
  43411. private _meshPickProceed;
  43412. private _previousButtonPressed;
  43413. private _currentPickResult;
  43414. private _previousPickResult;
  43415. private _totalPointersPressed;
  43416. private _doubleClickOccured;
  43417. private _pointerOverMesh;
  43418. private _pickedDownMesh;
  43419. private _pickedUpMesh;
  43420. private _pointerX;
  43421. private _pointerY;
  43422. private _unTranslatedPointerX;
  43423. private _unTranslatedPointerY;
  43424. private _startingPointerPosition;
  43425. private _previousStartingPointerPosition;
  43426. private _startingPointerTime;
  43427. private _previousStartingPointerTime;
  43428. private _pointerCaptures;
  43429. private _meshUnderPointerId;
  43430. private _onKeyDown;
  43431. private _onKeyUp;
  43432. private _onCanvasFocusObserver;
  43433. private _onCanvasBlurObserver;
  43434. private _scene;
  43435. /**
  43436. * Creates a new InputManager
  43437. * @param scene defines the hosting scene
  43438. */
  43439. constructor(scene: Scene);
  43440. /**
  43441. * Gets the mesh that is currently under the pointer
  43442. */
  43443. get meshUnderPointer(): Nullable<AbstractMesh>;
  43444. /**
  43445. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43446. * @param pointerId the pointer id to use
  43447. * @returns The mesh under this pointer id or null if not found
  43448. */
  43449. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43450. /**
  43451. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43452. */
  43453. get unTranslatedPointer(): Vector2;
  43454. /**
  43455. * Gets or sets the current on-screen X position of the pointer
  43456. */
  43457. get pointerX(): number;
  43458. set pointerX(value: number);
  43459. /**
  43460. * Gets or sets the current on-screen Y position of the pointer
  43461. */
  43462. get pointerY(): number;
  43463. set pointerY(value: number);
  43464. private _updatePointerPosition;
  43465. private _processPointerMove;
  43466. private _setRayOnPointerInfo;
  43467. private _checkPrePointerObservable;
  43468. /**
  43469. * Use this method to simulate a pointer move on a mesh
  43470. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43471. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43472. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43473. */
  43474. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43475. /**
  43476. * Use this method to simulate a pointer down on a mesh
  43477. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43478. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43479. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43480. */
  43481. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43482. private _processPointerDown;
  43483. /** @hidden */
  43484. _isPointerSwiping(): boolean;
  43485. /**
  43486. * Use this method to simulate a pointer up on a mesh
  43487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43490. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43491. */
  43492. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43493. private _processPointerUp;
  43494. /**
  43495. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43496. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43497. * @returns true if the pointer was captured
  43498. */
  43499. isPointerCaptured(pointerId?: number): boolean;
  43500. /**
  43501. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43502. * @param attachUp defines if you want to attach events to pointerup
  43503. * @param attachDown defines if you want to attach events to pointerdown
  43504. * @param attachMove defines if you want to attach events to pointermove
  43505. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43506. */
  43507. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43508. /**
  43509. * Detaches all event handlers
  43510. */
  43511. detachControl(): void;
  43512. /**
  43513. * Force the value of meshUnderPointer
  43514. * @param mesh defines the mesh to use
  43515. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43516. */
  43517. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43518. /**
  43519. * Gets the mesh under the pointer
  43520. * @returns a Mesh or null if no mesh is under the pointer
  43521. */
  43522. getPointerOverMesh(): Nullable<AbstractMesh>;
  43523. }
  43524. }
  43525. declare module "babylonjs/Animations/animationGroup" {
  43526. import { Animatable } from "babylonjs/Animations/animatable";
  43527. import { Animation } from "babylonjs/Animations/animation";
  43528. import { Scene, IDisposable } from "babylonjs/scene";
  43529. import { Observable } from "babylonjs/Misc/observable";
  43530. import { Nullable } from "babylonjs/types";
  43531. import "babylonjs/Animations/animatable";
  43532. /**
  43533. * This class defines the direct association between an animation and a target
  43534. */
  43535. export class TargetedAnimation {
  43536. /**
  43537. * Animation to perform
  43538. */
  43539. animation: Animation;
  43540. /**
  43541. * Target to animate
  43542. */
  43543. target: any;
  43544. /**
  43545. * Returns the string "TargetedAnimation"
  43546. * @returns "TargetedAnimation"
  43547. */
  43548. getClassName(): string;
  43549. /**
  43550. * Serialize the object
  43551. * @returns the JSON object representing the current entity
  43552. */
  43553. serialize(): any;
  43554. }
  43555. /**
  43556. * Use this class to create coordinated animations on multiple targets
  43557. */
  43558. export class AnimationGroup implements IDisposable {
  43559. /** The name of the animation group */
  43560. name: string;
  43561. private _scene;
  43562. private _targetedAnimations;
  43563. private _animatables;
  43564. private _from;
  43565. private _to;
  43566. private _isStarted;
  43567. private _isPaused;
  43568. private _speedRatio;
  43569. private _loopAnimation;
  43570. private _isAdditive;
  43571. /**
  43572. * Gets or sets the unique id of the node
  43573. */
  43574. uniqueId: number;
  43575. /**
  43576. * This observable will notify when one animation have ended
  43577. */
  43578. onAnimationEndObservable: Observable<TargetedAnimation>;
  43579. /**
  43580. * Observer raised when one animation loops
  43581. */
  43582. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43583. /**
  43584. * Observer raised when all animations have looped
  43585. */
  43586. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43587. /**
  43588. * This observable will notify when all animations have ended.
  43589. */
  43590. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43591. /**
  43592. * This observable will notify when all animations have paused.
  43593. */
  43594. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43595. /**
  43596. * This observable will notify when all animations are playing.
  43597. */
  43598. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43599. /**
  43600. * Gets the first frame
  43601. */
  43602. get from(): number;
  43603. /**
  43604. * Gets the last frame
  43605. */
  43606. get to(): number;
  43607. /**
  43608. * Define if the animations are started
  43609. */
  43610. get isStarted(): boolean;
  43611. /**
  43612. * Gets a value indicating that the current group is playing
  43613. */
  43614. get isPlaying(): boolean;
  43615. /**
  43616. * Gets or sets the speed ratio to use for all animations
  43617. */
  43618. get speedRatio(): number;
  43619. /**
  43620. * Gets or sets the speed ratio to use for all animations
  43621. */
  43622. set speedRatio(value: number);
  43623. /**
  43624. * Gets or sets if all animations should loop or not
  43625. */
  43626. get loopAnimation(): boolean;
  43627. set loopAnimation(value: boolean);
  43628. /**
  43629. * Gets or sets if all animations should be evaluated additively
  43630. */
  43631. get isAdditive(): boolean;
  43632. set isAdditive(value: boolean);
  43633. /**
  43634. * Gets the targeted animations for this animation group
  43635. */
  43636. get targetedAnimations(): Array<TargetedAnimation>;
  43637. /**
  43638. * returning the list of animatables controlled by this animation group.
  43639. */
  43640. get animatables(): Array<Animatable>;
  43641. /**
  43642. * Gets the list of target animations
  43643. */
  43644. get children(): TargetedAnimation[];
  43645. /**
  43646. * Instantiates a new Animation Group.
  43647. * This helps managing several animations at once.
  43648. * @see https://doc.babylonjs.com/how_to/group
  43649. * @param name Defines the name of the group
  43650. * @param scene Defines the scene the group belongs to
  43651. */
  43652. constructor(
  43653. /** The name of the animation group */
  43654. name: string, scene?: Nullable<Scene>);
  43655. /**
  43656. * Add an animation (with its target) in the group
  43657. * @param animation defines the animation we want to add
  43658. * @param target defines the target of the animation
  43659. * @returns the TargetedAnimation object
  43660. */
  43661. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43662. /**
  43663. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43664. * It can add constant keys at begin or end
  43665. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43666. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43667. * @returns the animation group
  43668. */
  43669. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43670. private _animationLoopCount;
  43671. private _animationLoopFlags;
  43672. private _processLoop;
  43673. /**
  43674. * Start all animations on given targets
  43675. * @param loop defines if animations must loop
  43676. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43677. * @param from defines the from key (optional)
  43678. * @param to defines the to key (optional)
  43679. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43680. * @returns the current animation group
  43681. */
  43682. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43683. /**
  43684. * Pause all animations
  43685. * @returns the animation group
  43686. */
  43687. pause(): AnimationGroup;
  43688. /**
  43689. * Play all animations to initial state
  43690. * This function will start() the animations if they were not started or will restart() them if they were paused
  43691. * @param loop defines if animations must loop
  43692. * @returns the animation group
  43693. */
  43694. play(loop?: boolean): AnimationGroup;
  43695. /**
  43696. * Reset all animations to initial state
  43697. * @returns the animation group
  43698. */
  43699. reset(): AnimationGroup;
  43700. /**
  43701. * Restart animations from key 0
  43702. * @returns the animation group
  43703. */
  43704. restart(): AnimationGroup;
  43705. /**
  43706. * Stop all animations
  43707. * @returns the animation group
  43708. */
  43709. stop(): AnimationGroup;
  43710. /**
  43711. * Set animation weight for all animatables
  43712. * @param weight defines the weight to use
  43713. * @return the animationGroup
  43714. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43715. */
  43716. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43717. /**
  43718. * Synchronize and normalize all animatables with a source animatable
  43719. * @param root defines the root animatable to synchronize with
  43720. * @return the animationGroup
  43721. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43722. */
  43723. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43724. /**
  43725. * Goes to a specific frame in this animation group
  43726. * @param frame the frame number to go to
  43727. * @return the animationGroup
  43728. */
  43729. goToFrame(frame: number): AnimationGroup;
  43730. /**
  43731. * Dispose all associated resources
  43732. */
  43733. dispose(): void;
  43734. private _checkAnimationGroupEnded;
  43735. /**
  43736. * Clone the current animation group and returns a copy
  43737. * @param newName defines the name of the new group
  43738. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43739. * @returns the new aniamtion group
  43740. */
  43741. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43742. /**
  43743. * Serializes the animationGroup to an object
  43744. * @returns Serialized object
  43745. */
  43746. serialize(): any;
  43747. /**
  43748. * Returns a new AnimationGroup object parsed from the source provided.
  43749. * @param parsedAnimationGroup defines the source
  43750. * @param scene defines the scene that will receive the animationGroup
  43751. * @returns a new AnimationGroup
  43752. */
  43753. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43754. /**
  43755. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43756. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43757. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43758. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43759. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43760. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43761. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43762. */
  43763. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43764. /**
  43765. * Returns the string "AnimationGroup"
  43766. * @returns "AnimationGroup"
  43767. */
  43768. getClassName(): string;
  43769. /**
  43770. * Creates a detailled string about the object
  43771. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43772. * @returns a string representing the object
  43773. */
  43774. toString(fullDetails?: boolean): string;
  43775. }
  43776. }
  43777. declare module "babylonjs/scene" {
  43778. import { Nullable } from "babylonjs/types";
  43779. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43780. import { Observable } from "babylonjs/Misc/observable";
  43781. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43782. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43783. import { Geometry } from "babylonjs/Meshes/geometry";
  43784. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43785. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43787. import { Mesh } from "babylonjs/Meshes/mesh";
  43788. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43789. import { Bone } from "babylonjs/Bones/bone";
  43790. import { Skeleton } from "babylonjs/Bones/skeleton";
  43791. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43792. import { Camera } from "babylonjs/Cameras/camera";
  43793. import { AbstractScene } from "babylonjs/abstractScene";
  43794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43795. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43796. import { Material } from "babylonjs/Materials/material";
  43797. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43798. import { Effect } from "babylonjs/Materials/effect";
  43799. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43800. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43801. import { Light } from "babylonjs/Lights/light";
  43802. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43803. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43804. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43805. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43806. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43807. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43808. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43809. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43810. import { Engine } from "babylonjs/Engines/engine";
  43811. import { Node } from "babylonjs/node";
  43812. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43813. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43814. import { WebRequest } from "babylonjs/Misc/webRequest";
  43815. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43816. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43817. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43818. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43819. import { Plane } from "babylonjs/Maths/math.plane";
  43820. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43821. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43822. import { Ray } from "babylonjs/Culling/ray";
  43823. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43824. import { Animation } from "babylonjs/Animations/animation";
  43825. import { Animatable } from "babylonjs/Animations/animatable";
  43826. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43827. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43828. import { Collider } from "babylonjs/Collisions/collider";
  43829. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43830. /**
  43831. * Define an interface for all classes that will hold resources
  43832. */
  43833. export interface IDisposable {
  43834. /**
  43835. * Releases all held resources
  43836. */
  43837. dispose(): void;
  43838. }
  43839. /** Interface defining initialization parameters for Scene class */
  43840. export interface SceneOptions {
  43841. /**
  43842. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43843. * It will improve performance when the number of geometries becomes important.
  43844. */
  43845. useGeometryUniqueIdsMap?: boolean;
  43846. /**
  43847. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43848. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43849. */
  43850. useMaterialMeshMap?: boolean;
  43851. /**
  43852. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43853. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43854. */
  43855. useClonedMeshMap?: boolean;
  43856. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43857. virtual?: boolean;
  43858. }
  43859. /**
  43860. * Represents a scene to be rendered by the engine.
  43861. * @see https://doc.babylonjs.com/features/scene
  43862. */
  43863. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43864. /** The fog is deactivated */
  43865. static readonly FOGMODE_NONE: number;
  43866. /** The fog density is following an exponential function */
  43867. static readonly FOGMODE_EXP: number;
  43868. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43869. static readonly FOGMODE_EXP2: number;
  43870. /** The fog density is following a linear function. */
  43871. static readonly FOGMODE_LINEAR: number;
  43872. /**
  43873. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43874. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43875. */
  43876. static MinDeltaTime: number;
  43877. /**
  43878. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43879. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43880. */
  43881. static MaxDeltaTime: number;
  43882. /**
  43883. * Factory used to create the default material.
  43884. * @param name The name of the material to create
  43885. * @param scene The scene to create the material for
  43886. * @returns The default material
  43887. */
  43888. static DefaultMaterialFactory(scene: Scene): Material;
  43889. /**
  43890. * Factory used to create the a collision coordinator.
  43891. * @returns The collision coordinator
  43892. */
  43893. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43894. /** @hidden */
  43895. _inputManager: InputManager;
  43896. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  43897. cameraToUseForPointers: Nullable<Camera>;
  43898. /** @hidden */
  43899. readonly _isScene: boolean;
  43900. /** @hidden */
  43901. _blockEntityCollection: boolean;
  43902. /**
  43903. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  43904. */
  43905. autoClear: boolean;
  43906. /**
  43907. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  43908. */
  43909. autoClearDepthAndStencil: boolean;
  43910. /**
  43911. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  43912. */
  43913. clearColor: Color4;
  43914. /**
  43915. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  43916. */
  43917. ambientColor: Color3;
  43918. /**
  43919. * This is use to store the default BRDF lookup for PBR materials in your scene.
  43920. * It should only be one of the following (if not the default embedded one):
  43921. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  43922. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  43923. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  43924. * The material properties need to be setup according to the type of texture in use.
  43925. */
  43926. environmentBRDFTexture: BaseTexture;
  43927. /**
  43928. * Texture used in all pbr material as the reflection texture.
  43929. * As in the majority of the scene they are the same (exception for multi room and so on),
  43930. * this is easier to reference from here than from all the materials.
  43931. */
  43932. get environmentTexture(): Nullable<BaseTexture>;
  43933. /**
  43934. * Texture used in all pbr material as the reflection texture.
  43935. * As in the majority of the scene they are the same (exception for multi room and so on),
  43936. * this is easier to set here than in all the materials.
  43937. */
  43938. set environmentTexture(value: Nullable<BaseTexture>);
  43939. /** @hidden */
  43940. protected _environmentIntensity: number;
  43941. /**
  43942. * Intensity of the environment in all pbr material.
  43943. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  43944. * As in the majority of the scene they are the same (exception for multi room and so on),
  43945. * this is easier to reference from here than from all the materials.
  43946. */
  43947. get environmentIntensity(): number;
  43948. /**
  43949. * Intensity of the environment in all pbr material.
  43950. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  43951. * As in the majority of the scene they are the same (exception for multi room and so on),
  43952. * this is easier to set here than in all the materials.
  43953. */
  43954. set environmentIntensity(value: number);
  43955. /** @hidden */
  43956. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43957. /**
  43958. * Default image processing configuration used either in the rendering
  43959. * Forward main pass or through the imageProcessingPostProcess if present.
  43960. * As in the majority of the scene they are the same (exception for multi camera),
  43961. * this is easier to reference from here than from all the materials and post process.
  43962. *
  43963. * No setter as we it is a shared configuration, you can set the values instead.
  43964. */
  43965. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43966. private _forceWireframe;
  43967. /**
  43968. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  43969. */
  43970. set forceWireframe(value: boolean);
  43971. get forceWireframe(): boolean;
  43972. private _skipFrustumClipping;
  43973. /**
  43974. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  43975. */
  43976. set skipFrustumClipping(value: boolean);
  43977. get skipFrustumClipping(): boolean;
  43978. private _forcePointsCloud;
  43979. /**
  43980. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  43981. */
  43982. set forcePointsCloud(value: boolean);
  43983. get forcePointsCloud(): boolean;
  43984. /**
  43985. * Gets or sets the active clipplane 1
  43986. */
  43987. clipPlane: Nullable<Plane>;
  43988. /**
  43989. * Gets or sets the active clipplane 2
  43990. */
  43991. clipPlane2: Nullable<Plane>;
  43992. /**
  43993. * Gets or sets the active clipplane 3
  43994. */
  43995. clipPlane3: Nullable<Plane>;
  43996. /**
  43997. * Gets or sets the active clipplane 4
  43998. */
  43999. clipPlane4: Nullable<Plane>;
  44000. /**
  44001. * Gets or sets the active clipplane 5
  44002. */
  44003. clipPlane5: Nullable<Plane>;
  44004. /**
  44005. * Gets or sets the active clipplane 6
  44006. */
  44007. clipPlane6: Nullable<Plane>;
  44008. /**
  44009. * Gets or sets a boolean indicating if animations are enabled
  44010. */
  44011. animationsEnabled: boolean;
  44012. private _animationPropertiesOverride;
  44013. /**
  44014. * Gets or sets the animation properties override
  44015. */
  44016. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44017. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44018. /**
  44019. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44020. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44021. */
  44022. useConstantAnimationDeltaTime: boolean;
  44023. /**
  44024. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44025. * Please note that it requires to run a ray cast through the scene on every frame
  44026. */
  44027. constantlyUpdateMeshUnderPointer: boolean;
  44028. /**
  44029. * Defines the HTML cursor to use when hovering over interactive elements
  44030. */
  44031. hoverCursor: string;
  44032. /**
  44033. * Defines the HTML default cursor to use (empty by default)
  44034. */
  44035. defaultCursor: string;
  44036. /**
  44037. * Defines whether cursors are handled by the scene.
  44038. */
  44039. doNotHandleCursors: boolean;
  44040. /**
  44041. * This is used to call preventDefault() on pointer down
  44042. * in order to block unwanted artifacts like system double clicks
  44043. */
  44044. preventDefaultOnPointerDown: boolean;
  44045. /**
  44046. * This is used to call preventDefault() on pointer up
  44047. * in order to block unwanted artifacts like system double clicks
  44048. */
  44049. preventDefaultOnPointerUp: boolean;
  44050. /**
  44051. * Gets or sets user defined metadata
  44052. */
  44053. metadata: any;
  44054. /**
  44055. * For internal use only. Please do not use.
  44056. */
  44057. reservedDataStore: any;
  44058. /**
  44059. * Gets the name of the plugin used to load this scene (null by default)
  44060. */
  44061. loadingPluginName: string;
  44062. /**
  44063. * Use this array to add regular expressions used to disable offline support for specific urls
  44064. */
  44065. disableOfflineSupportExceptionRules: RegExp[];
  44066. /**
  44067. * An event triggered when the scene is disposed.
  44068. */
  44069. onDisposeObservable: Observable<Scene>;
  44070. private _onDisposeObserver;
  44071. /** Sets a function to be executed when this scene is disposed. */
  44072. set onDispose(callback: () => void);
  44073. /**
  44074. * An event triggered before rendering the scene (right after animations and physics)
  44075. */
  44076. onBeforeRenderObservable: Observable<Scene>;
  44077. private _onBeforeRenderObserver;
  44078. /** Sets a function to be executed before rendering this scene */
  44079. set beforeRender(callback: Nullable<() => void>);
  44080. /**
  44081. * An event triggered after rendering the scene
  44082. */
  44083. onAfterRenderObservable: Observable<Scene>;
  44084. /**
  44085. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44086. */
  44087. onAfterRenderCameraObservable: Observable<Camera>;
  44088. private _onAfterRenderObserver;
  44089. /** Sets a function to be executed after rendering this scene */
  44090. set afterRender(callback: Nullable<() => void>);
  44091. /**
  44092. * An event triggered before animating the scene
  44093. */
  44094. onBeforeAnimationsObservable: Observable<Scene>;
  44095. /**
  44096. * An event triggered after animations processing
  44097. */
  44098. onAfterAnimationsObservable: Observable<Scene>;
  44099. /**
  44100. * An event triggered before draw calls are ready to be sent
  44101. */
  44102. onBeforeDrawPhaseObservable: Observable<Scene>;
  44103. /**
  44104. * An event triggered after draw calls have been sent
  44105. */
  44106. onAfterDrawPhaseObservable: Observable<Scene>;
  44107. /**
  44108. * An event triggered when the scene is ready
  44109. */
  44110. onReadyObservable: Observable<Scene>;
  44111. /**
  44112. * An event triggered before rendering a camera
  44113. */
  44114. onBeforeCameraRenderObservable: Observable<Camera>;
  44115. private _onBeforeCameraRenderObserver;
  44116. /** Sets a function to be executed before rendering a camera*/
  44117. set beforeCameraRender(callback: () => void);
  44118. /**
  44119. * An event triggered after rendering a camera
  44120. */
  44121. onAfterCameraRenderObservable: Observable<Camera>;
  44122. private _onAfterCameraRenderObserver;
  44123. /** Sets a function to be executed after rendering a camera*/
  44124. set afterCameraRender(callback: () => void);
  44125. /**
  44126. * An event triggered when active meshes evaluation is about to start
  44127. */
  44128. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44129. /**
  44130. * An event triggered when active meshes evaluation is done
  44131. */
  44132. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44133. /**
  44134. * An event triggered when particles rendering is about to start
  44135. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44136. */
  44137. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44138. /**
  44139. * An event triggered when particles rendering is done
  44140. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44141. */
  44142. onAfterParticlesRenderingObservable: Observable<Scene>;
  44143. /**
  44144. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44145. */
  44146. onDataLoadedObservable: Observable<Scene>;
  44147. /**
  44148. * An event triggered when a camera is created
  44149. */
  44150. onNewCameraAddedObservable: Observable<Camera>;
  44151. /**
  44152. * An event triggered when a camera is removed
  44153. */
  44154. onCameraRemovedObservable: Observable<Camera>;
  44155. /**
  44156. * An event triggered when a light is created
  44157. */
  44158. onNewLightAddedObservable: Observable<Light>;
  44159. /**
  44160. * An event triggered when a light is removed
  44161. */
  44162. onLightRemovedObservable: Observable<Light>;
  44163. /**
  44164. * An event triggered when a geometry is created
  44165. */
  44166. onNewGeometryAddedObservable: Observable<Geometry>;
  44167. /**
  44168. * An event triggered when a geometry is removed
  44169. */
  44170. onGeometryRemovedObservable: Observable<Geometry>;
  44171. /**
  44172. * An event triggered when a transform node is created
  44173. */
  44174. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44175. /**
  44176. * An event triggered when a transform node is removed
  44177. */
  44178. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44179. /**
  44180. * An event triggered when a mesh is created
  44181. */
  44182. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44183. /**
  44184. * An event triggered when a mesh is removed
  44185. */
  44186. onMeshRemovedObservable: Observable<AbstractMesh>;
  44187. /**
  44188. * An event triggered when a skeleton is created
  44189. */
  44190. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44191. /**
  44192. * An event triggered when a skeleton is removed
  44193. */
  44194. onSkeletonRemovedObservable: Observable<Skeleton>;
  44195. /**
  44196. * An event triggered when a material is created
  44197. */
  44198. onNewMaterialAddedObservable: Observable<Material>;
  44199. /**
  44200. * An event triggered when a material is removed
  44201. */
  44202. onMaterialRemovedObservable: Observable<Material>;
  44203. /**
  44204. * An event triggered when a texture is created
  44205. */
  44206. onNewTextureAddedObservable: Observable<BaseTexture>;
  44207. /**
  44208. * An event triggered when a texture is removed
  44209. */
  44210. onTextureRemovedObservable: Observable<BaseTexture>;
  44211. /**
  44212. * An event triggered when render targets are about to be rendered
  44213. * Can happen multiple times per frame.
  44214. */
  44215. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44216. /**
  44217. * An event triggered when render targets were rendered.
  44218. * Can happen multiple times per frame.
  44219. */
  44220. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44221. /**
  44222. * An event triggered before calculating deterministic simulation step
  44223. */
  44224. onBeforeStepObservable: Observable<Scene>;
  44225. /**
  44226. * An event triggered after calculating deterministic simulation step
  44227. */
  44228. onAfterStepObservable: Observable<Scene>;
  44229. /**
  44230. * An event triggered when the activeCamera property is updated
  44231. */
  44232. onActiveCameraChanged: Observable<Scene>;
  44233. /**
  44234. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44235. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44236. * 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)
  44237. */
  44238. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44239. /**
  44240. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44241. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44242. * 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)
  44243. */
  44244. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44245. /**
  44246. * This Observable will when a mesh has been imported into the scene.
  44247. */
  44248. onMeshImportedObservable: Observable<AbstractMesh>;
  44249. /**
  44250. * This Observable will when an animation file has been imported into the scene.
  44251. */
  44252. onAnimationFileImportedObservable: Observable<Scene>;
  44253. /**
  44254. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44255. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44256. */
  44257. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44258. /** @hidden */
  44259. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44260. /**
  44261. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44262. */
  44263. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44264. /**
  44265. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44266. */
  44267. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44268. /**
  44269. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44270. */
  44271. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44272. /** Callback called when a pointer move is detected */
  44273. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44274. /** Callback called when a pointer down is detected */
  44275. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44276. /** Callback called when a pointer up is detected */
  44277. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44278. /** Callback called when a pointer pick is detected */
  44279. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44280. /**
  44281. * 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).
  44282. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44283. */
  44284. onPrePointerObservable: Observable<PointerInfoPre>;
  44285. /**
  44286. * Observable event triggered each time an input event is received from the rendering canvas
  44287. */
  44288. onPointerObservable: Observable<PointerInfo>;
  44289. /**
  44290. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44291. */
  44292. get unTranslatedPointer(): Vector2;
  44293. /**
  44294. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44295. */
  44296. static get DragMovementThreshold(): number;
  44297. static set DragMovementThreshold(value: number);
  44298. /**
  44299. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44300. */
  44301. static get LongPressDelay(): number;
  44302. static set LongPressDelay(value: number);
  44303. /**
  44304. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44305. */
  44306. static get DoubleClickDelay(): number;
  44307. static set DoubleClickDelay(value: number);
  44308. /** If you need to check double click without raising a single click at first click, enable this flag */
  44309. static get ExclusiveDoubleClickMode(): boolean;
  44310. static set ExclusiveDoubleClickMode(value: boolean);
  44311. /** @hidden */
  44312. _mirroredCameraPosition: Nullable<Vector3>;
  44313. /**
  44314. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44315. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44316. */
  44317. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44318. /**
  44319. * Observable event triggered each time an keyboard event is received from the hosting window
  44320. */
  44321. onKeyboardObservable: Observable<KeyboardInfo>;
  44322. private _useRightHandedSystem;
  44323. /**
  44324. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44325. */
  44326. set useRightHandedSystem(value: boolean);
  44327. get useRightHandedSystem(): boolean;
  44328. private _timeAccumulator;
  44329. private _currentStepId;
  44330. private _currentInternalStep;
  44331. /**
  44332. * Sets the step Id used by deterministic lock step
  44333. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44334. * @param newStepId defines the step Id
  44335. */
  44336. setStepId(newStepId: number): void;
  44337. /**
  44338. * Gets the step Id used by deterministic lock step
  44339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44340. * @returns the step Id
  44341. */
  44342. getStepId(): number;
  44343. /**
  44344. * Gets the internal step used by deterministic lock step
  44345. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44346. * @returns the internal step
  44347. */
  44348. getInternalStep(): number;
  44349. private _fogEnabled;
  44350. /**
  44351. * Gets or sets a boolean indicating if fog is enabled on this scene
  44352. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44353. * (Default is true)
  44354. */
  44355. set fogEnabled(value: boolean);
  44356. get fogEnabled(): boolean;
  44357. private _fogMode;
  44358. /**
  44359. * Gets or sets the fog mode to use
  44360. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44361. * | mode | value |
  44362. * | --- | --- |
  44363. * | FOGMODE_NONE | 0 |
  44364. * | FOGMODE_EXP | 1 |
  44365. * | FOGMODE_EXP2 | 2 |
  44366. * | FOGMODE_LINEAR | 3 |
  44367. */
  44368. set fogMode(value: number);
  44369. get fogMode(): number;
  44370. /**
  44371. * Gets or sets the fog color to use
  44372. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44373. * (Default is Color3(0.2, 0.2, 0.3))
  44374. */
  44375. fogColor: Color3;
  44376. /**
  44377. * Gets or sets the fog density to use
  44378. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44379. * (Default is 0.1)
  44380. */
  44381. fogDensity: number;
  44382. /**
  44383. * Gets or sets the fog start distance to use
  44384. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44385. * (Default is 0)
  44386. */
  44387. fogStart: number;
  44388. /**
  44389. * Gets or sets the fog end distance to use
  44390. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44391. * (Default is 1000)
  44392. */
  44393. fogEnd: number;
  44394. /**
  44395. * Flag indicating that the frame buffer binding is handled by another component
  44396. */
  44397. prePass: boolean;
  44398. private _shadowsEnabled;
  44399. /**
  44400. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44401. */
  44402. set shadowsEnabled(value: boolean);
  44403. get shadowsEnabled(): boolean;
  44404. private _lightsEnabled;
  44405. /**
  44406. * Gets or sets a boolean indicating if lights are enabled on this scene
  44407. */
  44408. set lightsEnabled(value: boolean);
  44409. get lightsEnabled(): boolean;
  44410. /** All of the active cameras added to this scene. */
  44411. activeCameras: Camera[];
  44412. /** @hidden */
  44413. _activeCamera: Nullable<Camera>;
  44414. /** Gets or sets the current active camera */
  44415. get activeCamera(): Nullable<Camera>;
  44416. set activeCamera(value: Nullable<Camera>);
  44417. private _defaultMaterial;
  44418. /** The default material used on meshes when no material is affected */
  44419. get defaultMaterial(): Material;
  44420. /** The default material used on meshes when no material is affected */
  44421. set defaultMaterial(value: Material);
  44422. private _texturesEnabled;
  44423. /**
  44424. * Gets or sets a boolean indicating if textures are enabled on this scene
  44425. */
  44426. set texturesEnabled(value: boolean);
  44427. get texturesEnabled(): boolean;
  44428. /**
  44429. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44430. */
  44431. physicsEnabled: boolean;
  44432. /**
  44433. * Gets or sets a boolean indicating if particles are enabled on this scene
  44434. */
  44435. particlesEnabled: boolean;
  44436. /**
  44437. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44438. */
  44439. spritesEnabled: boolean;
  44440. private _skeletonsEnabled;
  44441. /**
  44442. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44443. */
  44444. set skeletonsEnabled(value: boolean);
  44445. get skeletonsEnabled(): boolean;
  44446. /**
  44447. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44448. */
  44449. lensFlaresEnabled: boolean;
  44450. /**
  44451. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44452. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44453. */
  44454. collisionsEnabled: boolean;
  44455. private _collisionCoordinator;
  44456. /** @hidden */
  44457. get collisionCoordinator(): ICollisionCoordinator;
  44458. /**
  44459. * Defines the gravity applied to this scene (used only for collisions)
  44460. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44461. */
  44462. gravity: Vector3;
  44463. /**
  44464. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44465. */
  44466. postProcessesEnabled: boolean;
  44467. /**
  44468. * Gets the current postprocess manager
  44469. */
  44470. postProcessManager: PostProcessManager;
  44471. /**
  44472. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44473. */
  44474. renderTargetsEnabled: boolean;
  44475. /**
  44476. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44477. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44478. */
  44479. dumpNextRenderTargets: boolean;
  44480. /**
  44481. * The list of user defined render targets added to the scene
  44482. */
  44483. customRenderTargets: RenderTargetTexture[];
  44484. /**
  44485. * Defines if texture loading must be delayed
  44486. * If true, textures will only be loaded when they need to be rendered
  44487. */
  44488. useDelayedTextureLoading: boolean;
  44489. /**
  44490. * Gets the list of meshes imported to the scene through SceneLoader
  44491. */
  44492. importedMeshesFiles: String[];
  44493. /**
  44494. * Gets or sets a boolean indicating if probes are enabled on this scene
  44495. */
  44496. probesEnabled: boolean;
  44497. /**
  44498. * Gets or sets the current offline provider to use to store scene data
  44499. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44500. */
  44501. offlineProvider: IOfflineProvider;
  44502. /**
  44503. * Gets or sets the action manager associated with the scene
  44504. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44505. */
  44506. actionManager: AbstractActionManager;
  44507. private _meshesForIntersections;
  44508. /**
  44509. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44510. */
  44511. proceduralTexturesEnabled: boolean;
  44512. private _engine;
  44513. private _totalVertices;
  44514. /** @hidden */
  44515. _activeIndices: PerfCounter;
  44516. /** @hidden */
  44517. _activeParticles: PerfCounter;
  44518. /** @hidden */
  44519. _activeBones: PerfCounter;
  44520. private _animationRatio;
  44521. /** @hidden */
  44522. _animationTimeLast: number;
  44523. /** @hidden */
  44524. _animationTime: number;
  44525. /**
  44526. * Gets or sets a general scale for animation speed
  44527. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44528. */
  44529. animationTimeScale: number;
  44530. /** @hidden */
  44531. _cachedMaterial: Nullable<Material>;
  44532. /** @hidden */
  44533. _cachedEffect: Nullable<Effect>;
  44534. /** @hidden */
  44535. _cachedVisibility: Nullable<number>;
  44536. private _renderId;
  44537. private _frameId;
  44538. private _executeWhenReadyTimeoutId;
  44539. private _intermediateRendering;
  44540. private _viewUpdateFlag;
  44541. private _projectionUpdateFlag;
  44542. /** @hidden */
  44543. _toBeDisposed: Nullable<IDisposable>[];
  44544. private _activeRequests;
  44545. /** @hidden */
  44546. _pendingData: any[];
  44547. private _isDisposed;
  44548. /**
  44549. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44550. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44551. */
  44552. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44553. private _activeMeshes;
  44554. private _processedMaterials;
  44555. private _renderTargets;
  44556. /** @hidden */
  44557. _activeParticleSystems: SmartArray<IParticleSystem>;
  44558. private _activeSkeletons;
  44559. private _softwareSkinnedMeshes;
  44560. private _renderingManager;
  44561. /** @hidden */
  44562. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44563. private _transformMatrix;
  44564. private _sceneUbo;
  44565. /** @hidden */
  44566. _viewMatrix: Matrix;
  44567. private _projectionMatrix;
  44568. /** @hidden */
  44569. _forcedViewPosition: Nullable<Vector3>;
  44570. /** @hidden */
  44571. _frustumPlanes: Plane[];
  44572. /**
  44573. * Gets the list of frustum planes (built from the active camera)
  44574. */
  44575. get frustumPlanes(): Plane[];
  44576. /**
  44577. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44578. * This is useful if there are more lights that the maximum simulteanous authorized
  44579. */
  44580. requireLightSorting: boolean;
  44581. /** @hidden */
  44582. readonly useMaterialMeshMap: boolean;
  44583. /** @hidden */
  44584. readonly useClonedMeshMap: boolean;
  44585. private _externalData;
  44586. private _uid;
  44587. /**
  44588. * @hidden
  44589. * Backing store of defined scene components.
  44590. */
  44591. _components: ISceneComponent[];
  44592. /**
  44593. * @hidden
  44594. * Backing store of defined scene components.
  44595. */
  44596. _serializableComponents: ISceneSerializableComponent[];
  44597. /**
  44598. * List of components to register on the next registration step.
  44599. */
  44600. private _transientComponents;
  44601. /**
  44602. * Registers the transient components if needed.
  44603. */
  44604. private _registerTransientComponents;
  44605. /**
  44606. * @hidden
  44607. * Add a component to the scene.
  44608. * Note that the ccomponent could be registered on th next frame if this is called after
  44609. * the register component stage.
  44610. * @param component Defines the component to add to the scene
  44611. */
  44612. _addComponent(component: ISceneComponent): void;
  44613. /**
  44614. * @hidden
  44615. * Gets a component from the scene.
  44616. * @param name defines the name of the component to retrieve
  44617. * @returns the component or null if not present
  44618. */
  44619. _getComponent(name: string): Nullable<ISceneComponent>;
  44620. /**
  44621. * @hidden
  44622. * Defines the actions happening before camera updates.
  44623. */
  44624. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44625. /**
  44626. * @hidden
  44627. * Defines the actions happening before clear the canvas.
  44628. */
  44629. _beforeClearStage: Stage<SimpleStageAction>;
  44630. /**
  44631. * @hidden
  44632. * Defines the actions when collecting render targets for the frame.
  44633. */
  44634. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44635. /**
  44636. * @hidden
  44637. * Defines the actions happening for one camera in the frame.
  44638. */
  44639. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44640. /**
  44641. * @hidden
  44642. * Defines the actions happening during the per mesh ready checks.
  44643. */
  44644. _isReadyForMeshStage: Stage<MeshStageAction>;
  44645. /**
  44646. * @hidden
  44647. * Defines the actions happening before evaluate active mesh checks.
  44648. */
  44649. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44650. /**
  44651. * @hidden
  44652. * Defines the actions happening during the evaluate sub mesh checks.
  44653. */
  44654. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44655. /**
  44656. * @hidden
  44657. * Defines the actions happening during the active mesh stage.
  44658. */
  44659. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44660. /**
  44661. * @hidden
  44662. * Defines the actions happening during the per camera render target step.
  44663. */
  44664. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44665. /**
  44666. * @hidden
  44667. * Defines the actions happening just before the active camera is drawing.
  44668. */
  44669. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44670. /**
  44671. * @hidden
  44672. * Defines the actions happening just before a render target is drawing.
  44673. */
  44674. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44675. /**
  44676. * @hidden
  44677. * Defines the actions happening just before a rendering group is drawing.
  44678. */
  44679. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44680. /**
  44681. * @hidden
  44682. * Defines the actions happening just before a mesh is drawing.
  44683. */
  44684. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44685. /**
  44686. * @hidden
  44687. * Defines the actions happening just after a mesh has been drawn.
  44688. */
  44689. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44690. /**
  44691. * @hidden
  44692. * Defines the actions happening just after a rendering group has been drawn.
  44693. */
  44694. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44695. /**
  44696. * @hidden
  44697. * Defines the actions happening just after the active camera has been drawn.
  44698. */
  44699. _afterCameraDrawStage: Stage<CameraStageAction>;
  44700. /**
  44701. * @hidden
  44702. * Defines the actions happening just after a render target has been drawn.
  44703. */
  44704. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44705. /**
  44706. * @hidden
  44707. * Defines the actions happening just after rendering all cameras and computing intersections.
  44708. */
  44709. _afterRenderStage: Stage<SimpleStageAction>;
  44710. /**
  44711. * @hidden
  44712. * Defines the actions happening when a pointer move event happens.
  44713. */
  44714. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44715. /**
  44716. * @hidden
  44717. * Defines the actions happening when a pointer down event happens.
  44718. */
  44719. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44720. /**
  44721. * @hidden
  44722. * Defines the actions happening when a pointer up event happens.
  44723. */
  44724. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44725. /**
  44726. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44727. */
  44728. private geometriesByUniqueId;
  44729. /**
  44730. * Creates a new Scene
  44731. * @param engine defines the engine to use to render this scene
  44732. * @param options defines the scene options
  44733. */
  44734. constructor(engine: Engine, options?: SceneOptions);
  44735. /**
  44736. * Gets a string identifying the name of the class
  44737. * @returns "Scene" string
  44738. */
  44739. getClassName(): string;
  44740. private _defaultMeshCandidates;
  44741. /**
  44742. * @hidden
  44743. */
  44744. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44745. private _defaultSubMeshCandidates;
  44746. /**
  44747. * @hidden
  44748. */
  44749. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44750. /**
  44751. * Sets the default candidate providers for the scene.
  44752. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44753. * and getCollidingSubMeshCandidates to their default function
  44754. */
  44755. setDefaultCandidateProviders(): void;
  44756. /**
  44757. * Gets the mesh that is currently under the pointer
  44758. */
  44759. get meshUnderPointer(): Nullable<AbstractMesh>;
  44760. /**
  44761. * Gets or sets the current on-screen X position of the pointer
  44762. */
  44763. get pointerX(): number;
  44764. set pointerX(value: number);
  44765. /**
  44766. * Gets or sets the current on-screen Y position of the pointer
  44767. */
  44768. get pointerY(): number;
  44769. set pointerY(value: number);
  44770. /**
  44771. * Gets the cached material (ie. the latest rendered one)
  44772. * @returns the cached material
  44773. */
  44774. getCachedMaterial(): Nullable<Material>;
  44775. /**
  44776. * Gets the cached effect (ie. the latest rendered one)
  44777. * @returns the cached effect
  44778. */
  44779. getCachedEffect(): Nullable<Effect>;
  44780. /**
  44781. * Gets the cached visibility state (ie. the latest rendered one)
  44782. * @returns the cached visibility state
  44783. */
  44784. getCachedVisibility(): Nullable<number>;
  44785. /**
  44786. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44787. * @param material defines the current material
  44788. * @param effect defines the current effect
  44789. * @param visibility defines the current visibility state
  44790. * @returns true if one parameter is not cached
  44791. */
  44792. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44793. /**
  44794. * Gets the engine associated with the scene
  44795. * @returns an Engine
  44796. */
  44797. getEngine(): Engine;
  44798. /**
  44799. * Gets the total number of vertices rendered per frame
  44800. * @returns the total number of vertices rendered per frame
  44801. */
  44802. getTotalVertices(): number;
  44803. /**
  44804. * Gets the performance counter for total vertices
  44805. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44806. */
  44807. get totalVerticesPerfCounter(): PerfCounter;
  44808. /**
  44809. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44810. * @returns the total number of active indices rendered per frame
  44811. */
  44812. getActiveIndices(): number;
  44813. /**
  44814. * Gets the performance counter for active indices
  44815. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44816. */
  44817. get totalActiveIndicesPerfCounter(): PerfCounter;
  44818. /**
  44819. * Gets the total number of active particles rendered per frame
  44820. * @returns the total number of active particles rendered per frame
  44821. */
  44822. getActiveParticles(): number;
  44823. /**
  44824. * Gets the performance counter for active particles
  44825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44826. */
  44827. get activeParticlesPerfCounter(): PerfCounter;
  44828. /**
  44829. * Gets the total number of active bones rendered per frame
  44830. * @returns the total number of active bones rendered per frame
  44831. */
  44832. getActiveBones(): number;
  44833. /**
  44834. * Gets the performance counter for active bones
  44835. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44836. */
  44837. get activeBonesPerfCounter(): PerfCounter;
  44838. /**
  44839. * Gets the array of active meshes
  44840. * @returns an array of AbstractMesh
  44841. */
  44842. getActiveMeshes(): SmartArray<AbstractMesh>;
  44843. /**
  44844. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44845. * @returns a number
  44846. */
  44847. getAnimationRatio(): number;
  44848. /**
  44849. * Gets an unique Id for the current render phase
  44850. * @returns a number
  44851. */
  44852. getRenderId(): number;
  44853. /**
  44854. * Gets an unique Id for the current frame
  44855. * @returns a number
  44856. */
  44857. getFrameId(): number;
  44858. /** Call this function if you want to manually increment the render Id*/
  44859. incrementRenderId(): void;
  44860. private _createUbo;
  44861. /**
  44862. * Use this method to simulate a pointer move on a mesh
  44863. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44864. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44865. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44866. * @returns the current scene
  44867. */
  44868. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44869. /**
  44870. * Use this method to simulate a pointer down on a mesh
  44871. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44872. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44873. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44874. * @returns the current scene
  44875. */
  44876. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44877. /**
  44878. * Use this method to simulate a pointer up on a mesh
  44879. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44880. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44881. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44882. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44883. * @returns the current scene
  44884. */
  44885. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44886. /**
  44887. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44888. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44889. * @returns true if the pointer was captured
  44890. */
  44891. isPointerCaptured(pointerId?: number): boolean;
  44892. /**
  44893. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44894. * @param attachUp defines if you want to attach events to pointerup
  44895. * @param attachDown defines if you want to attach events to pointerdown
  44896. * @param attachMove defines if you want to attach events to pointermove
  44897. */
  44898. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  44899. /** Detaches all event handlers*/
  44900. detachControl(): void;
  44901. /**
  44902. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  44903. * Delay loaded resources are not taking in account
  44904. * @return true if all required resources are ready
  44905. */
  44906. isReady(): boolean;
  44907. /** Resets all cached information relative to material (including effect and visibility) */
  44908. resetCachedMaterial(): void;
  44909. /**
  44910. * Registers a function to be called before every frame render
  44911. * @param func defines the function to register
  44912. */
  44913. registerBeforeRender(func: () => void): void;
  44914. /**
  44915. * Unregisters a function called before every frame render
  44916. * @param func defines the function to unregister
  44917. */
  44918. unregisterBeforeRender(func: () => void): void;
  44919. /**
  44920. * Registers a function to be called after every frame render
  44921. * @param func defines the function to register
  44922. */
  44923. registerAfterRender(func: () => void): void;
  44924. /**
  44925. * Unregisters a function called after every frame render
  44926. * @param func defines the function to unregister
  44927. */
  44928. unregisterAfterRender(func: () => void): void;
  44929. private _executeOnceBeforeRender;
  44930. /**
  44931. * The provided function will run before render once and will be disposed afterwards.
  44932. * A timeout delay can be provided so that the function will be executed in N ms.
  44933. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  44934. * @param func The function to be executed.
  44935. * @param timeout optional delay in ms
  44936. */
  44937. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  44938. /** @hidden */
  44939. _addPendingData(data: any): void;
  44940. /** @hidden */
  44941. _removePendingData(data: any): void;
  44942. /**
  44943. * Returns the number of items waiting to be loaded
  44944. * @returns the number of items waiting to be loaded
  44945. */
  44946. getWaitingItemsCount(): number;
  44947. /**
  44948. * Returns a boolean indicating if the scene is still loading data
  44949. */
  44950. get isLoading(): boolean;
  44951. /**
  44952. * Registers a function to be executed when the scene is ready
  44953. * @param {Function} func - the function to be executed
  44954. */
  44955. executeWhenReady(func: () => void): void;
  44956. /**
  44957. * Returns a promise that resolves when the scene is ready
  44958. * @returns A promise that resolves when the scene is ready
  44959. */
  44960. whenReadyAsync(): Promise<void>;
  44961. /** @hidden */
  44962. _checkIsReady(): void;
  44963. /**
  44964. * Gets all animatable attached to the scene
  44965. */
  44966. get animatables(): Animatable[];
  44967. /**
  44968. * Resets the last animation time frame.
  44969. * Useful to override when animations start running when loading a scene for the first time.
  44970. */
  44971. resetLastAnimationTimeFrame(): void;
  44972. /**
  44973. * Gets the current view matrix
  44974. * @returns a Matrix
  44975. */
  44976. getViewMatrix(): Matrix;
  44977. /**
  44978. * Gets the current projection matrix
  44979. * @returns a Matrix
  44980. */
  44981. getProjectionMatrix(): Matrix;
  44982. /**
  44983. * Gets the current transform matrix
  44984. * @returns a Matrix made of View * Projection
  44985. */
  44986. getTransformMatrix(): Matrix;
  44987. /**
  44988. * Sets the current transform matrix
  44989. * @param viewL defines the View matrix to use
  44990. * @param projectionL defines the Projection matrix to use
  44991. * @param viewR defines the right View matrix to use (if provided)
  44992. * @param projectionR defines the right Projection matrix to use (if provided)
  44993. */
  44994. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44995. /**
  44996. * Gets the uniform buffer used to store scene data
  44997. * @returns a UniformBuffer
  44998. */
  44999. getSceneUniformBuffer(): UniformBuffer;
  45000. /**
  45001. * Gets an unique (relatively to the current scene) Id
  45002. * @returns an unique number for the scene
  45003. */
  45004. getUniqueId(): number;
  45005. /**
  45006. * Add a mesh to the list of scene's meshes
  45007. * @param newMesh defines the mesh to add
  45008. * @param recursive if all child meshes should also be added to the scene
  45009. */
  45010. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45011. /**
  45012. * Remove a mesh for the list of scene's meshes
  45013. * @param toRemove defines the mesh to remove
  45014. * @param recursive if all child meshes should also be removed from the scene
  45015. * @returns the index where the mesh was in the mesh list
  45016. */
  45017. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45018. /**
  45019. * Add a transform node to the list of scene's transform nodes
  45020. * @param newTransformNode defines the transform node to add
  45021. */
  45022. addTransformNode(newTransformNode: TransformNode): void;
  45023. /**
  45024. * Remove a transform node for the list of scene's transform nodes
  45025. * @param toRemove defines the transform node to remove
  45026. * @returns the index where the transform node was in the transform node list
  45027. */
  45028. removeTransformNode(toRemove: TransformNode): number;
  45029. /**
  45030. * Remove a skeleton for the list of scene's skeletons
  45031. * @param toRemove defines the skeleton to remove
  45032. * @returns the index where the skeleton was in the skeleton list
  45033. */
  45034. removeSkeleton(toRemove: Skeleton): number;
  45035. /**
  45036. * Remove a morph target for the list of scene's morph targets
  45037. * @param toRemove defines the morph target to remove
  45038. * @returns the index where the morph target was in the morph target list
  45039. */
  45040. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45041. /**
  45042. * Remove a light for the list of scene's lights
  45043. * @param toRemove defines the light to remove
  45044. * @returns the index where the light was in the light list
  45045. */
  45046. removeLight(toRemove: Light): number;
  45047. /**
  45048. * Remove a camera for the list of scene's cameras
  45049. * @param toRemove defines the camera to remove
  45050. * @returns the index where the camera was in the camera list
  45051. */
  45052. removeCamera(toRemove: Camera): number;
  45053. /**
  45054. * Remove a particle system for the list of scene's particle systems
  45055. * @param toRemove defines the particle system to remove
  45056. * @returns the index where the particle system was in the particle system list
  45057. */
  45058. removeParticleSystem(toRemove: IParticleSystem): number;
  45059. /**
  45060. * Remove a animation for the list of scene's animations
  45061. * @param toRemove defines the animation to remove
  45062. * @returns the index where the animation was in the animation list
  45063. */
  45064. removeAnimation(toRemove: Animation): number;
  45065. /**
  45066. * Will stop the animation of the given target
  45067. * @param target - the target
  45068. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45069. * @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)
  45070. */
  45071. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45072. /**
  45073. * Removes the given animation group from this scene.
  45074. * @param toRemove The animation group to remove
  45075. * @returns The index of the removed animation group
  45076. */
  45077. removeAnimationGroup(toRemove: AnimationGroup): number;
  45078. /**
  45079. * Removes the given multi-material from this scene.
  45080. * @param toRemove The multi-material to remove
  45081. * @returns The index of the removed multi-material
  45082. */
  45083. removeMultiMaterial(toRemove: MultiMaterial): number;
  45084. /**
  45085. * Removes the given material from this scene.
  45086. * @param toRemove The material to remove
  45087. * @returns The index of the removed material
  45088. */
  45089. removeMaterial(toRemove: Material): number;
  45090. /**
  45091. * Removes the given action manager from this scene.
  45092. * @param toRemove The action manager to remove
  45093. * @returns The index of the removed action manager
  45094. */
  45095. removeActionManager(toRemove: AbstractActionManager): number;
  45096. /**
  45097. * Removes the given texture from this scene.
  45098. * @param toRemove The texture to remove
  45099. * @returns The index of the removed texture
  45100. */
  45101. removeTexture(toRemove: BaseTexture): number;
  45102. /**
  45103. * Adds the given light to this scene
  45104. * @param newLight The light to add
  45105. */
  45106. addLight(newLight: Light): void;
  45107. /**
  45108. * Sorts the list list based on light priorities
  45109. */
  45110. sortLightsByPriority(): void;
  45111. /**
  45112. * Adds the given camera to this scene
  45113. * @param newCamera The camera to add
  45114. */
  45115. addCamera(newCamera: Camera): void;
  45116. /**
  45117. * Adds the given skeleton to this scene
  45118. * @param newSkeleton The skeleton to add
  45119. */
  45120. addSkeleton(newSkeleton: Skeleton): void;
  45121. /**
  45122. * Adds the given particle system to this scene
  45123. * @param newParticleSystem The particle system to add
  45124. */
  45125. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45126. /**
  45127. * Adds the given animation to this scene
  45128. * @param newAnimation The animation to add
  45129. */
  45130. addAnimation(newAnimation: Animation): void;
  45131. /**
  45132. * Adds the given animation group to this scene.
  45133. * @param newAnimationGroup The animation group to add
  45134. */
  45135. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45136. /**
  45137. * Adds the given multi-material to this scene
  45138. * @param newMultiMaterial The multi-material to add
  45139. */
  45140. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45141. /**
  45142. * Adds the given material to this scene
  45143. * @param newMaterial The material to add
  45144. */
  45145. addMaterial(newMaterial: Material): void;
  45146. /**
  45147. * Adds the given morph target to this scene
  45148. * @param newMorphTargetManager The morph target to add
  45149. */
  45150. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45151. /**
  45152. * Adds the given geometry to this scene
  45153. * @param newGeometry The geometry to add
  45154. */
  45155. addGeometry(newGeometry: Geometry): void;
  45156. /**
  45157. * Adds the given action manager to this scene
  45158. * @param newActionManager The action manager to add
  45159. */
  45160. addActionManager(newActionManager: AbstractActionManager): void;
  45161. /**
  45162. * Adds the given texture to this scene.
  45163. * @param newTexture The texture to add
  45164. */
  45165. addTexture(newTexture: BaseTexture): void;
  45166. /**
  45167. * Switch active camera
  45168. * @param newCamera defines the new active camera
  45169. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45170. */
  45171. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45172. /**
  45173. * sets the active camera of the scene using its ID
  45174. * @param id defines the camera's ID
  45175. * @return the new active camera or null if none found.
  45176. */
  45177. setActiveCameraByID(id: string): Nullable<Camera>;
  45178. /**
  45179. * sets the active camera of the scene using its name
  45180. * @param name defines the camera's name
  45181. * @returns the new active camera or null if none found.
  45182. */
  45183. setActiveCameraByName(name: string): Nullable<Camera>;
  45184. /**
  45185. * get an animation group using its name
  45186. * @param name defines the material's name
  45187. * @return the animation group or null if none found.
  45188. */
  45189. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45190. /**
  45191. * Get a material using its unique id
  45192. * @param uniqueId defines the material's unique id
  45193. * @return the material or null if none found.
  45194. */
  45195. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45196. /**
  45197. * get a material using its id
  45198. * @param id defines the material's ID
  45199. * @return the material or null if none found.
  45200. */
  45201. getMaterialByID(id: string): Nullable<Material>;
  45202. /**
  45203. * Gets a the last added material using a given id
  45204. * @param id defines the material's ID
  45205. * @return the last material with the given id or null if none found.
  45206. */
  45207. getLastMaterialByID(id: string): Nullable<Material>;
  45208. /**
  45209. * Gets a material using its name
  45210. * @param name defines the material's name
  45211. * @return the material or null if none found.
  45212. */
  45213. getMaterialByName(name: string): Nullable<Material>;
  45214. /**
  45215. * Get a texture using its unique id
  45216. * @param uniqueId defines the texture's unique id
  45217. * @return the texture or null if none found.
  45218. */
  45219. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45220. /**
  45221. * Gets a camera using its id
  45222. * @param id defines the id to look for
  45223. * @returns the camera or null if not found
  45224. */
  45225. getCameraByID(id: string): Nullable<Camera>;
  45226. /**
  45227. * Gets a camera using its unique id
  45228. * @param uniqueId defines the unique id to look for
  45229. * @returns the camera or null if not found
  45230. */
  45231. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45232. /**
  45233. * Gets a camera using its name
  45234. * @param name defines the camera's name
  45235. * @return the camera or null if none found.
  45236. */
  45237. getCameraByName(name: string): Nullable<Camera>;
  45238. /**
  45239. * Gets a bone using its id
  45240. * @param id defines the bone's id
  45241. * @return the bone or null if not found
  45242. */
  45243. getBoneByID(id: string): Nullable<Bone>;
  45244. /**
  45245. * Gets a bone using its id
  45246. * @param name defines the bone's name
  45247. * @return the bone or null if not found
  45248. */
  45249. getBoneByName(name: string): Nullable<Bone>;
  45250. /**
  45251. * Gets a light node using its name
  45252. * @param name defines the the light's name
  45253. * @return the light or null if none found.
  45254. */
  45255. getLightByName(name: string): Nullable<Light>;
  45256. /**
  45257. * Gets a light node using its id
  45258. * @param id defines the light's id
  45259. * @return the light or null if none found.
  45260. */
  45261. getLightByID(id: string): Nullable<Light>;
  45262. /**
  45263. * Gets a light node using its scene-generated unique ID
  45264. * @param uniqueId defines the light's unique id
  45265. * @return the light or null if none found.
  45266. */
  45267. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45268. /**
  45269. * Gets a particle system by id
  45270. * @param id defines the particle system id
  45271. * @return the corresponding system or null if none found
  45272. */
  45273. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45274. /**
  45275. * Gets a geometry using its ID
  45276. * @param id defines the geometry's id
  45277. * @return the geometry or null if none found.
  45278. */
  45279. getGeometryByID(id: string): Nullable<Geometry>;
  45280. private _getGeometryByUniqueID;
  45281. /**
  45282. * Add a new geometry to this scene
  45283. * @param geometry defines the geometry to be added to the scene.
  45284. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45285. * @return a boolean defining if the geometry was added or not
  45286. */
  45287. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45288. /**
  45289. * Removes an existing geometry
  45290. * @param geometry defines the geometry to be removed from the scene
  45291. * @return a boolean defining if the geometry was removed or not
  45292. */
  45293. removeGeometry(geometry: Geometry): boolean;
  45294. /**
  45295. * Gets the list of geometries attached to the scene
  45296. * @returns an array of Geometry
  45297. */
  45298. getGeometries(): Geometry[];
  45299. /**
  45300. * Gets the first added mesh found of a given ID
  45301. * @param id defines the id to search for
  45302. * @return the mesh found or null if not found at all
  45303. */
  45304. getMeshByID(id: string): Nullable<AbstractMesh>;
  45305. /**
  45306. * Gets a list of meshes using their id
  45307. * @param id defines the id to search for
  45308. * @returns a list of meshes
  45309. */
  45310. getMeshesByID(id: string): Array<AbstractMesh>;
  45311. /**
  45312. * Gets the first added transform node found of a given ID
  45313. * @param id defines the id to search for
  45314. * @return the found transform node or null if not found at all.
  45315. */
  45316. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45317. /**
  45318. * Gets a transform node with its auto-generated unique id
  45319. * @param uniqueId efines the unique id to search for
  45320. * @return the found transform node or null if not found at all.
  45321. */
  45322. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45323. /**
  45324. * Gets a list of transform nodes using their id
  45325. * @param id defines the id to search for
  45326. * @returns a list of transform nodes
  45327. */
  45328. getTransformNodesByID(id: string): Array<TransformNode>;
  45329. /**
  45330. * Gets a mesh with its auto-generated unique id
  45331. * @param uniqueId defines the unique id to search for
  45332. * @return the found mesh or null if not found at all.
  45333. */
  45334. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45335. /**
  45336. * Gets a the last added mesh using a given id
  45337. * @param id defines the id to search for
  45338. * @return the found mesh or null if not found at all.
  45339. */
  45340. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45341. /**
  45342. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45343. * @param id defines the id to search for
  45344. * @return the found node or null if not found at all
  45345. */
  45346. getLastEntryByID(id: string): Nullable<Node>;
  45347. /**
  45348. * Gets a node (Mesh, Camera, Light) using a given id
  45349. * @param id defines the id to search for
  45350. * @return the found node or null if not found at all
  45351. */
  45352. getNodeByID(id: string): Nullable<Node>;
  45353. /**
  45354. * Gets a node (Mesh, Camera, Light) using a given name
  45355. * @param name defines the name to search for
  45356. * @return the found node or null if not found at all.
  45357. */
  45358. getNodeByName(name: string): Nullable<Node>;
  45359. /**
  45360. * Gets a mesh using a given name
  45361. * @param name defines the name to search for
  45362. * @return the found mesh or null if not found at all.
  45363. */
  45364. getMeshByName(name: string): Nullable<AbstractMesh>;
  45365. /**
  45366. * Gets a transform node using a given name
  45367. * @param name defines the name to search for
  45368. * @return the found transform node or null if not found at all.
  45369. */
  45370. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45371. /**
  45372. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45373. * @param id defines the id to search for
  45374. * @return the found skeleton or null if not found at all.
  45375. */
  45376. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45377. /**
  45378. * Gets a skeleton using a given auto generated unique id
  45379. * @param uniqueId defines the unique id to search for
  45380. * @return the found skeleton or null if not found at all.
  45381. */
  45382. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45383. /**
  45384. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45385. * @param id defines the id to search for
  45386. * @return the found skeleton or null if not found at all.
  45387. */
  45388. getSkeletonById(id: string): Nullable<Skeleton>;
  45389. /**
  45390. * Gets a skeleton using a given name
  45391. * @param name defines the name to search for
  45392. * @return the found skeleton or null if not found at all.
  45393. */
  45394. getSkeletonByName(name: string): Nullable<Skeleton>;
  45395. /**
  45396. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45397. * @param id defines the id to search for
  45398. * @return the found morph target manager or null if not found at all.
  45399. */
  45400. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45401. /**
  45402. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45403. * @param id defines the id to search for
  45404. * @return the found morph target or null if not found at all.
  45405. */
  45406. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45407. /**
  45408. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45409. * @param name defines the name to search for
  45410. * @return the found morph target or null if not found at all.
  45411. */
  45412. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45413. /**
  45414. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45415. * @param name defines the name to search for
  45416. * @return the found post process or null if not found at all.
  45417. */
  45418. getPostProcessByName(name: string): Nullable<PostProcess>;
  45419. /**
  45420. * Gets a boolean indicating if the given mesh is active
  45421. * @param mesh defines the mesh to look for
  45422. * @returns true if the mesh is in the active list
  45423. */
  45424. isActiveMesh(mesh: AbstractMesh): boolean;
  45425. /**
  45426. * Return a unique id as a string which can serve as an identifier for the scene
  45427. */
  45428. get uid(): string;
  45429. /**
  45430. * Add an externaly attached data from its key.
  45431. * This method call will fail and return false, if such key already exists.
  45432. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45433. * @param key the unique key that identifies the data
  45434. * @param data the data object to associate to the key for this Engine instance
  45435. * @return true if no such key were already present and the data was added successfully, false otherwise
  45436. */
  45437. addExternalData<T>(key: string, data: T): boolean;
  45438. /**
  45439. * Get an externaly attached data from its key
  45440. * @param key the unique key that identifies the data
  45441. * @return the associated data, if present (can be null), or undefined if not present
  45442. */
  45443. getExternalData<T>(key: string): Nullable<T>;
  45444. /**
  45445. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45446. * @param key the unique key that identifies the data
  45447. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45448. * @return the associated data, can be null if the factory returned null.
  45449. */
  45450. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45451. /**
  45452. * Remove an externaly attached data from the Engine instance
  45453. * @param key the unique key that identifies the data
  45454. * @return true if the data was successfully removed, false if it doesn't exist
  45455. */
  45456. removeExternalData(key: string): boolean;
  45457. private _evaluateSubMesh;
  45458. /**
  45459. * Clear the processed materials smart array preventing retention point in material dispose.
  45460. */
  45461. freeProcessedMaterials(): void;
  45462. private _preventFreeActiveMeshesAndRenderingGroups;
  45463. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45464. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45465. * when disposing several meshes in a row or a hierarchy of meshes.
  45466. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45467. */
  45468. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45469. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45470. /**
  45471. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45472. */
  45473. freeActiveMeshes(): void;
  45474. /**
  45475. * Clear the info related to rendering groups preventing retention points during dispose.
  45476. */
  45477. freeRenderingGroups(): void;
  45478. /** @hidden */
  45479. _isInIntermediateRendering(): boolean;
  45480. /**
  45481. * Lambda returning the list of potentially active meshes.
  45482. */
  45483. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45484. /**
  45485. * Lambda returning the list of potentially active sub meshes.
  45486. */
  45487. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45488. /**
  45489. * Lambda returning the list of potentially intersecting sub meshes.
  45490. */
  45491. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45492. /**
  45493. * Lambda returning the list of potentially colliding sub meshes.
  45494. */
  45495. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45496. private _activeMeshesFrozen;
  45497. private _skipEvaluateActiveMeshesCompletely;
  45498. /**
  45499. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45500. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45501. * @param onSuccess optional success callback
  45502. * @param onError optional error callback
  45503. * @returns the current scene
  45504. */
  45505. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45506. /**
  45507. * Use this function to restart evaluating active meshes on every frame
  45508. * @returns the current scene
  45509. */
  45510. unfreezeActiveMeshes(): Scene;
  45511. private _evaluateActiveMeshes;
  45512. private _activeMesh;
  45513. /**
  45514. * Update the transform matrix to update from the current active camera
  45515. * @param force defines a boolean used to force the update even if cache is up to date
  45516. */
  45517. updateTransformMatrix(force?: boolean): void;
  45518. private _bindFrameBuffer;
  45519. /** @hidden */
  45520. _allowPostProcessClearColor: boolean;
  45521. /** @hidden */
  45522. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45523. private _processSubCameras;
  45524. private _checkIntersections;
  45525. /** @hidden */
  45526. _advancePhysicsEngineStep(step: number): void;
  45527. /**
  45528. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45529. */
  45530. getDeterministicFrameTime: () => number;
  45531. /** @hidden */
  45532. _animate(): void;
  45533. /** Execute all animations (for a frame) */
  45534. animate(): void;
  45535. /**
  45536. * Render the scene
  45537. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45538. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45539. */
  45540. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45541. /**
  45542. * Freeze all materials
  45543. * A frozen material will not be updatable but should be faster to render
  45544. */
  45545. freezeMaterials(): void;
  45546. /**
  45547. * Unfreeze all materials
  45548. * A frozen material will not be updatable but should be faster to render
  45549. */
  45550. unfreezeMaterials(): void;
  45551. /**
  45552. * Releases all held ressources
  45553. */
  45554. dispose(): void;
  45555. /**
  45556. * Gets if the scene is already disposed
  45557. */
  45558. get isDisposed(): boolean;
  45559. /**
  45560. * Call this function to reduce memory footprint of the scene.
  45561. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45562. */
  45563. clearCachedVertexData(): void;
  45564. /**
  45565. * This function will remove the local cached buffer data from texture.
  45566. * It will save memory but will prevent the texture from being rebuilt
  45567. */
  45568. cleanCachedTextureBuffer(): void;
  45569. /**
  45570. * Get the world extend vectors with an optional filter
  45571. *
  45572. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45573. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45574. */
  45575. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45576. min: Vector3;
  45577. max: Vector3;
  45578. };
  45579. /**
  45580. * Creates a ray that can be used to pick in the scene
  45581. * @param x defines the x coordinate of the origin (on-screen)
  45582. * @param y defines the y coordinate of the origin (on-screen)
  45583. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45584. * @param camera defines the camera to use for the picking
  45585. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45586. * @returns a Ray
  45587. */
  45588. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45589. /**
  45590. * Creates a ray that can be used to pick in the scene
  45591. * @param x defines the x coordinate of the origin (on-screen)
  45592. * @param y defines the y coordinate of the origin (on-screen)
  45593. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45594. * @param result defines the ray where to store the picking ray
  45595. * @param camera defines the camera to use for the picking
  45596. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45597. * @returns the current scene
  45598. */
  45599. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45600. /**
  45601. * Creates a ray that can be used to pick in the scene
  45602. * @param x defines the x coordinate of the origin (on-screen)
  45603. * @param y defines the y coordinate of the origin (on-screen)
  45604. * @param camera defines the camera to use for the picking
  45605. * @returns a Ray
  45606. */
  45607. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45608. /**
  45609. * Creates a ray that can be used to pick in the scene
  45610. * @param x defines the x coordinate of the origin (on-screen)
  45611. * @param y defines the y coordinate of the origin (on-screen)
  45612. * @param result defines the ray where to store the picking ray
  45613. * @param camera defines the camera to use for the picking
  45614. * @returns the current scene
  45615. */
  45616. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45617. /** Launch a ray to try to pick a mesh in the scene
  45618. * @param x position on screen
  45619. * @param y position on screen
  45620. * @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
  45621. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45622. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45623. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45624. * @returns a PickingInfo
  45625. */
  45626. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45627. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45628. * @param x position on screen
  45629. * @param y position on screen
  45630. * @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
  45631. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45632. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45633. * @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)
  45634. */
  45635. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45636. /** Use the given ray to pick a mesh in the scene
  45637. * @param ray The ray to use to pick meshes
  45638. * @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
  45639. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45640. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45641. * @returns a PickingInfo
  45642. */
  45643. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45644. /**
  45645. * Launch a ray to try to pick a mesh in the scene
  45646. * @param x X position on screen
  45647. * @param y Y position on screen
  45648. * @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
  45649. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45650. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45651. * @returns an array of PickingInfo
  45652. */
  45653. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45654. /**
  45655. * Launch a ray to try to pick a mesh in the scene
  45656. * @param ray Ray to use
  45657. * @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
  45658. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45659. * @returns an array of PickingInfo
  45660. */
  45661. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45662. /**
  45663. * Force the value of meshUnderPointer
  45664. * @param mesh defines the mesh to use
  45665. * @param pointerId optional pointer id when using more than one pointer
  45666. */
  45667. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45668. /**
  45669. * Gets the mesh under the pointer
  45670. * @returns a Mesh or null if no mesh is under the pointer
  45671. */
  45672. getPointerOverMesh(): Nullable<AbstractMesh>;
  45673. /** @hidden */
  45674. _rebuildGeometries(): void;
  45675. /** @hidden */
  45676. _rebuildTextures(): void;
  45677. private _getByTags;
  45678. /**
  45679. * Get a list of meshes by tags
  45680. * @param tagsQuery defines the tags query to use
  45681. * @param forEach defines a predicate used to filter results
  45682. * @returns an array of Mesh
  45683. */
  45684. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45685. /**
  45686. * Get a list of cameras by tags
  45687. * @param tagsQuery defines the tags query to use
  45688. * @param forEach defines a predicate used to filter results
  45689. * @returns an array of Camera
  45690. */
  45691. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45692. /**
  45693. * Get a list of lights by tags
  45694. * @param tagsQuery defines the tags query to use
  45695. * @param forEach defines a predicate used to filter results
  45696. * @returns an array of Light
  45697. */
  45698. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45699. /**
  45700. * Get a list of materials by tags
  45701. * @param tagsQuery defines the tags query to use
  45702. * @param forEach defines a predicate used to filter results
  45703. * @returns an array of Material
  45704. */
  45705. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45706. /**
  45707. * Get a list of transform nodes by tags
  45708. * @param tagsQuery defines the tags query to use
  45709. * @param forEach defines a predicate used to filter results
  45710. * @returns an array of TransformNode
  45711. */
  45712. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45713. /**
  45714. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45715. * This allowed control for front to back rendering or reversly depending of the special needs.
  45716. *
  45717. * @param renderingGroupId The rendering group id corresponding to its index
  45718. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45719. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45720. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45721. */
  45722. 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;
  45723. /**
  45724. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45725. *
  45726. * @param renderingGroupId The rendering group id corresponding to its index
  45727. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45728. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45729. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45730. */
  45731. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45732. /**
  45733. * Gets the current auto clear configuration for one rendering group of the rendering
  45734. * manager.
  45735. * @param index the rendering group index to get the information for
  45736. * @returns The auto clear setup for the requested rendering group
  45737. */
  45738. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45739. private _blockMaterialDirtyMechanism;
  45740. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45741. get blockMaterialDirtyMechanism(): boolean;
  45742. set blockMaterialDirtyMechanism(value: boolean);
  45743. /**
  45744. * Will flag all materials as dirty to trigger new shader compilation
  45745. * @param flag defines the flag used to specify which material part must be marked as dirty
  45746. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45747. */
  45748. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45749. /** @hidden */
  45750. _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;
  45751. /** @hidden */
  45752. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45753. /** @hidden */
  45754. _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;
  45755. /** @hidden */
  45756. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45757. /** @hidden */
  45758. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45759. /** @hidden */
  45760. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45761. }
  45762. }
  45763. declare module "babylonjs/assetContainer" {
  45764. import { AbstractScene } from "babylonjs/abstractScene";
  45765. import { Scene } from "babylonjs/scene";
  45766. import { Mesh } from "babylonjs/Meshes/mesh";
  45767. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45768. import { Skeleton } from "babylonjs/Bones/skeleton";
  45769. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45770. import { Animatable } from "babylonjs/Animations/animatable";
  45771. import { Nullable } from "babylonjs/types";
  45772. import { Node } from "babylonjs/node";
  45773. /**
  45774. * Set of assets to keep when moving a scene into an asset container.
  45775. */
  45776. export class KeepAssets extends AbstractScene {
  45777. }
  45778. /**
  45779. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45780. */
  45781. export class InstantiatedEntries {
  45782. /**
  45783. * List of new root nodes (eg. nodes with no parent)
  45784. */
  45785. rootNodes: TransformNode[];
  45786. /**
  45787. * List of new skeletons
  45788. */
  45789. skeletons: Skeleton[];
  45790. /**
  45791. * List of new animation groups
  45792. */
  45793. animationGroups: AnimationGroup[];
  45794. }
  45795. /**
  45796. * Container with a set of assets that can be added or removed from a scene.
  45797. */
  45798. export class AssetContainer extends AbstractScene {
  45799. private _wasAddedToScene;
  45800. /**
  45801. * The scene the AssetContainer belongs to.
  45802. */
  45803. scene: Scene;
  45804. /**
  45805. * Instantiates an AssetContainer.
  45806. * @param scene The scene the AssetContainer belongs to.
  45807. */
  45808. constructor(scene: Scene);
  45809. /**
  45810. * Instantiate or clone all meshes and add the new ones to the scene.
  45811. * Skeletons and animation groups will all be cloned
  45812. * @param nameFunction defines an optional function used to get new names for clones
  45813. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45814. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45815. */
  45816. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45817. /**
  45818. * Adds all the assets from the container to the scene.
  45819. */
  45820. addAllToScene(): void;
  45821. /**
  45822. * Removes all the assets in the container from the scene
  45823. */
  45824. removeAllFromScene(): void;
  45825. /**
  45826. * Disposes all the assets in the container
  45827. */
  45828. dispose(): void;
  45829. private _moveAssets;
  45830. /**
  45831. * Removes all the assets contained in the scene and adds them to the container.
  45832. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45833. */
  45834. moveAllFromScene(keepAssets?: KeepAssets): void;
  45835. /**
  45836. * 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.
  45837. * @returns the root mesh
  45838. */
  45839. createRootMesh(): Mesh;
  45840. /**
  45841. * Merge animations (direct and animation groups) from this asset container into a scene
  45842. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45843. * @param animatables set of animatables to retarget to a node from the scene
  45844. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45845. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45846. */
  45847. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45848. }
  45849. }
  45850. declare module "babylonjs/abstractScene" {
  45851. import { Scene } from "babylonjs/scene";
  45852. import { Nullable } from "babylonjs/types";
  45853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45854. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45855. import { Geometry } from "babylonjs/Meshes/geometry";
  45856. import { Skeleton } from "babylonjs/Bones/skeleton";
  45857. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45858. import { AssetContainer } from "babylonjs/assetContainer";
  45859. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45860. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45862. import { Material } from "babylonjs/Materials/material";
  45863. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45864. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45865. import { Camera } from "babylonjs/Cameras/camera";
  45866. import { Light } from "babylonjs/Lights/light";
  45867. import { Node } from "babylonjs/node";
  45868. import { Animation } from "babylonjs/Animations/animation";
  45869. /**
  45870. * Defines how the parser contract is defined.
  45871. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45872. */
  45873. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45874. /**
  45875. * Defines how the individual parser contract is defined.
  45876. * These parser can parse an individual asset
  45877. */
  45878. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45879. /**
  45880. * Base class of the scene acting as a container for the different elements composing a scene.
  45881. * This class is dynamically extended by the different components of the scene increasing
  45882. * flexibility and reducing coupling
  45883. */
  45884. export abstract class AbstractScene {
  45885. /**
  45886. * Stores the list of available parsers in the application.
  45887. */
  45888. private static _BabylonFileParsers;
  45889. /**
  45890. * Stores the list of available individual parsers in the application.
  45891. */
  45892. private static _IndividualBabylonFileParsers;
  45893. /**
  45894. * Adds a parser in the list of available ones
  45895. * @param name Defines the name of the parser
  45896. * @param parser Defines the parser to add
  45897. */
  45898. static AddParser(name: string, parser: BabylonFileParser): void;
  45899. /**
  45900. * Gets a general parser from the list of avaialble ones
  45901. * @param name Defines the name of the parser
  45902. * @returns the requested parser or null
  45903. */
  45904. static GetParser(name: string): Nullable<BabylonFileParser>;
  45905. /**
  45906. * Adds n individual parser in the list of available ones
  45907. * @param name Defines the name of the parser
  45908. * @param parser Defines the parser to add
  45909. */
  45910. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  45911. /**
  45912. * Gets an individual parser from the list of avaialble ones
  45913. * @param name Defines the name of the parser
  45914. * @returns the requested parser or null
  45915. */
  45916. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  45917. /**
  45918. * Parser json data and populate both a scene and its associated container object
  45919. * @param jsonData Defines the data to parse
  45920. * @param scene Defines the scene to parse the data for
  45921. * @param container Defines the container attached to the parsing sequence
  45922. * @param rootUrl Defines the root url of the data
  45923. */
  45924. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  45925. /**
  45926. * Gets the list of root nodes (ie. nodes with no parent)
  45927. */
  45928. rootNodes: Node[];
  45929. /** All of the cameras added to this scene
  45930. * @see https://doc.babylonjs.com/babylon101/cameras
  45931. */
  45932. cameras: Camera[];
  45933. /**
  45934. * All of the lights added to this scene
  45935. * @see https://doc.babylonjs.com/babylon101/lights
  45936. */
  45937. lights: Light[];
  45938. /**
  45939. * All of the (abstract) meshes added to this scene
  45940. */
  45941. meshes: AbstractMesh[];
  45942. /**
  45943. * The list of skeletons added to the scene
  45944. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  45945. */
  45946. skeletons: Skeleton[];
  45947. /**
  45948. * All of the particle systems added to this scene
  45949. * @see https://doc.babylonjs.com/babylon101/particles
  45950. */
  45951. particleSystems: IParticleSystem[];
  45952. /**
  45953. * Gets a list of Animations associated with the scene
  45954. */
  45955. animations: Animation[];
  45956. /**
  45957. * All of the animation groups added to this scene
  45958. * @see https://doc.babylonjs.com/how_to/group
  45959. */
  45960. animationGroups: AnimationGroup[];
  45961. /**
  45962. * All of the multi-materials added to this scene
  45963. * @see https://doc.babylonjs.com/how_to/multi_materials
  45964. */
  45965. multiMaterials: MultiMaterial[];
  45966. /**
  45967. * All of the materials added to this scene
  45968. * In the context of a Scene, it is not supposed to be modified manually.
  45969. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  45970. * Note also that the order of the Material within the array is not significant and might change.
  45971. * @see https://doc.babylonjs.com/babylon101/materials
  45972. */
  45973. materials: Material[];
  45974. /**
  45975. * The list of morph target managers added to the scene
  45976. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  45977. */
  45978. morphTargetManagers: MorphTargetManager[];
  45979. /**
  45980. * The list of geometries used in the scene.
  45981. */
  45982. geometries: Geometry[];
  45983. /**
  45984. * All of the tranform nodes added to this scene
  45985. * In the context of a Scene, it is not supposed to be modified manually.
  45986. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  45987. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  45988. * @see https://doc.babylonjs.com/how_to/transformnode
  45989. */
  45990. transformNodes: TransformNode[];
  45991. /**
  45992. * ActionManagers available on the scene.
  45993. */
  45994. actionManagers: AbstractActionManager[];
  45995. /**
  45996. * Textures to keep.
  45997. */
  45998. textures: BaseTexture[];
  45999. /** @hidden */
  46000. protected _environmentTexture: Nullable<BaseTexture>;
  46001. /**
  46002. * Texture used in all pbr material as the reflection texture.
  46003. * As in the majority of the scene they are the same (exception for multi room and so on),
  46004. * this is easier to reference from here than from all the materials.
  46005. */
  46006. get environmentTexture(): Nullable<BaseTexture>;
  46007. set environmentTexture(value: Nullable<BaseTexture>);
  46008. /**
  46009. * The list of postprocesses added to the scene
  46010. */
  46011. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46012. /**
  46013. * @returns all meshes, lights, cameras, transformNodes and bones
  46014. */
  46015. getNodes(): Array<Node>;
  46016. }
  46017. }
  46018. declare module "babylonjs/Audio/sound" {
  46019. import { Observable } from "babylonjs/Misc/observable";
  46020. import { Vector3 } from "babylonjs/Maths/math.vector";
  46021. import { Nullable } from "babylonjs/types";
  46022. import { Scene } from "babylonjs/scene";
  46023. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46024. /**
  46025. * Interface used to define options for Sound class
  46026. */
  46027. export interface ISoundOptions {
  46028. /**
  46029. * Does the sound autoplay once loaded.
  46030. */
  46031. autoplay?: boolean;
  46032. /**
  46033. * Does the sound loop after it finishes playing once.
  46034. */
  46035. loop?: boolean;
  46036. /**
  46037. * Sound's volume
  46038. */
  46039. volume?: number;
  46040. /**
  46041. * Is it a spatial sound?
  46042. */
  46043. spatialSound?: boolean;
  46044. /**
  46045. * Maximum distance to hear that sound
  46046. */
  46047. maxDistance?: number;
  46048. /**
  46049. * Uses user defined attenuation function
  46050. */
  46051. useCustomAttenuation?: boolean;
  46052. /**
  46053. * Define the roll off factor of spatial sounds.
  46054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46055. */
  46056. rolloffFactor?: number;
  46057. /**
  46058. * Define the reference distance the sound should be heard perfectly.
  46059. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46060. */
  46061. refDistance?: number;
  46062. /**
  46063. * Define the distance attenuation model the sound will follow.
  46064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46065. */
  46066. distanceModel?: string;
  46067. /**
  46068. * Defines the playback speed (1 by default)
  46069. */
  46070. playbackRate?: number;
  46071. /**
  46072. * Defines if the sound is from a streaming source
  46073. */
  46074. streaming?: boolean;
  46075. /**
  46076. * Defines an optional length (in seconds) inside the sound file
  46077. */
  46078. length?: number;
  46079. /**
  46080. * Defines an optional offset (in seconds) inside the sound file
  46081. */
  46082. offset?: number;
  46083. /**
  46084. * If true, URLs will not be required to state the audio file codec to use.
  46085. */
  46086. skipCodecCheck?: boolean;
  46087. }
  46088. /**
  46089. * Defines a sound that can be played in the application.
  46090. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46091. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46092. */
  46093. export class Sound {
  46094. /**
  46095. * The name of the sound in the scene.
  46096. */
  46097. name: string;
  46098. /**
  46099. * Does the sound autoplay once loaded.
  46100. */
  46101. autoplay: boolean;
  46102. /**
  46103. * Does the sound loop after it finishes playing once.
  46104. */
  46105. loop: boolean;
  46106. /**
  46107. * Does the sound use a custom attenuation curve to simulate the falloff
  46108. * happening when the source gets further away from the camera.
  46109. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46110. */
  46111. useCustomAttenuation: boolean;
  46112. /**
  46113. * The sound track id this sound belongs to.
  46114. */
  46115. soundTrackId: number;
  46116. /**
  46117. * Is this sound currently played.
  46118. */
  46119. isPlaying: boolean;
  46120. /**
  46121. * Is this sound currently paused.
  46122. */
  46123. isPaused: boolean;
  46124. /**
  46125. * Does this sound enables spatial sound.
  46126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46127. */
  46128. spatialSound: boolean;
  46129. /**
  46130. * Define the reference distance the sound should be heard perfectly.
  46131. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46132. */
  46133. refDistance: number;
  46134. /**
  46135. * Define the roll off factor of spatial sounds.
  46136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46137. */
  46138. rolloffFactor: number;
  46139. /**
  46140. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46142. */
  46143. maxDistance: number;
  46144. /**
  46145. * Define the distance attenuation model the sound will follow.
  46146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46147. */
  46148. distanceModel: string;
  46149. /**
  46150. * @hidden
  46151. * Back Compat
  46152. **/
  46153. onended: () => any;
  46154. /**
  46155. * Gets or sets an object used to store user defined information for the sound.
  46156. */
  46157. metadata: any;
  46158. /**
  46159. * Observable event when the current playing sound finishes.
  46160. */
  46161. onEndedObservable: Observable<Sound>;
  46162. private _panningModel;
  46163. private _playbackRate;
  46164. private _streaming;
  46165. private _startTime;
  46166. private _startOffset;
  46167. private _position;
  46168. /** @hidden */
  46169. _positionInEmitterSpace: boolean;
  46170. private _localDirection;
  46171. private _volume;
  46172. private _isReadyToPlay;
  46173. private _isDirectional;
  46174. private _readyToPlayCallback;
  46175. private _audioBuffer;
  46176. private _soundSource;
  46177. private _streamingSource;
  46178. private _soundPanner;
  46179. private _soundGain;
  46180. private _inputAudioNode;
  46181. private _outputAudioNode;
  46182. private _coneInnerAngle;
  46183. private _coneOuterAngle;
  46184. private _coneOuterGain;
  46185. private _scene;
  46186. private _connectedTransformNode;
  46187. private _customAttenuationFunction;
  46188. private _registerFunc;
  46189. private _isOutputConnected;
  46190. private _htmlAudioElement;
  46191. private _urlType;
  46192. private _length?;
  46193. private _offset?;
  46194. /** @hidden */
  46195. static _SceneComponentInitialization: (scene: Scene) => void;
  46196. /**
  46197. * Create a sound and attach it to a scene
  46198. * @param name Name of your sound
  46199. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46200. * @param scene defines the scene the sound belongs to
  46201. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46202. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46203. */
  46204. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46205. /**
  46206. * Release the sound and its associated resources
  46207. */
  46208. dispose(): void;
  46209. /**
  46210. * Gets if the sounds is ready to be played or not.
  46211. * @returns true if ready, otherwise false
  46212. */
  46213. isReady(): boolean;
  46214. private _soundLoaded;
  46215. /**
  46216. * Sets the data of the sound from an audiobuffer
  46217. * @param audioBuffer The audioBuffer containing the data
  46218. */
  46219. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46220. /**
  46221. * Updates the current sounds options such as maxdistance, loop...
  46222. * @param options A JSON object containing values named as the object properties
  46223. */
  46224. updateOptions(options: ISoundOptions): void;
  46225. private _createSpatialParameters;
  46226. private _updateSpatialParameters;
  46227. /**
  46228. * Switch the panning model to HRTF:
  46229. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46231. */
  46232. switchPanningModelToHRTF(): void;
  46233. /**
  46234. * Switch the panning model to Equal Power:
  46235. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46236. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46237. */
  46238. switchPanningModelToEqualPower(): void;
  46239. private _switchPanningModel;
  46240. /**
  46241. * Connect this sound to a sound track audio node like gain...
  46242. * @param soundTrackAudioNode the sound track audio node to connect to
  46243. */
  46244. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46245. /**
  46246. * Transform this sound into a directional source
  46247. * @param coneInnerAngle Size of the inner cone in degree
  46248. * @param coneOuterAngle Size of the outer cone in degree
  46249. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46250. */
  46251. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46252. /**
  46253. * Gets or sets the inner angle for the directional cone.
  46254. */
  46255. get directionalConeInnerAngle(): number;
  46256. /**
  46257. * Gets or sets the inner angle for the directional cone.
  46258. */
  46259. set directionalConeInnerAngle(value: number);
  46260. /**
  46261. * Gets or sets the outer angle for the directional cone.
  46262. */
  46263. get directionalConeOuterAngle(): number;
  46264. /**
  46265. * Gets or sets the outer angle for the directional cone.
  46266. */
  46267. set directionalConeOuterAngle(value: number);
  46268. /**
  46269. * Sets the position of the emitter if spatial sound is enabled
  46270. * @param newPosition Defines the new posisiton
  46271. */
  46272. setPosition(newPosition: Vector3): void;
  46273. /**
  46274. * Sets the local direction of the emitter if spatial sound is enabled
  46275. * @param newLocalDirection Defines the new local direction
  46276. */
  46277. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46278. private _updateDirection;
  46279. /** @hidden */
  46280. updateDistanceFromListener(): void;
  46281. /**
  46282. * Sets a new custom attenuation function for the sound.
  46283. * @param callback Defines the function used for the attenuation
  46284. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46285. */
  46286. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46287. /**
  46288. * Play the sound
  46289. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46290. * @param offset (optional) Start the sound at a specific time in seconds
  46291. * @param length (optional) Sound duration (in seconds)
  46292. */
  46293. play(time?: number, offset?: number, length?: number): void;
  46294. private _onended;
  46295. /**
  46296. * Stop the sound
  46297. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46298. */
  46299. stop(time?: number): void;
  46300. /**
  46301. * Put the sound in pause
  46302. */
  46303. pause(): void;
  46304. /**
  46305. * Sets a dedicated volume for this sounds
  46306. * @param newVolume Define the new volume of the sound
  46307. * @param time Define time for gradual change to new volume
  46308. */
  46309. setVolume(newVolume: number, time?: number): void;
  46310. /**
  46311. * Set the sound play back rate
  46312. * @param newPlaybackRate Define the playback rate the sound should be played at
  46313. */
  46314. setPlaybackRate(newPlaybackRate: number): void;
  46315. /**
  46316. * Gets the volume of the sound.
  46317. * @returns the volume of the sound
  46318. */
  46319. getVolume(): number;
  46320. /**
  46321. * Attach the sound to a dedicated mesh
  46322. * @param transformNode The transform node to connect the sound with
  46323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46324. */
  46325. attachToMesh(transformNode: TransformNode): void;
  46326. /**
  46327. * Detach the sound from the previously attached mesh
  46328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46329. */
  46330. detachFromMesh(): void;
  46331. private _onRegisterAfterWorldMatrixUpdate;
  46332. /**
  46333. * Clone the current sound in the scene.
  46334. * @returns the new sound clone
  46335. */
  46336. clone(): Nullable<Sound>;
  46337. /**
  46338. * Gets the current underlying audio buffer containing the data
  46339. * @returns the audio buffer
  46340. */
  46341. getAudioBuffer(): Nullable<AudioBuffer>;
  46342. /**
  46343. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46344. * @returns the source node
  46345. */
  46346. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46347. /**
  46348. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46349. * @returns the gain node
  46350. */
  46351. getSoundGain(): Nullable<GainNode>;
  46352. /**
  46353. * Serializes the Sound in a JSON representation
  46354. * @returns the JSON representation of the sound
  46355. */
  46356. serialize(): any;
  46357. /**
  46358. * Parse a JSON representation of a sound to innstantiate in a given scene
  46359. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46360. * @param scene Define the scene the new parsed sound should be created in
  46361. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46362. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46363. * @returns the newly parsed sound
  46364. */
  46365. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46366. }
  46367. }
  46368. declare module "babylonjs/Actions/directAudioActions" {
  46369. import { Action } from "babylonjs/Actions/action";
  46370. import { Condition } from "babylonjs/Actions/condition";
  46371. import { Sound } from "babylonjs/Audio/sound";
  46372. /**
  46373. * This defines an action helpful to play a defined sound on a triggered action.
  46374. */
  46375. export class PlaySoundAction extends Action {
  46376. private _sound;
  46377. /**
  46378. * Instantiate the action
  46379. * @param triggerOptions defines the trigger options
  46380. * @param sound defines the sound to play
  46381. * @param condition defines the trigger related conditions
  46382. */
  46383. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46384. /** @hidden */
  46385. _prepare(): void;
  46386. /**
  46387. * Execute the action and play the sound.
  46388. */
  46389. execute(): void;
  46390. /**
  46391. * Serializes the actions and its related information.
  46392. * @param parent defines the object to serialize in
  46393. * @returns the serialized object
  46394. */
  46395. serialize(parent: any): any;
  46396. }
  46397. /**
  46398. * This defines an action helpful to stop a defined sound on a triggered action.
  46399. */
  46400. export class StopSoundAction extends Action {
  46401. private _sound;
  46402. /**
  46403. * Instantiate the action
  46404. * @param triggerOptions defines the trigger options
  46405. * @param sound defines the sound to stop
  46406. * @param condition defines the trigger related conditions
  46407. */
  46408. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46409. /** @hidden */
  46410. _prepare(): void;
  46411. /**
  46412. * Execute the action and stop the sound.
  46413. */
  46414. execute(): void;
  46415. /**
  46416. * Serializes the actions and its related information.
  46417. * @param parent defines the object to serialize in
  46418. * @returns the serialized object
  46419. */
  46420. serialize(parent: any): any;
  46421. }
  46422. }
  46423. declare module "babylonjs/Actions/interpolateValueAction" {
  46424. import { Action } from "babylonjs/Actions/action";
  46425. import { Condition } from "babylonjs/Actions/condition";
  46426. import { Observable } from "babylonjs/Misc/observable";
  46427. /**
  46428. * This defines an action responsible to change the value of a property
  46429. * by interpolating between its current value and the newly set one once triggered.
  46430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46431. */
  46432. export class InterpolateValueAction extends Action {
  46433. /**
  46434. * Defines the path of the property where the value should be interpolated
  46435. */
  46436. propertyPath: string;
  46437. /**
  46438. * Defines the target value at the end of the interpolation.
  46439. */
  46440. value: any;
  46441. /**
  46442. * Defines the time it will take for the property to interpolate to the value.
  46443. */
  46444. duration: number;
  46445. /**
  46446. * Defines if the other scene animations should be stopped when the action has been triggered
  46447. */
  46448. stopOtherAnimations?: boolean;
  46449. /**
  46450. * Defines a callback raised once the interpolation animation has been done.
  46451. */
  46452. onInterpolationDone?: () => void;
  46453. /**
  46454. * Observable triggered once the interpolation animation has been done.
  46455. */
  46456. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46457. private _target;
  46458. private _effectiveTarget;
  46459. private _property;
  46460. /**
  46461. * Instantiate the action
  46462. * @param triggerOptions defines the trigger options
  46463. * @param target defines the object containing the value to interpolate
  46464. * @param propertyPath defines the path to the property in the target object
  46465. * @param value defines the target value at the end of the interpolation
  46466. * @param duration deines the time it will take for the property to interpolate to the value.
  46467. * @param condition defines the trigger related conditions
  46468. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46469. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46470. */
  46471. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46472. /** @hidden */
  46473. _prepare(): void;
  46474. /**
  46475. * Execute the action starts the value interpolation.
  46476. */
  46477. execute(): void;
  46478. /**
  46479. * Serializes the actions and its related information.
  46480. * @param parent defines the object to serialize in
  46481. * @returns the serialized object
  46482. */
  46483. serialize(parent: any): any;
  46484. }
  46485. }
  46486. declare module "babylonjs/Actions/index" {
  46487. export * from "babylonjs/Actions/abstractActionManager";
  46488. export * from "babylonjs/Actions/action";
  46489. export * from "babylonjs/Actions/actionEvent";
  46490. export * from "babylonjs/Actions/actionManager";
  46491. export * from "babylonjs/Actions/condition";
  46492. export * from "babylonjs/Actions/directActions";
  46493. export * from "babylonjs/Actions/directAudioActions";
  46494. export * from "babylonjs/Actions/interpolateValueAction";
  46495. }
  46496. declare module "babylonjs/Animations/index" {
  46497. export * from "babylonjs/Animations/animatable";
  46498. export * from "babylonjs/Animations/animation";
  46499. export * from "babylonjs/Animations/animationGroup";
  46500. export * from "babylonjs/Animations/animationPropertiesOverride";
  46501. export * from "babylonjs/Animations/easing";
  46502. export * from "babylonjs/Animations/runtimeAnimation";
  46503. export * from "babylonjs/Animations/animationEvent";
  46504. export * from "babylonjs/Animations/animationGroup";
  46505. export * from "babylonjs/Animations/animationKey";
  46506. export * from "babylonjs/Animations/animationRange";
  46507. export * from "babylonjs/Animations/animatable.interface";
  46508. }
  46509. declare module "babylonjs/Audio/soundTrack" {
  46510. import { Sound } from "babylonjs/Audio/sound";
  46511. import { Analyser } from "babylonjs/Audio/analyser";
  46512. import { Scene } from "babylonjs/scene";
  46513. /**
  46514. * Options allowed during the creation of a sound track.
  46515. */
  46516. export interface ISoundTrackOptions {
  46517. /**
  46518. * The volume the sound track should take during creation
  46519. */
  46520. volume?: number;
  46521. /**
  46522. * Define if the sound track is the main sound track of the scene
  46523. */
  46524. mainTrack?: boolean;
  46525. }
  46526. /**
  46527. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46528. * It will be also used in a future release to apply effects on a specific track.
  46529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46530. */
  46531. export class SoundTrack {
  46532. /**
  46533. * The unique identifier of the sound track in the scene.
  46534. */
  46535. id: number;
  46536. /**
  46537. * The list of sounds included in the sound track.
  46538. */
  46539. soundCollection: Array<Sound>;
  46540. private _outputAudioNode;
  46541. private _scene;
  46542. private _connectedAnalyser;
  46543. private _options;
  46544. private _isInitialized;
  46545. /**
  46546. * Creates a new sound track.
  46547. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46548. * @param scene Define the scene the sound track belongs to
  46549. * @param options
  46550. */
  46551. constructor(scene: Scene, options?: ISoundTrackOptions);
  46552. private _initializeSoundTrackAudioGraph;
  46553. /**
  46554. * Release the sound track and its associated resources
  46555. */
  46556. dispose(): void;
  46557. /**
  46558. * Adds a sound to this sound track
  46559. * @param sound define the cound to add
  46560. * @ignoreNaming
  46561. */
  46562. AddSound(sound: Sound): void;
  46563. /**
  46564. * Removes a sound to this sound track
  46565. * @param sound define the cound to remove
  46566. * @ignoreNaming
  46567. */
  46568. RemoveSound(sound: Sound): void;
  46569. /**
  46570. * Set a global volume for the full sound track.
  46571. * @param newVolume Define the new volume of the sound track
  46572. */
  46573. setVolume(newVolume: number): void;
  46574. /**
  46575. * Switch the panning model to HRTF:
  46576. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46577. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46578. */
  46579. switchPanningModelToHRTF(): void;
  46580. /**
  46581. * Switch the panning model to Equal Power:
  46582. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46584. */
  46585. switchPanningModelToEqualPower(): void;
  46586. /**
  46587. * Connect the sound track to an audio analyser allowing some amazing
  46588. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46590. * @param analyser The analyser to connect to the engine
  46591. */
  46592. connectToAnalyser(analyser: Analyser): void;
  46593. }
  46594. }
  46595. declare module "babylonjs/Audio/audioSceneComponent" {
  46596. import { Sound } from "babylonjs/Audio/sound";
  46597. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46598. import { Nullable } from "babylonjs/types";
  46599. import { Vector3 } from "babylonjs/Maths/math.vector";
  46600. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46601. import { Scene } from "babylonjs/scene";
  46602. import { AbstractScene } from "babylonjs/abstractScene";
  46603. import "babylonjs/Audio/audioEngine";
  46604. module "babylonjs/abstractScene" {
  46605. interface AbstractScene {
  46606. /**
  46607. * The list of sounds used in the scene.
  46608. */
  46609. sounds: Nullable<Array<Sound>>;
  46610. }
  46611. }
  46612. module "babylonjs/scene" {
  46613. interface Scene {
  46614. /**
  46615. * @hidden
  46616. * Backing field
  46617. */
  46618. _mainSoundTrack: SoundTrack;
  46619. /**
  46620. * The main sound track played by the scene.
  46621. * It cotains your primary collection of sounds.
  46622. */
  46623. mainSoundTrack: SoundTrack;
  46624. /**
  46625. * The list of sound tracks added to the scene
  46626. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46627. */
  46628. soundTracks: Nullable<Array<SoundTrack>>;
  46629. /**
  46630. * Gets a sound using a given name
  46631. * @param name defines the name to search for
  46632. * @return the found sound or null if not found at all.
  46633. */
  46634. getSoundByName(name: string): Nullable<Sound>;
  46635. /**
  46636. * Gets or sets if audio support is enabled
  46637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46638. */
  46639. audioEnabled: boolean;
  46640. /**
  46641. * Gets or sets if audio will be output to headphones
  46642. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46643. */
  46644. headphone: boolean;
  46645. /**
  46646. * Gets or sets custom audio listener position provider
  46647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46648. */
  46649. audioListenerPositionProvider: Nullable<() => Vector3>;
  46650. /**
  46651. * Gets or sets a refresh rate when using 3D audio positioning
  46652. */
  46653. audioPositioningRefreshRate: number;
  46654. }
  46655. }
  46656. /**
  46657. * Defines the sound scene component responsible to manage any sounds
  46658. * in a given scene.
  46659. */
  46660. export class AudioSceneComponent implements ISceneSerializableComponent {
  46661. private static _CameraDirectionLH;
  46662. private static _CameraDirectionRH;
  46663. /**
  46664. * The component name helpfull to identify the component in the list of scene components.
  46665. */
  46666. readonly name: string;
  46667. /**
  46668. * The scene the component belongs to.
  46669. */
  46670. scene: Scene;
  46671. private _audioEnabled;
  46672. /**
  46673. * Gets whether audio is enabled or not.
  46674. * Please use related enable/disable method to switch state.
  46675. */
  46676. get audioEnabled(): boolean;
  46677. private _headphone;
  46678. /**
  46679. * Gets whether audio is outputing to headphone or not.
  46680. * Please use the according Switch methods to change output.
  46681. */
  46682. get headphone(): boolean;
  46683. /**
  46684. * Gets or sets a refresh rate when using 3D audio positioning
  46685. */
  46686. audioPositioningRefreshRate: number;
  46687. private _audioListenerPositionProvider;
  46688. /**
  46689. * Gets the current audio listener position provider
  46690. */
  46691. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46692. /**
  46693. * Sets a custom listener position for all sounds in the scene
  46694. * By default, this is the position of the first active camera
  46695. */
  46696. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46697. /**
  46698. * Creates a new instance of the component for the given scene
  46699. * @param scene Defines the scene to register the component in
  46700. */
  46701. constructor(scene: Scene);
  46702. /**
  46703. * Registers the component in a given scene
  46704. */
  46705. register(): void;
  46706. /**
  46707. * Rebuilds the elements related to this component in case of
  46708. * context lost for instance.
  46709. */
  46710. rebuild(): void;
  46711. /**
  46712. * Serializes the component data to the specified json object
  46713. * @param serializationObject The object to serialize to
  46714. */
  46715. serialize(serializationObject: any): void;
  46716. /**
  46717. * Adds all the elements from the container to the scene
  46718. * @param container the container holding the elements
  46719. */
  46720. addFromContainer(container: AbstractScene): void;
  46721. /**
  46722. * Removes all the elements in the container from the scene
  46723. * @param container contains the elements to remove
  46724. * @param dispose if the removed element should be disposed (default: false)
  46725. */
  46726. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46727. /**
  46728. * Disposes the component and the associated ressources.
  46729. */
  46730. dispose(): void;
  46731. /**
  46732. * Disables audio in the associated scene.
  46733. */
  46734. disableAudio(): void;
  46735. /**
  46736. * Enables audio in the associated scene.
  46737. */
  46738. enableAudio(): void;
  46739. /**
  46740. * Switch audio to headphone output.
  46741. */
  46742. switchAudioModeForHeadphones(): void;
  46743. /**
  46744. * Switch audio to normal speakers.
  46745. */
  46746. switchAudioModeForNormalSpeakers(): void;
  46747. private _cachedCameraDirection;
  46748. private _cachedCameraPosition;
  46749. private _lastCheck;
  46750. private _afterRender;
  46751. }
  46752. }
  46753. declare module "babylonjs/Audio/weightedsound" {
  46754. import { Sound } from "babylonjs/Audio/sound";
  46755. /**
  46756. * Wraps one or more Sound objects and selects one with random weight for playback.
  46757. */
  46758. export class WeightedSound {
  46759. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46760. loop: boolean;
  46761. private _coneInnerAngle;
  46762. private _coneOuterAngle;
  46763. private _volume;
  46764. /** A Sound is currently playing. */
  46765. isPlaying: boolean;
  46766. /** A Sound is currently paused. */
  46767. isPaused: boolean;
  46768. private _sounds;
  46769. private _weights;
  46770. private _currentIndex?;
  46771. /**
  46772. * Creates a new WeightedSound from the list of sounds given.
  46773. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46774. * @param sounds Array of Sounds that will be selected from.
  46775. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46776. */
  46777. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46778. /**
  46779. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46780. */
  46781. get directionalConeInnerAngle(): number;
  46782. /**
  46783. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46784. */
  46785. set directionalConeInnerAngle(value: number);
  46786. /**
  46787. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46788. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46789. */
  46790. get directionalConeOuterAngle(): number;
  46791. /**
  46792. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46793. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46794. */
  46795. set directionalConeOuterAngle(value: number);
  46796. /**
  46797. * Playback volume.
  46798. */
  46799. get volume(): number;
  46800. /**
  46801. * Playback volume.
  46802. */
  46803. set volume(value: number);
  46804. private _onended;
  46805. /**
  46806. * Suspend playback
  46807. */
  46808. pause(): void;
  46809. /**
  46810. * Stop playback
  46811. */
  46812. stop(): void;
  46813. /**
  46814. * Start playback.
  46815. * @param startOffset Position the clip head at a specific time in seconds.
  46816. */
  46817. play(startOffset?: number): void;
  46818. }
  46819. }
  46820. declare module "babylonjs/Audio/index" {
  46821. export * from "babylonjs/Audio/analyser";
  46822. export * from "babylonjs/Audio/audioEngine";
  46823. export * from "babylonjs/Audio/audioSceneComponent";
  46824. export * from "babylonjs/Audio/sound";
  46825. export * from "babylonjs/Audio/soundTrack";
  46826. export * from "babylonjs/Audio/weightedsound";
  46827. }
  46828. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46829. import { Behavior } from "babylonjs/Behaviors/behavior";
  46830. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46831. import { BackEase } from "babylonjs/Animations/easing";
  46832. /**
  46833. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46834. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46835. */
  46836. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46837. /**
  46838. * Gets the name of the behavior.
  46839. */
  46840. get name(): string;
  46841. /**
  46842. * The easing function used by animations
  46843. */
  46844. static EasingFunction: BackEase;
  46845. /**
  46846. * The easing mode used by animations
  46847. */
  46848. static EasingMode: number;
  46849. /**
  46850. * The duration of the animation, in milliseconds
  46851. */
  46852. transitionDuration: number;
  46853. /**
  46854. * Length of the distance animated by the transition when lower radius is reached
  46855. */
  46856. lowerRadiusTransitionRange: number;
  46857. /**
  46858. * Length of the distance animated by the transition when upper radius is reached
  46859. */
  46860. upperRadiusTransitionRange: number;
  46861. private _autoTransitionRange;
  46862. /**
  46863. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46864. */
  46865. get autoTransitionRange(): boolean;
  46866. /**
  46867. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46868. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46869. */
  46870. set autoTransitionRange(value: boolean);
  46871. private _attachedCamera;
  46872. private _onAfterCheckInputsObserver;
  46873. private _onMeshTargetChangedObserver;
  46874. /**
  46875. * Initializes the behavior.
  46876. */
  46877. init(): void;
  46878. /**
  46879. * Attaches the behavior to its arc rotate camera.
  46880. * @param camera Defines the camera to attach the behavior to
  46881. */
  46882. attach(camera: ArcRotateCamera): void;
  46883. /**
  46884. * Detaches the behavior from its current arc rotate camera.
  46885. */
  46886. detach(): void;
  46887. private _radiusIsAnimating;
  46888. private _radiusBounceTransition;
  46889. private _animatables;
  46890. private _cachedWheelPrecision;
  46891. /**
  46892. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46893. * @param radiusLimit The limit to check against.
  46894. * @return Bool to indicate if at limit.
  46895. */
  46896. private _isRadiusAtLimit;
  46897. /**
  46898. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  46899. * @param radiusDelta The delta by which to animate to. Can be negative.
  46900. */
  46901. private _applyBoundRadiusAnimation;
  46902. /**
  46903. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  46904. */
  46905. protected _clearAnimationLocks(): void;
  46906. /**
  46907. * Stops and removes all animations that have been applied to the camera
  46908. */
  46909. stopAllAnimations(): void;
  46910. }
  46911. }
  46912. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  46913. import { Behavior } from "babylonjs/Behaviors/behavior";
  46914. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46915. import { ExponentialEase } from "babylonjs/Animations/easing";
  46916. import { Nullable } from "babylonjs/types";
  46917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46918. import { Vector3 } from "babylonjs/Maths/math.vector";
  46919. /**
  46920. * 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.
  46921. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46922. */
  46923. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  46924. /**
  46925. * Gets the name of the behavior.
  46926. */
  46927. get name(): string;
  46928. private _mode;
  46929. private _radiusScale;
  46930. private _positionScale;
  46931. private _defaultElevation;
  46932. private _elevationReturnTime;
  46933. private _elevationReturnWaitTime;
  46934. private _zoomStopsAnimation;
  46935. private _framingTime;
  46936. /**
  46937. * The easing function used by animations
  46938. */
  46939. static EasingFunction: ExponentialEase;
  46940. /**
  46941. * The easing mode used by animations
  46942. */
  46943. static EasingMode: number;
  46944. /**
  46945. * Sets the current mode used by the behavior
  46946. */
  46947. set mode(mode: number);
  46948. /**
  46949. * Gets current mode used by the behavior.
  46950. */
  46951. get mode(): number;
  46952. /**
  46953. * Sets the scale applied to the radius (1 by default)
  46954. */
  46955. set radiusScale(radius: number);
  46956. /**
  46957. * Gets the scale applied to the radius
  46958. */
  46959. get radiusScale(): number;
  46960. /**
  46961. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46962. */
  46963. set positionScale(scale: number);
  46964. /**
  46965. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46966. */
  46967. get positionScale(): number;
  46968. /**
  46969. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46970. * behaviour is triggered, in radians.
  46971. */
  46972. set defaultElevation(elevation: number);
  46973. /**
  46974. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46975. * behaviour is triggered, in radians.
  46976. */
  46977. get defaultElevation(): number;
  46978. /**
  46979. * Sets the time (in milliseconds) taken to return to the default beta position.
  46980. * Negative value indicates camera should not return to default.
  46981. */
  46982. set elevationReturnTime(speed: number);
  46983. /**
  46984. * Gets the time (in milliseconds) taken to return to the default beta position.
  46985. * Negative value indicates camera should not return to default.
  46986. */
  46987. get elevationReturnTime(): number;
  46988. /**
  46989. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46990. */
  46991. set elevationReturnWaitTime(time: number);
  46992. /**
  46993. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46994. */
  46995. get elevationReturnWaitTime(): number;
  46996. /**
  46997. * Sets the flag that indicates if user zooming should stop animation.
  46998. */
  46999. set zoomStopsAnimation(flag: boolean);
  47000. /**
  47001. * Gets the flag that indicates if user zooming should stop animation.
  47002. */
  47003. get zoomStopsAnimation(): boolean;
  47004. /**
  47005. * Sets the transition time when framing the mesh, in milliseconds
  47006. */
  47007. set framingTime(time: number);
  47008. /**
  47009. * Gets the transition time when framing the mesh, in milliseconds
  47010. */
  47011. get framingTime(): number;
  47012. /**
  47013. * Define if the behavior should automatically change the configured
  47014. * camera limits and sensibilities.
  47015. */
  47016. autoCorrectCameraLimitsAndSensibility: boolean;
  47017. private _onPrePointerObservableObserver;
  47018. private _onAfterCheckInputsObserver;
  47019. private _onMeshTargetChangedObserver;
  47020. private _attachedCamera;
  47021. private _isPointerDown;
  47022. private _lastInteractionTime;
  47023. /**
  47024. * Initializes the behavior.
  47025. */
  47026. init(): void;
  47027. /**
  47028. * Attaches the behavior to its arc rotate camera.
  47029. * @param camera Defines the camera to attach the behavior to
  47030. */
  47031. attach(camera: ArcRotateCamera): void;
  47032. /**
  47033. * Detaches the behavior from its current arc rotate camera.
  47034. */
  47035. detach(): void;
  47036. private _animatables;
  47037. private _betaIsAnimating;
  47038. private _betaTransition;
  47039. private _radiusTransition;
  47040. private _vectorTransition;
  47041. /**
  47042. * Targets the given mesh and updates zoom level accordingly.
  47043. * @param mesh The mesh to target.
  47044. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47045. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47046. */
  47047. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47048. /**
  47049. * Targets the given mesh with its children and updates zoom level accordingly.
  47050. * @param mesh The mesh to target.
  47051. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47052. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47053. */
  47054. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47055. /**
  47056. * Targets the given meshes with their children and updates zoom level accordingly.
  47057. * @param meshes The mesh to target.
  47058. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47059. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47060. */
  47061. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47062. /**
  47063. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47064. * @param minimumWorld Determines the smaller position of the bounding box extend
  47065. * @param maximumWorld Determines the bigger position of the bounding box extend
  47066. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47067. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47068. */
  47069. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47070. /**
  47071. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47072. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47073. * frustum width.
  47074. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47075. * to fully enclose the mesh in the viewing frustum.
  47076. */
  47077. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47078. /**
  47079. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47080. * is automatically returned to its default position (expected to be above ground plane).
  47081. */
  47082. private _maintainCameraAboveGround;
  47083. /**
  47084. * Returns the frustum slope based on the canvas ratio and camera FOV
  47085. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47086. */
  47087. private _getFrustumSlope;
  47088. /**
  47089. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47090. */
  47091. private _clearAnimationLocks;
  47092. /**
  47093. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47094. */
  47095. private _applyUserInteraction;
  47096. /**
  47097. * Stops and removes all animations that have been applied to the camera
  47098. */
  47099. stopAllAnimations(): void;
  47100. /**
  47101. * Gets a value indicating if the user is moving the camera
  47102. */
  47103. get isUserIsMoving(): boolean;
  47104. /**
  47105. * The camera can move all the way towards the mesh.
  47106. */
  47107. static IgnoreBoundsSizeMode: number;
  47108. /**
  47109. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47110. */
  47111. static FitFrustumSidesMode: number;
  47112. }
  47113. }
  47114. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47115. import { Nullable } from "babylonjs/types";
  47116. import { Camera } from "babylonjs/Cameras/camera";
  47117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47118. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47119. /**
  47120. * Base class for Camera Pointer Inputs.
  47121. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47122. * for example usage.
  47123. */
  47124. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47125. /**
  47126. * Defines the camera the input is attached to.
  47127. */
  47128. abstract camera: Camera;
  47129. /**
  47130. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47131. */
  47132. protected _altKey: boolean;
  47133. protected _ctrlKey: boolean;
  47134. protected _metaKey: boolean;
  47135. protected _shiftKey: boolean;
  47136. /**
  47137. * Which mouse buttons were pressed at time of last mouse event.
  47138. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47139. */
  47140. protected _buttonsPressed: number;
  47141. /**
  47142. * Defines the buttons associated with the input to handle camera move.
  47143. */
  47144. buttons: number[];
  47145. /**
  47146. * Attach the input controls to a specific dom element to get the input from.
  47147. * @param element Defines the element the controls should be listened from
  47148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47149. */
  47150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47151. /**
  47152. * Detach the current controls from the specified dom element.
  47153. * @param element Defines the element to stop listening the inputs from
  47154. */
  47155. detachControl(element: Nullable<HTMLElement>): void;
  47156. /**
  47157. * Gets the class name of the current input.
  47158. * @returns the class name
  47159. */
  47160. getClassName(): string;
  47161. /**
  47162. * Get the friendly name associated with the input class.
  47163. * @returns the input friendly name
  47164. */
  47165. getSimpleName(): string;
  47166. /**
  47167. * Called on pointer POINTERDOUBLETAP event.
  47168. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47169. */
  47170. protected onDoubleTap(type: string): void;
  47171. /**
  47172. * Called on pointer POINTERMOVE event if only a single touch is active.
  47173. * Override this method to provide functionality.
  47174. */
  47175. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47176. /**
  47177. * Called on pointer POINTERMOVE event if multiple touches are active.
  47178. * Override this method to provide functionality.
  47179. */
  47180. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47181. /**
  47182. * Called on JS contextmenu event.
  47183. * Override this method to provide functionality.
  47184. */
  47185. protected onContextMenu(evt: PointerEvent): void;
  47186. /**
  47187. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47188. * press.
  47189. * Override this method to provide functionality.
  47190. */
  47191. protected onButtonDown(evt: PointerEvent): void;
  47192. /**
  47193. * Called each time a new POINTERUP event occurs. Ie, for each button
  47194. * release.
  47195. * Override this method to provide functionality.
  47196. */
  47197. protected onButtonUp(evt: PointerEvent): void;
  47198. /**
  47199. * Called when window becomes inactive.
  47200. * Override this method to provide functionality.
  47201. */
  47202. protected onLostFocus(): void;
  47203. private _pointerInput;
  47204. private _observer;
  47205. private _onLostFocus;
  47206. private pointA;
  47207. private pointB;
  47208. }
  47209. }
  47210. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47211. import { Nullable } from "babylonjs/types";
  47212. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47213. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47214. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47215. /**
  47216. * Manage the pointers inputs to control an arc rotate camera.
  47217. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47218. */
  47219. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47220. /**
  47221. * Defines the camera the input is attached to.
  47222. */
  47223. camera: ArcRotateCamera;
  47224. /**
  47225. * Gets the class name of the current input.
  47226. * @returns the class name
  47227. */
  47228. getClassName(): string;
  47229. /**
  47230. * Defines the buttons associated with the input to handle camera move.
  47231. */
  47232. buttons: number[];
  47233. /**
  47234. * Defines the pointer angular sensibility along the X axis or how fast is
  47235. * the camera rotating.
  47236. */
  47237. angularSensibilityX: number;
  47238. /**
  47239. * Defines the pointer angular sensibility along the Y axis or how fast is
  47240. * the camera rotating.
  47241. */
  47242. angularSensibilityY: number;
  47243. /**
  47244. * Defines the pointer pinch precision or how fast is the camera zooming.
  47245. */
  47246. pinchPrecision: number;
  47247. /**
  47248. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47249. * from 0.
  47250. * It defines the percentage of current camera.radius to use as delta when
  47251. * pinch zoom is used.
  47252. */
  47253. pinchDeltaPercentage: number;
  47254. /**
  47255. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47256. * that any object in the plane at the camera's target point will scale
  47257. * perfectly with finger motion.
  47258. * Overrides pinchDeltaPercentage and pinchPrecision.
  47259. */
  47260. useNaturalPinchZoom: boolean;
  47261. /**
  47262. * Defines the pointer panning sensibility or how fast is the camera moving.
  47263. */
  47264. panningSensibility: number;
  47265. /**
  47266. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47267. */
  47268. multiTouchPanning: boolean;
  47269. /**
  47270. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47271. * zoom (pinch) through multitouch.
  47272. */
  47273. multiTouchPanAndZoom: boolean;
  47274. /**
  47275. * Revers pinch action direction.
  47276. */
  47277. pinchInwards: boolean;
  47278. private _isPanClick;
  47279. private _twoFingerActivityCount;
  47280. private _isPinching;
  47281. /**
  47282. * Called on pointer POINTERMOVE event if only a single touch is active.
  47283. */
  47284. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47285. /**
  47286. * Called on pointer POINTERDOUBLETAP event.
  47287. */
  47288. protected onDoubleTap(type: string): void;
  47289. /**
  47290. * Called on pointer POINTERMOVE event if multiple touches are active.
  47291. */
  47292. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47293. /**
  47294. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47295. * press.
  47296. */
  47297. protected onButtonDown(evt: PointerEvent): void;
  47298. /**
  47299. * Called each time a new POINTERUP event occurs. Ie, for each button
  47300. * release.
  47301. */
  47302. protected onButtonUp(evt: PointerEvent): void;
  47303. /**
  47304. * Called when window becomes inactive.
  47305. */
  47306. protected onLostFocus(): void;
  47307. }
  47308. }
  47309. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47310. import { Nullable } from "babylonjs/types";
  47311. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47313. /**
  47314. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47315. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47316. */
  47317. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47318. /**
  47319. * Defines the camera the input is attached to.
  47320. */
  47321. camera: ArcRotateCamera;
  47322. /**
  47323. * Defines the list of key codes associated with the up action (increase alpha)
  47324. */
  47325. keysUp: number[];
  47326. /**
  47327. * Defines the list of key codes associated with the down action (decrease alpha)
  47328. */
  47329. keysDown: number[];
  47330. /**
  47331. * Defines the list of key codes associated with the left action (increase beta)
  47332. */
  47333. keysLeft: number[];
  47334. /**
  47335. * Defines the list of key codes associated with the right action (decrease beta)
  47336. */
  47337. keysRight: number[];
  47338. /**
  47339. * Defines the list of key codes associated with the reset action.
  47340. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47341. */
  47342. keysReset: number[];
  47343. /**
  47344. * Defines the panning sensibility of the inputs.
  47345. * (How fast is the camera panning)
  47346. */
  47347. panningSensibility: number;
  47348. /**
  47349. * Defines the zooming sensibility of the inputs.
  47350. * (How fast is the camera zooming)
  47351. */
  47352. zoomingSensibility: number;
  47353. /**
  47354. * Defines whether maintaining the alt key down switch the movement mode from
  47355. * orientation to zoom.
  47356. */
  47357. useAltToZoom: boolean;
  47358. /**
  47359. * Rotation speed of the camera
  47360. */
  47361. angularSpeed: number;
  47362. private _keys;
  47363. private _ctrlPressed;
  47364. private _altPressed;
  47365. private _onCanvasBlurObserver;
  47366. private _onKeyboardObserver;
  47367. private _engine;
  47368. private _scene;
  47369. /**
  47370. * Attach the input controls to a specific dom element to get the input from.
  47371. * @param element Defines the element the controls should be listened from
  47372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47373. */
  47374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47375. /**
  47376. * Detach the current controls from the specified dom element.
  47377. * @param element Defines the element to stop listening the inputs from
  47378. */
  47379. detachControl(element: Nullable<HTMLElement>): void;
  47380. /**
  47381. * Update the current camera state depending on the inputs that have been used this frame.
  47382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47383. */
  47384. checkInputs(): void;
  47385. /**
  47386. * Gets the class name of the current intput.
  47387. * @returns the class name
  47388. */
  47389. getClassName(): string;
  47390. /**
  47391. * Get the friendly name associated with the input class.
  47392. * @returns the input friendly name
  47393. */
  47394. getSimpleName(): string;
  47395. }
  47396. }
  47397. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47398. import { Nullable } from "babylonjs/types";
  47399. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47401. /**
  47402. * Manage the mouse wheel inputs to control an arc rotate camera.
  47403. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47404. */
  47405. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47406. /**
  47407. * Defines the camera the input is attached to.
  47408. */
  47409. camera: ArcRotateCamera;
  47410. /**
  47411. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47412. */
  47413. wheelPrecision: number;
  47414. /**
  47415. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47416. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47417. */
  47418. wheelDeltaPercentage: number;
  47419. private _wheel;
  47420. private _observer;
  47421. private computeDeltaFromMouseWheelLegacyEvent;
  47422. /**
  47423. * Attach the input controls to a specific dom element to get the input from.
  47424. * @param element Defines the element the controls should be listened from
  47425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47426. */
  47427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47428. /**
  47429. * Detach the current controls from the specified dom element.
  47430. * @param element Defines the element to stop listening the inputs from
  47431. */
  47432. detachControl(element: Nullable<HTMLElement>): void;
  47433. /**
  47434. * Gets the class name of the current intput.
  47435. * @returns the class name
  47436. */
  47437. getClassName(): string;
  47438. /**
  47439. * Get the friendly name associated with the input class.
  47440. * @returns the input friendly name
  47441. */
  47442. getSimpleName(): string;
  47443. }
  47444. }
  47445. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47446. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47447. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47448. /**
  47449. * Default Inputs manager for the ArcRotateCamera.
  47450. * It groups all the default supported inputs for ease of use.
  47451. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47452. */
  47453. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47454. /**
  47455. * Instantiates a new ArcRotateCameraInputsManager.
  47456. * @param camera Defines the camera the inputs belong to
  47457. */
  47458. constructor(camera: ArcRotateCamera);
  47459. /**
  47460. * Add mouse wheel input support to the input manager.
  47461. * @returns the current input manager
  47462. */
  47463. addMouseWheel(): ArcRotateCameraInputsManager;
  47464. /**
  47465. * Add pointers input support to the input manager.
  47466. * @returns the current input manager
  47467. */
  47468. addPointers(): ArcRotateCameraInputsManager;
  47469. /**
  47470. * Add keyboard input support to the input manager.
  47471. * @returns the current input manager
  47472. */
  47473. addKeyboard(): ArcRotateCameraInputsManager;
  47474. }
  47475. }
  47476. declare module "babylonjs/Cameras/arcRotateCamera" {
  47477. import { Observable } from "babylonjs/Misc/observable";
  47478. import { Nullable } from "babylonjs/types";
  47479. import { Scene } from "babylonjs/scene";
  47480. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47482. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47483. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47484. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47485. import { Camera } from "babylonjs/Cameras/camera";
  47486. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47487. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47488. import { Collider } from "babylonjs/Collisions/collider";
  47489. /**
  47490. * This represents an orbital type of camera.
  47491. *
  47492. * 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.
  47493. * 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.
  47494. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47495. */
  47496. export class ArcRotateCamera extends TargetCamera {
  47497. /**
  47498. * Defines the rotation angle of the camera along the longitudinal axis.
  47499. */
  47500. alpha: number;
  47501. /**
  47502. * Defines the rotation angle of the camera along the latitudinal axis.
  47503. */
  47504. beta: number;
  47505. /**
  47506. * Defines the radius of the camera from it s target point.
  47507. */
  47508. radius: number;
  47509. protected _target: Vector3;
  47510. protected _targetHost: Nullable<AbstractMesh>;
  47511. /**
  47512. * Defines the target point of the camera.
  47513. * The camera looks towards it form the radius distance.
  47514. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47515. */
  47516. get target(): Vector3;
  47517. set target(value: Vector3);
  47518. /**
  47519. * Define the current local position of the camera in the scene
  47520. */
  47521. get position(): Vector3;
  47522. set position(newPosition: Vector3);
  47523. protected _upToYMatrix: Matrix;
  47524. protected _YToUpMatrix: Matrix;
  47525. /**
  47526. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47527. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47528. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47529. */
  47530. set upVector(vec: Vector3);
  47531. get upVector(): Vector3;
  47532. /**
  47533. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47534. */
  47535. setMatUp(): void;
  47536. /**
  47537. * Current inertia value on the longitudinal axis.
  47538. * The bigger this number the longer it will take for the camera to stop.
  47539. */
  47540. inertialAlphaOffset: number;
  47541. /**
  47542. * Current inertia value on the latitudinal axis.
  47543. * The bigger this number the longer it will take for the camera to stop.
  47544. */
  47545. inertialBetaOffset: number;
  47546. /**
  47547. * Current inertia value on the radius axis.
  47548. * The bigger this number the longer it will take for the camera to stop.
  47549. */
  47550. inertialRadiusOffset: number;
  47551. /**
  47552. * Minimum allowed angle on the longitudinal axis.
  47553. * This can help limiting how the Camera is able to move in the scene.
  47554. */
  47555. lowerAlphaLimit: Nullable<number>;
  47556. /**
  47557. * Maximum allowed angle on the longitudinal axis.
  47558. * This can help limiting how the Camera is able to move in the scene.
  47559. */
  47560. upperAlphaLimit: Nullable<number>;
  47561. /**
  47562. * Minimum allowed angle on the latitudinal axis.
  47563. * This can help limiting how the Camera is able to move in the scene.
  47564. */
  47565. lowerBetaLimit: number;
  47566. /**
  47567. * Maximum allowed angle on the latitudinal axis.
  47568. * This can help limiting how the Camera is able to move in the scene.
  47569. */
  47570. upperBetaLimit: number;
  47571. /**
  47572. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47573. * This can help limiting how the Camera is able to move in the scene.
  47574. */
  47575. lowerRadiusLimit: Nullable<number>;
  47576. /**
  47577. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47578. * This can help limiting how the Camera is able to move in the scene.
  47579. */
  47580. upperRadiusLimit: Nullable<number>;
  47581. /**
  47582. * Defines the current inertia value used during panning of the camera along the X axis.
  47583. */
  47584. inertialPanningX: number;
  47585. /**
  47586. * Defines the current inertia value used during panning of the camera along the Y axis.
  47587. */
  47588. inertialPanningY: number;
  47589. /**
  47590. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47591. * Basically if your fingers moves away from more than this distance you will be considered
  47592. * in pinch mode.
  47593. */
  47594. pinchToPanMaxDistance: number;
  47595. /**
  47596. * Defines the maximum distance the camera can pan.
  47597. * This could help keeping the cammera always in your scene.
  47598. */
  47599. panningDistanceLimit: Nullable<number>;
  47600. /**
  47601. * Defines the target of the camera before paning.
  47602. */
  47603. panningOriginTarget: Vector3;
  47604. /**
  47605. * Defines the value of the inertia used during panning.
  47606. * 0 would mean stop inertia and one would mean no decelleration at all.
  47607. */
  47608. panningInertia: number;
  47609. /**
  47610. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47611. */
  47612. get angularSensibilityX(): number;
  47613. set angularSensibilityX(value: number);
  47614. /**
  47615. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47616. */
  47617. get angularSensibilityY(): number;
  47618. set angularSensibilityY(value: number);
  47619. /**
  47620. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47621. */
  47622. get pinchPrecision(): number;
  47623. set pinchPrecision(value: number);
  47624. /**
  47625. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47626. * It will be used instead of pinchDeltaPrecision if different from 0.
  47627. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47628. */
  47629. get pinchDeltaPercentage(): number;
  47630. set pinchDeltaPercentage(value: number);
  47631. /**
  47632. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47633. * and pinch delta percentage.
  47634. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47635. * that any object in the plane at the camera's target point will scale
  47636. * perfectly with finger motion.
  47637. */
  47638. get useNaturalPinchZoom(): boolean;
  47639. set useNaturalPinchZoom(value: boolean);
  47640. /**
  47641. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47642. */
  47643. get panningSensibility(): number;
  47644. set panningSensibility(value: number);
  47645. /**
  47646. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47647. */
  47648. get keysUp(): number[];
  47649. set keysUp(value: number[]);
  47650. /**
  47651. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47652. */
  47653. get keysDown(): number[];
  47654. set keysDown(value: number[]);
  47655. /**
  47656. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47657. */
  47658. get keysLeft(): number[];
  47659. set keysLeft(value: number[]);
  47660. /**
  47661. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47662. */
  47663. get keysRight(): number[];
  47664. set keysRight(value: number[]);
  47665. /**
  47666. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47667. */
  47668. get wheelPrecision(): number;
  47669. set wheelPrecision(value: number);
  47670. /**
  47671. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47672. * It will be used instead of pinchDeltaPrecision if different from 0.
  47673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47674. */
  47675. get wheelDeltaPercentage(): number;
  47676. set wheelDeltaPercentage(value: number);
  47677. /**
  47678. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47679. */
  47680. zoomOnFactor: number;
  47681. /**
  47682. * Defines a screen offset for the camera position.
  47683. */
  47684. targetScreenOffset: Vector2;
  47685. /**
  47686. * Allows the camera to be completely reversed.
  47687. * If false the camera can not arrive upside down.
  47688. */
  47689. allowUpsideDown: boolean;
  47690. /**
  47691. * Define if double tap/click is used to restore the previously saved state of the camera.
  47692. */
  47693. useInputToRestoreState: boolean;
  47694. /** @hidden */
  47695. _viewMatrix: Matrix;
  47696. /** @hidden */
  47697. _useCtrlForPanning: boolean;
  47698. /** @hidden */
  47699. _panningMouseButton: number;
  47700. /**
  47701. * Defines the input associated to the camera.
  47702. */
  47703. inputs: ArcRotateCameraInputsManager;
  47704. /** @hidden */
  47705. _reset: () => void;
  47706. /**
  47707. * Defines the allowed panning axis.
  47708. */
  47709. panningAxis: Vector3;
  47710. protected _localDirection: Vector3;
  47711. protected _transformedDirection: Vector3;
  47712. private _bouncingBehavior;
  47713. /**
  47714. * Gets the bouncing behavior of the camera if it has been enabled.
  47715. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47716. */
  47717. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47718. /**
  47719. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47720. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47721. */
  47722. get useBouncingBehavior(): boolean;
  47723. set useBouncingBehavior(value: boolean);
  47724. private _framingBehavior;
  47725. /**
  47726. * Gets the framing behavior of the camera if it has been enabled.
  47727. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47728. */
  47729. get framingBehavior(): Nullable<FramingBehavior>;
  47730. /**
  47731. * Defines if the framing behavior of the camera is enabled on the camera.
  47732. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47733. */
  47734. get useFramingBehavior(): boolean;
  47735. set useFramingBehavior(value: boolean);
  47736. private _autoRotationBehavior;
  47737. /**
  47738. * Gets the auto rotation behavior of the camera if it has been enabled.
  47739. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47740. */
  47741. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47742. /**
  47743. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47744. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47745. */
  47746. get useAutoRotationBehavior(): boolean;
  47747. set useAutoRotationBehavior(value: boolean);
  47748. /**
  47749. * Observable triggered when the mesh target has been changed on the camera.
  47750. */
  47751. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47752. /**
  47753. * Event raised when the camera is colliding with a mesh.
  47754. */
  47755. onCollide: (collidedMesh: AbstractMesh) => void;
  47756. /**
  47757. * Defines whether the camera should check collision with the objects oh the scene.
  47758. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47759. */
  47760. checkCollisions: boolean;
  47761. /**
  47762. * Defines the collision radius of the camera.
  47763. * This simulates a sphere around the camera.
  47764. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47765. */
  47766. collisionRadius: Vector3;
  47767. protected _collider: Collider;
  47768. protected _previousPosition: Vector3;
  47769. protected _collisionVelocity: Vector3;
  47770. protected _newPosition: Vector3;
  47771. protected _previousAlpha: number;
  47772. protected _previousBeta: number;
  47773. protected _previousRadius: number;
  47774. protected _collisionTriggered: boolean;
  47775. protected _targetBoundingCenter: Nullable<Vector3>;
  47776. private _computationVector;
  47777. /**
  47778. * Instantiates a new ArcRotateCamera in a given scene
  47779. * @param name Defines the name of the camera
  47780. * @param alpha Defines the camera rotation along the logitudinal axis
  47781. * @param beta Defines the camera rotation along the latitudinal axis
  47782. * @param radius Defines the camera distance from its target
  47783. * @param target Defines the camera target
  47784. * @param scene Defines the scene the camera belongs to
  47785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47786. */
  47787. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47788. /** @hidden */
  47789. _initCache(): void;
  47790. /** @hidden */
  47791. _updateCache(ignoreParentClass?: boolean): void;
  47792. protected _getTargetPosition(): Vector3;
  47793. private _storedAlpha;
  47794. private _storedBeta;
  47795. private _storedRadius;
  47796. private _storedTarget;
  47797. private _storedTargetScreenOffset;
  47798. /**
  47799. * Stores the current state of the camera (alpha, beta, radius and target)
  47800. * @returns the camera itself
  47801. */
  47802. storeState(): Camera;
  47803. /**
  47804. * @hidden
  47805. * Restored camera state. You must call storeState() first
  47806. */
  47807. _restoreStateValues(): boolean;
  47808. /** @hidden */
  47809. _isSynchronizedViewMatrix(): boolean;
  47810. /**
  47811. * Attached controls to the current camera.
  47812. * @param element Defines the element the controls should be listened from
  47813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47814. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47815. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47816. */
  47817. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47818. /**
  47819. * Detach the current controls from the camera.
  47820. * The camera will stop reacting to inputs.
  47821. * @param element Defines the element to stop listening the inputs from
  47822. */
  47823. detachControl(element: HTMLElement): void;
  47824. /** @hidden */
  47825. _checkInputs(): void;
  47826. protected _checkLimits(): void;
  47827. /**
  47828. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47829. */
  47830. rebuildAnglesAndRadius(): void;
  47831. /**
  47832. * Use a position to define the current camera related information like alpha, beta and radius
  47833. * @param position Defines the position to set the camera at
  47834. */
  47835. setPosition(position: Vector3): void;
  47836. /**
  47837. * Defines the target the camera should look at.
  47838. * This will automatically adapt alpha beta and radius to fit within the new target.
  47839. * @param target Defines the new target as a Vector or a mesh
  47840. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47841. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47842. */
  47843. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47844. /** @hidden */
  47845. _getViewMatrix(): Matrix;
  47846. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47847. /**
  47848. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47849. * @param meshes Defines the mesh to zoom on
  47850. * @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)
  47851. */
  47852. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47853. /**
  47854. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47855. * The target will be changed but the radius
  47856. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47857. * @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)
  47858. */
  47859. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47860. min: Vector3;
  47861. max: Vector3;
  47862. distance: number;
  47863. }, doNotUpdateMaxZ?: boolean): void;
  47864. /**
  47865. * @override
  47866. * Override Camera.createRigCamera
  47867. */
  47868. createRigCamera(name: string, cameraIndex: number): Camera;
  47869. /**
  47870. * @hidden
  47871. * @override
  47872. * Override Camera._updateRigCameras
  47873. */
  47874. _updateRigCameras(): void;
  47875. /**
  47876. * Destroy the camera and release the current resources hold by it.
  47877. */
  47878. dispose(): void;
  47879. /**
  47880. * Gets the current object class name.
  47881. * @return the class name
  47882. */
  47883. getClassName(): string;
  47884. }
  47885. }
  47886. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47887. import { Behavior } from "babylonjs/Behaviors/behavior";
  47888. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47889. /**
  47890. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47891. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47892. */
  47893. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47894. /**
  47895. * Gets the name of the behavior.
  47896. */
  47897. get name(): string;
  47898. private _zoomStopsAnimation;
  47899. private _idleRotationSpeed;
  47900. private _idleRotationWaitTime;
  47901. private _idleRotationSpinupTime;
  47902. /**
  47903. * Sets the flag that indicates if user zooming should stop animation.
  47904. */
  47905. set zoomStopsAnimation(flag: boolean);
  47906. /**
  47907. * Gets the flag that indicates if user zooming should stop animation.
  47908. */
  47909. get zoomStopsAnimation(): boolean;
  47910. /**
  47911. * Sets the default speed at which the camera rotates around the model.
  47912. */
  47913. set idleRotationSpeed(speed: number);
  47914. /**
  47915. * Gets the default speed at which the camera rotates around the model.
  47916. */
  47917. get idleRotationSpeed(): number;
  47918. /**
  47919. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  47920. */
  47921. set idleRotationWaitTime(time: number);
  47922. /**
  47923. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  47924. */
  47925. get idleRotationWaitTime(): number;
  47926. /**
  47927. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47928. */
  47929. set idleRotationSpinupTime(time: number);
  47930. /**
  47931. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47932. */
  47933. get idleRotationSpinupTime(): number;
  47934. /**
  47935. * Gets a value indicating if the camera is currently rotating because of this behavior
  47936. */
  47937. get rotationInProgress(): boolean;
  47938. private _onPrePointerObservableObserver;
  47939. private _onAfterCheckInputsObserver;
  47940. private _attachedCamera;
  47941. private _isPointerDown;
  47942. private _lastFrameTime;
  47943. private _lastInteractionTime;
  47944. private _cameraRotationSpeed;
  47945. /**
  47946. * Initializes the behavior.
  47947. */
  47948. init(): void;
  47949. /**
  47950. * Attaches the behavior to its arc rotate camera.
  47951. * @param camera Defines the camera to attach the behavior to
  47952. */
  47953. attach(camera: ArcRotateCamera): void;
  47954. /**
  47955. * Detaches the behavior from its current arc rotate camera.
  47956. */
  47957. detach(): void;
  47958. /**
  47959. * Returns true if user is scrolling.
  47960. * @return true if user is scrolling.
  47961. */
  47962. private _userIsZooming;
  47963. private _lastFrameRadius;
  47964. private _shouldAnimationStopForInteraction;
  47965. /**
  47966. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47967. */
  47968. private _applyUserInteraction;
  47969. private _userIsMoving;
  47970. }
  47971. }
  47972. declare module "babylonjs/Behaviors/Cameras/index" {
  47973. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47974. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47975. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  47976. }
  47977. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  47978. import { Mesh } from "babylonjs/Meshes/mesh";
  47979. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47980. import { Behavior } from "babylonjs/Behaviors/behavior";
  47981. /**
  47982. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47983. */
  47984. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47985. private ui;
  47986. /**
  47987. * The name of the behavior
  47988. */
  47989. name: string;
  47990. /**
  47991. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47992. */
  47993. distanceAwayFromFace: number;
  47994. /**
  47995. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47996. */
  47997. distanceAwayFromBottomOfFace: number;
  47998. private _faceVectors;
  47999. private _target;
  48000. private _scene;
  48001. private _onRenderObserver;
  48002. private _tmpMatrix;
  48003. private _tmpVector;
  48004. /**
  48005. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48006. * @param ui The transform node that should be attched to the mesh
  48007. */
  48008. constructor(ui: TransformNode);
  48009. /**
  48010. * Initializes the behavior
  48011. */
  48012. init(): void;
  48013. private _closestFace;
  48014. private _zeroVector;
  48015. private _lookAtTmpMatrix;
  48016. private _lookAtToRef;
  48017. /**
  48018. * Attaches the AttachToBoxBehavior to the passed in mesh
  48019. * @param target The mesh that the specified node will be attached to
  48020. */
  48021. attach(target: Mesh): void;
  48022. /**
  48023. * Detaches the behavior from the mesh
  48024. */
  48025. detach(): void;
  48026. }
  48027. }
  48028. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48029. import { Behavior } from "babylonjs/Behaviors/behavior";
  48030. import { Mesh } from "babylonjs/Meshes/mesh";
  48031. /**
  48032. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48033. */
  48034. export class FadeInOutBehavior implements Behavior<Mesh> {
  48035. /**
  48036. * Time in milliseconds to delay before fading in (Default: 0)
  48037. */
  48038. delay: number;
  48039. /**
  48040. * Time in milliseconds for the mesh to fade in (Default: 300)
  48041. */
  48042. fadeInTime: number;
  48043. private _millisecondsPerFrame;
  48044. private _hovered;
  48045. private _hoverValue;
  48046. private _ownerNode;
  48047. /**
  48048. * Instatiates the FadeInOutBehavior
  48049. */
  48050. constructor();
  48051. /**
  48052. * The name of the behavior
  48053. */
  48054. get name(): string;
  48055. /**
  48056. * Initializes the behavior
  48057. */
  48058. init(): void;
  48059. /**
  48060. * Attaches the fade behavior on the passed in mesh
  48061. * @param ownerNode The mesh that will be faded in/out once attached
  48062. */
  48063. attach(ownerNode: Mesh): void;
  48064. /**
  48065. * Detaches the behavior from the mesh
  48066. */
  48067. detach(): void;
  48068. /**
  48069. * Triggers the mesh to begin fading in or out
  48070. * @param value if the object should fade in or out (true to fade in)
  48071. */
  48072. fadeIn(value: boolean): void;
  48073. private _update;
  48074. private _setAllVisibility;
  48075. }
  48076. }
  48077. declare module "babylonjs/Misc/pivotTools" {
  48078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48079. /**
  48080. * Class containing a set of static utilities functions for managing Pivots
  48081. * @hidden
  48082. */
  48083. export class PivotTools {
  48084. private static _PivotCached;
  48085. private static _OldPivotPoint;
  48086. private static _PivotTranslation;
  48087. private static _PivotTmpVector;
  48088. private static _PivotPostMultiplyPivotMatrix;
  48089. /** @hidden */
  48090. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48091. /** @hidden */
  48092. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48093. }
  48094. }
  48095. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48096. import { Scene } from "babylonjs/scene";
  48097. import { Vector4 } from "babylonjs/Maths/math.vector";
  48098. import { Mesh } from "babylonjs/Meshes/mesh";
  48099. import { Nullable } from "babylonjs/types";
  48100. import { Plane } from "babylonjs/Maths/math.plane";
  48101. /**
  48102. * Class containing static functions to help procedurally build meshes
  48103. */
  48104. export class PlaneBuilder {
  48105. /**
  48106. * Creates a plane mesh
  48107. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48108. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48109. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48113. * @param name defines the name of the mesh
  48114. * @param options defines the options used to create the mesh
  48115. * @param scene defines the hosting scene
  48116. * @returns the plane mesh
  48117. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48118. */
  48119. static CreatePlane(name: string, options: {
  48120. size?: number;
  48121. width?: number;
  48122. height?: number;
  48123. sideOrientation?: number;
  48124. frontUVs?: Vector4;
  48125. backUVs?: Vector4;
  48126. updatable?: boolean;
  48127. sourcePlane?: Plane;
  48128. }, scene?: Nullable<Scene>): Mesh;
  48129. }
  48130. }
  48131. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48132. import { Behavior } from "babylonjs/Behaviors/behavior";
  48133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48134. import { Observable } from "babylonjs/Misc/observable";
  48135. import { Vector3 } from "babylonjs/Maths/math.vector";
  48136. import { Ray } from "babylonjs/Culling/ray";
  48137. import "babylonjs/Meshes/Builders/planeBuilder";
  48138. /**
  48139. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48140. */
  48141. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48142. private static _AnyMouseID;
  48143. /**
  48144. * Abstract mesh the behavior is set on
  48145. */
  48146. attachedNode: AbstractMesh;
  48147. private _dragPlane;
  48148. private _scene;
  48149. private _pointerObserver;
  48150. private _beforeRenderObserver;
  48151. private static _planeScene;
  48152. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48153. /**
  48154. * 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)
  48155. */
  48156. maxDragAngle: number;
  48157. /**
  48158. * @hidden
  48159. */
  48160. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48161. /**
  48162. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48163. */
  48164. currentDraggingPointerID: number;
  48165. /**
  48166. * The last position where the pointer hit the drag plane in world space
  48167. */
  48168. lastDragPosition: Vector3;
  48169. /**
  48170. * If the behavior is currently in a dragging state
  48171. */
  48172. dragging: boolean;
  48173. /**
  48174. * 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)
  48175. */
  48176. dragDeltaRatio: number;
  48177. /**
  48178. * If the drag plane orientation should be updated during the dragging (Default: true)
  48179. */
  48180. updateDragPlane: boolean;
  48181. private _debugMode;
  48182. private _moving;
  48183. /**
  48184. * Fires each time the attached mesh is dragged with the pointer
  48185. * * delta between last drag position and current drag position in world space
  48186. * * dragDistance along the drag axis
  48187. * * dragPlaneNormal normal of the current drag plane used during the drag
  48188. * * dragPlanePoint in world space where the drag intersects the drag plane
  48189. */
  48190. onDragObservable: Observable<{
  48191. delta: Vector3;
  48192. dragPlanePoint: Vector3;
  48193. dragPlaneNormal: Vector3;
  48194. dragDistance: number;
  48195. pointerId: number;
  48196. }>;
  48197. /**
  48198. * Fires each time a drag begins (eg. mouse down on mesh)
  48199. */
  48200. onDragStartObservable: Observable<{
  48201. dragPlanePoint: Vector3;
  48202. pointerId: number;
  48203. }>;
  48204. /**
  48205. * Fires each time a drag ends (eg. mouse release after drag)
  48206. */
  48207. onDragEndObservable: Observable<{
  48208. dragPlanePoint: Vector3;
  48209. pointerId: number;
  48210. }>;
  48211. /**
  48212. * If the attached mesh should be moved when dragged
  48213. */
  48214. moveAttached: boolean;
  48215. /**
  48216. * If the drag behavior will react to drag events (Default: true)
  48217. */
  48218. enabled: boolean;
  48219. /**
  48220. * If pointer events should start and release the drag (Default: true)
  48221. */
  48222. startAndReleaseDragOnPointerEvents: boolean;
  48223. /**
  48224. * If camera controls should be detached during the drag
  48225. */
  48226. detachCameraControls: boolean;
  48227. /**
  48228. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48229. */
  48230. useObjectOrientationForDragging: boolean;
  48231. private _options;
  48232. /**
  48233. * Gets the options used by the behavior
  48234. */
  48235. get options(): {
  48236. dragAxis?: Vector3;
  48237. dragPlaneNormal?: Vector3;
  48238. };
  48239. /**
  48240. * Sets the options used by the behavior
  48241. */
  48242. set options(options: {
  48243. dragAxis?: Vector3;
  48244. dragPlaneNormal?: Vector3;
  48245. });
  48246. /**
  48247. * Creates a pointer drag behavior that can be attached to a mesh
  48248. * @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)
  48249. */
  48250. constructor(options?: {
  48251. dragAxis?: Vector3;
  48252. dragPlaneNormal?: Vector3;
  48253. });
  48254. /**
  48255. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48256. */
  48257. validateDrag: (targetPosition: Vector3) => boolean;
  48258. /**
  48259. * The name of the behavior
  48260. */
  48261. get name(): string;
  48262. /**
  48263. * Initializes the behavior
  48264. */
  48265. init(): void;
  48266. private _tmpVector;
  48267. private _alternatePickedPoint;
  48268. private _worldDragAxis;
  48269. private _targetPosition;
  48270. private _attachedElement;
  48271. /**
  48272. * Attaches the drag behavior the passed in mesh
  48273. * @param ownerNode The mesh that will be dragged around once attached
  48274. * @param predicate Predicate to use for pick filtering
  48275. */
  48276. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48277. /**
  48278. * Force relase the drag action by code.
  48279. */
  48280. releaseDrag(): void;
  48281. private _startDragRay;
  48282. private _lastPointerRay;
  48283. /**
  48284. * Simulates the start of a pointer drag event on the behavior
  48285. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48286. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48287. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48288. */
  48289. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48290. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48291. private _dragDelta;
  48292. protected _moveDrag(ray: Ray): void;
  48293. private _pickWithRayOnDragPlane;
  48294. private _pointA;
  48295. private _pointC;
  48296. private _localAxis;
  48297. private _lookAt;
  48298. private _updateDragPlanePosition;
  48299. /**
  48300. * Detaches the behavior from the mesh
  48301. */
  48302. detach(): void;
  48303. }
  48304. }
  48305. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48306. import { Mesh } from "babylonjs/Meshes/mesh";
  48307. import { Behavior } from "babylonjs/Behaviors/behavior";
  48308. /**
  48309. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48310. */
  48311. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48312. private _dragBehaviorA;
  48313. private _dragBehaviorB;
  48314. private _startDistance;
  48315. private _initialScale;
  48316. private _targetScale;
  48317. private _ownerNode;
  48318. private _sceneRenderObserver;
  48319. /**
  48320. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48321. */
  48322. constructor();
  48323. /**
  48324. * The name of the behavior
  48325. */
  48326. get name(): string;
  48327. /**
  48328. * Initializes the behavior
  48329. */
  48330. init(): void;
  48331. private _getCurrentDistance;
  48332. /**
  48333. * Attaches the scale behavior the passed in mesh
  48334. * @param ownerNode The mesh that will be scaled around once attached
  48335. */
  48336. attach(ownerNode: Mesh): void;
  48337. /**
  48338. * Detaches the behavior from the mesh
  48339. */
  48340. detach(): void;
  48341. }
  48342. }
  48343. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48344. import { Behavior } from "babylonjs/Behaviors/behavior";
  48345. import { Mesh } from "babylonjs/Meshes/mesh";
  48346. import { Observable } from "babylonjs/Misc/observable";
  48347. /**
  48348. * 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
  48349. */
  48350. export class SixDofDragBehavior implements Behavior<Mesh> {
  48351. private static _virtualScene;
  48352. private _ownerNode;
  48353. private _sceneRenderObserver;
  48354. private _scene;
  48355. private _targetPosition;
  48356. private _virtualOriginMesh;
  48357. private _virtualDragMesh;
  48358. private _pointerObserver;
  48359. private _moving;
  48360. private _startingOrientation;
  48361. private _attachedElement;
  48362. /**
  48363. * 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)
  48364. */
  48365. private zDragFactor;
  48366. /**
  48367. * If the object should rotate to face the drag origin
  48368. */
  48369. rotateDraggedObject: boolean;
  48370. /**
  48371. * If the behavior is currently in a dragging state
  48372. */
  48373. dragging: boolean;
  48374. /**
  48375. * 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)
  48376. */
  48377. dragDeltaRatio: number;
  48378. /**
  48379. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48380. */
  48381. currentDraggingPointerID: number;
  48382. /**
  48383. * If camera controls should be detached during the drag
  48384. */
  48385. detachCameraControls: boolean;
  48386. /**
  48387. * Fires each time a drag starts
  48388. */
  48389. onDragStartObservable: Observable<{}>;
  48390. /**
  48391. * Fires each time a drag ends (eg. mouse release after drag)
  48392. */
  48393. onDragEndObservable: Observable<{}>;
  48394. /**
  48395. * 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
  48396. */
  48397. constructor();
  48398. /**
  48399. * The name of the behavior
  48400. */
  48401. get name(): string;
  48402. /**
  48403. * Initializes the behavior
  48404. */
  48405. init(): void;
  48406. /**
  48407. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48408. */
  48409. private get _pointerCamera();
  48410. /**
  48411. * Attaches the scale behavior the passed in mesh
  48412. * @param ownerNode The mesh that will be scaled around once attached
  48413. */
  48414. attach(ownerNode: Mesh): void;
  48415. /**
  48416. * Detaches the behavior from the mesh
  48417. */
  48418. detach(): void;
  48419. }
  48420. }
  48421. declare module "babylonjs/Behaviors/Meshes/index" {
  48422. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48423. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48424. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48425. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48426. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48427. }
  48428. declare module "babylonjs/Behaviors/index" {
  48429. export * from "babylonjs/Behaviors/behavior";
  48430. export * from "babylonjs/Behaviors/Cameras/index";
  48431. export * from "babylonjs/Behaviors/Meshes/index";
  48432. }
  48433. declare module "babylonjs/Bones/boneIKController" {
  48434. import { Bone } from "babylonjs/Bones/bone";
  48435. import { Vector3 } from "babylonjs/Maths/math.vector";
  48436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48437. import { Nullable } from "babylonjs/types";
  48438. /**
  48439. * Class used to apply inverse kinematics to bones
  48440. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48441. */
  48442. export class BoneIKController {
  48443. private static _tmpVecs;
  48444. private static _tmpQuat;
  48445. private static _tmpMats;
  48446. /**
  48447. * Gets or sets the target mesh
  48448. */
  48449. targetMesh: AbstractMesh;
  48450. /** Gets or sets the mesh used as pole */
  48451. poleTargetMesh: AbstractMesh;
  48452. /**
  48453. * Gets or sets the bone used as pole
  48454. */
  48455. poleTargetBone: Nullable<Bone>;
  48456. /**
  48457. * Gets or sets the target position
  48458. */
  48459. targetPosition: Vector3;
  48460. /**
  48461. * Gets or sets the pole target position
  48462. */
  48463. poleTargetPosition: Vector3;
  48464. /**
  48465. * Gets or sets the pole target local offset
  48466. */
  48467. poleTargetLocalOffset: Vector3;
  48468. /**
  48469. * Gets or sets the pole angle
  48470. */
  48471. poleAngle: number;
  48472. /**
  48473. * Gets or sets the mesh associated with the controller
  48474. */
  48475. mesh: AbstractMesh;
  48476. /**
  48477. * 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)
  48478. */
  48479. slerpAmount: number;
  48480. private _bone1Quat;
  48481. private _bone1Mat;
  48482. private _bone2Ang;
  48483. private _bone1;
  48484. private _bone2;
  48485. private _bone1Length;
  48486. private _bone2Length;
  48487. private _maxAngle;
  48488. private _maxReach;
  48489. private _rightHandedSystem;
  48490. private _bendAxis;
  48491. private _slerping;
  48492. private _adjustRoll;
  48493. /**
  48494. * Gets or sets maximum allowed angle
  48495. */
  48496. get maxAngle(): number;
  48497. set maxAngle(value: number);
  48498. /**
  48499. * Creates a new BoneIKController
  48500. * @param mesh defines the mesh to control
  48501. * @param bone defines the bone to control
  48502. * @param options defines options to set up the controller
  48503. */
  48504. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48505. targetMesh?: AbstractMesh;
  48506. poleTargetMesh?: AbstractMesh;
  48507. poleTargetBone?: Bone;
  48508. poleTargetLocalOffset?: Vector3;
  48509. poleAngle?: number;
  48510. bendAxis?: Vector3;
  48511. maxAngle?: number;
  48512. slerpAmount?: number;
  48513. });
  48514. private _setMaxAngle;
  48515. /**
  48516. * Force the controller to update the bones
  48517. */
  48518. update(): void;
  48519. }
  48520. }
  48521. declare module "babylonjs/Bones/boneLookController" {
  48522. import { Vector3 } from "babylonjs/Maths/math.vector";
  48523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48524. import { Bone } from "babylonjs/Bones/bone";
  48525. import { Space } from "babylonjs/Maths/math.axis";
  48526. /**
  48527. * Class used to make a bone look toward a point in space
  48528. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48529. */
  48530. export class BoneLookController {
  48531. private static _tmpVecs;
  48532. private static _tmpQuat;
  48533. private static _tmpMats;
  48534. /**
  48535. * The target Vector3 that the bone will look at
  48536. */
  48537. target: Vector3;
  48538. /**
  48539. * The mesh that the bone is attached to
  48540. */
  48541. mesh: AbstractMesh;
  48542. /**
  48543. * The bone that will be looking to the target
  48544. */
  48545. bone: Bone;
  48546. /**
  48547. * The up axis of the coordinate system that is used when the bone is rotated
  48548. */
  48549. upAxis: Vector3;
  48550. /**
  48551. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48552. */
  48553. upAxisSpace: Space;
  48554. /**
  48555. * Used to make an adjustment to the yaw of the bone
  48556. */
  48557. adjustYaw: number;
  48558. /**
  48559. * Used to make an adjustment to the pitch of the bone
  48560. */
  48561. adjustPitch: number;
  48562. /**
  48563. * Used to make an adjustment to the roll of the bone
  48564. */
  48565. adjustRoll: number;
  48566. /**
  48567. * 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)
  48568. */
  48569. slerpAmount: number;
  48570. private _minYaw;
  48571. private _maxYaw;
  48572. private _minPitch;
  48573. private _maxPitch;
  48574. private _minYawSin;
  48575. private _minYawCos;
  48576. private _maxYawSin;
  48577. private _maxYawCos;
  48578. private _midYawConstraint;
  48579. private _minPitchTan;
  48580. private _maxPitchTan;
  48581. private _boneQuat;
  48582. private _slerping;
  48583. private _transformYawPitch;
  48584. private _transformYawPitchInv;
  48585. private _firstFrameSkipped;
  48586. private _yawRange;
  48587. private _fowardAxis;
  48588. /**
  48589. * Gets or sets the minimum yaw angle that the bone can look to
  48590. */
  48591. get minYaw(): number;
  48592. set minYaw(value: number);
  48593. /**
  48594. * Gets or sets the maximum yaw angle that the bone can look to
  48595. */
  48596. get maxYaw(): number;
  48597. set maxYaw(value: number);
  48598. /**
  48599. * Gets or sets the minimum pitch angle that the bone can look to
  48600. */
  48601. get minPitch(): number;
  48602. set minPitch(value: number);
  48603. /**
  48604. * Gets or sets the maximum pitch angle that the bone can look to
  48605. */
  48606. get maxPitch(): number;
  48607. set maxPitch(value: number);
  48608. /**
  48609. * Create a BoneLookController
  48610. * @param mesh the mesh that the bone belongs to
  48611. * @param bone the bone that will be looking to the target
  48612. * @param target the target Vector3 to look at
  48613. * @param options optional settings:
  48614. * * maxYaw: the maximum angle the bone will yaw to
  48615. * * minYaw: the minimum angle the bone will yaw to
  48616. * * maxPitch: the maximum angle the bone will pitch to
  48617. * * minPitch: the minimum angle the bone will yaw to
  48618. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48619. * * upAxis: the up axis of the coordinate system
  48620. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48621. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48622. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48623. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48624. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48625. * * adjustRoll: used to make an adjustment to the roll of the bone
  48626. **/
  48627. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48628. maxYaw?: number;
  48629. minYaw?: number;
  48630. maxPitch?: number;
  48631. minPitch?: number;
  48632. slerpAmount?: number;
  48633. upAxis?: Vector3;
  48634. upAxisSpace?: Space;
  48635. yawAxis?: Vector3;
  48636. pitchAxis?: Vector3;
  48637. adjustYaw?: number;
  48638. adjustPitch?: number;
  48639. adjustRoll?: number;
  48640. });
  48641. /**
  48642. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48643. */
  48644. update(): void;
  48645. private _getAngleDiff;
  48646. private _getAngleBetween;
  48647. private _isAngleBetween;
  48648. }
  48649. }
  48650. declare module "babylonjs/Bones/index" {
  48651. export * from "babylonjs/Bones/bone";
  48652. export * from "babylonjs/Bones/boneIKController";
  48653. export * from "babylonjs/Bones/boneLookController";
  48654. export * from "babylonjs/Bones/skeleton";
  48655. }
  48656. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48657. import { Nullable } from "babylonjs/types";
  48658. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48659. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48660. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48661. /**
  48662. * Manage the gamepad inputs to control an arc rotate camera.
  48663. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48664. */
  48665. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48666. /**
  48667. * Defines the camera the input is attached to.
  48668. */
  48669. camera: ArcRotateCamera;
  48670. /**
  48671. * Defines the gamepad the input is gathering event from.
  48672. */
  48673. gamepad: Nullable<Gamepad>;
  48674. /**
  48675. * Defines the gamepad rotation sensiblity.
  48676. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48677. */
  48678. gamepadRotationSensibility: number;
  48679. /**
  48680. * Defines the gamepad move sensiblity.
  48681. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48682. */
  48683. gamepadMoveSensibility: number;
  48684. private _yAxisScale;
  48685. /**
  48686. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48687. */
  48688. get invertYAxis(): boolean;
  48689. set invertYAxis(value: boolean);
  48690. private _onGamepadConnectedObserver;
  48691. private _onGamepadDisconnectedObserver;
  48692. /**
  48693. * Attach the input controls to a specific dom element to get the input from.
  48694. * @param element Defines the element the controls should be listened from
  48695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48696. */
  48697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48698. /**
  48699. * Detach the current controls from the specified dom element.
  48700. * @param element Defines the element to stop listening the inputs from
  48701. */
  48702. detachControl(element: Nullable<HTMLElement>): void;
  48703. /**
  48704. * Update the current camera state depending on the inputs that have been used this frame.
  48705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48706. */
  48707. checkInputs(): void;
  48708. /**
  48709. * Gets the class name of the current intput.
  48710. * @returns the class name
  48711. */
  48712. getClassName(): string;
  48713. /**
  48714. * Get the friendly name associated with the input class.
  48715. * @returns the input friendly name
  48716. */
  48717. getSimpleName(): string;
  48718. }
  48719. }
  48720. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48721. import { Nullable } from "babylonjs/types";
  48722. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48723. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48724. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48725. interface ArcRotateCameraInputsManager {
  48726. /**
  48727. * Add orientation input support to the input manager.
  48728. * @returns the current input manager
  48729. */
  48730. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48731. }
  48732. }
  48733. /**
  48734. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48735. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48736. */
  48737. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48738. /**
  48739. * Defines the camera the input is attached to.
  48740. */
  48741. camera: ArcRotateCamera;
  48742. /**
  48743. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48744. */
  48745. alphaCorrection: number;
  48746. /**
  48747. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48748. */
  48749. gammaCorrection: number;
  48750. private _alpha;
  48751. private _gamma;
  48752. private _dirty;
  48753. private _deviceOrientationHandler;
  48754. /**
  48755. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48756. */
  48757. constructor();
  48758. /**
  48759. * Attach the input controls to a specific dom element to get the input from.
  48760. * @param element Defines the element the controls should be listened from
  48761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48762. */
  48763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48764. /** @hidden */
  48765. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48766. /**
  48767. * Update the current camera state depending on the inputs that have been used this frame.
  48768. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48769. */
  48770. checkInputs(): void;
  48771. /**
  48772. * Detach the current controls from the specified dom element.
  48773. * @param element Defines the element to stop listening the inputs from
  48774. */
  48775. detachControl(element: Nullable<HTMLElement>): void;
  48776. /**
  48777. * Gets the class name of the current intput.
  48778. * @returns the class name
  48779. */
  48780. getClassName(): string;
  48781. /**
  48782. * Get the friendly name associated with the input class.
  48783. * @returns the input friendly name
  48784. */
  48785. getSimpleName(): string;
  48786. }
  48787. }
  48788. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48789. import { Nullable } from "babylonjs/types";
  48790. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48791. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48792. /**
  48793. * Listen to mouse events to control the camera.
  48794. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48795. */
  48796. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48797. /**
  48798. * Defines the camera the input is attached to.
  48799. */
  48800. camera: FlyCamera;
  48801. /**
  48802. * Defines if touch is enabled. (Default is true.)
  48803. */
  48804. touchEnabled: boolean;
  48805. /**
  48806. * Defines the buttons associated with the input to handle camera rotation.
  48807. */
  48808. buttons: number[];
  48809. /**
  48810. * Assign buttons for Yaw control.
  48811. */
  48812. buttonsYaw: number[];
  48813. /**
  48814. * Assign buttons for Pitch control.
  48815. */
  48816. buttonsPitch: number[];
  48817. /**
  48818. * Assign buttons for Roll control.
  48819. */
  48820. buttonsRoll: number[];
  48821. /**
  48822. * Detect if any button is being pressed while mouse is moved.
  48823. * -1 = Mouse locked.
  48824. * 0 = Left button.
  48825. * 1 = Middle Button.
  48826. * 2 = Right Button.
  48827. */
  48828. activeButton: number;
  48829. /**
  48830. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48831. * Higher values reduce its sensitivity.
  48832. */
  48833. angularSensibility: number;
  48834. private _observer;
  48835. private _rollObserver;
  48836. private previousPosition;
  48837. private noPreventDefault;
  48838. private element;
  48839. /**
  48840. * Listen to mouse events to control the camera.
  48841. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48842. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48843. */
  48844. constructor(touchEnabled?: boolean);
  48845. /**
  48846. * Attach the mouse control to the HTML DOM element.
  48847. * @param element Defines the element that listens to the input events.
  48848. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48849. */
  48850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48851. /**
  48852. * Detach the current controls from the specified dom element.
  48853. * @param element Defines the element to stop listening the inputs from
  48854. */
  48855. detachControl(element: Nullable<HTMLElement>): void;
  48856. /**
  48857. * Gets the class name of the current input.
  48858. * @returns the class name.
  48859. */
  48860. getClassName(): string;
  48861. /**
  48862. * Get the friendly name associated with the input class.
  48863. * @returns the input's friendly name.
  48864. */
  48865. getSimpleName(): string;
  48866. private _pointerInput;
  48867. private _onMouseMove;
  48868. /**
  48869. * Rotate camera by mouse offset.
  48870. */
  48871. private rotateCamera;
  48872. }
  48873. }
  48874. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48875. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48876. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48877. /**
  48878. * Default Inputs manager for the FlyCamera.
  48879. * It groups all the default supported inputs for ease of use.
  48880. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48881. */
  48882. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48883. /**
  48884. * Instantiates a new FlyCameraInputsManager.
  48885. * @param camera Defines the camera the inputs belong to.
  48886. */
  48887. constructor(camera: FlyCamera);
  48888. /**
  48889. * Add keyboard input support to the input manager.
  48890. * @returns the new FlyCameraKeyboardMoveInput().
  48891. */
  48892. addKeyboard(): FlyCameraInputsManager;
  48893. /**
  48894. * Add mouse input support to the input manager.
  48895. * @param touchEnabled Enable touch screen support.
  48896. * @returns the new FlyCameraMouseInput().
  48897. */
  48898. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  48899. }
  48900. }
  48901. declare module "babylonjs/Cameras/flyCamera" {
  48902. import { Scene } from "babylonjs/scene";
  48903. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  48904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48905. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48906. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  48907. /**
  48908. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48909. * such as in a 3D Space Shooter or a Flight Simulator.
  48910. */
  48911. export class FlyCamera extends TargetCamera {
  48912. /**
  48913. * Define the collision ellipsoid of the camera.
  48914. * This is helpful for simulating a camera body, like a player's body.
  48915. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48916. */
  48917. ellipsoid: Vector3;
  48918. /**
  48919. * Define an offset for the position of the ellipsoid around the camera.
  48920. * This can be helpful if the camera is attached away from the player's body center,
  48921. * such as at its head.
  48922. */
  48923. ellipsoidOffset: Vector3;
  48924. /**
  48925. * Enable or disable collisions of the camera with the rest of the scene objects.
  48926. */
  48927. checkCollisions: boolean;
  48928. /**
  48929. * Enable or disable gravity on the camera.
  48930. */
  48931. applyGravity: boolean;
  48932. /**
  48933. * Define the current direction the camera is moving to.
  48934. */
  48935. cameraDirection: Vector3;
  48936. /**
  48937. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  48938. * This overrides and empties cameraRotation.
  48939. */
  48940. rotationQuaternion: Quaternion;
  48941. /**
  48942. * Track Roll to maintain the wanted Rolling when looking around.
  48943. */
  48944. _trackRoll: number;
  48945. /**
  48946. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  48947. */
  48948. rollCorrect: number;
  48949. /**
  48950. * Mimic a banked turn, Rolling the camera when Yawing.
  48951. * It's recommended to use rollCorrect = 10 for faster banking correction.
  48952. */
  48953. bankedTurn: boolean;
  48954. /**
  48955. * Limit in radians for how much Roll banking will add. (Default: 90°)
  48956. */
  48957. bankedTurnLimit: number;
  48958. /**
  48959. * Value of 0 disables the banked Roll.
  48960. * Value of 1 is equal to the Yaw angle in radians.
  48961. */
  48962. bankedTurnMultiplier: number;
  48963. /**
  48964. * The inputs manager loads all the input sources, such as keyboard and mouse.
  48965. */
  48966. inputs: FlyCameraInputsManager;
  48967. /**
  48968. * Gets the input sensibility for mouse input.
  48969. * Higher values reduce sensitivity.
  48970. */
  48971. get angularSensibility(): number;
  48972. /**
  48973. * Sets the input sensibility for a mouse input.
  48974. * Higher values reduce sensitivity.
  48975. */
  48976. set angularSensibility(value: number);
  48977. /**
  48978. * Get the keys for camera movement forward.
  48979. */
  48980. get keysForward(): number[];
  48981. /**
  48982. * Set the keys for camera movement forward.
  48983. */
  48984. set keysForward(value: number[]);
  48985. /**
  48986. * Get the keys for camera movement backward.
  48987. */
  48988. get keysBackward(): number[];
  48989. set keysBackward(value: number[]);
  48990. /**
  48991. * Get the keys for camera movement up.
  48992. */
  48993. get keysUp(): number[];
  48994. /**
  48995. * Set the keys for camera movement up.
  48996. */
  48997. set keysUp(value: number[]);
  48998. /**
  48999. * Get the keys for camera movement down.
  49000. */
  49001. get keysDown(): number[];
  49002. /**
  49003. * Set the keys for camera movement down.
  49004. */
  49005. set keysDown(value: number[]);
  49006. /**
  49007. * Get the keys for camera movement left.
  49008. */
  49009. get keysLeft(): number[];
  49010. /**
  49011. * Set the keys for camera movement left.
  49012. */
  49013. set keysLeft(value: number[]);
  49014. /**
  49015. * Set the keys for camera movement right.
  49016. */
  49017. get keysRight(): number[];
  49018. /**
  49019. * Set the keys for camera movement right.
  49020. */
  49021. set keysRight(value: number[]);
  49022. /**
  49023. * Event raised when the camera collides with a mesh in the scene.
  49024. */
  49025. onCollide: (collidedMesh: AbstractMesh) => void;
  49026. private _collider;
  49027. private _needMoveForGravity;
  49028. private _oldPosition;
  49029. private _diffPosition;
  49030. private _newPosition;
  49031. /** @hidden */
  49032. _localDirection: Vector3;
  49033. /** @hidden */
  49034. _transformedDirection: Vector3;
  49035. /**
  49036. * Instantiates a FlyCamera.
  49037. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49038. * such as in a 3D Space Shooter or a Flight Simulator.
  49039. * @param name Define the name of the camera in the scene.
  49040. * @param position Define the starting position of the camera in the scene.
  49041. * @param scene Define the scene the camera belongs to.
  49042. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49043. */
  49044. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49045. /**
  49046. * Attach a control to the HTML DOM element.
  49047. * @param element Defines the element that listens to the input events.
  49048. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49049. */
  49050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49051. /**
  49052. * Detach a control from the HTML DOM element.
  49053. * The camera will stop reacting to that input.
  49054. * @param element Defines the element that listens to the input events.
  49055. */
  49056. detachControl(element: HTMLElement): void;
  49057. private _collisionMask;
  49058. /**
  49059. * Get the mask that the camera ignores in collision events.
  49060. */
  49061. get collisionMask(): number;
  49062. /**
  49063. * Set the mask that the camera ignores in collision events.
  49064. */
  49065. set collisionMask(mask: number);
  49066. /** @hidden */
  49067. _collideWithWorld(displacement: Vector3): void;
  49068. /** @hidden */
  49069. private _onCollisionPositionChange;
  49070. /** @hidden */
  49071. _checkInputs(): void;
  49072. /** @hidden */
  49073. _decideIfNeedsToMove(): boolean;
  49074. /** @hidden */
  49075. _updatePosition(): void;
  49076. /**
  49077. * Restore the Roll to its target value at the rate specified.
  49078. * @param rate - Higher means slower restoring.
  49079. * @hidden
  49080. */
  49081. restoreRoll(rate: number): void;
  49082. /**
  49083. * Destroy the camera and release the current resources held by it.
  49084. */
  49085. dispose(): void;
  49086. /**
  49087. * Get the current object class name.
  49088. * @returns the class name.
  49089. */
  49090. getClassName(): string;
  49091. }
  49092. }
  49093. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49094. import { Nullable } from "babylonjs/types";
  49095. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49096. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49097. /**
  49098. * Listen to keyboard events to control the camera.
  49099. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49100. */
  49101. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49102. /**
  49103. * Defines the camera the input is attached to.
  49104. */
  49105. camera: FlyCamera;
  49106. /**
  49107. * The list of keyboard keys used to control the forward move of the camera.
  49108. */
  49109. keysForward: number[];
  49110. /**
  49111. * The list of keyboard keys used to control the backward move of the camera.
  49112. */
  49113. keysBackward: number[];
  49114. /**
  49115. * The list of keyboard keys used to control the forward move of the camera.
  49116. */
  49117. keysUp: number[];
  49118. /**
  49119. * The list of keyboard keys used to control the backward move of the camera.
  49120. */
  49121. keysDown: number[];
  49122. /**
  49123. * The list of keyboard keys used to control the right strafe move of the camera.
  49124. */
  49125. keysRight: number[];
  49126. /**
  49127. * The list of keyboard keys used to control the left strafe move of the camera.
  49128. */
  49129. keysLeft: number[];
  49130. private _keys;
  49131. private _onCanvasBlurObserver;
  49132. private _onKeyboardObserver;
  49133. private _engine;
  49134. private _scene;
  49135. /**
  49136. * Attach the input controls to a specific dom element to get the input from.
  49137. * @param element Defines the element the controls should be listened from
  49138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49139. */
  49140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49141. /**
  49142. * Detach the current controls from the specified dom element.
  49143. * @param element Defines the element to stop listening the inputs from
  49144. */
  49145. detachControl(element: Nullable<HTMLElement>): void;
  49146. /**
  49147. * Gets the class name of the current intput.
  49148. * @returns the class name
  49149. */
  49150. getClassName(): string;
  49151. /** @hidden */
  49152. _onLostFocus(e: FocusEvent): void;
  49153. /**
  49154. * Get the friendly name associated with the input class.
  49155. * @returns the input friendly name
  49156. */
  49157. getSimpleName(): string;
  49158. /**
  49159. * Update the current camera state depending on the inputs that have been used this frame.
  49160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49161. */
  49162. checkInputs(): void;
  49163. }
  49164. }
  49165. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49166. import { Nullable } from "babylonjs/types";
  49167. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49168. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49169. /**
  49170. * Manage the mouse wheel inputs to control a follow camera.
  49171. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49172. */
  49173. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49174. /**
  49175. * Defines the camera the input is attached to.
  49176. */
  49177. camera: FollowCamera;
  49178. /**
  49179. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49180. */
  49181. axisControlRadius: boolean;
  49182. /**
  49183. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49184. */
  49185. axisControlHeight: boolean;
  49186. /**
  49187. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49188. */
  49189. axisControlRotation: boolean;
  49190. /**
  49191. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49192. * relation to mouseWheel events.
  49193. */
  49194. wheelPrecision: number;
  49195. /**
  49196. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49197. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49198. */
  49199. wheelDeltaPercentage: number;
  49200. private _wheel;
  49201. private _observer;
  49202. /**
  49203. * Attach the input controls to a specific dom element to get the input from.
  49204. * @param element Defines the element the controls should be listened from
  49205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49206. */
  49207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49208. /**
  49209. * Detach the current controls from the specified dom element.
  49210. * @param element Defines the element to stop listening the inputs from
  49211. */
  49212. detachControl(element: Nullable<HTMLElement>): void;
  49213. /**
  49214. * Gets the class name of the current intput.
  49215. * @returns the class name
  49216. */
  49217. getClassName(): string;
  49218. /**
  49219. * Get the friendly name associated with the input class.
  49220. * @returns the input friendly name
  49221. */
  49222. getSimpleName(): string;
  49223. }
  49224. }
  49225. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49226. import { Nullable } from "babylonjs/types";
  49227. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49228. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49229. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49230. /**
  49231. * Manage the pointers inputs to control an follow camera.
  49232. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49233. */
  49234. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49235. /**
  49236. * Defines the camera the input is attached to.
  49237. */
  49238. camera: FollowCamera;
  49239. /**
  49240. * Gets the class name of the current input.
  49241. * @returns the class name
  49242. */
  49243. getClassName(): string;
  49244. /**
  49245. * Defines the pointer angular sensibility along the X axis or how fast is
  49246. * the camera rotating.
  49247. * A negative number will reverse the axis direction.
  49248. */
  49249. angularSensibilityX: number;
  49250. /**
  49251. * Defines the pointer angular sensibility along the Y axis or how fast is
  49252. * the camera rotating.
  49253. * A negative number will reverse the axis direction.
  49254. */
  49255. angularSensibilityY: number;
  49256. /**
  49257. * Defines the pointer pinch precision or how fast is the camera zooming.
  49258. * A negative number will reverse the axis direction.
  49259. */
  49260. pinchPrecision: number;
  49261. /**
  49262. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49263. * from 0.
  49264. * It defines the percentage of current camera.radius to use as delta when
  49265. * pinch zoom is used.
  49266. */
  49267. pinchDeltaPercentage: number;
  49268. /**
  49269. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49270. */
  49271. axisXControlRadius: boolean;
  49272. /**
  49273. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49274. */
  49275. axisXControlHeight: boolean;
  49276. /**
  49277. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49278. */
  49279. axisXControlRotation: boolean;
  49280. /**
  49281. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49282. */
  49283. axisYControlRadius: boolean;
  49284. /**
  49285. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49286. */
  49287. axisYControlHeight: boolean;
  49288. /**
  49289. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49290. */
  49291. axisYControlRotation: boolean;
  49292. /**
  49293. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49294. */
  49295. axisPinchControlRadius: boolean;
  49296. /**
  49297. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49298. */
  49299. axisPinchControlHeight: boolean;
  49300. /**
  49301. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49302. */
  49303. axisPinchControlRotation: boolean;
  49304. /**
  49305. * Log error messages if basic misconfiguration has occurred.
  49306. */
  49307. warningEnable: boolean;
  49308. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49309. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49310. private _warningCounter;
  49311. private _warning;
  49312. }
  49313. }
  49314. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49315. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49316. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49317. /**
  49318. * Default Inputs manager for the FollowCamera.
  49319. * It groups all the default supported inputs for ease of use.
  49320. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49321. */
  49322. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49323. /**
  49324. * Instantiates a new FollowCameraInputsManager.
  49325. * @param camera Defines the camera the inputs belong to
  49326. */
  49327. constructor(camera: FollowCamera);
  49328. /**
  49329. * Add keyboard input support to the input manager.
  49330. * @returns the current input manager
  49331. */
  49332. addKeyboard(): FollowCameraInputsManager;
  49333. /**
  49334. * Add mouse wheel input support to the input manager.
  49335. * @returns the current input manager
  49336. */
  49337. addMouseWheel(): FollowCameraInputsManager;
  49338. /**
  49339. * Add pointers input support to the input manager.
  49340. * @returns the current input manager
  49341. */
  49342. addPointers(): FollowCameraInputsManager;
  49343. /**
  49344. * Add orientation input support to the input manager.
  49345. * @returns the current input manager
  49346. */
  49347. addVRDeviceOrientation(): FollowCameraInputsManager;
  49348. }
  49349. }
  49350. declare module "babylonjs/Cameras/followCamera" {
  49351. import { Nullable } from "babylonjs/types";
  49352. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49353. import { Scene } from "babylonjs/scene";
  49354. import { Vector3 } from "babylonjs/Maths/math.vector";
  49355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49356. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49357. /**
  49358. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49359. * an arc rotate version arcFollowCamera are available.
  49360. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49361. */
  49362. export class FollowCamera extends TargetCamera {
  49363. /**
  49364. * Distance the follow camera should follow an object at
  49365. */
  49366. radius: number;
  49367. /**
  49368. * Minimum allowed distance of the camera to the axis of rotation
  49369. * (The camera can not get closer).
  49370. * This can help limiting how the Camera is able to move in the scene.
  49371. */
  49372. lowerRadiusLimit: Nullable<number>;
  49373. /**
  49374. * Maximum allowed distance of the camera to the axis of rotation
  49375. * (The camera can not get further).
  49376. * This can help limiting how the Camera is able to move in the scene.
  49377. */
  49378. upperRadiusLimit: Nullable<number>;
  49379. /**
  49380. * Define a rotation offset between the camera and the object it follows
  49381. */
  49382. rotationOffset: number;
  49383. /**
  49384. * Minimum allowed angle to camera position relative to target object.
  49385. * This can help limiting how the Camera is able to move in the scene.
  49386. */
  49387. lowerRotationOffsetLimit: Nullable<number>;
  49388. /**
  49389. * Maximum allowed angle to camera position relative to target object.
  49390. * This can help limiting how the Camera is able to move in the scene.
  49391. */
  49392. upperRotationOffsetLimit: Nullable<number>;
  49393. /**
  49394. * Define a height offset between the camera and the object it follows.
  49395. * It can help following an object from the top (like a car chaing a plane)
  49396. */
  49397. heightOffset: number;
  49398. /**
  49399. * Minimum allowed height of camera position relative to target object.
  49400. * This can help limiting how the Camera is able to move in the scene.
  49401. */
  49402. lowerHeightOffsetLimit: Nullable<number>;
  49403. /**
  49404. * Maximum allowed height of camera position relative to target object.
  49405. * This can help limiting how the Camera is able to move in the scene.
  49406. */
  49407. upperHeightOffsetLimit: Nullable<number>;
  49408. /**
  49409. * Define how fast the camera can accelerate to follow it s target.
  49410. */
  49411. cameraAcceleration: number;
  49412. /**
  49413. * Define the speed limit of the camera following an object.
  49414. */
  49415. maxCameraSpeed: number;
  49416. /**
  49417. * Define the target of the camera.
  49418. */
  49419. lockedTarget: Nullable<AbstractMesh>;
  49420. /**
  49421. * Defines the input associated with the camera.
  49422. */
  49423. inputs: FollowCameraInputsManager;
  49424. /**
  49425. * Instantiates the follow camera.
  49426. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49427. * @param name Define the name of the camera in the scene
  49428. * @param position Define the position of the camera
  49429. * @param scene Define the scene the camera belong to
  49430. * @param lockedTarget Define the target of the camera
  49431. */
  49432. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49433. private _follow;
  49434. /**
  49435. * Attached controls to the current camera.
  49436. * @param element Defines the element the controls should be listened from
  49437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49438. */
  49439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49440. /**
  49441. * Detach the current controls from the camera.
  49442. * The camera will stop reacting to inputs.
  49443. * @param element Defines the element to stop listening the inputs from
  49444. */
  49445. detachControl(element: HTMLElement): void;
  49446. /** @hidden */
  49447. _checkInputs(): void;
  49448. private _checkLimits;
  49449. /**
  49450. * Gets the camera class name.
  49451. * @returns the class name
  49452. */
  49453. getClassName(): string;
  49454. }
  49455. /**
  49456. * Arc Rotate version of the follow camera.
  49457. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49458. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49459. */
  49460. export class ArcFollowCamera extends TargetCamera {
  49461. /** The longitudinal angle of the camera */
  49462. alpha: number;
  49463. /** The latitudinal angle of the camera */
  49464. beta: number;
  49465. /** The radius of the camera from its target */
  49466. radius: number;
  49467. private _cartesianCoordinates;
  49468. /** Define the camera target (the mesh it should follow) */
  49469. private _meshTarget;
  49470. /**
  49471. * Instantiates a new ArcFollowCamera
  49472. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49473. * @param name Define the name of the camera
  49474. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49475. * @param beta Define the rotation angle of the camera around the elevation axis
  49476. * @param radius Define the radius of the camera from its target point
  49477. * @param target Define the target of the camera
  49478. * @param scene Define the scene the camera belongs to
  49479. */
  49480. constructor(name: string,
  49481. /** The longitudinal angle of the camera */
  49482. alpha: number,
  49483. /** The latitudinal angle of the camera */
  49484. beta: number,
  49485. /** The radius of the camera from its target */
  49486. radius: number,
  49487. /** Define the camera target (the mesh it should follow) */
  49488. target: Nullable<AbstractMesh>, scene: Scene);
  49489. private _follow;
  49490. /** @hidden */
  49491. _checkInputs(): void;
  49492. /**
  49493. * Returns the class name of the object.
  49494. * It is mostly used internally for serialization purposes.
  49495. */
  49496. getClassName(): string;
  49497. }
  49498. }
  49499. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49500. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49501. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49502. import { Nullable } from "babylonjs/types";
  49503. /**
  49504. * Manage the keyboard inputs to control the movement of a follow camera.
  49505. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49506. */
  49507. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49508. /**
  49509. * Defines the camera the input is attached to.
  49510. */
  49511. camera: FollowCamera;
  49512. /**
  49513. * Defines the list of key codes associated with the up action (increase heightOffset)
  49514. */
  49515. keysHeightOffsetIncr: number[];
  49516. /**
  49517. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49518. */
  49519. keysHeightOffsetDecr: number[];
  49520. /**
  49521. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49522. */
  49523. keysHeightOffsetModifierAlt: boolean;
  49524. /**
  49525. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49526. */
  49527. keysHeightOffsetModifierCtrl: boolean;
  49528. /**
  49529. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49530. */
  49531. keysHeightOffsetModifierShift: boolean;
  49532. /**
  49533. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49534. */
  49535. keysRotationOffsetIncr: number[];
  49536. /**
  49537. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49538. */
  49539. keysRotationOffsetDecr: number[];
  49540. /**
  49541. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49542. */
  49543. keysRotationOffsetModifierAlt: boolean;
  49544. /**
  49545. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49546. */
  49547. keysRotationOffsetModifierCtrl: boolean;
  49548. /**
  49549. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49550. */
  49551. keysRotationOffsetModifierShift: boolean;
  49552. /**
  49553. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49554. */
  49555. keysRadiusIncr: number[];
  49556. /**
  49557. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49558. */
  49559. keysRadiusDecr: number[];
  49560. /**
  49561. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49562. */
  49563. keysRadiusModifierAlt: boolean;
  49564. /**
  49565. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49566. */
  49567. keysRadiusModifierCtrl: boolean;
  49568. /**
  49569. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49570. */
  49571. keysRadiusModifierShift: boolean;
  49572. /**
  49573. * Defines the rate of change of heightOffset.
  49574. */
  49575. heightSensibility: number;
  49576. /**
  49577. * Defines the rate of change of rotationOffset.
  49578. */
  49579. rotationSensibility: number;
  49580. /**
  49581. * Defines the rate of change of radius.
  49582. */
  49583. radiusSensibility: number;
  49584. private _keys;
  49585. private _ctrlPressed;
  49586. private _altPressed;
  49587. private _shiftPressed;
  49588. private _onCanvasBlurObserver;
  49589. private _onKeyboardObserver;
  49590. private _engine;
  49591. private _scene;
  49592. /**
  49593. * Attach the input controls to a specific dom element to get the input from.
  49594. * @param element Defines the element the controls should be listened from
  49595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49596. */
  49597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49598. /**
  49599. * Detach the current controls from the specified dom element.
  49600. * @param element Defines the element to stop listening the inputs from
  49601. */
  49602. detachControl(element: Nullable<HTMLElement>): void;
  49603. /**
  49604. * Update the current camera state depending on the inputs that have been used this frame.
  49605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49606. */
  49607. checkInputs(): void;
  49608. /**
  49609. * Gets the class name of the current input.
  49610. * @returns the class name
  49611. */
  49612. getClassName(): string;
  49613. /**
  49614. * Get the friendly name associated with the input class.
  49615. * @returns the input friendly name
  49616. */
  49617. getSimpleName(): string;
  49618. /**
  49619. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49620. * allow modification of the heightOffset value.
  49621. */
  49622. private _modifierHeightOffset;
  49623. /**
  49624. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49625. * allow modification of the rotationOffset value.
  49626. */
  49627. private _modifierRotationOffset;
  49628. /**
  49629. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49630. * allow modification of the radius value.
  49631. */
  49632. private _modifierRadius;
  49633. }
  49634. }
  49635. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49636. import { Nullable } from "babylonjs/types";
  49637. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49638. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49639. import { Observable } from "babylonjs/Misc/observable";
  49640. module "babylonjs/Cameras/freeCameraInputsManager" {
  49641. interface FreeCameraInputsManager {
  49642. /**
  49643. * @hidden
  49644. */
  49645. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49646. /**
  49647. * Add orientation input support to the input manager.
  49648. * @returns the current input manager
  49649. */
  49650. addDeviceOrientation(): FreeCameraInputsManager;
  49651. }
  49652. }
  49653. /**
  49654. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49655. * Screen rotation is taken into account.
  49656. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49657. */
  49658. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49659. private _camera;
  49660. private _screenOrientationAngle;
  49661. private _constantTranform;
  49662. private _screenQuaternion;
  49663. private _alpha;
  49664. private _beta;
  49665. private _gamma;
  49666. /**
  49667. * Can be used to detect if a device orientation sensor is available on a device
  49668. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49669. * @returns a promise that will resolve on orientation change
  49670. */
  49671. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49672. /**
  49673. * @hidden
  49674. */
  49675. _onDeviceOrientationChangedObservable: Observable<void>;
  49676. /**
  49677. * Instantiates a new input
  49678. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49679. */
  49680. constructor();
  49681. /**
  49682. * Define the camera controlled by the input.
  49683. */
  49684. get camera(): FreeCamera;
  49685. set camera(camera: FreeCamera);
  49686. /**
  49687. * Attach the input controls to a specific dom element to get the input from.
  49688. * @param element Defines the element the controls should be listened from
  49689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49690. */
  49691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49692. private _orientationChanged;
  49693. private _deviceOrientation;
  49694. /**
  49695. * Detach the current controls from the specified dom element.
  49696. * @param element Defines the element to stop listening the inputs from
  49697. */
  49698. detachControl(element: Nullable<HTMLElement>): void;
  49699. /**
  49700. * Update the current camera state depending on the inputs that have been used this frame.
  49701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49702. */
  49703. checkInputs(): void;
  49704. /**
  49705. * Gets the class name of the current intput.
  49706. * @returns the class name
  49707. */
  49708. getClassName(): string;
  49709. /**
  49710. * Get the friendly name associated with the input class.
  49711. * @returns the input friendly name
  49712. */
  49713. getSimpleName(): string;
  49714. }
  49715. }
  49716. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49717. import { Nullable } from "babylonjs/types";
  49718. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49719. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49720. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49721. /**
  49722. * Manage the gamepad inputs to control a free camera.
  49723. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49724. */
  49725. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49726. /**
  49727. * Define the camera the input is attached to.
  49728. */
  49729. camera: FreeCamera;
  49730. /**
  49731. * Define the Gamepad controlling the input
  49732. */
  49733. gamepad: Nullable<Gamepad>;
  49734. /**
  49735. * Defines the gamepad rotation sensiblity.
  49736. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49737. */
  49738. gamepadAngularSensibility: number;
  49739. /**
  49740. * Defines the gamepad move sensiblity.
  49741. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49742. */
  49743. gamepadMoveSensibility: number;
  49744. private _yAxisScale;
  49745. /**
  49746. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49747. */
  49748. get invertYAxis(): boolean;
  49749. set invertYAxis(value: boolean);
  49750. private _onGamepadConnectedObserver;
  49751. private _onGamepadDisconnectedObserver;
  49752. private _cameraTransform;
  49753. private _deltaTransform;
  49754. private _vector3;
  49755. private _vector2;
  49756. /**
  49757. * Attach the input controls to a specific dom element to get the input from.
  49758. * @param element Defines the element the controls should be listened from
  49759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49760. */
  49761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49762. /**
  49763. * Detach the current controls from the specified dom element.
  49764. * @param element Defines the element to stop listening the inputs from
  49765. */
  49766. detachControl(element: Nullable<HTMLElement>): void;
  49767. /**
  49768. * Update the current camera state depending on the inputs that have been used this frame.
  49769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49770. */
  49771. checkInputs(): void;
  49772. /**
  49773. * Gets the class name of the current intput.
  49774. * @returns the class name
  49775. */
  49776. getClassName(): string;
  49777. /**
  49778. * Get the friendly name associated with the input class.
  49779. * @returns the input friendly name
  49780. */
  49781. getSimpleName(): string;
  49782. }
  49783. }
  49784. declare module "babylonjs/Misc/virtualJoystick" {
  49785. import { Nullable } from "babylonjs/types";
  49786. import { Vector3 } from "babylonjs/Maths/math.vector";
  49787. /**
  49788. * Defines the potential axis of a Joystick
  49789. */
  49790. export enum JoystickAxis {
  49791. /** X axis */
  49792. X = 0,
  49793. /** Y axis */
  49794. Y = 1,
  49795. /** Z axis */
  49796. Z = 2
  49797. }
  49798. /**
  49799. * Represents the different customization options available
  49800. * for VirtualJoystick
  49801. */
  49802. interface VirtualJoystickCustomizations {
  49803. /**
  49804. * Size of the joystick's puck
  49805. */
  49806. puckSize: number;
  49807. /**
  49808. * Size of the joystick's container
  49809. */
  49810. containerSize: number;
  49811. /**
  49812. * Color of the joystick && puck
  49813. */
  49814. color: string;
  49815. /**
  49816. * Image URL for the joystick's puck
  49817. */
  49818. puckImage?: string;
  49819. /**
  49820. * Image URL for the joystick's container
  49821. */
  49822. containerImage?: string;
  49823. /**
  49824. * Defines the unmoving position of the joystick container
  49825. */
  49826. position?: {
  49827. x: number;
  49828. y: number;
  49829. };
  49830. /**
  49831. * Defines whether or not the joystick container is always visible
  49832. */
  49833. alwaysVisible: boolean;
  49834. /**
  49835. * Defines whether or not to limit the movement of the puck to the joystick's container
  49836. */
  49837. limitToContainer: boolean;
  49838. }
  49839. /**
  49840. * Class used to define virtual joystick (used in touch mode)
  49841. */
  49842. export class VirtualJoystick {
  49843. /**
  49844. * Gets or sets a boolean indicating that left and right values must be inverted
  49845. */
  49846. reverseLeftRight: boolean;
  49847. /**
  49848. * Gets or sets a boolean indicating that up and down values must be inverted
  49849. */
  49850. reverseUpDown: boolean;
  49851. /**
  49852. * Gets the offset value for the position (ie. the change of the position value)
  49853. */
  49854. deltaPosition: Vector3;
  49855. /**
  49856. * Gets a boolean indicating if the virtual joystick was pressed
  49857. */
  49858. pressed: boolean;
  49859. /**
  49860. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49861. */
  49862. static Canvas: Nullable<HTMLCanvasElement>;
  49863. /**
  49864. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49865. */
  49866. limitToContainer: boolean;
  49867. private static _globalJoystickIndex;
  49868. private static _alwaysVisibleSticks;
  49869. private static vjCanvasContext;
  49870. private static vjCanvasWidth;
  49871. private static vjCanvasHeight;
  49872. private static halfWidth;
  49873. private static _GetDefaultOptions;
  49874. private _action;
  49875. private _axisTargetedByLeftAndRight;
  49876. private _axisTargetedByUpAndDown;
  49877. private _joystickSensibility;
  49878. private _inversedSensibility;
  49879. private _joystickPointerID;
  49880. private _joystickColor;
  49881. private _joystickPointerPos;
  49882. private _joystickPreviousPointerPos;
  49883. private _joystickPointerStartPos;
  49884. private _deltaJoystickVector;
  49885. private _leftJoystick;
  49886. private _touches;
  49887. private _joystickPosition;
  49888. private _alwaysVisible;
  49889. private _puckImage;
  49890. private _containerImage;
  49891. private _joystickPuckSize;
  49892. private _joystickContainerSize;
  49893. private _clearPuckSize;
  49894. private _clearContainerSize;
  49895. private _clearPuckSizeOffset;
  49896. private _clearContainerSizeOffset;
  49897. private _onPointerDownHandlerRef;
  49898. private _onPointerMoveHandlerRef;
  49899. private _onPointerUpHandlerRef;
  49900. private _onResize;
  49901. /**
  49902. * Creates a new virtual joystick
  49903. * @param leftJoystick defines that the joystick is for left hand (false by default)
  49904. * @param customizations Defines the options we want to customize the VirtualJoystick
  49905. */
  49906. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  49907. /**
  49908. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  49909. * @param newJoystickSensibility defines the new sensibility
  49910. */
  49911. setJoystickSensibility(newJoystickSensibility: number): void;
  49912. private _onPointerDown;
  49913. private _onPointerMove;
  49914. private _onPointerUp;
  49915. /**
  49916. * Change the color of the virtual joystick
  49917. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  49918. */
  49919. setJoystickColor(newColor: string): void;
  49920. /**
  49921. * Size of the joystick's container
  49922. */
  49923. set containerSize(newSize: number);
  49924. get containerSize(): number;
  49925. /**
  49926. * Size of the joystick's puck
  49927. */
  49928. set puckSize(newSize: number);
  49929. get puckSize(): number;
  49930. /**
  49931. * Clears the set position of the joystick
  49932. */
  49933. clearPosition(): void;
  49934. /**
  49935. * Defines whether or not the joystick container is always visible
  49936. */
  49937. set alwaysVisible(value: boolean);
  49938. get alwaysVisible(): boolean;
  49939. /**
  49940. * Sets the constant position of the Joystick container
  49941. * @param x X axis coordinate
  49942. * @param y Y axis coordinate
  49943. */
  49944. setPosition(x: number, y: number): void;
  49945. /**
  49946. * Defines a callback to call when the joystick is touched
  49947. * @param action defines the callback
  49948. */
  49949. setActionOnTouch(action: () => any): void;
  49950. /**
  49951. * Defines which axis you'd like to control for left & right
  49952. * @param axis defines the axis to use
  49953. */
  49954. setAxisForLeftRight(axis: JoystickAxis): void;
  49955. /**
  49956. * Defines which axis you'd like to control for up & down
  49957. * @param axis defines the axis to use
  49958. */
  49959. setAxisForUpDown(axis: JoystickAxis): void;
  49960. /**
  49961. * Clears the canvas from the previous puck / container draw
  49962. */
  49963. private _clearPreviousDraw;
  49964. /**
  49965. * Loads `urlPath` to be used for the container's image
  49966. * @param urlPath defines the urlPath of an image to use
  49967. */
  49968. setContainerImage(urlPath: string): void;
  49969. /**
  49970. * Loads `urlPath` to be used for the puck's image
  49971. * @param urlPath defines the urlPath of an image to use
  49972. */
  49973. setPuckImage(urlPath: string): void;
  49974. /**
  49975. * Draws the Virtual Joystick's container
  49976. */
  49977. private _drawContainer;
  49978. /**
  49979. * Draws the Virtual Joystick's puck
  49980. */
  49981. private _drawPuck;
  49982. private _drawVirtualJoystick;
  49983. /**
  49984. * Release internal HTML canvas
  49985. */
  49986. releaseCanvas(): void;
  49987. }
  49988. }
  49989. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  49990. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  49991. import { Nullable } from "babylonjs/types";
  49992. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49993. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49994. module "babylonjs/Cameras/freeCameraInputsManager" {
  49995. interface FreeCameraInputsManager {
  49996. /**
  49997. * Add virtual joystick input support to the input manager.
  49998. * @returns the current input manager
  49999. */
  50000. addVirtualJoystick(): FreeCameraInputsManager;
  50001. }
  50002. }
  50003. /**
  50004. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50006. */
  50007. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50008. /**
  50009. * Defines the camera the input is attached to.
  50010. */
  50011. camera: FreeCamera;
  50012. private _leftjoystick;
  50013. private _rightjoystick;
  50014. /**
  50015. * Gets the left stick of the virtual joystick.
  50016. * @returns The virtual Joystick
  50017. */
  50018. getLeftJoystick(): VirtualJoystick;
  50019. /**
  50020. * Gets the right stick of the virtual joystick.
  50021. * @returns The virtual Joystick
  50022. */
  50023. getRightJoystick(): VirtualJoystick;
  50024. /**
  50025. * Update the current camera state depending on the inputs that have been used this frame.
  50026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50027. */
  50028. checkInputs(): void;
  50029. /**
  50030. * Attach the input controls to a specific dom element to get the input from.
  50031. * @param element Defines the element the controls should be listened from
  50032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50033. */
  50034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50035. /**
  50036. * Detach the current controls from the specified dom element.
  50037. * @param element Defines the element to stop listening the inputs from
  50038. */
  50039. detachControl(element: Nullable<HTMLElement>): void;
  50040. /**
  50041. * Gets the class name of the current intput.
  50042. * @returns the class name
  50043. */
  50044. getClassName(): string;
  50045. /**
  50046. * Get the friendly name associated with the input class.
  50047. * @returns the input friendly name
  50048. */
  50049. getSimpleName(): string;
  50050. }
  50051. }
  50052. declare module "babylonjs/Cameras/Inputs/index" {
  50053. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50054. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50055. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50056. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50057. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50058. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50059. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50060. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50061. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50062. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50063. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50064. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50065. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50066. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50067. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50068. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50069. }
  50070. declare module "babylonjs/Cameras/touchCamera" {
  50071. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50072. import { Scene } from "babylonjs/scene";
  50073. import { Vector3 } from "babylonjs/Maths/math.vector";
  50074. /**
  50075. * This represents a FPS type of camera controlled by touch.
  50076. * This is like a universal camera minus the Gamepad controls.
  50077. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50078. */
  50079. export class TouchCamera extends FreeCamera {
  50080. /**
  50081. * Defines the touch sensibility for rotation.
  50082. * The higher the faster.
  50083. */
  50084. get touchAngularSensibility(): number;
  50085. set touchAngularSensibility(value: number);
  50086. /**
  50087. * Defines the touch sensibility for move.
  50088. * The higher the faster.
  50089. */
  50090. get touchMoveSensibility(): number;
  50091. set touchMoveSensibility(value: number);
  50092. /**
  50093. * Instantiates a new touch camera.
  50094. * This represents a FPS type of camera controlled by touch.
  50095. * This is like a universal camera minus the Gamepad controls.
  50096. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50097. * @param name Define the name of the camera in the scene
  50098. * @param position Define the start position of the camera in the scene
  50099. * @param scene Define the scene the camera belongs to
  50100. */
  50101. constructor(name: string, position: Vector3, scene: Scene);
  50102. /**
  50103. * Gets the current object class name.
  50104. * @return the class name
  50105. */
  50106. getClassName(): string;
  50107. /** @hidden */
  50108. _setupInputs(): void;
  50109. }
  50110. }
  50111. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50112. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50113. import { Scene } from "babylonjs/scene";
  50114. import { Vector3 } from "babylonjs/Maths/math.vector";
  50115. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50116. import { Axis } from "babylonjs/Maths/math.axis";
  50117. /**
  50118. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50119. * being tilted forward or back and left or right.
  50120. */
  50121. export class DeviceOrientationCamera extends FreeCamera {
  50122. private _initialQuaternion;
  50123. private _quaternionCache;
  50124. private _tmpDragQuaternion;
  50125. private _disablePointerInputWhenUsingDeviceOrientation;
  50126. /**
  50127. * Creates a new device orientation camera
  50128. * @param name The name of the camera
  50129. * @param position The start position camera
  50130. * @param scene The scene the camera belongs to
  50131. */
  50132. constructor(name: string, position: Vector3, scene: Scene);
  50133. /**
  50134. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50135. */
  50136. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50137. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50138. private _dragFactor;
  50139. /**
  50140. * Enabled turning on the y axis when the orientation sensor is active
  50141. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50142. */
  50143. enableHorizontalDragging(dragFactor?: number): void;
  50144. /**
  50145. * Gets the current instance class name ("DeviceOrientationCamera").
  50146. * This helps avoiding instanceof at run time.
  50147. * @returns the class name
  50148. */
  50149. getClassName(): string;
  50150. /**
  50151. * @hidden
  50152. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50153. */
  50154. _checkInputs(): void;
  50155. /**
  50156. * Reset the camera to its default orientation on the specified axis only.
  50157. * @param axis The axis to reset
  50158. */
  50159. resetToCurrentRotation(axis?: Axis): void;
  50160. }
  50161. }
  50162. declare module "babylonjs/Gamepads/xboxGamepad" {
  50163. import { Observable } from "babylonjs/Misc/observable";
  50164. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50165. /**
  50166. * Defines supported buttons for XBox360 compatible gamepads
  50167. */
  50168. export enum Xbox360Button {
  50169. /** A */
  50170. A = 0,
  50171. /** B */
  50172. B = 1,
  50173. /** X */
  50174. X = 2,
  50175. /** Y */
  50176. Y = 3,
  50177. /** Left button */
  50178. LB = 4,
  50179. /** Right button */
  50180. RB = 5,
  50181. /** Back */
  50182. Back = 8,
  50183. /** Start */
  50184. Start = 9,
  50185. /** Left stick */
  50186. LeftStick = 10,
  50187. /** Right stick */
  50188. RightStick = 11
  50189. }
  50190. /** Defines values for XBox360 DPad */
  50191. export enum Xbox360Dpad {
  50192. /** Up */
  50193. Up = 12,
  50194. /** Down */
  50195. Down = 13,
  50196. /** Left */
  50197. Left = 14,
  50198. /** Right */
  50199. Right = 15
  50200. }
  50201. /**
  50202. * Defines a XBox360 gamepad
  50203. */
  50204. export class Xbox360Pad extends Gamepad {
  50205. private _leftTrigger;
  50206. private _rightTrigger;
  50207. private _onlefttriggerchanged;
  50208. private _onrighttriggerchanged;
  50209. private _onbuttondown;
  50210. private _onbuttonup;
  50211. private _ondpaddown;
  50212. private _ondpadup;
  50213. /** Observable raised when a button is pressed */
  50214. onButtonDownObservable: Observable<Xbox360Button>;
  50215. /** Observable raised when a button is released */
  50216. onButtonUpObservable: Observable<Xbox360Button>;
  50217. /** Observable raised when a pad is pressed */
  50218. onPadDownObservable: Observable<Xbox360Dpad>;
  50219. /** Observable raised when a pad is released */
  50220. onPadUpObservable: Observable<Xbox360Dpad>;
  50221. private _buttonA;
  50222. private _buttonB;
  50223. private _buttonX;
  50224. private _buttonY;
  50225. private _buttonBack;
  50226. private _buttonStart;
  50227. private _buttonLB;
  50228. private _buttonRB;
  50229. private _buttonLeftStick;
  50230. private _buttonRightStick;
  50231. private _dPadUp;
  50232. private _dPadDown;
  50233. private _dPadLeft;
  50234. private _dPadRight;
  50235. private _isXboxOnePad;
  50236. /**
  50237. * Creates a new XBox360 gamepad object
  50238. * @param id defines the id of this gamepad
  50239. * @param index defines its index
  50240. * @param gamepad defines the internal HTML gamepad object
  50241. * @param xboxOne defines if it is a XBox One gamepad
  50242. */
  50243. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50244. /**
  50245. * Defines the callback to call when left trigger is pressed
  50246. * @param callback defines the callback to use
  50247. */
  50248. onlefttriggerchanged(callback: (value: number) => void): void;
  50249. /**
  50250. * Defines the callback to call when right trigger is pressed
  50251. * @param callback defines the callback to use
  50252. */
  50253. onrighttriggerchanged(callback: (value: number) => void): void;
  50254. /**
  50255. * Gets the left trigger value
  50256. */
  50257. get leftTrigger(): number;
  50258. /**
  50259. * Sets the left trigger value
  50260. */
  50261. set leftTrigger(newValue: number);
  50262. /**
  50263. * Gets the right trigger value
  50264. */
  50265. get rightTrigger(): number;
  50266. /**
  50267. * Sets the right trigger value
  50268. */
  50269. set rightTrigger(newValue: number);
  50270. /**
  50271. * Defines the callback to call when a button is pressed
  50272. * @param callback defines the callback to use
  50273. */
  50274. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50275. /**
  50276. * Defines the callback to call when a button is released
  50277. * @param callback defines the callback to use
  50278. */
  50279. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50280. /**
  50281. * Defines the callback to call when a pad is pressed
  50282. * @param callback defines the callback to use
  50283. */
  50284. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50285. /**
  50286. * Defines the callback to call when a pad is released
  50287. * @param callback defines the callback to use
  50288. */
  50289. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50290. private _setButtonValue;
  50291. private _setDPadValue;
  50292. /**
  50293. * Gets the value of the `A` button
  50294. */
  50295. get buttonA(): number;
  50296. /**
  50297. * Sets the value of the `A` button
  50298. */
  50299. set buttonA(value: number);
  50300. /**
  50301. * Gets the value of the `B` button
  50302. */
  50303. get buttonB(): number;
  50304. /**
  50305. * Sets the value of the `B` button
  50306. */
  50307. set buttonB(value: number);
  50308. /**
  50309. * Gets the value of the `X` button
  50310. */
  50311. get buttonX(): number;
  50312. /**
  50313. * Sets the value of the `X` button
  50314. */
  50315. set buttonX(value: number);
  50316. /**
  50317. * Gets the value of the `Y` button
  50318. */
  50319. get buttonY(): number;
  50320. /**
  50321. * Sets the value of the `Y` button
  50322. */
  50323. set buttonY(value: number);
  50324. /**
  50325. * Gets the value of the `Start` button
  50326. */
  50327. get buttonStart(): number;
  50328. /**
  50329. * Sets the value of the `Start` button
  50330. */
  50331. set buttonStart(value: number);
  50332. /**
  50333. * Gets the value of the `Back` button
  50334. */
  50335. get buttonBack(): number;
  50336. /**
  50337. * Sets the value of the `Back` button
  50338. */
  50339. set buttonBack(value: number);
  50340. /**
  50341. * Gets the value of the `Left` button
  50342. */
  50343. get buttonLB(): number;
  50344. /**
  50345. * Sets the value of the `Left` button
  50346. */
  50347. set buttonLB(value: number);
  50348. /**
  50349. * Gets the value of the `Right` button
  50350. */
  50351. get buttonRB(): number;
  50352. /**
  50353. * Sets the value of the `Right` button
  50354. */
  50355. set buttonRB(value: number);
  50356. /**
  50357. * Gets the value of the Left joystick
  50358. */
  50359. get buttonLeftStick(): number;
  50360. /**
  50361. * Sets the value of the Left joystick
  50362. */
  50363. set buttonLeftStick(value: number);
  50364. /**
  50365. * Gets the value of the Right joystick
  50366. */
  50367. get buttonRightStick(): number;
  50368. /**
  50369. * Sets the value of the Right joystick
  50370. */
  50371. set buttonRightStick(value: number);
  50372. /**
  50373. * Gets the value of D-pad up
  50374. */
  50375. get dPadUp(): number;
  50376. /**
  50377. * Sets the value of D-pad up
  50378. */
  50379. set dPadUp(value: number);
  50380. /**
  50381. * Gets the value of D-pad down
  50382. */
  50383. get dPadDown(): number;
  50384. /**
  50385. * Sets the value of D-pad down
  50386. */
  50387. set dPadDown(value: number);
  50388. /**
  50389. * Gets the value of D-pad left
  50390. */
  50391. get dPadLeft(): number;
  50392. /**
  50393. * Sets the value of D-pad left
  50394. */
  50395. set dPadLeft(value: number);
  50396. /**
  50397. * Gets the value of D-pad right
  50398. */
  50399. get dPadRight(): number;
  50400. /**
  50401. * Sets the value of D-pad right
  50402. */
  50403. set dPadRight(value: number);
  50404. /**
  50405. * Force the gamepad to synchronize with device values
  50406. */
  50407. update(): void;
  50408. /**
  50409. * Disposes the gamepad
  50410. */
  50411. dispose(): void;
  50412. }
  50413. }
  50414. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50415. import { Observable } from "babylonjs/Misc/observable";
  50416. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50417. /**
  50418. * Defines supported buttons for DualShock compatible gamepads
  50419. */
  50420. export enum DualShockButton {
  50421. /** Cross */
  50422. Cross = 0,
  50423. /** Circle */
  50424. Circle = 1,
  50425. /** Square */
  50426. Square = 2,
  50427. /** Triangle */
  50428. Triangle = 3,
  50429. /** L1 */
  50430. L1 = 4,
  50431. /** R1 */
  50432. R1 = 5,
  50433. /** Share */
  50434. Share = 8,
  50435. /** Options */
  50436. Options = 9,
  50437. /** Left stick */
  50438. LeftStick = 10,
  50439. /** Right stick */
  50440. RightStick = 11
  50441. }
  50442. /** Defines values for DualShock DPad */
  50443. export enum DualShockDpad {
  50444. /** Up */
  50445. Up = 12,
  50446. /** Down */
  50447. Down = 13,
  50448. /** Left */
  50449. Left = 14,
  50450. /** Right */
  50451. Right = 15
  50452. }
  50453. /**
  50454. * Defines a DualShock gamepad
  50455. */
  50456. export class DualShockPad extends Gamepad {
  50457. private _leftTrigger;
  50458. private _rightTrigger;
  50459. private _onlefttriggerchanged;
  50460. private _onrighttriggerchanged;
  50461. private _onbuttondown;
  50462. private _onbuttonup;
  50463. private _ondpaddown;
  50464. private _ondpadup;
  50465. /** Observable raised when a button is pressed */
  50466. onButtonDownObservable: Observable<DualShockButton>;
  50467. /** Observable raised when a button is released */
  50468. onButtonUpObservable: Observable<DualShockButton>;
  50469. /** Observable raised when a pad is pressed */
  50470. onPadDownObservable: Observable<DualShockDpad>;
  50471. /** Observable raised when a pad is released */
  50472. onPadUpObservable: Observable<DualShockDpad>;
  50473. private _buttonCross;
  50474. private _buttonCircle;
  50475. private _buttonSquare;
  50476. private _buttonTriangle;
  50477. private _buttonShare;
  50478. private _buttonOptions;
  50479. private _buttonL1;
  50480. private _buttonR1;
  50481. private _buttonLeftStick;
  50482. private _buttonRightStick;
  50483. private _dPadUp;
  50484. private _dPadDown;
  50485. private _dPadLeft;
  50486. private _dPadRight;
  50487. /**
  50488. * Creates a new DualShock gamepad object
  50489. * @param id defines the id of this gamepad
  50490. * @param index defines its index
  50491. * @param gamepad defines the internal HTML gamepad object
  50492. */
  50493. constructor(id: string, index: number, gamepad: any);
  50494. /**
  50495. * Defines the callback to call when left trigger is pressed
  50496. * @param callback defines the callback to use
  50497. */
  50498. onlefttriggerchanged(callback: (value: number) => void): void;
  50499. /**
  50500. * Defines the callback to call when right trigger is pressed
  50501. * @param callback defines the callback to use
  50502. */
  50503. onrighttriggerchanged(callback: (value: number) => void): void;
  50504. /**
  50505. * Gets the left trigger value
  50506. */
  50507. get leftTrigger(): number;
  50508. /**
  50509. * Sets the left trigger value
  50510. */
  50511. set leftTrigger(newValue: number);
  50512. /**
  50513. * Gets the right trigger value
  50514. */
  50515. get rightTrigger(): number;
  50516. /**
  50517. * Sets the right trigger value
  50518. */
  50519. set rightTrigger(newValue: number);
  50520. /**
  50521. * Defines the callback to call when a button is pressed
  50522. * @param callback defines the callback to use
  50523. */
  50524. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50525. /**
  50526. * Defines the callback to call when a button is released
  50527. * @param callback defines the callback to use
  50528. */
  50529. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50530. /**
  50531. * Defines the callback to call when a pad is pressed
  50532. * @param callback defines the callback to use
  50533. */
  50534. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50535. /**
  50536. * Defines the callback to call when a pad is released
  50537. * @param callback defines the callback to use
  50538. */
  50539. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50540. private _setButtonValue;
  50541. private _setDPadValue;
  50542. /**
  50543. * Gets the value of the `Cross` button
  50544. */
  50545. get buttonCross(): number;
  50546. /**
  50547. * Sets the value of the `Cross` button
  50548. */
  50549. set buttonCross(value: number);
  50550. /**
  50551. * Gets the value of the `Circle` button
  50552. */
  50553. get buttonCircle(): number;
  50554. /**
  50555. * Sets the value of the `Circle` button
  50556. */
  50557. set buttonCircle(value: number);
  50558. /**
  50559. * Gets the value of the `Square` button
  50560. */
  50561. get buttonSquare(): number;
  50562. /**
  50563. * Sets the value of the `Square` button
  50564. */
  50565. set buttonSquare(value: number);
  50566. /**
  50567. * Gets the value of the `Triangle` button
  50568. */
  50569. get buttonTriangle(): number;
  50570. /**
  50571. * Sets the value of the `Triangle` button
  50572. */
  50573. set buttonTriangle(value: number);
  50574. /**
  50575. * Gets the value of the `Options` button
  50576. */
  50577. get buttonOptions(): number;
  50578. /**
  50579. * Sets the value of the `Options` button
  50580. */
  50581. set buttonOptions(value: number);
  50582. /**
  50583. * Gets the value of the `Share` button
  50584. */
  50585. get buttonShare(): number;
  50586. /**
  50587. * Sets the value of the `Share` button
  50588. */
  50589. set buttonShare(value: number);
  50590. /**
  50591. * Gets the value of the `L1` button
  50592. */
  50593. get buttonL1(): number;
  50594. /**
  50595. * Sets the value of the `L1` button
  50596. */
  50597. set buttonL1(value: number);
  50598. /**
  50599. * Gets the value of the `R1` button
  50600. */
  50601. get buttonR1(): number;
  50602. /**
  50603. * Sets the value of the `R1` button
  50604. */
  50605. set buttonR1(value: number);
  50606. /**
  50607. * Gets the value of the Left joystick
  50608. */
  50609. get buttonLeftStick(): number;
  50610. /**
  50611. * Sets the value of the Left joystick
  50612. */
  50613. set buttonLeftStick(value: number);
  50614. /**
  50615. * Gets the value of the Right joystick
  50616. */
  50617. get buttonRightStick(): number;
  50618. /**
  50619. * Sets the value of the Right joystick
  50620. */
  50621. set buttonRightStick(value: number);
  50622. /**
  50623. * Gets the value of D-pad up
  50624. */
  50625. get dPadUp(): number;
  50626. /**
  50627. * Sets the value of D-pad up
  50628. */
  50629. set dPadUp(value: number);
  50630. /**
  50631. * Gets the value of D-pad down
  50632. */
  50633. get dPadDown(): number;
  50634. /**
  50635. * Sets the value of D-pad down
  50636. */
  50637. set dPadDown(value: number);
  50638. /**
  50639. * Gets the value of D-pad left
  50640. */
  50641. get dPadLeft(): number;
  50642. /**
  50643. * Sets the value of D-pad left
  50644. */
  50645. set dPadLeft(value: number);
  50646. /**
  50647. * Gets the value of D-pad right
  50648. */
  50649. get dPadRight(): number;
  50650. /**
  50651. * Sets the value of D-pad right
  50652. */
  50653. set dPadRight(value: number);
  50654. /**
  50655. * Force the gamepad to synchronize with device values
  50656. */
  50657. update(): void;
  50658. /**
  50659. * Disposes the gamepad
  50660. */
  50661. dispose(): void;
  50662. }
  50663. }
  50664. declare module "babylonjs/Gamepads/gamepadManager" {
  50665. import { Observable } from "babylonjs/Misc/observable";
  50666. import { Nullable } from "babylonjs/types";
  50667. import { Scene } from "babylonjs/scene";
  50668. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50669. /**
  50670. * Manager for handling gamepads
  50671. */
  50672. export class GamepadManager {
  50673. private _scene?;
  50674. private _babylonGamepads;
  50675. private _oneGamepadConnected;
  50676. /** @hidden */
  50677. _isMonitoring: boolean;
  50678. private _gamepadEventSupported;
  50679. private _gamepadSupport?;
  50680. /**
  50681. * observable to be triggered when the gamepad controller has been connected
  50682. */
  50683. onGamepadConnectedObservable: Observable<Gamepad>;
  50684. /**
  50685. * observable to be triggered when the gamepad controller has been disconnected
  50686. */
  50687. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50688. private _onGamepadConnectedEvent;
  50689. private _onGamepadDisconnectedEvent;
  50690. /**
  50691. * Initializes the gamepad manager
  50692. * @param _scene BabylonJS scene
  50693. */
  50694. constructor(_scene?: Scene | undefined);
  50695. /**
  50696. * The gamepads in the game pad manager
  50697. */
  50698. get gamepads(): Gamepad[];
  50699. /**
  50700. * Get the gamepad controllers based on type
  50701. * @param type The type of gamepad controller
  50702. * @returns Nullable gamepad
  50703. */
  50704. getGamepadByType(type?: number): Nullable<Gamepad>;
  50705. /**
  50706. * Disposes the gamepad manager
  50707. */
  50708. dispose(): void;
  50709. private _addNewGamepad;
  50710. private _startMonitoringGamepads;
  50711. private _stopMonitoringGamepads;
  50712. /** @hidden */
  50713. _checkGamepadsStatus(): void;
  50714. private _updateGamepadObjects;
  50715. }
  50716. }
  50717. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50718. import { Nullable } from "babylonjs/types";
  50719. import { Scene } from "babylonjs/scene";
  50720. import { ISceneComponent } from "babylonjs/sceneComponent";
  50721. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50722. module "babylonjs/scene" {
  50723. interface Scene {
  50724. /** @hidden */
  50725. _gamepadManager: Nullable<GamepadManager>;
  50726. /**
  50727. * Gets the gamepad manager associated with the scene
  50728. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50729. */
  50730. gamepadManager: GamepadManager;
  50731. }
  50732. }
  50733. module "babylonjs/Cameras/freeCameraInputsManager" {
  50734. /**
  50735. * Interface representing a free camera inputs manager
  50736. */
  50737. interface FreeCameraInputsManager {
  50738. /**
  50739. * Adds gamepad input support to the FreeCameraInputsManager.
  50740. * @returns the FreeCameraInputsManager
  50741. */
  50742. addGamepad(): FreeCameraInputsManager;
  50743. }
  50744. }
  50745. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50746. /**
  50747. * Interface representing an arc rotate camera inputs manager
  50748. */
  50749. interface ArcRotateCameraInputsManager {
  50750. /**
  50751. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50752. * @returns the camera inputs manager
  50753. */
  50754. addGamepad(): ArcRotateCameraInputsManager;
  50755. }
  50756. }
  50757. /**
  50758. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50759. */
  50760. export class GamepadSystemSceneComponent implements ISceneComponent {
  50761. /**
  50762. * The component name helpfull to identify the component in the list of scene components.
  50763. */
  50764. readonly name: string;
  50765. /**
  50766. * The scene the component belongs to.
  50767. */
  50768. scene: Scene;
  50769. /**
  50770. * Creates a new instance of the component for the given scene
  50771. * @param scene Defines the scene to register the component in
  50772. */
  50773. constructor(scene: Scene);
  50774. /**
  50775. * Registers the component in a given scene
  50776. */
  50777. register(): void;
  50778. /**
  50779. * Rebuilds the elements related to this component in case of
  50780. * context lost for instance.
  50781. */
  50782. rebuild(): void;
  50783. /**
  50784. * Disposes the component and the associated ressources
  50785. */
  50786. dispose(): void;
  50787. private _beforeCameraUpdate;
  50788. }
  50789. }
  50790. declare module "babylonjs/Cameras/universalCamera" {
  50791. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50792. import { Scene } from "babylonjs/scene";
  50793. import { Vector3 } from "babylonjs/Maths/math.vector";
  50794. import "babylonjs/Gamepads/gamepadSceneComponent";
  50795. /**
  50796. * 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,
  50797. * which still works and will still be found in many Playgrounds.
  50798. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50799. */
  50800. export class UniversalCamera extends TouchCamera {
  50801. /**
  50802. * Defines the gamepad rotation sensiblity.
  50803. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50804. */
  50805. get gamepadAngularSensibility(): number;
  50806. set gamepadAngularSensibility(value: number);
  50807. /**
  50808. * Defines the gamepad move sensiblity.
  50809. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50810. */
  50811. get gamepadMoveSensibility(): number;
  50812. set gamepadMoveSensibility(value: number);
  50813. /**
  50814. * 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,
  50815. * which still works and will still be found in many Playgrounds.
  50816. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50817. * @param name Define the name of the camera in the scene
  50818. * @param position Define the start position of the camera in the scene
  50819. * @param scene Define the scene the camera belongs to
  50820. */
  50821. constructor(name: string, position: Vector3, scene: Scene);
  50822. /**
  50823. * Gets the current object class name.
  50824. * @return the class name
  50825. */
  50826. getClassName(): string;
  50827. }
  50828. }
  50829. declare module "babylonjs/Cameras/gamepadCamera" {
  50830. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50831. import { Scene } from "babylonjs/scene";
  50832. import { Vector3 } from "babylonjs/Maths/math.vector";
  50833. /**
  50834. * This represents a FPS type of camera. This is only here for back compat purpose.
  50835. * Please use the UniversalCamera instead as both are identical.
  50836. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50837. */
  50838. export class GamepadCamera extends UniversalCamera {
  50839. /**
  50840. * Instantiates a new Gamepad Camera
  50841. * This represents a FPS type of camera. This is only here for back compat purpose.
  50842. * Please use the UniversalCamera instead as both are identical.
  50843. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50844. * @param name Define the name of the camera in the scene
  50845. * @param position Define the start position of the camera in the scene
  50846. * @param scene Define the scene the camera belongs to
  50847. */
  50848. constructor(name: string, position: Vector3, scene: Scene);
  50849. /**
  50850. * Gets the current object class name.
  50851. * @return the class name
  50852. */
  50853. getClassName(): string;
  50854. }
  50855. }
  50856. declare module "babylonjs/Shaders/pass.fragment" {
  50857. /** @hidden */
  50858. export var passPixelShader: {
  50859. name: string;
  50860. shader: string;
  50861. };
  50862. }
  50863. declare module "babylonjs/Shaders/passCube.fragment" {
  50864. /** @hidden */
  50865. export var passCubePixelShader: {
  50866. name: string;
  50867. shader: string;
  50868. };
  50869. }
  50870. declare module "babylonjs/PostProcesses/passPostProcess" {
  50871. import { Nullable } from "babylonjs/types";
  50872. import { Camera } from "babylonjs/Cameras/camera";
  50873. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50874. import { Engine } from "babylonjs/Engines/engine";
  50875. import "babylonjs/Shaders/pass.fragment";
  50876. import "babylonjs/Shaders/passCube.fragment";
  50877. import { Scene } from "babylonjs/scene";
  50878. /**
  50879. * PassPostProcess which produces an output the same as it's input
  50880. */
  50881. export class PassPostProcess extends PostProcess {
  50882. /**
  50883. * Gets a string identifying the name of the class
  50884. * @returns "PassPostProcess" string
  50885. */
  50886. getClassName(): string;
  50887. /**
  50888. * Creates the PassPostProcess
  50889. * @param name The name of the effect.
  50890. * @param options The required width/height ratio to downsize to before computing the render pass.
  50891. * @param camera The camera to apply the render pass to.
  50892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50893. * @param engine The engine which the post process will be applied. (default: current engine)
  50894. * @param reusable If the post process can be reused on the same frame. (default: false)
  50895. * @param textureType The type of texture to be used when performing the post processing.
  50896. * @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)
  50897. */
  50898. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50899. /** @hidden */
  50900. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  50901. }
  50902. /**
  50903. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  50904. */
  50905. export class PassCubePostProcess extends PostProcess {
  50906. private _face;
  50907. /**
  50908. * Gets or sets the cube face to display.
  50909. * * 0 is +X
  50910. * * 1 is -X
  50911. * * 2 is +Y
  50912. * * 3 is -Y
  50913. * * 4 is +Z
  50914. * * 5 is -Z
  50915. */
  50916. get face(): number;
  50917. set face(value: number);
  50918. /**
  50919. * Gets a string identifying the name of the class
  50920. * @returns "PassCubePostProcess" string
  50921. */
  50922. getClassName(): string;
  50923. /**
  50924. * Creates the PassCubePostProcess
  50925. * @param name The name of the effect.
  50926. * @param options The required width/height ratio to downsize to before computing the render pass.
  50927. * @param camera The camera to apply the render pass to.
  50928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50929. * @param engine The engine which the post process will be applied. (default: current engine)
  50930. * @param reusable If the post process can be reused on the same frame. (default: false)
  50931. * @param textureType The type of texture to be used when performing the post processing.
  50932. * @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)
  50933. */
  50934. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50935. /** @hidden */
  50936. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  50937. }
  50938. }
  50939. declare module "babylonjs/Shaders/anaglyph.fragment" {
  50940. /** @hidden */
  50941. export var anaglyphPixelShader: {
  50942. name: string;
  50943. shader: string;
  50944. };
  50945. }
  50946. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  50947. import { Engine } from "babylonjs/Engines/engine";
  50948. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50949. import { Camera } from "babylonjs/Cameras/camera";
  50950. import "babylonjs/Shaders/anaglyph.fragment";
  50951. /**
  50952. * Postprocess used to generate anaglyphic rendering
  50953. */
  50954. export class AnaglyphPostProcess extends PostProcess {
  50955. private _passedProcess;
  50956. /**
  50957. * Gets a string identifying the name of the class
  50958. * @returns "AnaglyphPostProcess" string
  50959. */
  50960. getClassName(): string;
  50961. /**
  50962. * Creates a new AnaglyphPostProcess
  50963. * @param name defines postprocess name
  50964. * @param options defines creation options or target ratio scale
  50965. * @param rigCameras defines cameras using this postprocess
  50966. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  50967. * @param engine defines hosting engine
  50968. * @param reusable defines if the postprocess will be reused multiple times per frame
  50969. */
  50970. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  50971. }
  50972. }
  50973. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  50974. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  50975. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50976. import { Scene } from "babylonjs/scene";
  50977. import { Vector3 } from "babylonjs/Maths/math.vector";
  50978. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50979. /**
  50980. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  50981. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  50982. */
  50983. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  50984. /**
  50985. * Creates a new AnaglyphArcRotateCamera
  50986. * @param name defines camera name
  50987. * @param alpha defines alpha angle (in radians)
  50988. * @param beta defines beta angle (in radians)
  50989. * @param radius defines radius
  50990. * @param target defines camera target
  50991. * @param interaxialDistance defines distance between each color axis
  50992. * @param scene defines the hosting scene
  50993. */
  50994. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  50995. /**
  50996. * Gets camera class name
  50997. * @returns AnaglyphArcRotateCamera
  50998. */
  50999. getClassName(): string;
  51000. }
  51001. }
  51002. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51003. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51004. import { Scene } from "babylonjs/scene";
  51005. import { Vector3 } from "babylonjs/Maths/math.vector";
  51006. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51007. /**
  51008. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51009. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51010. */
  51011. export class AnaglyphFreeCamera extends FreeCamera {
  51012. /**
  51013. * Creates a new AnaglyphFreeCamera
  51014. * @param name defines camera name
  51015. * @param position defines initial position
  51016. * @param interaxialDistance defines distance between each color axis
  51017. * @param scene defines the hosting scene
  51018. */
  51019. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51020. /**
  51021. * Gets camera class name
  51022. * @returns AnaglyphFreeCamera
  51023. */
  51024. getClassName(): string;
  51025. }
  51026. }
  51027. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51028. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51029. import { Scene } from "babylonjs/scene";
  51030. import { Vector3 } from "babylonjs/Maths/math.vector";
  51031. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51032. /**
  51033. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51034. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51035. */
  51036. export class AnaglyphGamepadCamera extends GamepadCamera {
  51037. /**
  51038. * Creates a new AnaglyphGamepadCamera
  51039. * @param name defines camera name
  51040. * @param position defines initial position
  51041. * @param interaxialDistance defines distance between each color axis
  51042. * @param scene defines the hosting scene
  51043. */
  51044. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51045. /**
  51046. * Gets camera class name
  51047. * @returns AnaglyphGamepadCamera
  51048. */
  51049. getClassName(): string;
  51050. }
  51051. }
  51052. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51053. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51054. import { Scene } from "babylonjs/scene";
  51055. import { Vector3 } from "babylonjs/Maths/math.vector";
  51056. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51057. /**
  51058. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51059. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51060. */
  51061. export class AnaglyphUniversalCamera extends UniversalCamera {
  51062. /**
  51063. * Creates a new AnaglyphUniversalCamera
  51064. * @param name defines camera name
  51065. * @param position defines initial position
  51066. * @param interaxialDistance defines distance between each color axis
  51067. * @param scene defines the hosting scene
  51068. */
  51069. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51070. /**
  51071. * Gets camera class name
  51072. * @returns AnaglyphUniversalCamera
  51073. */
  51074. getClassName(): string;
  51075. }
  51076. }
  51077. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51078. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51079. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51080. import { Scene } from "babylonjs/scene";
  51081. import { Vector3 } from "babylonjs/Maths/math.vector";
  51082. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51083. /**
  51084. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51085. * @see https://doc.babylonjs.com/features/cameras
  51086. */
  51087. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51088. /**
  51089. * Creates a new StereoscopicArcRotateCamera
  51090. * @param name defines camera name
  51091. * @param alpha defines alpha angle (in radians)
  51092. * @param beta defines beta angle (in radians)
  51093. * @param radius defines radius
  51094. * @param target defines camera target
  51095. * @param interaxialDistance defines distance between each color axis
  51096. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51097. * @param scene defines the hosting scene
  51098. */
  51099. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51100. /**
  51101. * Gets camera class name
  51102. * @returns StereoscopicArcRotateCamera
  51103. */
  51104. getClassName(): string;
  51105. }
  51106. }
  51107. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51108. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51109. import { Scene } from "babylonjs/scene";
  51110. import { Vector3 } from "babylonjs/Maths/math.vector";
  51111. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51112. /**
  51113. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51114. * @see https://doc.babylonjs.com/features/cameras
  51115. */
  51116. export class StereoscopicFreeCamera extends FreeCamera {
  51117. /**
  51118. * Creates a new StereoscopicFreeCamera
  51119. * @param name defines camera name
  51120. * @param position defines initial position
  51121. * @param interaxialDistance defines distance between each color axis
  51122. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51123. * @param scene defines the hosting scene
  51124. */
  51125. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51126. /**
  51127. * Gets camera class name
  51128. * @returns StereoscopicFreeCamera
  51129. */
  51130. getClassName(): string;
  51131. }
  51132. }
  51133. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51134. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51135. import { Scene } from "babylonjs/scene";
  51136. import { Vector3 } from "babylonjs/Maths/math.vector";
  51137. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51138. /**
  51139. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51140. * @see https://doc.babylonjs.com/features/cameras
  51141. */
  51142. export class StereoscopicGamepadCamera extends GamepadCamera {
  51143. /**
  51144. * Creates a new StereoscopicGamepadCamera
  51145. * @param name defines camera name
  51146. * @param position defines initial position
  51147. * @param interaxialDistance defines distance between each color axis
  51148. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51149. * @param scene defines the hosting scene
  51150. */
  51151. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51152. /**
  51153. * Gets camera class name
  51154. * @returns StereoscopicGamepadCamera
  51155. */
  51156. getClassName(): string;
  51157. }
  51158. }
  51159. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51160. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51161. import { Scene } from "babylonjs/scene";
  51162. import { Vector3 } from "babylonjs/Maths/math.vector";
  51163. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51164. /**
  51165. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51166. * @see https://doc.babylonjs.com/features/cameras
  51167. */
  51168. export class StereoscopicUniversalCamera extends UniversalCamera {
  51169. /**
  51170. * Creates a new StereoscopicUniversalCamera
  51171. * @param name defines camera name
  51172. * @param position defines initial position
  51173. * @param interaxialDistance defines distance between each color axis
  51174. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51175. * @param scene defines the hosting scene
  51176. */
  51177. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51178. /**
  51179. * Gets camera class name
  51180. * @returns StereoscopicUniversalCamera
  51181. */
  51182. getClassName(): string;
  51183. }
  51184. }
  51185. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51186. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51187. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51188. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51189. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51190. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51191. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51192. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51193. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51194. }
  51195. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51197. import { Scene } from "babylonjs/scene";
  51198. import { Vector3 } from "babylonjs/Maths/math.vector";
  51199. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51200. /**
  51201. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51202. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51203. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51204. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51205. */
  51206. export class VirtualJoysticksCamera extends FreeCamera {
  51207. /**
  51208. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51209. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51210. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51211. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51212. * @param name Define the name of the camera in the scene
  51213. * @param position Define the start position of the camera in the scene
  51214. * @param scene Define the scene the camera belongs to
  51215. */
  51216. constructor(name: string, position: Vector3, scene: Scene);
  51217. /**
  51218. * Gets the current object class name.
  51219. * @return the class name
  51220. */
  51221. getClassName(): string;
  51222. }
  51223. }
  51224. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51225. import { Matrix } from "babylonjs/Maths/math.vector";
  51226. /**
  51227. * This represents all the required metrics to create a VR camera.
  51228. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51229. */
  51230. export class VRCameraMetrics {
  51231. /**
  51232. * Define the horizontal resolution off the screen.
  51233. */
  51234. hResolution: number;
  51235. /**
  51236. * Define the vertical resolution off the screen.
  51237. */
  51238. vResolution: number;
  51239. /**
  51240. * Define the horizontal screen size.
  51241. */
  51242. hScreenSize: number;
  51243. /**
  51244. * Define the vertical screen size.
  51245. */
  51246. vScreenSize: number;
  51247. /**
  51248. * Define the vertical screen center position.
  51249. */
  51250. vScreenCenter: number;
  51251. /**
  51252. * Define the distance of the eyes to the screen.
  51253. */
  51254. eyeToScreenDistance: number;
  51255. /**
  51256. * Define the distance between both lenses
  51257. */
  51258. lensSeparationDistance: number;
  51259. /**
  51260. * Define the distance between both viewer's eyes.
  51261. */
  51262. interpupillaryDistance: number;
  51263. /**
  51264. * Define the distortion factor of the VR postprocess.
  51265. * Please, touch with care.
  51266. */
  51267. distortionK: number[];
  51268. /**
  51269. * Define the chromatic aberration correction factors for the VR post process.
  51270. */
  51271. chromaAbCorrection: number[];
  51272. /**
  51273. * Define the scale factor of the post process.
  51274. * The smaller the better but the slower.
  51275. */
  51276. postProcessScaleFactor: number;
  51277. /**
  51278. * Define an offset for the lens center.
  51279. */
  51280. lensCenterOffset: number;
  51281. /**
  51282. * Define if the current vr camera should compensate the distortion of the lense or not.
  51283. */
  51284. compensateDistortion: boolean;
  51285. /**
  51286. * Defines if multiview should be enabled when rendering (Default: false)
  51287. */
  51288. multiviewEnabled: boolean;
  51289. /**
  51290. * Gets the rendering aspect ratio based on the provided resolutions.
  51291. */
  51292. get aspectRatio(): number;
  51293. /**
  51294. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51295. */
  51296. get aspectRatioFov(): number;
  51297. /**
  51298. * @hidden
  51299. */
  51300. get leftHMatrix(): Matrix;
  51301. /**
  51302. * @hidden
  51303. */
  51304. get rightHMatrix(): Matrix;
  51305. /**
  51306. * @hidden
  51307. */
  51308. get leftPreViewMatrix(): Matrix;
  51309. /**
  51310. * @hidden
  51311. */
  51312. get rightPreViewMatrix(): Matrix;
  51313. /**
  51314. * Get the default VRMetrics based on the most generic setup.
  51315. * @returns the default vr metrics
  51316. */
  51317. static GetDefault(): VRCameraMetrics;
  51318. }
  51319. }
  51320. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51321. /** @hidden */
  51322. export var vrDistortionCorrectionPixelShader: {
  51323. name: string;
  51324. shader: string;
  51325. };
  51326. }
  51327. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51328. import { Camera } from "babylonjs/Cameras/camera";
  51329. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51330. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51331. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51332. /**
  51333. * VRDistortionCorrectionPostProcess used for mobile VR
  51334. */
  51335. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51336. private _isRightEye;
  51337. private _distortionFactors;
  51338. private _postProcessScaleFactor;
  51339. private _lensCenterOffset;
  51340. private _scaleIn;
  51341. private _scaleFactor;
  51342. private _lensCenter;
  51343. /**
  51344. * Gets a string identifying the name of the class
  51345. * @returns "VRDistortionCorrectionPostProcess" string
  51346. */
  51347. getClassName(): string;
  51348. /**
  51349. * Initializes the VRDistortionCorrectionPostProcess
  51350. * @param name The name of the effect.
  51351. * @param camera The camera to apply the render pass to.
  51352. * @param isRightEye If this is for the right eye distortion
  51353. * @param vrMetrics All the required metrics for the VR camera
  51354. */
  51355. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51356. }
  51357. }
  51358. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51359. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51360. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51361. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51362. import { Scene } from "babylonjs/scene";
  51363. import { Vector3 } from "babylonjs/Maths/math.vector";
  51364. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51365. import "babylonjs/Cameras/RigModes/vrRigMode";
  51366. /**
  51367. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51368. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51369. */
  51370. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51371. /**
  51372. * Creates a new VRDeviceOrientationArcRotateCamera
  51373. * @param name defines camera name
  51374. * @param alpha defines the camera rotation along the logitudinal axis
  51375. * @param beta defines the camera rotation along the latitudinal axis
  51376. * @param radius defines the camera distance from its target
  51377. * @param target defines the camera target
  51378. * @param scene defines the scene the camera belongs to
  51379. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51380. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51381. */
  51382. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51383. /**
  51384. * Gets camera class name
  51385. * @returns VRDeviceOrientationArcRotateCamera
  51386. */
  51387. getClassName(): string;
  51388. }
  51389. }
  51390. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51391. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51392. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51393. import { Scene } from "babylonjs/scene";
  51394. import { Vector3 } from "babylonjs/Maths/math.vector";
  51395. import "babylonjs/Cameras/RigModes/vrRigMode";
  51396. /**
  51397. * Camera used to simulate VR rendering (based on FreeCamera)
  51398. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51399. */
  51400. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51401. /**
  51402. * Creates a new VRDeviceOrientationFreeCamera
  51403. * @param name defines camera name
  51404. * @param position defines the start position of the camera
  51405. * @param scene defines the scene the camera belongs to
  51406. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51407. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51408. */
  51409. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51410. /**
  51411. * Gets camera class name
  51412. * @returns VRDeviceOrientationFreeCamera
  51413. */
  51414. getClassName(): string;
  51415. }
  51416. }
  51417. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51418. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51419. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51420. import { Scene } from "babylonjs/scene";
  51421. import { Vector3 } from "babylonjs/Maths/math.vector";
  51422. import "babylonjs/Gamepads/gamepadSceneComponent";
  51423. /**
  51424. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51425. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51426. */
  51427. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51428. /**
  51429. * Creates a new VRDeviceOrientationGamepadCamera
  51430. * @param name defines camera name
  51431. * @param position defines the start position of the camera
  51432. * @param scene defines the scene the camera belongs to
  51433. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51434. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51435. */
  51436. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51437. /**
  51438. * Gets camera class name
  51439. * @returns VRDeviceOrientationGamepadCamera
  51440. */
  51441. getClassName(): string;
  51442. }
  51443. }
  51444. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51445. import { Scene } from "babylonjs/scene";
  51446. import { Texture } from "babylonjs/Materials/Textures/texture";
  51447. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51448. /**
  51449. * A class extending Texture allowing drawing on a texture
  51450. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51451. */
  51452. export class DynamicTexture extends Texture {
  51453. private _generateMipMaps;
  51454. private _canvas;
  51455. private _context;
  51456. /**
  51457. * Creates a DynamicTexture
  51458. * @param name defines the name of the texture
  51459. * @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
  51460. * @param scene defines the scene where you want the texture
  51461. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51462. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51463. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51464. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51465. */
  51466. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51467. /**
  51468. * Get the current class name of the texture useful for serialization or dynamic coding.
  51469. * @returns "DynamicTexture"
  51470. */
  51471. getClassName(): string;
  51472. /**
  51473. * Gets the current state of canRescale
  51474. */
  51475. get canRescale(): boolean;
  51476. private _recreate;
  51477. /**
  51478. * Scales the texture
  51479. * @param ratio the scale factor to apply to both width and height
  51480. */
  51481. scale(ratio: number): void;
  51482. /**
  51483. * Resizes the texture
  51484. * @param width the new width
  51485. * @param height the new height
  51486. */
  51487. scaleTo(width: number, height: number): void;
  51488. /**
  51489. * Gets the context of the canvas used by the texture
  51490. * @returns the canvas context of the dynamic texture
  51491. */
  51492. getContext(): CanvasRenderingContext2D;
  51493. /**
  51494. * Clears the texture
  51495. */
  51496. clear(): void;
  51497. /**
  51498. * Updates the texture
  51499. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51500. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51501. */
  51502. update(invertY?: boolean, premulAlpha?: boolean): void;
  51503. /**
  51504. * Draws text onto the texture
  51505. * @param text defines the text to be drawn
  51506. * @param x defines the placement of the text from the left
  51507. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51508. * @param font defines the font to be used with font-style, font-size, font-name
  51509. * @param color defines the color used for the text
  51510. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51511. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51512. * @param update defines whether texture is immediately update (default is true)
  51513. */
  51514. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51515. /**
  51516. * Clones the texture
  51517. * @returns the clone of the texture.
  51518. */
  51519. clone(): DynamicTexture;
  51520. /**
  51521. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51522. * @returns a serialized dynamic texture object
  51523. */
  51524. serialize(): any;
  51525. private _IsCanvasElement;
  51526. /** @hidden */
  51527. _rebuild(): void;
  51528. }
  51529. }
  51530. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51531. import { Scene } from "babylonjs/scene";
  51532. import { Color3 } from "babylonjs/Maths/math.color";
  51533. import { Mesh } from "babylonjs/Meshes/mesh";
  51534. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51535. import { Nullable } from "babylonjs/types";
  51536. /**
  51537. * Class containing static functions to help procedurally build meshes
  51538. */
  51539. export class GroundBuilder {
  51540. /**
  51541. * Creates a ground mesh
  51542. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51543. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51545. * @param name defines the name of the mesh
  51546. * @param options defines the options used to create the mesh
  51547. * @param scene defines the hosting scene
  51548. * @returns the ground mesh
  51549. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51550. */
  51551. static CreateGround(name: string, options: {
  51552. width?: number;
  51553. height?: number;
  51554. subdivisions?: number;
  51555. subdivisionsX?: number;
  51556. subdivisionsY?: number;
  51557. updatable?: boolean;
  51558. }, scene: any): Mesh;
  51559. /**
  51560. * Creates a tiled ground mesh
  51561. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51562. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51563. * * 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
  51564. * * 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
  51565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51566. * @param name defines the name of the mesh
  51567. * @param options defines the options used to create the mesh
  51568. * @param scene defines the hosting scene
  51569. * @returns the tiled ground mesh
  51570. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51571. */
  51572. static CreateTiledGround(name: string, options: {
  51573. xmin: number;
  51574. zmin: number;
  51575. xmax: number;
  51576. zmax: number;
  51577. subdivisions?: {
  51578. w: number;
  51579. h: number;
  51580. };
  51581. precision?: {
  51582. w: number;
  51583. h: number;
  51584. };
  51585. updatable?: boolean;
  51586. }, scene?: Nullable<Scene>): Mesh;
  51587. /**
  51588. * Creates a ground mesh from a height map
  51589. * * The parameter `url` sets the URL of the height map image resource.
  51590. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51591. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51592. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51593. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51594. * * 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.
  51595. * * 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).
  51596. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51598. * @param name defines the name of the mesh
  51599. * @param url defines the url to the height map
  51600. * @param options defines the options used to create the mesh
  51601. * @param scene defines the hosting scene
  51602. * @returns the ground mesh
  51603. * @see https://doc.babylonjs.com/babylon101/height_map
  51604. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51605. */
  51606. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51607. width?: number;
  51608. height?: number;
  51609. subdivisions?: number;
  51610. minHeight?: number;
  51611. maxHeight?: number;
  51612. colorFilter?: Color3;
  51613. alphaFilter?: number;
  51614. updatable?: boolean;
  51615. onReady?: (mesh: GroundMesh) => void;
  51616. }, scene?: Nullable<Scene>): GroundMesh;
  51617. }
  51618. }
  51619. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51620. import { Vector4 } from "babylonjs/Maths/math.vector";
  51621. import { Mesh } from "babylonjs/Meshes/mesh";
  51622. /**
  51623. * Class containing static functions to help procedurally build meshes
  51624. */
  51625. export class TorusBuilder {
  51626. /**
  51627. * Creates a torus mesh
  51628. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51629. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51630. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51634. * @param name defines the name of the mesh
  51635. * @param options defines the options used to create the mesh
  51636. * @param scene defines the hosting scene
  51637. * @returns the torus mesh
  51638. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51639. */
  51640. static CreateTorus(name: string, options: {
  51641. diameter?: number;
  51642. thickness?: number;
  51643. tessellation?: number;
  51644. updatable?: boolean;
  51645. sideOrientation?: number;
  51646. frontUVs?: Vector4;
  51647. backUVs?: Vector4;
  51648. }, scene: any): Mesh;
  51649. }
  51650. }
  51651. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51652. import { Vector4 } from "babylonjs/Maths/math.vector";
  51653. import { Color4 } from "babylonjs/Maths/math.color";
  51654. import { Mesh } from "babylonjs/Meshes/mesh";
  51655. /**
  51656. * Class containing static functions to help procedurally build meshes
  51657. */
  51658. export class CylinderBuilder {
  51659. /**
  51660. * Creates a cylinder or a cone mesh
  51661. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51662. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51663. * * 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.
  51664. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51665. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51666. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51667. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51668. * * 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).
  51669. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51670. * * 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).
  51671. * * 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
  51672. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51673. * * 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
  51674. * * 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.
  51675. * * If `enclose` is false, a ring surface is one element.
  51676. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51677. * * 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
  51678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51681. * @param name defines the name of the mesh
  51682. * @param options defines the options used to create the mesh
  51683. * @param scene defines the hosting scene
  51684. * @returns the cylinder mesh
  51685. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51686. */
  51687. static CreateCylinder(name: string, options: {
  51688. height?: number;
  51689. diameterTop?: number;
  51690. diameterBottom?: number;
  51691. diameter?: number;
  51692. tessellation?: number;
  51693. subdivisions?: number;
  51694. arc?: number;
  51695. faceColors?: Color4[];
  51696. faceUV?: Vector4[];
  51697. updatable?: boolean;
  51698. hasRings?: boolean;
  51699. enclose?: boolean;
  51700. cap?: number;
  51701. sideOrientation?: number;
  51702. frontUVs?: Vector4;
  51703. backUVs?: Vector4;
  51704. }, scene: any): Mesh;
  51705. }
  51706. }
  51707. declare module "babylonjs/XR/webXRTypes" {
  51708. import { Nullable } from "babylonjs/types";
  51709. import { IDisposable } from "babylonjs/scene";
  51710. /**
  51711. * States of the webXR experience
  51712. */
  51713. export enum WebXRState {
  51714. /**
  51715. * Transitioning to being in XR mode
  51716. */
  51717. ENTERING_XR = 0,
  51718. /**
  51719. * Transitioning to non XR mode
  51720. */
  51721. EXITING_XR = 1,
  51722. /**
  51723. * In XR mode and presenting
  51724. */
  51725. IN_XR = 2,
  51726. /**
  51727. * Not entered XR mode
  51728. */
  51729. NOT_IN_XR = 3
  51730. }
  51731. /**
  51732. * Abstraction of the XR render target
  51733. */
  51734. export interface WebXRRenderTarget extends IDisposable {
  51735. /**
  51736. * xrpresent context of the canvas which can be used to display/mirror xr content
  51737. */
  51738. canvasContext: WebGLRenderingContext;
  51739. /**
  51740. * xr layer for the canvas
  51741. */
  51742. xrLayer: Nullable<XRWebGLLayer>;
  51743. /**
  51744. * Initializes the xr layer for the session
  51745. * @param xrSession xr session
  51746. * @returns a promise that will resolve once the XR Layer has been created
  51747. */
  51748. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51749. }
  51750. }
  51751. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51752. import { Nullable } from "babylonjs/types";
  51753. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51754. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51755. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51756. import { Observable } from "babylonjs/Misc/observable";
  51757. /**
  51758. * COnfiguration object for WebXR output canvas
  51759. */
  51760. export class WebXRManagedOutputCanvasOptions {
  51761. /**
  51762. * An optional canvas in case you wish to create it yourself and provide it here.
  51763. * If not provided, a new canvas will be created
  51764. */
  51765. canvasElement?: HTMLCanvasElement;
  51766. /**
  51767. * Options for this XR Layer output
  51768. */
  51769. canvasOptions?: XRWebGLLayerOptions;
  51770. /**
  51771. * CSS styling for a newly created canvas (if not provided)
  51772. */
  51773. newCanvasCssStyle?: string;
  51774. /**
  51775. * Get the default values of the configuration object
  51776. * @param engine defines the engine to use (can be null)
  51777. * @returns default values of this configuration object
  51778. */
  51779. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51780. }
  51781. /**
  51782. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51783. */
  51784. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51785. private _options;
  51786. private _canvas;
  51787. private _engine;
  51788. private _originalCanvasSize;
  51789. /**
  51790. * Rendering context of the canvas which can be used to display/mirror xr content
  51791. */
  51792. canvasContext: WebGLRenderingContext;
  51793. /**
  51794. * xr layer for the canvas
  51795. */
  51796. xrLayer: Nullable<XRWebGLLayer>;
  51797. /**
  51798. * Obseervers registered here will be triggered when the xr layer was initialized
  51799. */
  51800. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51801. /**
  51802. * Initializes the canvas to be added/removed upon entering/exiting xr
  51803. * @param _xrSessionManager The XR Session manager
  51804. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51805. */
  51806. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51807. /**
  51808. * Disposes of the object
  51809. */
  51810. dispose(): void;
  51811. /**
  51812. * Initializes the xr layer for the session
  51813. * @param xrSession xr session
  51814. * @returns a promise that will resolve once the XR Layer has been created
  51815. */
  51816. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51817. private _addCanvas;
  51818. private _removeCanvas;
  51819. private _setCanvasSize;
  51820. private _setManagedOutputCanvas;
  51821. }
  51822. }
  51823. declare module "babylonjs/XR/webXRSessionManager" {
  51824. import { Observable } from "babylonjs/Misc/observable";
  51825. import { Nullable } from "babylonjs/types";
  51826. import { IDisposable, Scene } from "babylonjs/scene";
  51827. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51828. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51829. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51830. /**
  51831. * Manages an XRSession to work with Babylon's engine
  51832. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51833. */
  51834. export class WebXRSessionManager implements IDisposable {
  51835. /** The scene which the session should be created for */
  51836. scene: Scene;
  51837. private _referenceSpace;
  51838. private _rttProvider;
  51839. private _sessionEnded;
  51840. private _xrNavigator;
  51841. private baseLayer;
  51842. /**
  51843. * The base reference space from which the session started. good if you want to reset your
  51844. * reference space
  51845. */
  51846. baseReferenceSpace: XRReferenceSpace;
  51847. /**
  51848. * Current XR frame
  51849. */
  51850. currentFrame: Nullable<XRFrame>;
  51851. /** WebXR timestamp updated every frame */
  51852. currentTimestamp: number;
  51853. /**
  51854. * Used just in case of a failure to initialize an immersive session.
  51855. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51856. */
  51857. defaultHeightCompensation: number;
  51858. /**
  51859. * Fires every time a new xrFrame arrives which can be used to update the camera
  51860. */
  51861. onXRFrameObservable: Observable<XRFrame>;
  51862. /**
  51863. * Fires when the reference space changed
  51864. */
  51865. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51866. /**
  51867. * Fires when the xr session is ended either by the device or manually done
  51868. */
  51869. onXRSessionEnded: Observable<any>;
  51870. /**
  51871. * Fires when the xr session is ended either by the device or manually done
  51872. */
  51873. onXRSessionInit: Observable<XRSession>;
  51874. /**
  51875. * Underlying xr session
  51876. */
  51877. session: XRSession;
  51878. /**
  51879. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  51880. * or get the offset the player is currently at.
  51881. */
  51882. viewerReferenceSpace: XRReferenceSpace;
  51883. /**
  51884. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  51885. * @param scene The scene which the session should be created for
  51886. */
  51887. constructor(
  51888. /** The scene which the session should be created for */
  51889. scene: Scene);
  51890. /**
  51891. * The current reference space used in this session. This reference space can constantly change!
  51892. * It is mainly used to offset the camera's position.
  51893. */
  51894. get referenceSpace(): XRReferenceSpace;
  51895. /**
  51896. * Set a new reference space and triggers the observable
  51897. */
  51898. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  51899. /**
  51900. * Disposes of the session manager
  51901. */
  51902. dispose(): void;
  51903. /**
  51904. * Stops the xrSession and restores the render loop
  51905. * @returns Promise which resolves after it exits XR
  51906. */
  51907. exitXRAsync(): Promise<void>;
  51908. /**
  51909. * Gets the correct render target texture to be rendered this frame for this eye
  51910. * @param eye the eye for which to get the render target
  51911. * @returns the render target for the specified eye
  51912. */
  51913. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  51914. /**
  51915. * Creates a WebXRRenderTarget object for the XR session
  51916. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  51917. * @param options optional options to provide when creating a new render target
  51918. * @returns a WebXR render target to which the session can render
  51919. */
  51920. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  51921. /**
  51922. * Initializes the manager
  51923. * After initialization enterXR can be called to start an XR session
  51924. * @returns Promise which resolves after it is initialized
  51925. */
  51926. initializeAsync(): Promise<void>;
  51927. /**
  51928. * Initializes an xr session
  51929. * @param xrSessionMode mode to initialize
  51930. * @param xrSessionInit defines optional and required values to pass to the session builder
  51931. * @returns a promise which will resolve once the session has been initialized
  51932. */
  51933. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  51934. /**
  51935. * Checks if a session would be supported for the creation options specified
  51936. * @param sessionMode session mode to check if supported eg. immersive-vr
  51937. * @returns A Promise that resolves to true if supported and false if not
  51938. */
  51939. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  51940. /**
  51941. * Resets the reference space to the one started the session
  51942. */
  51943. resetReferenceSpace(): void;
  51944. /**
  51945. * Starts rendering to the xr layer
  51946. */
  51947. runXRRenderLoop(): void;
  51948. /**
  51949. * Sets the reference space on the xr session
  51950. * @param referenceSpaceType space to set
  51951. * @returns a promise that will resolve once the reference space has been set
  51952. */
  51953. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  51954. /**
  51955. * Updates the render state of the session
  51956. * @param state state to set
  51957. * @returns a promise that resolves once the render state has been updated
  51958. */
  51959. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  51960. /**
  51961. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  51962. * @param sessionMode defines the session to test
  51963. * @returns a promise with boolean as final value
  51964. */
  51965. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  51966. private _createRenderTargetTexture;
  51967. }
  51968. }
  51969. declare module "babylonjs/XR/webXRCamera" {
  51970. import { Vector3 } from "babylonjs/Maths/math.vector";
  51971. import { Scene } from "babylonjs/scene";
  51972. import { Camera } from "babylonjs/Cameras/camera";
  51973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51974. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51975. import { Observable } from "babylonjs/Misc/observable";
  51976. /**
  51977. * WebXR Camera which holds the views for the xrSession
  51978. * @see https://doc.babylonjs.com/how_to/webxr_camera
  51979. */
  51980. export class WebXRCamera extends FreeCamera {
  51981. private _xrSessionManager;
  51982. private _firstFrame;
  51983. private _referenceQuaternion;
  51984. private _referencedPosition;
  51985. private _xrInvPositionCache;
  51986. private _xrInvQuaternionCache;
  51987. /**
  51988. * Observable raised before camera teleportation
  51989. */
  51990. onBeforeCameraTeleport: Observable<Vector3>;
  51991. /**
  51992. * Observable raised after camera teleportation
  51993. */
  51994. onAfterCameraTeleport: Observable<Vector3>;
  51995. /**
  51996. * Should position compensation execute on first frame.
  51997. * This is used when copying the position from a native (non XR) camera
  51998. */
  51999. compensateOnFirstFrame: boolean;
  52000. /**
  52001. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52002. * @param name the name of the camera
  52003. * @param scene the scene to add the camera to
  52004. * @param _xrSessionManager a constructed xr session manager
  52005. */
  52006. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52007. /**
  52008. * Return the user's height, unrelated to the current ground.
  52009. * This will be the y position of this camera, when ground level is 0.
  52010. */
  52011. get realWorldHeight(): number;
  52012. /** @hidden */
  52013. _updateForDualEyeDebugging(): void;
  52014. /**
  52015. * Sets this camera's transformation based on a non-vr camera
  52016. * @param otherCamera the non-vr camera to copy the transformation from
  52017. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52018. */
  52019. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52020. /**
  52021. * Gets the current instance class name ("WebXRCamera").
  52022. * @returns the class name
  52023. */
  52024. getClassName(): string;
  52025. private _rotate180;
  52026. private _updateFromXRSession;
  52027. private _updateNumberOfRigCameras;
  52028. private _updateReferenceSpace;
  52029. private _updateReferenceSpaceOffset;
  52030. }
  52031. }
  52032. declare module "babylonjs/XR/webXRFeaturesManager" {
  52033. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52034. import { IDisposable } from "babylonjs/scene";
  52035. /**
  52036. * Defining the interface required for a (webxr) feature
  52037. */
  52038. export interface IWebXRFeature extends IDisposable {
  52039. /**
  52040. * Is this feature attached
  52041. */
  52042. attached: boolean;
  52043. /**
  52044. * Should auto-attach be disabled?
  52045. */
  52046. disableAutoAttach: boolean;
  52047. /**
  52048. * Attach the feature to the session
  52049. * Will usually be called by the features manager
  52050. *
  52051. * @param force should attachment be forced (even when already attached)
  52052. * @returns true if successful.
  52053. */
  52054. attach(force?: boolean): boolean;
  52055. /**
  52056. * Detach the feature from the session
  52057. * Will usually be called by the features manager
  52058. *
  52059. * @returns true if successful.
  52060. */
  52061. detach(): boolean;
  52062. /**
  52063. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52064. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52065. *
  52066. * @returns whether or not the feature is compatible in this environment
  52067. */
  52068. isCompatible(): boolean;
  52069. /**
  52070. * Was this feature disposed;
  52071. */
  52072. isDisposed: boolean;
  52073. /**
  52074. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52075. */
  52076. xrNativeFeatureName?: string;
  52077. /**
  52078. * A list of (Babylon WebXR) features this feature depends on
  52079. */
  52080. dependsOn?: string[];
  52081. }
  52082. /**
  52083. * A list of the currently available features without referencing them
  52084. */
  52085. export class WebXRFeatureName {
  52086. /**
  52087. * The name of the anchor system feature
  52088. */
  52089. static readonly ANCHOR_SYSTEM: string;
  52090. /**
  52091. * The name of the background remover feature
  52092. */
  52093. static readonly BACKGROUND_REMOVER: string;
  52094. /**
  52095. * The name of the hit test feature
  52096. */
  52097. static readonly HIT_TEST: string;
  52098. /**
  52099. * physics impostors for xr controllers feature
  52100. */
  52101. static readonly PHYSICS_CONTROLLERS: string;
  52102. /**
  52103. * The name of the plane detection feature
  52104. */
  52105. static readonly PLANE_DETECTION: string;
  52106. /**
  52107. * The name of the pointer selection feature
  52108. */
  52109. static readonly POINTER_SELECTION: string;
  52110. /**
  52111. * The name of the teleportation feature
  52112. */
  52113. static readonly TELEPORTATION: string;
  52114. /**
  52115. * The name of the feature points feature.
  52116. */
  52117. static readonly FEATURE_POINTS: string;
  52118. /**
  52119. * The name of the hand tracking feature.
  52120. */
  52121. static readonly HAND_TRACKING: string;
  52122. }
  52123. /**
  52124. * Defining the constructor of a feature. Used to register the modules.
  52125. */
  52126. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52127. /**
  52128. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52129. * It is mainly used in AR sessions.
  52130. *
  52131. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52132. */
  52133. export class WebXRFeaturesManager implements IDisposable {
  52134. private _xrSessionManager;
  52135. private static readonly _AvailableFeatures;
  52136. private _features;
  52137. /**
  52138. * constructs a new features manages.
  52139. *
  52140. * @param _xrSessionManager an instance of WebXRSessionManager
  52141. */
  52142. constructor(_xrSessionManager: WebXRSessionManager);
  52143. /**
  52144. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52145. * Mainly used internally.
  52146. *
  52147. * @param featureName the name of the feature to register
  52148. * @param constructorFunction the function used to construct the module
  52149. * @param version the (babylon) version of the module
  52150. * @param stable is that a stable version of this module
  52151. */
  52152. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52153. /**
  52154. * Returns a constructor of a specific feature.
  52155. *
  52156. * @param featureName the name of the feature to construct
  52157. * @param version the version of the feature to load
  52158. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52159. * @param options optional options provided to the module.
  52160. * @returns a function that, when called, will return a new instance of this feature
  52161. */
  52162. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52163. /**
  52164. * Can be used to return the list of features currently registered
  52165. *
  52166. * @returns an Array of available features
  52167. */
  52168. static GetAvailableFeatures(): string[];
  52169. /**
  52170. * Gets the versions available for a specific feature
  52171. * @param featureName the name of the feature
  52172. * @returns an array with the available versions
  52173. */
  52174. static GetAvailableVersions(featureName: string): string[];
  52175. /**
  52176. * Return the latest unstable version of this feature
  52177. * @param featureName the name of the feature to search
  52178. * @returns the version number. if not found will return -1
  52179. */
  52180. static GetLatestVersionOfFeature(featureName: string): number;
  52181. /**
  52182. * Return the latest stable version of this feature
  52183. * @param featureName the name of the feature to search
  52184. * @returns the version number. if not found will return -1
  52185. */
  52186. static GetStableVersionOfFeature(featureName: string): number;
  52187. /**
  52188. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52189. * Can be used during a session to start a feature
  52190. * @param featureName the name of feature to attach
  52191. */
  52192. attachFeature(featureName: string): void;
  52193. /**
  52194. * Can be used inside a session or when the session ends to detach a specific feature
  52195. * @param featureName the name of the feature to detach
  52196. */
  52197. detachFeature(featureName: string): void;
  52198. /**
  52199. * Used to disable an already-enabled feature
  52200. * The feature will be disposed and will be recreated once enabled.
  52201. * @param featureName the feature to disable
  52202. * @returns true if disable was successful
  52203. */
  52204. disableFeature(featureName: string | {
  52205. Name: string;
  52206. }): boolean;
  52207. /**
  52208. * dispose this features manager
  52209. */
  52210. dispose(): void;
  52211. /**
  52212. * 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.
  52213. * 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.
  52214. *
  52215. * @param featureName the name of the feature to load or the class of the feature
  52216. * @param version optional version to load. if not provided the latest version will be enabled
  52217. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52218. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52219. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52220. * @returns a new constructed feature or throws an error if feature not found.
  52221. */
  52222. enableFeature(featureName: string | {
  52223. Name: string;
  52224. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52225. /**
  52226. * get the implementation of an enabled feature.
  52227. * @param featureName the name of the feature to load
  52228. * @returns the feature class, if found
  52229. */
  52230. getEnabledFeature(featureName: string): IWebXRFeature;
  52231. /**
  52232. * Get the list of enabled features
  52233. * @returns an array of enabled features
  52234. */
  52235. getEnabledFeatures(): string[];
  52236. /**
  52237. * This function will exten the session creation configuration object with enabled features.
  52238. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52239. * according to the defined "required" variable, provided during enableFeature call
  52240. * @param xrSessionInit the xr Session init object to extend
  52241. *
  52242. * @returns an extended XRSessionInit object
  52243. */
  52244. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52245. }
  52246. }
  52247. declare module "babylonjs/XR/webXRExperienceHelper" {
  52248. import { Observable } from "babylonjs/Misc/observable";
  52249. import { IDisposable, Scene } from "babylonjs/scene";
  52250. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52251. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52252. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52253. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52254. /**
  52255. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52256. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52257. */
  52258. export class WebXRExperienceHelper implements IDisposable {
  52259. private scene;
  52260. private _nonVRCamera;
  52261. private _originalSceneAutoClear;
  52262. private _supported;
  52263. /**
  52264. * Camera used to render xr content
  52265. */
  52266. camera: WebXRCamera;
  52267. /** A features manager for this xr session */
  52268. featuresManager: WebXRFeaturesManager;
  52269. /**
  52270. * Observers registered here will be triggered after the camera's initial transformation is set
  52271. * This can be used to set a different ground level or an extra rotation.
  52272. *
  52273. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52274. * to the position set after this observable is done executing.
  52275. */
  52276. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52277. /**
  52278. * Fires when the state of the experience helper has changed
  52279. */
  52280. onStateChangedObservable: Observable<WebXRState>;
  52281. /** Session manager used to keep track of xr session */
  52282. sessionManager: WebXRSessionManager;
  52283. /**
  52284. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52285. */
  52286. state: WebXRState;
  52287. /**
  52288. * Creates a WebXRExperienceHelper
  52289. * @param scene The scene the helper should be created in
  52290. */
  52291. private constructor();
  52292. /**
  52293. * Creates the experience helper
  52294. * @param scene the scene to attach the experience helper to
  52295. * @returns a promise for the experience helper
  52296. */
  52297. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52298. /**
  52299. * Disposes of the experience helper
  52300. */
  52301. dispose(): void;
  52302. /**
  52303. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52304. * @param sessionMode options for the XR session
  52305. * @param referenceSpaceType frame of reference of the XR session
  52306. * @param renderTarget the output canvas that will be used to enter XR mode
  52307. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52308. * @returns promise that resolves after xr mode has entered
  52309. */
  52310. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52311. /**
  52312. * Exits XR mode and returns the scene to its original state
  52313. * @returns promise that resolves after xr mode has exited
  52314. */
  52315. exitXRAsync(): Promise<void>;
  52316. private _nonXRToXRCamera;
  52317. private _setState;
  52318. }
  52319. }
  52320. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52321. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52322. import { Observable } from "babylonjs/Misc/observable";
  52323. import { IDisposable } from "babylonjs/scene";
  52324. /**
  52325. * X-Y values for axes in WebXR
  52326. */
  52327. export interface IWebXRMotionControllerAxesValue {
  52328. /**
  52329. * The value of the x axis
  52330. */
  52331. x: number;
  52332. /**
  52333. * The value of the y-axis
  52334. */
  52335. y: number;
  52336. }
  52337. /**
  52338. * changed / previous values for the values of this component
  52339. */
  52340. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52341. /**
  52342. * current (this frame) value
  52343. */
  52344. current: T;
  52345. /**
  52346. * previous (last change) value
  52347. */
  52348. previous: T;
  52349. }
  52350. /**
  52351. * Represents changes in the component between current frame and last values recorded
  52352. */
  52353. export interface IWebXRMotionControllerComponentChanges {
  52354. /**
  52355. * will be populated with previous and current values if axes changed
  52356. */
  52357. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52358. /**
  52359. * will be populated with previous and current values if pressed changed
  52360. */
  52361. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52362. /**
  52363. * will be populated with previous and current values if touched changed
  52364. */
  52365. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52366. /**
  52367. * will be populated with previous and current values if value changed
  52368. */
  52369. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52370. }
  52371. /**
  52372. * This class represents a single component (for example button or thumbstick) of a motion controller
  52373. */
  52374. export class WebXRControllerComponent implements IDisposable {
  52375. /**
  52376. * the id of this component
  52377. */
  52378. id: string;
  52379. /**
  52380. * the type of the component
  52381. */
  52382. type: MotionControllerComponentType;
  52383. private _buttonIndex;
  52384. private _axesIndices;
  52385. private _axes;
  52386. private _changes;
  52387. private _currentValue;
  52388. private _hasChanges;
  52389. private _pressed;
  52390. private _touched;
  52391. /**
  52392. * button component type
  52393. */
  52394. static BUTTON_TYPE: MotionControllerComponentType;
  52395. /**
  52396. * squeeze component type
  52397. */
  52398. static SQUEEZE_TYPE: MotionControllerComponentType;
  52399. /**
  52400. * Thumbstick component type
  52401. */
  52402. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52403. /**
  52404. * Touchpad component type
  52405. */
  52406. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52407. /**
  52408. * trigger component type
  52409. */
  52410. static TRIGGER_TYPE: MotionControllerComponentType;
  52411. /**
  52412. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52413. * the axes data changes
  52414. */
  52415. onAxisValueChangedObservable: Observable<{
  52416. x: number;
  52417. y: number;
  52418. }>;
  52419. /**
  52420. * Observers registered here will be triggered when the state of a button changes
  52421. * State change is either pressed / touched / value
  52422. */
  52423. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52424. /**
  52425. * Creates a new component for a motion controller.
  52426. * It is created by the motion controller itself
  52427. *
  52428. * @param id the id of this component
  52429. * @param type the type of the component
  52430. * @param _buttonIndex index in the buttons array of the gamepad
  52431. * @param _axesIndices indices of the values in the axes array of the gamepad
  52432. */
  52433. constructor(
  52434. /**
  52435. * the id of this component
  52436. */
  52437. id: string,
  52438. /**
  52439. * the type of the component
  52440. */
  52441. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52442. /**
  52443. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52444. */
  52445. get axes(): IWebXRMotionControllerAxesValue;
  52446. /**
  52447. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52448. */
  52449. get changes(): IWebXRMotionControllerComponentChanges;
  52450. /**
  52451. * Return whether or not the component changed the last frame
  52452. */
  52453. get hasChanges(): boolean;
  52454. /**
  52455. * is the button currently pressed
  52456. */
  52457. get pressed(): boolean;
  52458. /**
  52459. * is the button currently touched
  52460. */
  52461. get touched(): boolean;
  52462. /**
  52463. * Get the current value of this component
  52464. */
  52465. get value(): number;
  52466. /**
  52467. * Dispose this component
  52468. */
  52469. dispose(): void;
  52470. /**
  52471. * Are there axes correlating to this component
  52472. * @return true is axes data is available
  52473. */
  52474. isAxes(): boolean;
  52475. /**
  52476. * Is this component a button (hence - pressable)
  52477. * @returns true if can be pressed
  52478. */
  52479. isButton(): boolean;
  52480. /**
  52481. * update this component using the gamepad object it is in. Called on every frame
  52482. * @param nativeController the native gamepad controller object
  52483. */
  52484. update(nativeController: IMinimalMotionControllerObject): void;
  52485. }
  52486. }
  52487. declare module "babylonjs/Loading/sceneLoader" {
  52488. import { Observable } from "babylonjs/Misc/observable";
  52489. import { Nullable } from "babylonjs/types";
  52490. import { Scene } from "babylonjs/scene";
  52491. import { Engine } from "babylonjs/Engines/engine";
  52492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52493. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52494. import { AssetContainer } from "babylonjs/assetContainer";
  52495. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52496. import { Skeleton } from "babylonjs/Bones/skeleton";
  52497. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52498. import { WebRequest } from "babylonjs/Misc/webRequest";
  52499. /**
  52500. * Interface used to represent data loading progression
  52501. */
  52502. export interface ISceneLoaderProgressEvent {
  52503. /**
  52504. * Defines if data length to load can be evaluated
  52505. */
  52506. readonly lengthComputable: boolean;
  52507. /**
  52508. * Defines the loaded data length
  52509. */
  52510. readonly loaded: number;
  52511. /**
  52512. * Defines the data length to load
  52513. */
  52514. readonly total: number;
  52515. }
  52516. /**
  52517. * Interface used by SceneLoader plugins to define supported file extensions
  52518. */
  52519. export interface ISceneLoaderPluginExtensions {
  52520. /**
  52521. * Defines the list of supported extensions
  52522. */
  52523. [extension: string]: {
  52524. isBinary: boolean;
  52525. };
  52526. }
  52527. /**
  52528. * Interface used by SceneLoader plugin factory
  52529. */
  52530. export interface ISceneLoaderPluginFactory {
  52531. /**
  52532. * Defines the name of the factory
  52533. */
  52534. name: string;
  52535. /**
  52536. * Function called to create a new plugin
  52537. * @return the new plugin
  52538. */
  52539. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52540. /**
  52541. * The callback that returns true if the data can be directly loaded.
  52542. * @param data string containing the file data
  52543. * @returns if the data can be loaded directly
  52544. */
  52545. canDirectLoad?(data: string): boolean;
  52546. }
  52547. /**
  52548. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52549. */
  52550. export interface ISceneLoaderPluginBase {
  52551. /**
  52552. * The friendly name of this plugin.
  52553. */
  52554. name: string;
  52555. /**
  52556. * The file extensions supported by this plugin.
  52557. */
  52558. extensions: string | ISceneLoaderPluginExtensions;
  52559. /**
  52560. * The callback called when loading from a url.
  52561. * @param scene scene loading this url
  52562. * @param url url to load
  52563. * @param onSuccess callback called when the file successfully loads
  52564. * @param onProgress callback called while file is loading (if the server supports this mode)
  52565. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52566. * @param onError callback called when the file fails to load
  52567. * @returns a file request object
  52568. */
  52569. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52570. /**
  52571. * The callback called when loading from a file object.
  52572. * @param scene scene loading this file
  52573. * @param file defines the file to load
  52574. * @param onSuccess defines the callback to call when data is loaded
  52575. * @param onProgress defines the callback to call during loading process
  52576. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52577. * @param onError defines the callback to call when an error occurs
  52578. * @returns a file request object
  52579. */
  52580. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52581. /**
  52582. * The callback that returns true if the data can be directly loaded.
  52583. * @param data string containing the file data
  52584. * @returns if the data can be loaded directly
  52585. */
  52586. canDirectLoad?(data: string): boolean;
  52587. /**
  52588. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52589. * @param scene scene loading this data
  52590. * @param data string containing the data
  52591. * @returns data to pass to the plugin
  52592. */
  52593. directLoad?(scene: Scene, data: string): any;
  52594. /**
  52595. * The callback that allows custom handling of the root url based on the response url.
  52596. * @param rootUrl the original root url
  52597. * @param responseURL the response url if available
  52598. * @returns the new root url
  52599. */
  52600. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52601. }
  52602. /**
  52603. * Interface used to define a SceneLoader plugin
  52604. */
  52605. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52606. /**
  52607. * Import meshes into a scene.
  52608. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52609. * @param scene The scene to import into
  52610. * @param data The data to import
  52611. * @param rootUrl The root url for scene and resources
  52612. * @param meshes The meshes array to import into
  52613. * @param particleSystems The particle systems array to import into
  52614. * @param skeletons The skeletons array to import into
  52615. * @param onError The callback when import fails
  52616. * @returns True if successful or false otherwise
  52617. */
  52618. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52619. /**
  52620. * Load into a scene.
  52621. * @param scene The scene to load into
  52622. * @param data The data to import
  52623. * @param rootUrl The root url for scene and resources
  52624. * @param onError The callback when import fails
  52625. * @returns True if successful or false otherwise
  52626. */
  52627. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52628. /**
  52629. * Load into an asset container.
  52630. * @param scene The scene to load into
  52631. * @param data The data to import
  52632. * @param rootUrl The root url for scene and resources
  52633. * @param onError The callback when import fails
  52634. * @returns The loaded asset container
  52635. */
  52636. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52637. }
  52638. /**
  52639. * Interface used to define an async SceneLoader plugin
  52640. */
  52641. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52642. /**
  52643. * Import meshes into a scene.
  52644. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52645. * @param scene The scene to import into
  52646. * @param data The data to import
  52647. * @param rootUrl The root url for scene and resources
  52648. * @param onProgress The callback when the load progresses
  52649. * @param fileName Defines the name of the file to load
  52650. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52651. */
  52652. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52653. meshes: AbstractMesh[];
  52654. particleSystems: IParticleSystem[];
  52655. skeletons: Skeleton[];
  52656. animationGroups: AnimationGroup[];
  52657. }>;
  52658. /**
  52659. * Load into a scene.
  52660. * @param scene The scene to load into
  52661. * @param data The data to import
  52662. * @param rootUrl The root url for scene and resources
  52663. * @param onProgress The callback when the load progresses
  52664. * @param fileName Defines the name of the file to load
  52665. * @returns Nothing
  52666. */
  52667. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52668. /**
  52669. * Load into an asset container.
  52670. * @param scene The scene to load into
  52671. * @param data The data to import
  52672. * @param rootUrl The root url for scene and resources
  52673. * @param onProgress The callback when the load progresses
  52674. * @param fileName Defines the name of the file to load
  52675. * @returns The loaded asset container
  52676. */
  52677. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52678. }
  52679. /**
  52680. * Mode that determines how to handle old animation groups before loading new ones.
  52681. */
  52682. export enum SceneLoaderAnimationGroupLoadingMode {
  52683. /**
  52684. * Reset all old animations to initial state then dispose them.
  52685. */
  52686. Clean = 0,
  52687. /**
  52688. * Stop all old animations.
  52689. */
  52690. Stop = 1,
  52691. /**
  52692. * Restart old animations from first frame.
  52693. */
  52694. Sync = 2,
  52695. /**
  52696. * Old animations remains untouched.
  52697. */
  52698. NoSync = 3
  52699. }
  52700. /**
  52701. * Defines a plugin registered by the SceneLoader
  52702. */
  52703. interface IRegisteredPlugin {
  52704. /**
  52705. * Defines the plugin to use
  52706. */
  52707. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52708. /**
  52709. * Defines if the plugin supports binary data
  52710. */
  52711. isBinary: boolean;
  52712. }
  52713. /**
  52714. * Class used to load scene from various file formats using registered plugins
  52715. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52716. */
  52717. export class SceneLoader {
  52718. /**
  52719. * No logging while loading
  52720. */
  52721. static readonly NO_LOGGING: number;
  52722. /**
  52723. * Minimal logging while loading
  52724. */
  52725. static readonly MINIMAL_LOGGING: number;
  52726. /**
  52727. * Summary logging while loading
  52728. */
  52729. static readonly SUMMARY_LOGGING: number;
  52730. /**
  52731. * Detailled logging while loading
  52732. */
  52733. static readonly DETAILED_LOGGING: number;
  52734. /**
  52735. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52736. */
  52737. static get ForceFullSceneLoadingForIncremental(): boolean;
  52738. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52739. /**
  52740. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52741. */
  52742. static get ShowLoadingScreen(): boolean;
  52743. static set ShowLoadingScreen(value: boolean);
  52744. /**
  52745. * Defines the current logging level (while loading the scene)
  52746. * @ignorenaming
  52747. */
  52748. static get loggingLevel(): number;
  52749. static set loggingLevel(value: number);
  52750. /**
  52751. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52752. */
  52753. static get CleanBoneMatrixWeights(): boolean;
  52754. static set CleanBoneMatrixWeights(value: boolean);
  52755. /**
  52756. * Event raised when a plugin is used to load a scene
  52757. */
  52758. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52759. private static _registeredPlugins;
  52760. private static _showingLoadingScreen;
  52761. /**
  52762. * Gets the default plugin (used to load Babylon files)
  52763. * @returns the .babylon plugin
  52764. */
  52765. static GetDefaultPlugin(): IRegisteredPlugin;
  52766. private static _GetPluginForExtension;
  52767. private static _GetPluginForDirectLoad;
  52768. private static _GetPluginForFilename;
  52769. private static _GetDirectLoad;
  52770. private static _LoadData;
  52771. private static _GetFileInfo;
  52772. /**
  52773. * Gets a plugin that can load the given extension
  52774. * @param extension defines the extension to load
  52775. * @returns a plugin or null if none works
  52776. */
  52777. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52778. /**
  52779. * Gets a boolean indicating that the given extension can be loaded
  52780. * @param extension defines the extension to load
  52781. * @returns true if the extension is supported
  52782. */
  52783. static IsPluginForExtensionAvailable(extension: string): boolean;
  52784. /**
  52785. * Adds a new plugin to the list of registered plugins
  52786. * @param plugin defines the plugin to add
  52787. */
  52788. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52789. /**
  52790. * Import meshes into a scene
  52791. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52792. * @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)
  52793. * @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)
  52794. * @param scene the instance of BABYLON.Scene to append to
  52795. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52796. * @param onProgress a callback with a progress event for each file being loaded
  52797. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52798. * @param pluginExtension the extension used to determine the plugin
  52799. * @returns The loaded plugin
  52800. */
  52801. 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>;
  52802. /**
  52803. * Import meshes into a scene
  52804. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52805. * @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)
  52806. * @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)
  52807. * @param scene the instance of BABYLON.Scene to append to
  52808. * @param onProgress a callback with a progress event for each file being loaded
  52809. * @param pluginExtension the extension used to determine the plugin
  52810. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52811. */
  52812. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52813. meshes: AbstractMesh[];
  52814. particleSystems: IParticleSystem[];
  52815. skeletons: Skeleton[];
  52816. animationGroups: AnimationGroup[];
  52817. }>;
  52818. /**
  52819. * Load a scene
  52820. * @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)
  52821. * @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)
  52822. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52823. * @param onSuccess a callback with the scene when import succeeds
  52824. * @param onProgress a callback with a progress event for each file being loaded
  52825. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52826. * @param pluginExtension the extension used to determine the plugin
  52827. * @returns The loaded plugin
  52828. */
  52829. 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>;
  52830. /**
  52831. * Load a scene
  52832. * @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)
  52833. * @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)
  52834. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52835. * @param onProgress a callback with a progress event for each file being loaded
  52836. * @param pluginExtension the extension used to determine the plugin
  52837. * @returns The loaded scene
  52838. */
  52839. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52840. /**
  52841. * Append a scene
  52842. * @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)
  52843. * @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)
  52844. * @param scene is the instance of BABYLON.Scene to append to
  52845. * @param onSuccess a callback with the scene when import succeeds
  52846. * @param onProgress a callback with a progress event for each file being loaded
  52847. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52848. * @param pluginExtension the extension used to determine the plugin
  52849. * @returns The loaded plugin
  52850. */
  52851. 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>;
  52852. /**
  52853. * Append a scene
  52854. * @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)
  52855. * @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)
  52856. * @param scene is the instance of BABYLON.Scene to append to
  52857. * @param onProgress a callback with a progress event for each file being loaded
  52858. * @param pluginExtension the extension used to determine the plugin
  52859. * @returns The given scene
  52860. */
  52861. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52862. /**
  52863. * Load a scene into an asset container
  52864. * @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)
  52865. * @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)
  52866. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52867. * @param onSuccess a callback with the scene when import succeeds
  52868. * @param onProgress a callback with a progress event for each file being loaded
  52869. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52870. * @param pluginExtension the extension used to determine the plugin
  52871. * @returns The loaded plugin
  52872. */
  52873. 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>;
  52874. /**
  52875. * Load a scene into an asset container
  52876. * @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)
  52877. * @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)
  52878. * @param scene is the instance of Scene to append to
  52879. * @param onProgress a callback with a progress event for each file being loaded
  52880. * @param pluginExtension the extension used to determine the plugin
  52881. * @returns The loaded asset container
  52882. */
  52883. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  52884. /**
  52885. * Import animations from a file into a scene
  52886. * @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)
  52887. * @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)
  52888. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52889. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52890. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52891. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52892. * @param onSuccess a callback with the scene when import succeeds
  52893. * @param onProgress a callback with a progress event for each file being loaded
  52894. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52895. * @param pluginExtension the extension used to determine the plugin
  52896. */
  52897. 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;
  52898. /**
  52899. * Import animations from a file into a scene
  52900. * @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)
  52901. * @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)
  52902. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52903. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52904. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52905. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52906. * @param onSuccess a callback with the scene when import succeeds
  52907. * @param onProgress a callback with a progress event for each file being loaded
  52908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52909. * @param pluginExtension the extension used to determine the plugin
  52910. * @returns the updated scene with imported animations
  52911. */
  52912. 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>;
  52913. }
  52914. }
  52915. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  52916. import { IDisposable, Scene } from "babylonjs/scene";
  52917. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  52918. import { Observable } from "babylonjs/Misc/observable";
  52919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52920. import { Nullable } from "babylonjs/types";
  52921. /**
  52922. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  52923. */
  52924. export type MotionControllerHandedness = "none" | "left" | "right";
  52925. /**
  52926. * The type of components available in motion controllers.
  52927. * This is not the name of the component.
  52928. */
  52929. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  52930. /**
  52931. * The state of a controller component
  52932. */
  52933. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  52934. /**
  52935. * The schema of motion controller layout.
  52936. * No object will be initialized using this interface
  52937. * This is used just to define the profile.
  52938. */
  52939. export interface IMotionControllerLayout {
  52940. /**
  52941. * Path to load the assets. Usually relative to the base path
  52942. */
  52943. assetPath: string;
  52944. /**
  52945. * Available components (unsorted)
  52946. */
  52947. components: {
  52948. /**
  52949. * A map of component Ids
  52950. */
  52951. [componentId: string]: {
  52952. /**
  52953. * The type of input the component outputs
  52954. */
  52955. type: MotionControllerComponentType;
  52956. /**
  52957. * The indices of this component in the gamepad object
  52958. */
  52959. gamepadIndices: {
  52960. /**
  52961. * Index of button
  52962. */
  52963. button?: number;
  52964. /**
  52965. * If available, index of x-axis
  52966. */
  52967. xAxis?: number;
  52968. /**
  52969. * If available, index of y-axis
  52970. */
  52971. yAxis?: number;
  52972. };
  52973. /**
  52974. * The mesh's root node name
  52975. */
  52976. rootNodeName: string;
  52977. /**
  52978. * Animation definitions for this model
  52979. */
  52980. visualResponses: {
  52981. [stateKey: string]: {
  52982. /**
  52983. * What property will be animated
  52984. */
  52985. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  52986. /**
  52987. * What states influence this visual response
  52988. */
  52989. states: MotionControllerComponentStateType[];
  52990. /**
  52991. * Type of animation - movement or visibility
  52992. */
  52993. valueNodeProperty: "transform" | "visibility";
  52994. /**
  52995. * Base node name to move. Its position will be calculated according to the min and max nodes
  52996. */
  52997. valueNodeName?: string;
  52998. /**
  52999. * Minimum movement node
  53000. */
  53001. minNodeName?: string;
  53002. /**
  53003. * Max movement node
  53004. */
  53005. maxNodeName?: string;
  53006. };
  53007. };
  53008. /**
  53009. * If touch enabled, what is the name of node to display user feedback
  53010. */
  53011. touchPointNodeName?: string;
  53012. };
  53013. };
  53014. /**
  53015. * Is it xr standard mapping or not
  53016. */
  53017. gamepadMapping: "" | "xr-standard";
  53018. /**
  53019. * Base root node of this entire model
  53020. */
  53021. rootNodeName: string;
  53022. /**
  53023. * Defines the main button component id
  53024. */
  53025. selectComponentId: string;
  53026. }
  53027. /**
  53028. * A definition for the layout map in the input profile
  53029. */
  53030. export interface IMotionControllerLayoutMap {
  53031. /**
  53032. * Layouts with handedness type as a key
  53033. */
  53034. [handedness: string]: IMotionControllerLayout;
  53035. }
  53036. /**
  53037. * The XR Input profile schema
  53038. * Profiles can be found here:
  53039. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53040. */
  53041. export interface IMotionControllerProfile {
  53042. /**
  53043. * fallback profiles for this profileId
  53044. */
  53045. fallbackProfileIds: string[];
  53046. /**
  53047. * The layout map, with handedness as key
  53048. */
  53049. layouts: IMotionControllerLayoutMap;
  53050. /**
  53051. * The id of this profile
  53052. * correlates to the profile(s) in the xrInput.profiles array
  53053. */
  53054. profileId: string;
  53055. }
  53056. /**
  53057. * A helper-interface for the 3 meshes needed for controller button animation
  53058. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53059. */
  53060. export interface IMotionControllerButtonMeshMap {
  53061. /**
  53062. * the mesh that defines the pressed value mesh position.
  53063. * This is used to find the max-position of this button
  53064. */
  53065. pressedMesh: AbstractMesh;
  53066. /**
  53067. * the mesh that defines the unpressed value mesh position.
  53068. * This is used to find the min (or initial) position of this button
  53069. */
  53070. unpressedMesh: AbstractMesh;
  53071. /**
  53072. * The mesh that will be changed when value changes
  53073. */
  53074. valueMesh: AbstractMesh;
  53075. }
  53076. /**
  53077. * A helper-interface for the 3 meshes needed for controller axis animation.
  53078. * This will be expanded when touchpad animations are fully supported
  53079. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53080. */
  53081. export interface IMotionControllerMeshMap {
  53082. /**
  53083. * the mesh that defines the maximum value mesh position.
  53084. */
  53085. maxMesh?: AbstractMesh;
  53086. /**
  53087. * the mesh that defines the minimum value mesh position.
  53088. */
  53089. minMesh?: AbstractMesh;
  53090. /**
  53091. * The mesh that will be changed when axis value changes
  53092. */
  53093. valueMesh?: AbstractMesh;
  53094. }
  53095. /**
  53096. * The elements needed for change-detection of the gamepad objects in motion controllers
  53097. */
  53098. export interface IMinimalMotionControllerObject {
  53099. /**
  53100. * Available axes of this controller
  53101. */
  53102. axes: number[];
  53103. /**
  53104. * An array of available buttons
  53105. */
  53106. buttons: Array<{
  53107. /**
  53108. * Value of the button/trigger
  53109. */
  53110. value: number;
  53111. /**
  53112. * If the button/trigger is currently touched
  53113. */
  53114. touched: boolean;
  53115. /**
  53116. * If the button/trigger is currently pressed
  53117. */
  53118. pressed: boolean;
  53119. }>;
  53120. /**
  53121. * EXPERIMENTAL haptic support.
  53122. */
  53123. hapticActuators?: Array<{
  53124. pulse: (value: number, duration: number) => Promise<boolean>;
  53125. }>;
  53126. }
  53127. /**
  53128. * An Abstract Motion controller
  53129. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53130. * Each component has an observable to check for changes in value and state
  53131. */
  53132. export abstract class WebXRAbstractMotionController implements IDisposable {
  53133. protected scene: Scene;
  53134. protected layout: IMotionControllerLayout;
  53135. /**
  53136. * The gamepad object correlating to this controller
  53137. */
  53138. gamepadObject: IMinimalMotionControllerObject;
  53139. /**
  53140. * handedness (left/right/none) of this controller
  53141. */
  53142. handedness: MotionControllerHandedness;
  53143. private _initComponent;
  53144. private _modelReady;
  53145. /**
  53146. * A map of components (WebXRControllerComponent) in this motion controller
  53147. * Components have a ComponentType and can also have both button and axis definitions
  53148. */
  53149. readonly components: {
  53150. [id: string]: WebXRControllerComponent;
  53151. };
  53152. /**
  53153. * Disable the model's animation. Can be set at any time.
  53154. */
  53155. disableAnimation: boolean;
  53156. /**
  53157. * Observers registered here will be triggered when the model of this controller is done loading
  53158. */
  53159. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53160. /**
  53161. * The profile id of this motion controller
  53162. */
  53163. abstract profileId: string;
  53164. /**
  53165. * The root mesh of the model. It is null if the model was not yet initialized
  53166. */
  53167. rootMesh: Nullable<AbstractMesh>;
  53168. /**
  53169. * constructs a new abstract motion controller
  53170. * @param scene the scene to which the model of the controller will be added
  53171. * @param layout The profile layout to load
  53172. * @param gamepadObject The gamepad object correlating to this controller
  53173. * @param handedness handedness (left/right/none) of this controller
  53174. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53175. */
  53176. constructor(scene: Scene, layout: IMotionControllerLayout,
  53177. /**
  53178. * The gamepad object correlating to this controller
  53179. */
  53180. gamepadObject: IMinimalMotionControllerObject,
  53181. /**
  53182. * handedness (left/right/none) of this controller
  53183. */
  53184. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53185. /**
  53186. * Dispose this controller, the model mesh and all its components
  53187. */
  53188. dispose(): void;
  53189. /**
  53190. * Returns all components of specific type
  53191. * @param type the type to search for
  53192. * @return an array of components with this type
  53193. */
  53194. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53195. /**
  53196. * get a component based an its component id as defined in layout.components
  53197. * @param id the id of the component
  53198. * @returns the component correlates to the id or undefined if not found
  53199. */
  53200. getComponent(id: string): WebXRControllerComponent;
  53201. /**
  53202. * Get the list of components available in this motion controller
  53203. * @returns an array of strings correlating to available components
  53204. */
  53205. getComponentIds(): string[];
  53206. /**
  53207. * Get the first component of specific type
  53208. * @param type type of component to find
  53209. * @return a controller component or null if not found
  53210. */
  53211. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53212. /**
  53213. * Get the main (Select) component of this controller as defined in the layout
  53214. * @returns the main component of this controller
  53215. */
  53216. getMainComponent(): WebXRControllerComponent;
  53217. /**
  53218. * Loads the model correlating to this controller
  53219. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53220. * @returns A promise fulfilled with the result of the model loading
  53221. */
  53222. loadModel(): Promise<boolean>;
  53223. /**
  53224. * Update this model using the current XRFrame
  53225. * @param xrFrame the current xr frame to use and update the model
  53226. */
  53227. updateFromXRFrame(xrFrame: XRFrame): void;
  53228. /**
  53229. * Backwards compatibility due to a deeply-integrated typo
  53230. */
  53231. get handness(): XREye;
  53232. /**
  53233. * Pulse (vibrate) this controller
  53234. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53235. * Consecutive calls to this function will cancel the last pulse call
  53236. *
  53237. * @param value the strength of the pulse in 0.0...1.0 range
  53238. * @param duration Duration of the pulse in milliseconds
  53239. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53240. * @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
  53241. */
  53242. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53243. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53244. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53245. /**
  53246. * Moves the axis on the controller mesh based on its current state
  53247. * @param axis the index of the axis
  53248. * @param axisValue the value of the axis which determines the meshes new position
  53249. * @hidden
  53250. */
  53251. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53252. /**
  53253. * Update the model itself with the current frame data
  53254. * @param xrFrame the frame to use for updating the model mesh
  53255. */
  53256. protected updateModel(xrFrame: XRFrame): void;
  53257. /**
  53258. * Get the filename and path for this controller's model
  53259. * @returns a map of filename and path
  53260. */
  53261. protected abstract _getFilenameAndPath(): {
  53262. filename: string;
  53263. path: string;
  53264. };
  53265. /**
  53266. * This function is called before the mesh is loaded. It checks for loading constraints.
  53267. * For example, this function can check if the GLB loader is available
  53268. * If this function returns false, the generic controller will be loaded instead
  53269. * @returns Is the client ready to load the mesh
  53270. */
  53271. protected abstract _getModelLoadingConstraints(): boolean;
  53272. /**
  53273. * This function will be called after the model was successfully loaded and can be used
  53274. * for mesh transformations before it is available for the user
  53275. * @param meshes the loaded meshes
  53276. */
  53277. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53278. /**
  53279. * Set the root mesh for this controller. Important for the WebXR controller class
  53280. * @param meshes the loaded meshes
  53281. */
  53282. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53283. /**
  53284. * A function executed each frame that updates the mesh (if needed)
  53285. * @param xrFrame the current xrFrame
  53286. */
  53287. protected abstract _updateModel(xrFrame: XRFrame): void;
  53288. private _getGenericFilenameAndPath;
  53289. private _getGenericParentMesh;
  53290. }
  53291. }
  53292. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53293. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53295. import { Scene } from "babylonjs/scene";
  53296. /**
  53297. * A generic trigger-only motion controller for WebXR
  53298. */
  53299. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53300. /**
  53301. * Static version of the profile id of this controller
  53302. */
  53303. static ProfileId: string;
  53304. profileId: string;
  53305. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53306. protected _getFilenameAndPath(): {
  53307. filename: string;
  53308. path: string;
  53309. };
  53310. protected _getModelLoadingConstraints(): boolean;
  53311. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53312. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53313. protected _updateModel(): void;
  53314. }
  53315. }
  53316. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53317. import { Vector4 } from "babylonjs/Maths/math.vector";
  53318. import { Mesh } from "babylonjs/Meshes/mesh";
  53319. import { Scene } from "babylonjs/scene";
  53320. import { Nullable } from "babylonjs/types";
  53321. /**
  53322. * Class containing static functions to help procedurally build meshes
  53323. */
  53324. export class SphereBuilder {
  53325. /**
  53326. * Creates a sphere mesh
  53327. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53328. * * 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`)
  53329. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53330. * * 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
  53331. * * 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)
  53332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53335. * @param name defines the name of the mesh
  53336. * @param options defines the options used to create the mesh
  53337. * @param scene defines the hosting scene
  53338. * @returns the sphere mesh
  53339. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53340. */
  53341. static CreateSphere(name: string, options: {
  53342. segments?: number;
  53343. diameter?: number;
  53344. diameterX?: number;
  53345. diameterY?: number;
  53346. diameterZ?: number;
  53347. arc?: number;
  53348. slice?: number;
  53349. sideOrientation?: number;
  53350. frontUVs?: Vector4;
  53351. backUVs?: Vector4;
  53352. updatable?: boolean;
  53353. }, scene?: Nullable<Scene>): Mesh;
  53354. }
  53355. }
  53356. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53358. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53359. import { Scene } from "babylonjs/scene";
  53360. /**
  53361. * A profiled motion controller has its profile loaded from an online repository.
  53362. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53363. */
  53364. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53365. private _repositoryUrl;
  53366. private _buttonMeshMapping;
  53367. private _touchDots;
  53368. /**
  53369. * The profile ID of this controller. Will be populated when the controller initializes.
  53370. */
  53371. profileId: string;
  53372. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53373. dispose(): void;
  53374. protected _getFilenameAndPath(): {
  53375. filename: string;
  53376. path: string;
  53377. };
  53378. protected _getModelLoadingConstraints(): boolean;
  53379. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53380. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53381. protected _updateModel(_xrFrame: XRFrame): void;
  53382. }
  53383. }
  53384. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53385. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53386. import { Scene } from "babylonjs/scene";
  53387. /**
  53388. * A construction function type to create a new controller based on an xrInput object
  53389. */
  53390. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53391. /**
  53392. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53393. *
  53394. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53395. * it should be replaced with auto-loaded controllers.
  53396. *
  53397. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53398. */
  53399. export class WebXRMotionControllerManager {
  53400. private static _AvailableControllers;
  53401. private static _Fallbacks;
  53402. private static _ProfileLoadingPromises;
  53403. private static _ProfilesList;
  53404. /**
  53405. * The base URL of the online controller repository. Can be changed at any time.
  53406. */
  53407. static BaseRepositoryUrl: string;
  53408. /**
  53409. * Which repository gets priority - local or online
  53410. */
  53411. static PrioritizeOnlineRepository: boolean;
  53412. /**
  53413. * Use the online repository, or use only locally-defined controllers
  53414. */
  53415. static UseOnlineRepository: boolean;
  53416. /**
  53417. * Clear the cache used for profile loading and reload when requested again
  53418. */
  53419. static ClearProfilesCache(): void;
  53420. /**
  53421. * Register the default fallbacks.
  53422. * This function is called automatically when this file is imported.
  53423. */
  53424. static DefaultFallbacks(): void;
  53425. /**
  53426. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53427. * @param profileId the profile to which a fallback needs to be found
  53428. * @return an array with corresponding fallback profiles
  53429. */
  53430. static FindFallbackWithProfileId(profileId: string): string[];
  53431. /**
  53432. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53433. * The order of search:
  53434. *
  53435. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53436. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53437. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53438. * 4) return the generic trigger controller if none were found
  53439. *
  53440. * @param xrInput the xrInput to which a new controller is initialized
  53441. * @param scene the scene to which the model will be added
  53442. * @param forceProfile force a certain profile for this controller
  53443. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53444. */
  53445. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53446. /**
  53447. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53448. *
  53449. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53450. *
  53451. * @param type the profile type to register
  53452. * @param constructFunction the function to be called when loading this profile
  53453. */
  53454. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53455. /**
  53456. * Register a fallback to a specific profile.
  53457. * @param profileId the profileId that will receive the fallbacks
  53458. * @param fallbacks A list of fallback profiles
  53459. */
  53460. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53461. /**
  53462. * Will update the list of profiles available in the repository
  53463. * @return a promise that resolves to a map of profiles available online
  53464. */
  53465. static UpdateProfilesList(): Promise<{
  53466. [profile: string]: string;
  53467. }>;
  53468. private static _LoadProfileFromRepository;
  53469. private static _LoadProfilesFromAvailableControllers;
  53470. }
  53471. }
  53472. declare module "babylonjs/XR/webXRInputSource" {
  53473. import { Observable } from "babylonjs/Misc/observable";
  53474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53475. import { Ray } from "babylonjs/Culling/ray";
  53476. import { Scene } from "babylonjs/scene";
  53477. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53478. /**
  53479. * Configuration options for the WebXR controller creation
  53480. */
  53481. export interface IWebXRControllerOptions {
  53482. /**
  53483. * Should the controller mesh be animated when a user interacts with it
  53484. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53485. */
  53486. disableMotionControllerAnimation?: boolean;
  53487. /**
  53488. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53489. */
  53490. doNotLoadControllerMesh?: boolean;
  53491. /**
  53492. * Force a specific controller type for this controller.
  53493. * This can be used when creating your own profile or when testing different controllers
  53494. */
  53495. forceControllerProfile?: string;
  53496. /**
  53497. * Defines a rendering group ID for meshes that will be loaded.
  53498. * This is for the default controllers only.
  53499. */
  53500. renderingGroupId?: number;
  53501. }
  53502. /**
  53503. * Represents an XR controller
  53504. */
  53505. export class WebXRInputSource {
  53506. private _scene;
  53507. /** The underlying input source for the controller */
  53508. inputSource: XRInputSource;
  53509. private _options;
  53510. private _tmpVector;
  53511. private _uniqueId;
  53512. private _disposed;
  53513. /**
  53514. * 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
  53515. */
  53516. grip?: AbstractMesh;
  53517. /**
  53518. * If available, this is the gamepad object related to this controller.
  53519. * Using this object it is possible to get click events and trackpad changes of the
  53520. * webxr controller that is currently being used.
  53521. */
  53522. motionController?: WebXRAbstractMotionController;
  53523. /**
  53524. * Event that fires when the controller is removed/disposed.
  53525. * The object provided as event data is this controller, after associated assets were disposed.
  53526. * uniqueId is still available.
  53527. */
  53528. onDisposeObservable: Observable<WebXRInputSource>;
  53529. /**
  53530. * Will be triggered when the mesh associated with the motion controller is done loading.
  53531. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53532. * A shortened version of controller -> motion controller -> on mesh loaded.
  53533. */
  53534. onMeshLoadedObservable: Observable<AbstractMesh>;
  53535. /**
  53536. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53537. */
  53538. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53539. /**
  53540. * Pointer which can be used to select objects or attach a visible laser to
  53541. */
  53542. pointer: AbstractMesh;
  53543. /**
  53544. * Creates the input source object
  53545. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53546. * @param _scene the scene which the controller should be associated to
  53547. * @param inputSource the underlying input source for the controller
  53548. * @param _options options for this controller creation
  53549. */
  53550. constructor(_scene: Scene,
  53551. /** The underlying input source for the controller */
  53552. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53553. /**
  53554. * Get this controllers unique id
  53555. */
  53556. get uniqueId(): string;
  53557. /**
  53558. * Disposes of the object
  53559. */
  53560. dispose(): void;
  53561. /**
  53562. * Gets a world space ray coming from the pointer or grip
  53563. * @param result the resulting ray
  53564. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53565. */
  53566. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53567. /**
  53568. * Updates the controller pose based on the given XRFrame
  53569. * @param xrFrame xr frame to update the pose with
  53570. * @param referenceSpace reference space to use
  53571. */
  53572. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53573. }
  53574. }
  53575. declare module "babylonjs/XR/webXRInput" {
  53576. import { Observable } from "babylonjs/Misc/observable";
  53577. import { IDisposable } from "babylonjs/scene";
  53578. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53579. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53580. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53581. /**
  53582. * The schema for initialization options of the XR Input class
  53583. */
  53584. export interface IWebXRInputOptions {
  53585. /**
  53586. * If set to true no model will be automatically loaded
  53587. */
  53588. doNotLoadControllerMeshes?: boolean;
  53589. /**
  53590. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53591. * If not found, the xr input profile data will be used.
  53592. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53593. */
  53594. forceInputProfile?: string;
  53595. /**
  53596. * Do not send a request to the controller repository to load the profile.
  53597. *
  53598. * Instead, use the controllers available in babylon itself.
  53599. */
  53600. disableOnlineControllerRepository?: boolean;
  53601. /**
  53602. * A custom URL for the controllers repository
  53603. */
  53604. customControllersRepositoryURL?: string;
  53605. /**
  53606. * Should the controller model's components not move according to the user input
  53607. */
  53608. disableControllerAnimation?: boolean;
  53609. /**
  53610. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53611. */
  53612. controllerOptions?: IWebXRControllerOptions;
  53613. }
  53614. /**
  53615. * XR input used to track XR inputs such as controllers/rays
  53616. */
  53617. export class WebXRInput implements IDisposable {
  53618. /**
  53619. * the xr session manager for this session
  53620. */
  53621. xrSessionManager: WebXRSessionManager;
  53622. /**
  53623. * the WebXR camera for this session. Mainly used for teleportation
  53624. */
  53625. xrCamera: WebXRCamera;
  53626. private readonly options;
  53627. /**
  53628. * XR controllers being tracked
  53629. */
  53630. controllers: Array<WebXRInputSource>;
  53631. private _frameObserver;
  53632. private _sessionEndedObserver;
  53633. private _sessionInitObserver;
  53634. /**
  53635. * Event when a controller has been connected/added
  53636. */
  53637. onControllerAddedObservable: Observable<WebXRInputSource>;
  53638. /**
  53639. * Event when a controller has been removed/disconnected
  53640. */
  53641. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53642. /**
  53643. * Initializes the WebXRInput
  53644. * @param xrSessionManager the xr session manager for this session
  53645. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53646. * @param options = initialization options for this xr input
  53647. */
  53648. constructor(
  53649. /**
  53650. * the xr session manager for this session
  53651. */
  53652. xrSessionManager: WebXRSessionManager,
  53653. /**
  53654. * the WebXR camera for this session. Mainly used for teleportation
  53655. */
  53656. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53657. private _onInputSourcesChange;
  53658. private _addAndRemoveControllers;
  53659. /**
  53660. * Disposes of the object
  53661. */
  53662. dispose(): void;
  53663. }
  53664. }
  53665. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53666. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53667. import { Observable, EventState } from "babylonjs/Misc/observable";
  53668. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53669. /**
  53670. * This is the base class for all WebXR features.
  53671. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53672. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53673. */
  53674. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53675. protected _xrSessionManager: WebXRSessionManager;
  53676. private _attached;
  53677. private _removeOnDetach;
  53678. /**
  53679. * Is this feature disposed?
  53680. */
  53681. isDisposed: boolean;
  53682. /**
  53683. * Should auto-attach be disabled?
  53684. */
  53685. disableAutoAttach: boolean;
  53686. /**
  53687. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53688. */
  53689. xrNativeFeatureName: string;
  53690. /**
  53691. * Construct a new (abstract) WebXR feature
  53692. * @param _xrSessionManager the xr session manager for this feature
  53693. */
  53694. constructor(_xrSessionManager: WebXRSessionManager);
  53695. /**
  53696. * Is this feature attached
  53697. */
  53698. get attached(): boolean;
  53699. /**
  53700. * attach this feature
  53701. *
  53702. * @param force should attachment be forced (even when already attached)
  53703. * @returns true if successful, false is failed or already attached
  53704. */
  53705. attach(force?: boolean): boolean;
  53706. /**
  53707. * detach this feature.
  53708. *
  53709. * @returns true if successful, false if failed or already detached
  53710. */
  53711. detach(): boolean;
  53712. /**
  53713. * Dispose this feature and all of the resources attached
  53714. */
  53715. dispose(): void;
  53716. /**
  53717. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53718. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53719. *
  53720. * @returns whether or not the feature is compatible in this environment
  53721. */
  53722. isCompatible(): boolean;
  53723. /**
  53724. * This is used to register callbacks that will automatically be removed when detach is called.
  53725. * @param observable the observable to which the observer will be attached
  53726. * @param callback the callback to register
  53727. */
  53728. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53729. /**
  53730. * Code in this function will be executed on each xrFrame received from the browser.
  53731. * This function will not execute after the feature is detached.
  53732. * @param _xrFrame the current frame
  53733. */
  53734. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53735. }
  53736. }
  53737. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53738. import { IDisposable, Scene } from "babylonjs/scene";
  53739. import { Nullable } from "babylonjs/types";
  53740. import { Observable } from "babylonjs/Misc/observable";
  53741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53742. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53743. import { Camera } from "babylonjs/Cameras/camera";
  53744. /**
  53745. * Renders a layer on top of an existing scene
  53746. */
  53747. export class UtilityLayerRenderer implements IDisposable {
  53748. /** the original scene that will be rendered on top of */
  53749. originalScene: Scene;
  53750. private _pointerCaptures;
  53751. private _lastPointerEvents;
  53752. private static _DefaultUtilityLayer;
  53753. private static _DefaultKeepDepthUtilityLayer;
  53754. private _sharedGizmoLight;
  53755. private _renderCamera;
  53756. /**
  53757. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53758. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53759. * @returns the camera that is used when rendering the utility layer
  53760. */
  53761. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53762. /**
  53763. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53764. * @param cam the camera that should be used when rendering the utility layer
  53765. */
  53766. setRenderCamera(cam: Nullable<Camera>): void;
  53767. /**
  53768. * @hidden
  53769. * Light which used by gizmos to get light shading
  53770. */
  53771. _getSharedGizmoLight(): HemisphericLight;
  53772. /**
  53773. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53774. */
  53775. pickUtilitySceneFirst: boolean;
  53776. /**
  53777. * 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)
  53778. */
  53779. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53780. /**
  53781. * 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)
  53782. */
  53783. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53784. /**
  53785. * The scene that is rendered on top of the original scene
  53786. */
  53787. utilityLayerScene: Scene;
  53788. /**
  53789. * If the utility layer should automatically be rendered on top of existing scene
  53790. */
  53791. shouldRender: boolean;
  53792. /**
  53793. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53794. */
  53795. onlyCheckPointerDownEvents: boolean;
  53796. /**
  53797. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53798. */
  53799. processAllEvents: boolean;
  53800. /**
  53801. * Observable raised when the pointer move from the utility layer scene to the main scene
  53802. */
  53803. onPointerOutObservable: Observable<number>;
  53804. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53805. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53806. private _afterRenderObserver;
  53807. private _sceneDisposeObserver;
  53808. private _originalPointerObserver;
  53809. /**
  53810. * Instantiates a UtilityLayerRenderer
  53811. * @param originalScene the original scene that will be rendered on top of
  53812. * @param handleEvents boolean indicating if the utility layer should handle events
  53813. */
  53814. constructor(
  53815. /** the original scene that will be rendered on top of */
  53816. originalScene: Scene, handleEvents?: boolean);
  53817. private _notifyObservers;
  53818. /**
  53819. * Renders the utility layers scene on top of the original scene
  53820. */
  53821. render(): void;
  53822. /**
  53823. * Disposes of the renderer
  53824. */
  53825. dispose(): void;
  53826. private _updateCamera;
  53827. }
  53828. }
  53829. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53830. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53832. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53833. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53834. import { Scene } from "babylonjs/scene";
  53835. import { Nullable } from "babylonjs/types";
  53836. import { Color3 } from "babylonjs/Maths/math.color";
  53837. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53838. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53839. /**
  53840. * Options interface for the pointer selection module
  53841. */
  53842. export interface IWebXRControllerPointerSelectionOptions {
  53843. /**
  53844. * if provided, this scene will be used to render meshes.
  53845. */
  53846. customUtilityLayerScene?: Scene;
  53847. /**
  53848. * 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)
  53849. * If not disabled, the last picked point will be used to execute a pointer up event
  53850. * If disabled, pointer up event will be triggered right after the pointer down event.
  53851. * Used in screen and gaze target ray mode only
  53852. */
  53853. disablePointerUpOnTouchOut: boolean;
  53854. /**
  53855. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53856. */
  53857. forceGazeMode: boolean;
  53858. /**
  53859. * 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
  53860. * to start a new countdown to the pointer down event.
  53861. * Defaults to 1.
  53862. */
  53863. gazeModePointerMovedFactor?: number;
  53864. /**
  53865. * Different button type to use instead of the main component
  53866. */
  53867. overrideButtonId?: string;
  53868. /**
  53869. * use this rendering group id for the meshes (optional)
  53870. */
  53871. renderingGroupId?: number;
  53872. /**
  53873. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  53874. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  53875. * 3000 means 3 seconds between pointing at something and selecting it
  53876. */
  53877. timeToSelect?: number;
  53878. /**
  53879. * Should meshes created here be added to a utility layer or the main scene
  53880. */
  53881. useUtilityLayer?: boolean;
  53882. /**
  53883. * Optional WebXR camera to be used for gaze selection
  53884. */
  53885. gazeCamera?: WebXRCamera;
  53886. /**
  53887. * the xr input to use with this pointer selection
  53888. */
  53889. xrInput: WebXRInput;
  53890. }
  53891. /**
  53892. * A module that will enable pointer selection for motion controllers of XR Input Sources
  53893. */
  53894. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  53895. private readonly _options;
  53896. private static _idCounter;
  53897. private _attachController;
  53898. private _controllers;
  53899. private _scene;
  53900. private _tmpVectorForPickCompare;
  53901. /**
  53902. * The module's name
  53903. */
  53904. static readonly Name: string;
  53905. /**
  53906. * The (Babylon) version of this module.
  53907. * This is an integer representing the implementation version.
  53908. * This number does not correspond to the WebXR specs version
  53909. */
  53910. static readonly Version: number;
  53911. /**
  53912. * Disable lighting on the laser pointer (so it will always be visible)
  53913. */
  53914. disablePointerLighting: boolean;
  53915. /**
  53916. * Disable lighting on the selection mesh (so it will always be visible)
  53917. */
  53918. disableSelectionMeshLighting: boolean;
  53919. /**
  53920. * Should the laser pointer be displayed
  53921. */
  53922. displayLaserPointer: boolean;
  53923. /**
  53924. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  53925. */
  53926. displaySelectionMesh: boolean;
  53927. /**
  53928. * This color will be set to the laser pointer when selection is triggered
  53929. */
  53930. laserPointerPickedColor: Color3;
  53931. /**
  53932. * Default color of the laser pointer
  53933. */
  53934. laserPointerDefaultColor: Color3;
  53935. /**
  53936. * default color of the selection ring
  53937. */
  53938. selectionMeshDefaultColor: Color3;
  53939. /**
  53940. * This color will be applied to the selection ring when selection is triggered
  53941. */
  53942. selectionMeshPickedColor: Color3;
  53943. /**
  53944. * Optional filter to be used for ray selection. This predicate shares behavior with
  53945. * scene.pointerMovePredicate which takes priority if it is also assigned.
  53946. */
  53947. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53948. /**
  53949. * constructs a new background remover module
  53950. * @param _xrSessionManager the session manager for this module
  53951. * @param _options read-only options to be used in this module
  53952. */
  53953. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  53954. /**
  53955. * attach this feature
  53956. * Will usually be called by the features manager
  53957. *
  53958. * @returns true if successful.
  53959. */
  53960. attach(): boolean;
  53961. /**
  53962. * detach this feature.
  53963. * Will usually be called by the features manager
  53964. *
  53965. * @returns true if successful.
  53966. */
  53967. detach(): boolean;
  53968. /**
  53969. * Will get the mesh under a specific pointer.
  53970. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  53971. * @param controllerId the controllerId to check
  53972. * @returns The mesh under pointer or null if no mesh is under the pointer
  53973. */
  53974. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  53975. /**
  53976. * Get the xr controller that correlates to the pointer id in the pointer event
  53977. *
  53978. * @param id the pointer id to search for
  53979. * @returns the controller that correlates to this id or null if not found
  53980. */
  53981. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  53982. protected _onXRFrame(_xrFrame: XRFrame): void;
  53983. private _attachGazeMode;
  53984. private _attachScreenRayMode;
  53985. private _attachTrackedPointerRayMode;
  53986. private _convertNormalToDirectionOfRay;
  53987. private _detachController;
  53988. private _generateNewMeshPair;
  53989. private _pickingMoved;
  53990. private _updatePointerDistance;
  53991. /** @hidden */
  53992. get lasterPointerDefaultColor(): Color3;
  53993. }
  53994. }
  53995. declare module "babylonjs/XR/webXREnterExitUI" {
  53996. import { Nullable } from "babylonjs/types";
  53997. import { Observable } from "babylonjs/Misc/observable";
  53998. import { IDisposable, Scene } from "babylonjs/scene";
  53999. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54000. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54001. /**
  54002. * Button which can be used to enter a different mode of XR
  54003. */
  54004. export class WebXREnterExitUIButton {
  54005. /** button element */
  54006. element: HTMLElement;
  54007. /** XR initialization options for the button */
  54008. sessionMode: XRSessionMode;
  54009. /** Reference space type */
  54010. referenceSpaceType: XRReferenceSpaceType;
  54011. /**
  54012. * Creates a WebXREnterExitUIButton
  54013. * @param element button element
  54014. * @param sessionMode XR initialization session mode
  54015. * @param referenceSpaceType the type of reference space to be used
  54016. */
  54017. constructor(
  54018. /** button element */
  54019. element: HTMLElement,
  54020. /** XR initialization options for the button */
  54021. sessionMode: XRSessionMode,
  54022. /** Reference space type */
  54023. referenceSpaceType: XRReferenceSpaceType);
  54024. /**
  54025. * Extendable function which can be used to update the button's visuals when the state changes
  54026. * @param activeButton the current active button in the UI
  54027. */
  54028. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54029. }
  54030. /**
  54031. * Options to create the webXR UI
  54032. */
  54033. export class WebXREnterExitUIOptions {
  54034. /**
  54035. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54036. */
  54037. customButtons?: Array<WebXREnterExitUIButton>;
  54038. /**
  54039. * A reference space type to use when creating the default button.
  54040. * Default is local-floor
  54041. */
  54042. referenceSpaceType?: XRReferenceSpaceType;
  54043. /**
  54044. * Context to enter xr with
  54045. */
  54046. renderTarget?: Nullable<WebXRRenderTarget>;
  54047. /**
  54048. * A session mode to use when creating the default button.
  54049. * Default is immersive-vr
  54050. */
  54051. sessionMode?: XRSessionMode;
  54052. /**
  54053. * A list of optional features to init the session with
  54054. */
  54055. optionalFeatures?: string[];
  54056. /**
  54057. * A list of optional features to init the session with
  54058. */
  54059. requiredFeatures?: string[];
  54060. }
  54061. /**
  54062. * UI to allow the user to enter/exit XR mode
  54063. */
  54064. export class WebXREnterExitUI implements IDisposable {
  54065. private scene;
  54066. /** version of the options passed to this UI */
  54067. options: WebXREnterExitUIOptions;
  54068. private _activeButton;
  54069. private _buttons;
  54070. /**
  54071. * The HTML Div Element to which buttons are added.
  54072. */
  54073. readonly overlay: HTMLDivElement;
  54074. /**
  54075. * Fired every time the active button is changed.
  54076. *
  54077. * When xr is entered via a button that launches xr that button will be the callback parameter
  54078. *
  54079. * When exiting xr the callback parameter will be null)
  54080. */
  54081. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54082. /**
  54083. *
  54084. * @param scene babylon scene object to use
  54085. * @param options (read-only) version of the options passed to this UI
  54086. */
  54087. private constructor();
  54088. /**
  54089. * Creates UI to allow the user to enter/exit XR mode
  54090. * @param scene the scene to add the ui to
  54091. * @param helper the xr experience helper to enter/exit xr with
  54092. * @param options options to configure the UI
  54093. * @returns the created ui
  54094. */
  54095. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54096. /**
  54097. * Disposes of the XR UI component
  54098. */
  54099. dispose(): void;
  54100. private _updateButtons;
  54101. }
  54102. }
  54103. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54104. import { Vector3 } from "babylonjs/Maths/math.vector";
  54105. import { Color4 } from "babylonjs/Maths/math.color";
  54106. import { Nullable } from "babylonjs/types";
  54107. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54108. import { Scene } from "babylonjs/scene";
  54109. /**
  54110. * Class containing static functions to help procedurally build meshes
  54111. */
  54112. export class LinesBuilder {
  54113. /**
  54114. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54115. * * 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
  54116. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54117. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54118. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54119. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54120. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54121. * * 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
  54122. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54125. * @param name defines the name of the new line system
  54126. * @param options defines the options used to create the line system
  54127. * @param scene defines the hosting scene
  54128. * @returns a new line system mesh
  54129. */
  54130. static CreateLineSystem(name: string, options: {
  54131. lines: Vector3[][];
  54132. updatable?: boolean;
  54133. instance?: Nullable<LinesMesh>;
  54134. colors?: Nullable<Color4[][]>;
  54135. useVertexAlpha?: boolean;
  54136. }, scene: Nullable<Scene>): LinesMesh;
  54137. /**
  54138. * Creates a line mesh
  54139. * 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
  54140. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54141. * * The parameter `points` is an array successive Vector3
  54142. * * 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
  54143. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54144. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54145. * * When updating an instance, remember that only point positions can change, not the number of points
  54146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54148. * @param name defines the name of the new line system
  54149. * @param options defines the options used to create the line system
  54150. * @param scene defines the hosting scene
  54151. * @returns a new line mesh
  54152. */
  54153. static CreateLines(name: string, options: {
  54154. points: Vector3[];
  54155. updatable?: boolean;
  54156. instance?: Nullable<LinesMesh>;
  54157. colors?: Color4[];
  54158. useVertexAlpha?: boolean;
  54159. }, scene?: Nullable<Scene>): LinesMesh;
  54160. /**
  54161. * Creates a dashed line mesh
  54162. * * 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
  54163. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54164. * * The parameter `points` is an array successive Vector3
  54165. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54166. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54167. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54168. * * 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
  54169. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54170. * * When updating an instance, remember that only point positions can change, not the number of points
  54171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54172. * @param name defines the name of the mesh
  54173. * @param options defines the options used to create the mesh
  54174. * @param scene defines the hosting scene
  54175. * @returns the dashed line mesh
  54176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54177. */
  54178. static CreateDashedLines(name: string, options: {
  54179. points: Vector3[];
  54180. dashSize?: number;
  54181. gapSize?: number;
  54182. dashNb?: number;
  54183. updatable?: boolean;
  54184. instance?: LinesMesh;
  54185. useVertexAlpha?: boolean;
  54186. }, scene?: Nullable<Scene>): LinesMesh;
  54187. }
  54188. }
  54189. declare module "babylonjs/Misc/timer" {
  54190. import { Observable, Observer } from "babylonjs/Misc/observable";
  54191. import { Nullable } from "babylonjs/types";
  54192. import { IDisposable } from "babylonjs/scene";
  54193. /**
  54194. * Construction options for a timer
  54195. */
  54196. export interface ITimerOptions<T> {
  54197. /**
  54198. * Time-to-end
  54199. */
  54200. timeout: number;
  54201. /**
  54202. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54203. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54204. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54205. */
  54206. contextObservable: Observable<T>;
  54207. /**
  54208. * Optional parameters when adding an observer to the observable
  54209. */
  54210. observableParameters?: {
  54211. mask?: number;
  54212. insertFirst?: boolean;
  54213. scope?: any;
  54214. };
  54215. /**
  54216. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54217. */
  54218. breakCondition?: (data?: ITimerData<T>) => boolean;
  54219. /**
  54220. * Will be triggered when the time condition has met
  54221. */
  54222. onEnded?: (data: ITimerData<any>) => void;
  54223. /**
  54224. * Will be triggered when the break condition has met (prematurely ended)
  54225. */
  54226. onAborted?: (data: ITimerData<any>) => void;
  54227. /**
  54228. * Optional function to execute on each tick (or count)
  54229. */
  54230. onTick?: (data: ITimerData<any>) => void;
  54231. }
  54232. /**
  54233. * An interface defining the data sent by the timer
  54234. */
  54235. export interface ITimerData<T> {
  54236. /**
  54237. * When did it start
  54238. */
  54239. startTime: number;
  54240. /**
  54241. * Time now
  54242. */
  54243. currentTime: number;
  54244. /**
  54245. * Time passed since started
  54246. */
  54247. deltaTime: number;
  54248. /**
  54249. * How much is completed, in [0.0...1.0].
  54250. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54251. */
  54252. completeRate: number;
  54253. /**
  54254. * What the registered observable sent in the last count
  54255. */
  54256. payload: T;
  54257. }
  54258. /**
  54259. * The current state of the timer
  54260. */
  54261. export enum TimerState {
  54262. /**
  54263. * Timer initialized, not yet started
  54264. */
  54265. INIT = 0,
  54266. /**
  54267. * Timer started and counting
  54268. */
  54269. STARTED = 1,
  54270. /**
  54271. * Timer ended (whether aborted or time reached)
  54272. */
  54273. ENDED = 2
  54274. }
  54275. /**
  54276. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54277. *
  54278. * @param options options with which to initialize this timer
  54279. */
  54280. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54281. /**
  54282. * An advanced implementation of a timer class
  54283. */
  54284. export class AdvancedTimer<T = any> implements IDisposable {
  54285. /**
  54286. * Will notify each time the timer calculates the remaining time
  54287. */
  54288. onEachCountObservable: Observable<ITimerData<T>>;
  54289. /**
  54290. * Will trigger when the timer was aborted due to the break condition
  54291. */
  54292. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54293. /**
  54294. * Will trigger when the timer ended successfully
  54295. */
  54296. onTimerEndedObservable: Observable<ITimerData<T>>;
  54297. /**
  54298. * Will trigger when the timer state has changed
  54299. */
  54300. onStateChangedObservable: Observable<TimerState>;
  54301. private _observer;
  54302. private _contextObservable;
  54303. private _observableParameters;
  54304. private _startTime;
  54305. private _timer;
  54306. private _state;
  54307. private _breakCondition;
  54308. private _timeToEnd;
  54309. private _breakOnNextTick;
  54310. /**
  54311. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54312. * @param options construction options for this advanced timer
  54313. */
  54314. constructor(options: ITimerOptions<T>);
  54315. /**
  54316. * set a breaking condition for this timer. Default is to never break during count
  54317. * @param predicate the new break condition. Returns true to break, false otherwise
  54318. */
  54319. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54320. /**
  54321. * Reset ALL associated observables in this advanced timer
  54322. */
  54323. clearObservables(): void;
  54324. /**
  54325. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54326. *
  54327. * @param timeToEnd how much time to measure until timer ended
  54328. */
  54329. start(timeToEnd?: number): void;
  54330. /**
  54331. * Will force a stop on the next tick.
  54332. */
  54333. stop(): void;
  54334. /**
  54335. * Dispose this timer, clearing all resources
  54336. */
  54337. dispose(): void;
  54338. private _setState;
  54339. private _tick;
  54340. private _stop;
  54341. }
  54342. }
  54343. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54344. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54345. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54346. import { Nullable } from "babylonjs/types";
  54347. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54349. import { Vector3 } from "babylonjs/Maths/math.vector";
  54350. import { Material } from "babylonjs/Materials/material";
  54351. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54352. import { Scene } from "babylonjs/scene";
  54353. /**
  54354. * The options container for the teleportation module
  54355. */
  54356. export interface IWebXRTeleportationOptions {
  54357. /**
  54358. * if provided, this scene will be used to render meshes.
  54359. */
  54360. customUtilityLayerScene?: Scene;
  54361. /**
  54362. * Values to configure the default target mesh
  54363. */
  54364. defaultTargetMeshOptions?: {
  54365. /**
  54366. * Fill color of the teleportation area
  54367. */
  54368. teleportationFillColor?: string;
  54369. /**
  54370. * Border color for the teleportation area
  54371. */
  54372. teleportationBorderColor?: string;
  54373. /**
  54374. * Disable the mesh's animation sequence
  54375. */
  54376. disableAnimation?: boolean;
  54377. /**
  54378. * Disable lighting on the material or the ring and arrow
  54379. */
  54380. disableLighting?: boolean;
  54381. /**
  54382. * Override the default material of the torus and arrow
  54383. */
  54384. torusArrowMaterial?: Material;
  54385. };
  54386. /**
  54387. * A list of meshes to use as floor meshes.
  54388. * Meshes can be added and removed after initializing the feature using the
  54389. * addFloorMesh and removeFloorMesh functions
  54390. * If empty, rotation will still work
  54391. */
  54392. floorMeshes?: AbstractMesh[];
  54393. /**
  54394. * use this rendering group id for the meshes (optional)
  54395. */
  54396. renderingGroupId?: number;
  54397. /**
  54398. * Should teleportation move only to snap points
  54399. */
  54400. snapPointsOnly?: boolean;
  54401. /**
  54402. * An array of points to which the teleportation will snap to.
  54403. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54404. */
  54405. snapPositions?: Vector3[];
  54406. /**
  54407. * How close should the teleportation ray be in order to snap to position.
  54408. * Default to 0.8 units (meters)
  54409. */
  54410. snapToPositionRadius?: number;
  54411. /**
  54412. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54413. * If you want to support rotation, make sure your mesh has a direction indicator.
  54414. *
  54415. * When left untouched, the default mesh will be initialized.
  54416. */
  54417. teleportationTargetMesh?: AbstractMesh;
  54418. /**
  54419. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54420. */
  54421. timeToTeleport?: number;
  54422. /**
  54423. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54424. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54425. */
  54426. useMainComponentOnly?: boolean;
  54427. /**
  54428. * Should meshes created here be added to a utility layer or the main scene
  54429. */
  54430. useUtilityLayer?: boolean;
  54431. /**
  54432. * Babylon XR Input class for controller
  54433. */
  54434. xrInput: WebXRInput;
  54435. /**
  54436. * Meshes that the teleportation ray cannot go through
  54437. */
  54438. pickBlockerMeshes?: AbstractMesh[];
  54439. }
  54440. /**
  54441. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54442. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54443. * the input of the attached controllers.
  54444. */
  54445. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54446. private _options;
  54447. private _controllers;
  54448. private _currentTeleportationControllerId;
  54449. private _floorMeshes;
  54450. private _quadraticBezierCurve;
  54451. private _selectionFeature;
  54452. private _snapToPositions;
  54453. private _snappedToPoint;
  54454. private _teleportationRingMaterial?;
  54455. private _tmpRay;
  54456. private _tmpVector;
  54457. private _tmpQuaternion;
  54458. /**
  54459. * The module's name
  54460. */
  54461. static readonly Name: string;
  54462. /**
  54463. * The (Babylon) version of this module.
  54464. * This is an integer representing the implementation version.
  54465. * This number does not correspond to the webxr specs version
  54466. */
  54467. static readonly Version: number;
  54468. /**
  54469. * Is movement backwards enabled
  54470. */
  54471. backwardsMovementEnabled: boolean;
  54472. /**
  54473. * Distance to travel when moving backwards
  54474. */
  54475. backwardsTeleportationDistance: number;
  54476. /**
  54477. * The distance from the user to the inspection point in the direction of the controller
  54478. * A higher number will allow the user to move further
  54479. * defaults to 5 (meters, in xr units)
  54480. */
  54481. parabolicCheckRadius: number;
  54482. /**
  54483. * Should the module support parabolic ray on top of direct ray
  54484. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54485. * Very helpful when moving between floors / different heights
  54486. */
  54487. parabolicRayEnabled: boolean;
  54488. /**
  54489. * How much rotation should be applied when rotating right and left
  54490. */
  54491. rotationAngle: number;
  54492. /**
  54493. * Is rotation enabled when moving forward?
  54494. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54495. */
  54496. rotationEnabled: boolean;
  54497. /**
  54498. * constructs a new anchor system
  54499. * @param _xrSessionManager an instance of WebXRSessionManager
  54500. * @param _options configuration object for this feature
  54501. */
  54502. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54503. /**
  54504. * Get the snapPointsOnly flag
  54505. */
  54506. get snapPointsOnly(): boolean;
  54507. /**
  54508. * Sets the snapPointsOnly flag
  54509. * @param snapToPoints should teleportation be exclusively to snap points
  54510. */
  54511. set snapPointsOnly(snapToPoints: boolean);
  54512. /**
  54513. * Add a new mesh to the floor meshes array
  54514. * @param mesh the mesh to use as floor mesh
  54515. */
  54516. addFloorMesh(mesh: AbstractMesh): void;
  54517. /**
  54518. * Add a new snap-to point to fix teleportation to this position
  54519. * @param newSnapPoint The new Snap-To point
  54520. */
  54521. addSnapPoint(newSnapPoint: Vector3): void;
  54522. attach(): boolean;
  54523. detach(): boolean;
  54524. dispose(): void;
  54525. /**
  54526. * Remove a mesh from the floor meshes array
  54527. * @param mesh the mesh to remove
  54528. */
  54529. removeFloorMesh(mesh: AbstractMesh): void;
  54530. /**
  54531. * Remove a mesh from the floor meshes array using its name
  54532. * @param name the mesh name to remove
  54533. */
  54534. removeFloorMeshByName(name: string): void;
  54535. /**
  54536. * 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
  54537. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54538. * @returns was the point found and removed or not
  54539. */
  54540. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54541. /**
  54542. * This function sets a selection feature that will be disabled when
  54543. * the forward ray is shown and will be reattached when hidden.
  54544. * This is used to remove the selection rays when moving.
  54545. * @param selectionFeature the feature to disable when forward movement is enabled
  54546. */
  54547. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54548. protected _onXRFrame(_xrFrame: XRFrame): void;
  54549. private _attachController;
  54550. private _createDefaultTargetMesh;
  54551. private _detachController;
  54552. private _findClosestSnapPointWithRadius;
  54553. private _setTargetMeshPosition;
  54554. private _setTargetMeshVisibility;
  54555. private _showParabolicPath;
  54556. private _teleportForward;
  54557. }
  54558. }
  54559. declare module "babylonjs/XR/webXRDefaultExperience" {
  54560. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54561. import { Scene } from "babylonjs/scene";
  54562. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54563. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54564. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54565. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54567. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54568. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54569. /**
  54570. * Options for the default xr helper
  54571. */
  54572. export class WebXRDefaultExperienceOptions {
  54573. /**
  54574. * Enable or disable default UI to enter XR
  54575. */
  54576. disableDefaultUI?: boolean;
  54577. /**
  54578. * Should teleportation not initialize. defaults to false.
  54579. */
  54580. disableTeleportation?: boolean;
  54581. /**
  54582. * Floor meshes that will be used for teleport
  54583. */
  54584. floorMeshes?: Array<AbstractMesh>;
  54585. /**
  54586. * If set to true, the first frame will not be used to reset position
  54587. * The first frame is mainly used when copying transformation from the old camera
  54588. * Mainly used in AR
  54589. */
  54590. ignoreNativeCameraTransformation?: boolean;
  54591. /**
  54592. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54593. */
  54594. inputOptions?: IWebXRInputOptions;
  54595. /**
  54596. * optional configuration for the output canvas
  54597. */
  54598. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54599. /**
  54600. * optional UI options. This can be used among other to change session mode and reference space type
  54601. */
  54602. uiOptions?: WebXREnterExitUIOptions;
  54603. /**
  54604. * When loading teleportation and pointer select, use stable versions instead of latest.
  54605. */
  54606. useStablePlugins?: boolean;
  54607. /**
  54608. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54609. */
  54610. renderingGroupId?: number;
  54611. /**
  54612. * A list of optional features to init the session with
  54613. * If set to true, all features we support will be added
  54614. */
  54615. optionalFeatures?: boolean | string[];
  54616. }
  54617. /**
  54618. * Default experience which provides a similar setup to the previous webVRExperience
  54619. */
  54620. export class WebXRDefaultExperience {
  54621. /**
  54622. * Base experience
  54623. */
  54624. baseExperience: WebXRExperienceHelper;
  54625. /**
  54626. * Enables ui for entering/exiting xr
  54627. */
  54628. enterExitUI: WebXREnterExitUI;
  54629. /**
  54630. * Input experience extension
  54631. */
  54632. input: WebXRInput;
  54633. /**
  54634. * Enables laser pointer and selection
  54635. */
  54636. pointerSelection: WebXRControllerPointerSelection;
  54637. /**
  54638. * Default target xr should render to
  54639. */
  54640. renderTarget: WebXRRenderTarget;
  54641. /**
  54642. * Enables teleportation
  54643. */
  54644. teleportation: WebXRMotionControllerTeleportation;
  54645. private constructor();
  54646. /**
  54647. * Creates the default xr experience
  54648. * @param scene scene
  54649. * @param options options for basic configuration
  54650. * @returns resulting WebXRDefaultExperience
  54651. */
  54652. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54653. /**
  54654. * DIsposes of the experience helper
  54655. */
  54656. dispose(): void;
  54657. }
  54658. }
  54659. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54660. import { Observable } from "babylonjs/Misc/observable";
  54661. import { Nullable } from "babylonjs/types";
  54662. import { Camera } from "babylonjs/Cameras/camera";
  54663. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54664. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54665. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54666. import { Scene } from "babylonjs/scene";
  54667. import { Vector3 } from "babylonjs/Maths/math.vector";
  54668. import { Color3 } from "babylonjs/Maths/math.color";
  54669. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54671. import { Mesh } from "babylonjs/Meshes/mesh";
  54672. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54673. import { EasingFunction } from "babylonjs/Animations/easing";
  54674. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54675. import "babylonjs/Meshes/Builders/groundBuilder";
  54676. import "babylonjs/Meshes/Builders/torusBuilder";
  54677. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54678. import "babylonjs/Gamepads/gamepadSceneComponent";
  54679. import "babylonjs/Animations/animatable";
  54680. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54681. /**
  54682. * Options to modify the vr teleportation behavior.
  54683. */
  54684. export interface VRTeleportationOptions {
  54685. /**
  54686. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54687. */
  54688. floorMeshName?: string;
  54689. /**
  54690. * A list of meshes to be used as the teleportation floor. (default: empty)
  54691. */
  54692. floorMeshes?: Mesh[];
  54693. /**
  54694. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54695. */
  54696. teleportationMode?: number;
  54697. /**
  54698. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54699. */
  54700. teleportationTime?: number;
  54701. /**
  54702. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54703. */
  54704. teleportationSpeed?: number;
  54705. /**
  54706. * The easing function used in the animation or null for Linear. (default CircleEase)
  54707. */
  54708. easingFunction?: EasingFunction;
  54709. }
  54710. /**
  54711. * Options to modify the vr experience helper's behavior.
  54712. */
  54713. export interface VRExperienceHelperOptions extends WebVROptions {
  54714. /**
  54715. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54716. */
  54717. createDeviceOrientationCamera?: boolean;
  54718. /**
  54719. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54720. */
  54721. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54722. /**
  54723. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54724. */
  54725. laserToggle?: boolean;
  54726. /**
  54727. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54728. */
  54729. floorMeshes?: Mesh[];
  54730. /**
  54731. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54732. */
  54733. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54734. /**
  54735. * Defines if WebXR should be used instead of WebVR (if available)
  54736. */
  54737. useXR?: boolean;
  54738. }
  54739. /**
  54740. * Event containing information after VR has been entered
  54741. */
  54742. export class OnAfterEnteringVRObservableEvent {
  54743. /**
  54744. * If entering vr was successful
  54745. */
  54746. success: boolean;
  54747. }
  54748. /**
  54749. * Helps to quickly add VR support to an existing scene.
  54750. * See https://doc.babylonjs.com/how_to/webvr_helper
  54751. */
  54752. export class VRExperienceHelper {
  54753. /** Options to modify the vr experience helper's behavior. */
  54754. webVROptions: VRExperienceHelperOptions;
  54755. private _scene;
  54756. private _position;
  54757. private _btnVR;
  54758. private _btnVRDisplayed;
  54759. private _webVRsupported;
  54760. private _webVRready;
  54761. private _webVRrequesting;
  54762. private _webVRpresenting;
  54763. private _hasEnteredVR;
  54764. private _fullscreenVRpresenting;
  54765. private _inputElement;
  54766. private _webVRCamera;
  54767. private _vrDeviceOrientationCamera;
  54768. private _deviceOrientationCamera;
  54769. private _existingCamera;
  54770. private _onKeyDown;
  54771. private _onVrDisplayPresentChange;
  54772. private _onVRDisplayChanged;
  54773. private _onVRRequestPresentStart;
  54774. private _onVRRequestPresentComplete;
  54775. /**
  54776. * 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)
  54777. */
  54778. enableGazeEvenWhenNoPointerLock: boolean;
  54779. /**
  54780. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54781. */
  54782. exitVROnDoubleTap: boolean;
  54783. /**
  54784. * Observable raised right before entering VR.
  54785. */
  54786. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54787. /**
  54788. * Observable raised when entering VR has completed.
  54789. */
  54790. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54791. /**
  54792. * Observable raised when exiting VR.
  54793. */
  54794. onExitingVRObservable: Observable<VRExperienceHelper>;
  54795. /**
  54796. * Observable raised when controller mesh is loaded.
  54797. */
  54798. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54799. /** Return this.onEnteringVRObservable
  54800. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54801. */
  54802. get onEnteringVR(): Observable<VRExperienceHelper>;
  54803. /** Return this.onExitingVRObservable
  54804. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54805. */
  54806. get onExitingVR(): Observable<VRExperienceHelper>;
  54807. /** Return this.onControllerMeshLoadedObservable
  54808. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54809. */
  54810. get onControllerMeshLoaded(): Observable<WebVRController>;
  54811. private _rayLength;
  54812. private _useCustomVRButton;
  54813. private _teleportationRequested;
  54814. private _teleportActive;
  54815. private _floorMeshName;
  54816. private _floorMeshesCollection;
  54817. private _teleportationMode;
  54818. private _teleportationTime;
  54819. private _teleportationSpeed;
  54820. private _teleportationEasing;
  54821. private _rotationAllowed;
  54822. private _teleportBackwardsVector;
  54823. private _teleportationTarget;
  54824. private _isDefaultTeleportationTarget;
  54825. private _postProcessMove;
  54826. private _teleportationFillColor;
  54827. private _teleportationBorderColor;
  54828. private _rotationAngle;
  54829. private _haloCenter;
  54830. private _cameraGazer;
  54831. private _padSensibilityUp;
  54832. private _padSensibilityDown;
  54833. private _leftController;
  54834. private _rightController;
  54835. private _gazeColor;
  54836. private _laserColor;
  54837. private _pickedLaserColor;
  54838. private _pickedGazeColor;
  54839. /**
  54840. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  54841. */
  54842. onNewMeshSelected: Observable<AbstractMesh>;
  54843. /**
  54844. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  54845. * This observable will provide the mesh and the controller used to select the mesh
  54846. */
  54847. onMeshSelectedWithController: Observable<{
  54848. mesh: AbstractMesh;
  54849. controller: WebVRController;
  54850. }>;
  54851. /**
  54852. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  54853. */
  54854. onNewMeshPicked: Observable<PickingInfo>;
  54855. private _circleEase;
  54856. /**
  54857. * Observable raised before camera teleportation
  54858. */
  54859. onBeforeCameraTeleport: Observable<Vector3>;
  54860. /**
  54861. * Observable raised after camera teleportation
  54862. */
  54863. onAfterCameraTeleport: Observable<Vector3>;
  54864. /**
  54865. * Observable raised when current selected mesh gets unselected
  54866. */
  54867. onSelectedMeshUnselected: Observable<AbstractMesh>;
  54868. private _raySelectionPredicate;
  54869. /**
  54870. * To be optionaly changed by user to define custom ray selection
  54871. */
  54872. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54873. /**
  54874. * To be optionaly changed by user to define custom selection logic (after ray selection)
  54875. */
  54876. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54877. /**
  54878. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  54879. */
  54880. teleportationEnabled: boolean;
  54881. private _defaultHeight;
  54882. private _teleportationInitialized;
  54883. private _interactionsEnabled;
  54884. private _interactionsRequested;
  54885. private _displayGaze;
  54886. private _displayLaserPointer;
  54887. /**
  54888. * The mesh used to display where the user is going to teleport.
  54889. */
  54890. get teleportationTarget(): Mesh;
  54891. /**
  54892. * Sets the mesh to be used to display where the user is going to teleport.
  54893. */
  54894. set teleportationTarget(value: Mesh);
  54895. /**
  54896. * 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
  54897. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  54898. * See https://doc.babylonjs.com/resources/baking_transformations
  54899. */
  54900. get gazeTrackerMesh(): Mesh;
  54901. set gazeTrackerMesh(value: Mesh);
  54902. /**
  54903. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  54904. */
  54905. updateGazeTrackerScale: boolean;
  54906. /**
  54907. * If the gaze trackers color should be updated when selecting meshes
  54908. */
  54909. updateGazeTrackerColor: boolean;
  54910. /**
  54911. * If the controller laser color should be updated when selecting meshes
  54912. */
  54913. updateControllerLaserColor: boolean;
  54914. /**
  54915. * The gaze tracking mesh corresponding to the left controller
  54916. */
  54917. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  54918. /**
  54919. * The gaze tracking mesh corresponding to the right controller
  54920. */
  54921. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  54922. /**
  54923. * If the ray of the gaze should be displayed.
  54924. */
  54925. get displayGaze(): boolean;
  54926. /**
  54927. * Sets if the ray of the gaze should be displayed.
  54928. */
  54929. set displayGaze(value: boolean);
  54930. /**
  54931. * If the ray of the LaserPointer should be displayed.
  54932. */
  54933. get displayLaserPointer(): boolean;
  54934. /**
  54935. * Sets if the ray of the LaserPointer should be displayed.
  54936. */
  54937. set displayLaserPointer(value: boolean);
  54938. /**
  54939. * The deviceOrientationCamera used as the camera when not in VR.
  54940. */
  54941. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  54942. /**
  54943. * Based on the current WebVR support, returns the current VR camera used.
  54944. */
  54945. get currentVRCamera(): Nullable<Camera>;
  54946. /**
  54947. * The webVRCamera which is used when in VR.
  54948. */
  54949. get webVRCamera(): WebVRFreeCamera;
  54950. /**
  54951. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  54952. */
  54953. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  54954. /**
  54955. * The html button that is used to trigger entering into VR.
  54956. */
  54957. get vrButton(): Nullable<HTMLButtonElement>;
  54958. private get _teleportationRequestInitiated();
  54959. /**
  54960. * Defines whether or not Pointer lock should be requested when switching to
  54961. * full screen.
  54962. */
  54963. requestPointerLockOnFullScreen: boolean;
  54964. /**
  54965. * If asking to force XR, this will be populated with the default xr experience
  54966. */
  54967. xr: WebXRDefaultExperience;
  54968. /**
  54969. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  54970. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  54971. */
  54972. xrTestDone: boolean;
  54973. /**
  54974. * Instantiates a VRExperienceHelper.
  54975. * Helps to quickly add VR support to an existing scene.
  54976. * @param scene The scene the VRExperienceHelper belongs to.
  54977. * @param webVROptions Options to modify the vr experience helper's behavior.
  54978. */
  54979. constructor(scene: Scene,
  54980. /** Options to modify the vr experience helper's behavior. */
  54981. webVROptions?: VRExperienceHelperOptions);
  54982. private completeVRInit;
  54983. private _onDefaultMeshLoaded;
  54984. private _onResize;
  54985. private _onFullscreenChange;
  54986. /**
  54987. * Gets a value indicating if we are currently in VR mode.
  54988. */
  54989. get isInVRMode(): boolean;
  54990. private onVrDisplayPresentChange;
  54991. private onVRDisplayChanged;
  54992. private moveButtonToBottomRight;
  54993. private displayVRButton;
  54994. private updateButtonVisibility;
  54995. private _cachedAngularSensibility;
  54996. /**
  54997. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  54998. * Otherwise, will use the fullscreen API.
  54999. */
  55000. enterVR(): void;
  55001. /**
  55002. * Attempt to exit VR, or fullscreen.
  55003. */
  55004. exitVR(): void;
  55005. /**
  55006. * The position of the vr experience helper.
  55007. */
  55008. get position(): Vector3;
  55009. /**
  55010. * Sets the position of the vr experience helper.
  55011. */
  55012. set position(value: Vector3);
  55013. /**
  55014. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55015. */
  55016. enableInteractions(): void;
  55017. private get _noControllerIsActive();
  55018. private beforeRender;
  55019. private _isTeleportationFloor;
  55020. /**
  55021. * Adds a floor mesh to be used for teleportation.
  55022. * @param floorMesh the mesh to be used for teleportation.
  55023. */
  55024. addFloorMesh(floorMesh: Mesh): void;
  55025. /**
  55026. * Removes a floor mesh from being used for teleportation.
  55027. * @param floorMesh the mesh to be removed.
  55028. */
  55029. removeFloorMesh(floorMesh: Mesh): void;
  55030. /**
  55031. * Enables interactions and teleportation using the VR controllers and gaze.
  55032. * @param vrTeleportationOptions options to modify teleportation behavior.
  55033. */
  55034. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55035. private _onNewGamepadConnected;
  55036. private _tryEnableInteractionOnController;
  55037. private _onNewGamepadDisconnected;
  55038. private _enableInteractionOnController;
  55039. private _checkTeleportWithRay;
  55040. private _checkRotate;
  55041. private _checkTeleportBackwards;
  55042. private _enableTeleportationOnController;
  55043. private _createTeleportationCircles;
  55044. private _displayTeleportationTarget;
  55045. private _hideTeleportationTarget;
  55046. private _rotateCamera;
  55047. private _moveTeleportationSelectorTo;
  55048. private _workingVector;
  55049. private _workingQuaternion;
  55050. private _workingMatrix;
  55051. /**
  55052. * Time Constant Teleportation Mode
  55053. */
  55054. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55055. /**
  55056. * Speed Constant Teleportation Mode
  55057. */
  55058. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55059. /**
  55060. * Teleports the users feet to the desired location
  55061. * @param location The location where the user's feet should be placed
  55062. */
  55063. teleportCamera(location: Vector3): void;
  55064. private _convertNormalToDirectionOfRay;
  55065. private _castRayAndSelectObject;
  55066. private _notifySelectedMeshUnselected;
  55067. /**
  55068. * Permanently set new colors for the laser pointer
  55069. * @param color the new laser color
  55070. * @param pickedColor the new laser color when picked mesh detected
  55071. */
  55072. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55073. /**
  55074. * Set lighting enabled / disabled on the laser pointer of both controllers
  55075. * @param enabled should the lighting be enabled on the laser pointer
  55076. */
  55077. setLaserLightingState(enabled?: boolean): void;
  55078. /**
  55079. * Permanently set new colors for the gaze pointer
  55080. * @param color the new gaze color
  55081. * @param pickedColor the new gaze color when picked mesh detected
  55082. */
  55083. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55084. /**
  55085. * Sets the color of the laser ray from the vr controllers.
  55086. * @param color new color for the ray.
  55087. */
  55088. changeLaserColor(color: Color3): void;
  55089. /**
  55090. * Sets the color of the ray from the vr headsets gaze.
  55091. * @param color new color for the ray.
  55092. */
  55093. changeGazeColor(color: Color3): void;
  55094. /**
  55095. * Exits VR and disposes of the vr experience helper
  55096. */
  55097. dispose(): void;
  55098. /**
  55099. * Gets the name of the VRExperienceHelper class
  55100. * @returns "VRExperienceHelper"
  55101. */
  55102. getClassName(): string;
  55103. }
  55104. }
  55105. declare module "babylonjs/Cameras/VR/index" {
  55106. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55107. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55108. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55109. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55110. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55111. export * from "babylonjs/Cameras/VR/webVRCamera";
  55112. }
  55113. declare module "babylonjs/Cameras/RigModes/index" {
  55114. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55115. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55116. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55117. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55118. }
  55119. declare module "babylonjs/Cameras/index" {
  55120. export * from "babylonjs/Cameras/Inputs/index";
  55121. export * from "babylonjs/Cameras/cameraInputsManager";
  55122. export * from "babylonjs/Cameras/camera";
  55123. export * from "babylonjs/Cameras/targetCamera";
  55124. export * from "babylonjs/Cameras/freeCamera";
  55125. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55126. export * from "babylonjs/Cameras/touchCamera";
  55127. export * from "babylonjs/Cameras/arcRotateCamera";
  55128. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55129. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55130. export * from "babylonjs/Cameras/flyCamera";
  55131. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55132. export * from "babylonjs/Cameras/followCamera";
  55133. export * from "babylonjs/Cameras/followCameraInputsManager";
  55134. export * from "babylonjs/Cameras/gamepadCamera";
  55135. export * from "babylonjs/Cameras/Stereoscopic/index";
  55136. export * from "babylonjs/Cameras/universalCamera";
  55137. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55138. export * from "babylonjs/Cameras/VR/index";
  55139. export * from "babylonjs/Cameras/RigModes/index";
  55140. }
  55141. declare module "babylonjs/Collisions/index" {
  55142. export * from "babylonjs/Collisions/collider";
  55143. export * from "babylonjs/Collisions/collisionCoordinator";
  55144. export * from "babylonjs/Collisions/pickingInfo";
  55145. export * from "babylonjs/Collisions/intersectionInfo";
  55146. export * from "babylonjs/Collisions/meshCollisionData";
  55147. }
  55148. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55149. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55150. import { Vector3 } from "babylonjs/Maths/math.vector";
  55151. import { Ray } from "babylonjs/Culling/ray";
  55152. import { Plane } from "babylonjs/Maths/math.plane";
  55153. /**
  55154. * Contains an array of blocks representing the octree
  55155. */
  55156. export interface IOctreeContainer<T> {
  55157. /**
  55158. * Blocks within the octree
  55159. */
  55160. blocks: Array<OctreeBlock<T>>;
  55161. }
  55162. /**
  55163. * Class used to store a cell in an octree
  55164. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55165. */
  55166. export class OctreeBlock<T> {
  55167. /**
  55168. * Gets the content of the current block
  55169. */
  55170. entries: T[];
  55171. /**
  55172. * Gets the list of block children
  55173. */
  55174. blocks: Array<OctreeBlock<T>>;
  55175. private _depth;
  55176. private _maxDepth;
  55177. private _capacity;
  55178. private _minPoint;
  55179. private _maxPoint;
  55180. private _boundingVectors;
  55181. private _creationFunc;
  55182. /**
  55183. * Creates a new block
  55184. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55185. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55186. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55187. * @param depth defines the current depth of this block in the octree
  55188. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55189. * @param creationFunc defines a callback to call when an element is added to the block
  55190. */
  55191. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55192. /**
  55193. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55194. */
  55195. get capacity(): number;
  55196. /**
  55197. * Gets the minimum vector (in world space) of the block's bounding box
  55198. */
  55199. get minPoint(): Vector3;
  55200. /**
  55201. * Gets the maximum vector (in world space) of the block's bounding box
  55202. */
  55203. get maxPoint(): Vector3;
  55204. /**
  55205. * Add a new element to this block
  55206. * @param entry defines the element to add
  55207. */
  55208. addEntry(entry: T): void;
  55209. /**
  55210. * Remove an element from this block
  55211. * @param entry defines the element to remove
  55212. */
  55213. removeEntry(entry: T): void;
  55214. /**
  55215. * Add an array of elements to this block
  55216. * @param entries defines the array of elements to add
  55217. */
  55218. addEntries(entries: T[]): void;
  55219. /**
  55220. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55221. * @param frustumPlanes defines the frustum planes to test
  55222. * @param selection defines the array to store current content if selection is positive
  55223. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55224. */
  55225. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55226. /**
  55227. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55228. * @param sphereCenter defines the bounding sphere center
  55229. * @param sphereRadius defines the bounding sphere radius
  55230. * @param selection defines the array to store current content if selection is positive
  55231. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55232. */
  55233. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55234. /**
  55235. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55236. * @param ray defines the ray to test with
  55237. * @param selection defines the array to store current content if selection is positive
  55238. */
  55239. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55240. /**
  55241. * Subdivide the content into child blocks (this block will then be empty)
  55242. */
  55243. createInnerBlocks(): void;
  55244. /**
  55245. * @hidden
  55246. */
  55247. 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;
  55248. }
  55249. }
  55250. declare module "babylonjs/Culling/Octrees/octree" {
  55251. import { SmartArray } from "babylonjs/Misc/smartArray";
  55252. import { Vector3 } from "babylonjs/Maths/math.vector";
  55253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55255. import { Ray } from "babylonjs/Culling/ray";
  55256. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55257. import { Plane } from "babylonjs/Maths/math.plane";
  55258. /**
  55259. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55260. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55261. */
  55262. export class Octree<T> {
  55263. /** 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.) */
  55264. maxDepth: number;
  55265. /**
  55266. * Blocks within the octree containing objects
  55267. */
  55268. blocks: Array<OctreeBlock<T>>;
  55269. /**
  55270. * Content stored in the octree
  55271. */
  55272. dynamicContent: T[];
  55273. private _maxBlockCapacity;
  55274. private _selectionContent;
  55275. private _creationFunc;
  55276. /**
  55277. * Creates a octree
  55278. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55279. * @param creationFunc function to be used to instatiate the octree
  55280. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55281. * @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.)
  55282. */
  55283. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55284. /** 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.) */
  55285. maxDepth?: number);
  55286. /**
  55287. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55288. * @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);
  55289. * @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);
  55290. * @param entries meshes to be added to the octree blocks
  55291. */
  55292. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55293. /**
  55294. * Adds a mesh to the octree
  55295. * @param entry Mesh to add to the octree
  55296. */
  55297. addMesh(entry: T): void;
  55298. /**
  55299. * Remove an element from the octree
  55300. * @param entry defines the element to remove
  55301. */
  55302. removeMesh(entry: T): void;
  55303. /**
  55304. * Selects an array of meshes within the frustum
  55305. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55306. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55307. * @returns array of meshes within the frustum
  55308. */
  55309. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55310. /**
  55311. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55312. * @param sphereCenter defines the bounding sphere center
  55313. * @param sphereRadius defines the bounding sphere radius
  55314. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55315. * @returns an array of objects that intersect the sphere
  55316. */
  55317. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55318. /**
  55319. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55320. * @param ray defines the ray to test with
  55321. * @returns array of intersected objects
  55322. */
  55323. intersectsRay(ray: Ray): SmartArray<T>;
  55324. /**
  55325. * Adds a mesh into the octree block if it intersects the block
  55326. */
  55327. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55328. /**
  55329. * Adds a submesh into the octree block if it intersects the block
  55330. */
  55331. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55332. }
  55333. }
  55334. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55335. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55336. import { Scene } from "babylonjs/scene";
  55337. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55339. import { Ray } from "babylonjs/Culling/ray";
  55340. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55341. import { Collider } from "babylonjs/Collisions/collider";
  55342. module "babylonjs/scene" {
  55343. interface Scene {
  55344. /**
  55345. * @hidden
  55346. * Backing Filed
  55347. */
  55348. _selectionOctree: Octree<AbstractMesh>;
  55349. /**
  55350. * Gets the octree used to boost mesh selection (picking)
  55351. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55352. */
  55353. selectionOctree: Octree<AbstractMesh>;
  55354. /**
  55355. * Creates or updates the octree used to boost selection (picking)
  55356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55357. * @param maxCapacity defines the maximum capacity per leaf
  55358. * @param maxDepth defines the maximum depth of the octree
  55359. * @returns an octree of AbstractMesh
  55360. */
  55361. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55362. }
  55363. }
  55364. module "babylonjs/Meshes/abstractMesh" {
  55365. interface AbstractMesh {
  55366. /**
  55367. * @hidden
  55368. * Backing Field
  55369. */
  55370. _submeshesOctree: Octree<SubMesh>;
  55371. /**
  55372. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55373. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55374. * @param maxCapacity defines the maximum size of each block (64 by default)
  55375. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55376. * @returns the new octree
  55377. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55378. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55379. */
  55380. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55381. }
  55382. }
  55383. /**
  55384. * Defines the octree scene component responsible to manage any octrees
  55385. * in a given scene.
  55386. */
  55387. export class OctreeSceneComponent {
  55388. /**
  55389. * The component name help to identify the component in the list of scene components.
  55390. */
  55391. readonly name: string;
  55392. /**
  55393. * The scene the component belongs to.
  55394. */
  55395. scene: Scene;
  55396. /**
  55397. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55398. */
  55399. readonly checksIsEnabled: boolean;
  55400. /**
  55401. * Creates a new instance of the component for the given scene
  55402. * @param scene Defines the scene to register the component in
  55403. */
  55404. constructor(scene: Scene);
  55405. /**
  55406. * Registers the component in a given scene
  55407. */
  55408. register(): void;
  55409. /**
  55410. * Return the list of active meshes
  55411. * @returns the list of active meshes
  55412. */
  55413. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55414. /**
  55415. * Return the list of active sub meshes
  55416. * @param mesh The mesh to get the candidates sub meshes from
  55417. * @returns the list of active sub meshes
  55418. */
  55419. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55420. private _tempRay;
  55421. /**
  55422. * Return the list of sub meshes intersecting with a given local ray
  55423. * @param mesh defines the mesh to find the submesh for
  55424. * @param localRay defines the ray in local space
  55425. * @returns the list of intersecting sub meshes
  55426. */
  55427. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55428. /**
  55429. * Return the list of sub meshes colliding with a collider
  55430. * @param mesh defines the mesh to find the submesh for
  55431. * @param collider defines the collider to evaluate the collision against
  55432. * @returns the list of colliding sub meshes
  55433. */
  55434. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55435. /**
  55436. * Rebuilds the elements related to this component in case of
  55437. * context lost for instance.
  55438. */
  55439. rebuild(): void;
  55440. /**
  55441. * Disposes the component and the associated ressources.
  55442. */
  55443. dispose(): void;
  55444. }
  55445. }
  55446. declare module "babylonjs/Culling/Octrees/index" {
  55447. export * from "babylonjs/Culling/Octrees/octree";
  55448. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55449. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55450. }
  55451. declare module "babylonjs/Culling/index" {
  55452. export * from "babylonjs/Culling/boundingBox";
  55453. export * from "babylonjs/Culling/boundingInfo";
  55454. export * from "babylonjs/Culling/boundingSphere";
  55455. export * from "babylonjs/Culling/Octrees/index";
  55456. export * from "babylonjs/Culling/ray";
  55457. }
  55458. declare module "babylonjs/Gizmos/gizmo" {
  55459. import { Nullable } from "babylonjs/types";
  55460. import { IDisposable } from "babylonjs/scene";
  55461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55462. import { Mesh } from "babylonjs/Meshes/mesh";
  55463. import { Node } from "babylonjs/node";
  55464. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55465. /**
  55466. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55467. */
  55468. export class Gizmo implements IDisposable {
  55469. /** The utility layer the gizmo will be added to */
  55470. gizmoLayer: UtilityLayerRenderer;
  55471. /**
  55472. * The root mesh of the gizmo
  55473. */
  55474. _rootMesh: Mesh;
  55475. private _attachedMesh;
  55476. private _attachedNode;
  55477. /**
  55478. * Ratio for the scale of the gizmo (Default: 1)
  55479. */
  55480. protected _scaleRatio: number;
  55481. /**
  55482. * boolean updated by pointermove when a gizmo mesh is hovered
  55483. */
  55484. protected _isHovered: boolean;
  55485. /**
  55486. * Ratio for the scale of the gizmo (Default: 1)
  55487. */
  55488. set scaleRatio(value: number);
  55489. get scaleRatio(): number;
  55490. /**
  55491. * True when the mouse pointer is hovered a gizmo mesh
  55492. */
  55493. get isHovered(): boolean;
  55494. /**
  55495. * If a custom mesh has been set (Default: false)
  55496. */
  55497. protected _customMeshSet: boolean;
  55498. /**
  55499. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55500. * * When set, interactions will be enabled
  55501. */
  55502. get attachedMesh(): Nullable<AbstractMesh>;
  55503. set attachedMesh(value: Nullable<AbstractMesh>);
  55504. /**
  55505. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55506. * * When set, interactions will be enabled
  55507. */
  55508. get attachedNode(): Nullable<Node>;
  55509. set attachedNode(value: Nullable<Node>);
  55510. /**
  55511. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55512. * @param mesh The mesh to replace the default mesh of the gizmo
  55513. */
  55514. setCustomMesh(mesh: Mesh): void;
  55515. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55516. /**
  55517. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55518. */
  55519. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55520. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55521. /**
  55522. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55523. */
  55524. updateGizmoPositionToMatchAttachedMesh: boolean;
  55525. /**
  55526. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55527. */
  55528. updateScale: boolean;
  55529. protected _interactionsEnabled: boolean;
  55530. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55531. private _beforeRenderObserver;
  55532. private _tempQuaternion;
  55533. private _tempVector;
  55534. private _tempVector2;
  55535. private _tempMatrix1;
  55536. private _tempMatrix2;
  55537. private _rightHandtoLeftHandMatrix;
  55538. /**
  55539. * Creates a gizmo
  55540. * @param gizmoLayer The utility layer the gizmo will be added to
  55541. */
  55542. constructor(
  55543. /** The utility layer the gizmo will be added to */
  55544. gizmoLayer?: UtilityLayerRenderer);
  55545. /**
  55546. * Updates the gizmo to match the attached mesh's position/rotation
  55547. */
  55548. protected _update(): void;
  55549. /**
  55550. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55551. * @param value Node, TransformNode or mesh
  55552. */
  55553. protected _matrixChanged(): void;
  55554. /**
  55555. * Disposes of the gizmo
  55556. */
  55557. dispose(): void;
  55558. }
  55559. }
  55560. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55561. import { Observable } from "babylonjs/Misc/observable";
  55562. import { Nullable } from "babylonjs/types";
  55563. import { Vector3 } from "babylonjs/Maths/math.vector";
  55564. import { Color3 } from "babylonjs/Maths/math.color";
  55565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55566. import { Node } from "babylonjs/node";
  55567. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55568. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55569. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55570. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55571. import { Scene } from "babylonjs/scene";
  55572. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55573. /**
  55574. * Single plane drag gizmo
  55575. */
  55576. export class PlaneDragGizmo extends Gizmo {
  55577. /**
  55578. * Drag behavior responsible for the gizmos dragging interactions
  55579. */
  55580. dragBehavior: PointerDragBehavior;
  55581. private _pointerObserver;
  55582. /**
  55583. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55584. */
  55585. snapDistance: number;
  55586. /**
  55587. * Event that fires each time the gizmo snaps to a new location.
  55588. * * snapDistance is the the change in distance
  55589. */
  55590. onSnapObservable: Observable<{
  55591. snapDistance: number;
  55592. }>;
  55593. private _plane;
  55594. private _coloredMaterial;
  55595. private _hoverMaterial;
  55596. private _isEnabled;
  55597. private _parent;
  55598. /** @hidden */
  55599. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55600. /** @hidden */
  55601. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55602. /**
  55603. * Creates a PlaneDragGizmo
  55604. * @param gizmoLayer The utility layer the gizmo will be added to
  55605. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55606. * @param color The color of the gizmo
  55607. */
  55608. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55609. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55610. /**
  55611. * If the gizmo is enabled
  55612. */
  55613. set isEnabled(value: boolean);
  55614. get isEnabled(): boolean;
  55615. /**
  55616. * Disposes of the gizmo
  55617. */
  55618. dispose(): void;
  55619. }
  55620. }
  55621. declare module "babylonjs/Gizmos/positionGizmo" {
  55622. import { Observable } from "babylonjs/Misc/observable";
  55623. import { Nullable } from "babylonjs/types";
  55624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55625. import { Node } from "babylonjs/node";
  55626. import { Mesh } from "babylonjs/Meshes/mesh";
  55627. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55628. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55629. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55630. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55631. /**
  55632. * Gizmo that enables dragging a mesh along 3 axis
  55633. */
  55634. export class PositionGizmo extends Gizmo {
  55635. /**
  55636. * Internal gizmo used for interactions on the x axis
  55637. */
  55638. xGizmo: AxisDragGizmo;
  55639. /**
  55640. * Internal gizmo used for interactions on the y axis
  55641. */
  55642. yGizmo: AxisDragGizmo;
  55643. /**
  55644. * Internal gizmo used for interactions on the z axis
  55645. */
  55646. zGizmo: AxisDragGizmo;
  55647. /**
  55648. * Internal gizmo used for interactions on the yz plane
  55649. */
  55650. xPlaneGizmo: PlaneDragGizmo;
  55651. /**
  55652. * Internal gizmo used for interactions on the xz plane
  55653. */
  55654. yPlaneGizmo: PlaneDragGizmo;
  55655. /**
  55656. * Internal gizmo used for interactions on the xy plane
  55657. */
  55658. zPlaneGizmo: PlaneDragGizmo;
  55659. /**
  55660. * private variables
  55661. */
  55662. private _meshAttached;
  55663. private _nodeAttached;
  55664. private _snapDistance;
  55665. /** Fires an event when any of it's sub gizmos are dragged */
  55666. onDragStartObservable: Observable<unknown>;
  55667. /** Fires an event when any of it's sub gizmos are released from dragging */
  55668. onDragEndObservable: Observable<unknown>;
  55669. /**
  55670. * If set to true, planar drag is enabled
  55671. */
  55672. private _planarGizmoEnabled;
  55673. get attachedMesh(): Nullable<AbstractMesh>;
  55674. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55675. get attachedNode(): Nullable<Node>;
  55676. set attachedNode(node: Nullable<Node>);
  55677. /**
  55678. * True when the mouse pointer is hovering a gizmo mesh
  55679. */
  55680. get isHovered(): boolean;
  55681. /**
  55682. * Creates a PositionGizmo
  55683. * @param gizmoLayer The utility layer the gizmo will be added to
  55684. @param thickness display gizmo axis thickness
  55685. */
  55686. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55687. /**
  55688. * If the planar drag gizmo is enabled
  55689. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55690. */
  55691. set planarGizmoEnabled(value: boolean);
  55692. get planarGizmoEnabled(): boolean;
  55693. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55694. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55695. /**
  55696. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55697. */
  55698. set snapDistance(value: number);
  55699. get snapDistance(): number;
  55700. /**
  55701. * Ratio for the scale of the gizmo (Default: 1)
  55702. */
  55703. set scaleRatio(value: number);
  55704. get scaleRatio(): number;
  55705. /**
  55706. * Disposes of the gizmo
  55707. */
  55708. dispose(): void;
  55709. /**
  55710. * CustomMeshes are not supported by this gizmo
  55711. * @param mesh The mesh to replace the default mesh of the gizmo
  55712. */
  55713. setCustomMesh(mesh: Mesh): void;
  55714. }
  55715. }
  55716. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55717. import { Observable } from "babylonjs/Misc/observable";
  55718. import { Nullable } from "babylonjs/types";
  55719. import { Vector3 } from "babylonjs/Maths/math.vector";
  55720. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55721. import { Node } from "babylonjs/node";
  55722. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55723. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55724. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55725. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55726. import { Scene } from "babylonjs/scene";
  55727. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55728. import { Color3 } from "babylonjs/Maths/math.color";
  55729. /**
  55730. * Single axis drag gizmo
  55731. */
  55732. export class AxisDragGizmo extends Gizmo {
  55733. /**
  55734. * Drag behavior responsible for the gizmos dragging interactions
  55735. */
  55736. dragBehavior: PointerDragBehavior;
  55737. private _pointerObserver;
  55738. /**
  55739. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55740. */
  55741. snapDistance: number;
  55742. /**
  55743. * Event that fires each time the gizmo snaps to a new location.
  55744. * * snapDistance is the the change in distance
  55745. */
  55746. onSnapObservable: Observable<{
  55747. snapDistance: number;
  55748. }>;
  55749. private _isEnabled;
  55750. private _parent;
  55751. private _arrow;
  55752. private _coloredMaterial;
  55753. private _hoverMaterial;
  55754. /** @hidden */
  55755. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55756. /** @hidden */
  55757. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55758. /**
  55759. * Creates an AxisDragGizmo
  55760. * @param gizmoLayer The utility layer the gizmo will be added to
  55761. * @param dragAxis The axis which the gizmo will be able to drag on
  55762. * @param color The color of the gizmo
  55763. * @param thickness display gizmo axis thickness
  55764. */
  55765. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55766. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55767. /**
  55768. * If the gizmo is enabled
  55769. */
  55770. set isEnabled(value: boolean);
  55771. get isEnabled(): boolean;
  55772. /**
  55773. * Disposes of the gizmo
  55774. */
  55775. dispose(): void;
  55776. }
  55777. }
  55778. declare module "babylonjs/Debug/axesViewer" {
  55779. import { Vector3 } from "babylonjs/Maths/math.vector";
  55780. import { Nullable } from "babylonjs/types";
  55781. import { Scene } from "babylonjs/scene";
  55782. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55783. /**
  55784. * The Axes viewer will show 3 axes in a specific point in space
  55785. */
  55786. export class AxesViewer {
  55787. private _xAxis;
  55788. private _yAxis;
  55789. private _zAxis;
  55790. private _scaleLinesFactor;
  55791. private _instanced;
  55792. /**
  55793. * Gets the hosting scene
  55794. */
  55795. scene: Nullable<Scene>;
  55796. /**
  55797. * Gets or sets a number used to scale line length
  55798. */
  55799. scaleLines: number;
  55800. /** Gets the node hierarchy used to render x-axis */
  55801. get xAxis(): TransformNode;
  55802. /** Gets the node hierarchy used to render y-axis */
  55803. get yAxis(): TransformNode;
  55804. /** Gets the node hierarchy used to render z-axis */
  55805. get zAxis(): TransformNode;
  55806. /**
  55807. * Creates a new AxesViewer
  55808. * @param scene defines the hosting scene
  55809. * @param scaleLines defines a number used to scale line length (1 by default)
  55810. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55811. * @param xAxis defines the node hierarchy used to render the x-axis
  55812. * @param yAxis defines the node hierarchy used to render the y-axis
  55813. * @param zAxis defines the node hierarchy used to render the z-axis
  55814. */
  55815. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55816. /**
  55817. * Force the viewer to update
  55818. * @param position defines the position of the viewer
  55819. * @param xaxis defines the x axis of the viewer
  55820. * @param yaxis defines the y axis of the viewer
  55821. * @param zaxis defines the z axis of the viewer
  55822. */
  55823. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55824. /**
  55825. * Creates an instance of this axes viewer.
  55826. * @returns a new axes viewer with instanced meshes
  55827. */
  55828. createInstance(): AxesViewer;
  55829. /** Releases resources */
  55830. dispose(): void;
  55831. private static _SetRenderingGroupId;
  55832. }
  55833. }
  55834. declare module "babylonjs/Debug/boneAxesViewer" {
  55835. import { Nullable } from "babylonjs/types";
  55836. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55837. import { Vector3 } from "babylonjs/Maths/math.vector";
  55838. import { Mesh } from "babylonjs/Meshes/mesh";
  55839. import { Bone } from "babylonjs/Bones/bone";
  55840. import { Scene } from "babylonjs/scene";
  55841. /**
  55842. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55843. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55844. */
  55845. export class BoneAxesViewer extends AxesViewer {
  55846. /**
  55847. * Gets or sets the target mesh where to display the axes viewer
  55848. */
  55849. mesh: Nullable<Mesh>;
  55850. /**
  55851. * Gets or sets the target bone where to display the axes viewer
  55852. */
  55853. bone: Nullable<Bone>;
  55854. /** Gets current position */
  55855. pos: Vector3;
  55856. /** Gets direction of X axis */
  55857. xaxis: Vector3;
  55858. /** Gets direction of Y axis */
  55859. yaxis: Vector3;
  55860. /** Gets direction of Z axis */
  55861. zaxis: Vector3;
  55862. /**
  55863. * Creates a new BoneAxesViewer
  55864. * @param scene defines the hosting scene
  55865. * @param bone defines the target bone
  55866. * @param mesh defines the target mesh
  55867. * @param scaleLines defines a scaling factor for line length (1 by default)
  55868. */
  55869. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55870. /**
  55871. * Force the viewer to update
  55872. */
  55873. update(): void;
  55874. /** Releases resources */
  55875. dispose(): void;
  55876. }
  55877. }
  55878. declare module "babylonjs/Debug/debugLayer" {
  55879. import { Scene } from "babylonjs/scene";
  55880. /**
  55881. * Interface used to define scene explorer extensibility option
  55882. */
  55883. export interface IExplorerExtensibilityOption {
  55884. /**
  55885. * Define the option label
  55886. */
  55887. label: string;
  55888. /**
  55889. * Defines the action to execute on click
  55890. */
  55891. action: (entity: any) => void;
  55892. }
  55893. /**
  55894. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55895. */
  55896. export interface IExplorerExtensibilityGroup {
  55897. /**
  55898. * Defines a predicate to test if a given type mut be extended
  55899. */
  55900. predicate: (entity: any) => boolean;
  55901. /**
  55902. * Gets the list of options added to a type
  55903. */
  55904. entries: IExplorerExtensibilityOption[];
  55905. }
  55906. /**
  55907. * Interface used to define the options to use to create the Inspector
  55908. */
  55909. export interface IInspectorOptions {
  55910. /**
  55911. * Display in overlay mode (default: false)
  55912. */
  55913. overlay?: boolean;
  55914. /**
  55915. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55916. */
  55917. globalRoot?: HTMLElement;
  55918. /**
  55919. * Display the Scene explorer
  55920. */
  55921. showExplorer?: boolean;
  55922. /**
  55923. * Display the property inspector
  55924. */
  55925. showInspector?: boolean;
  55926. /**
  55927. * Display in embed mode (both panes on the right)
  55928. */
  55929. embedMode?: boolean;
  55930. /**
  55931. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55932. */
  55933. handleResize?: boolean;
  55934. /**
  55935. * Allow the panes to popup (default: true)
  55936. */
  55937. enablePopup?: boolean;
  55938. /**
  55939. * Allow the panes to be closed by users (default: true)
  55940. */
  55941. enableClose?: boolean;
  55942. /**
  55943. * Optional list of extensibility entries
  55944. */
  55945. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55946. /**
  55947. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55948. */
  55949. inspectorURL?: string;
  55950. /**
  55951. * Optional initial tab (default to DebugLayerTab.Properties)
  55952. */
  55953. initialTab?: DebugLayerTab;
  55954. }
  55955. module "babylonjs/scene" {
  55956. interface Scene {
  55957. /**
  55958. * @hidden
  55959. * Backing field
  55960. */
  55961. _debugLayer: DebugLayer;
  55962. /**
  55963. * Gets the debug layer (aka Inspector) associated with the scene
  55964. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55965. */
  55966. debugLayer: DebugLayer;
  55967. }
  55968. }
  55969. /**
  55970. * Enum of inspector action tab
  55971. */
  55972. export enum DebugLayerTab {
  55973. /**
  55974. * Properties tag (default)
  55975. */
  55976. Properties = 0,
  55977. /**
  55978. * Debug tab
  55979. */
  55980. Debug = 1,
  55981. /**
  55982. * Statistics tab
  55983. */
  55984. Statistics = 2,
  55985. /**
  55986. * Tools tab
  55987. */
  55988. Tools = 3,
  55989. /**
  55990. * Settings tab
  55991. */
  55992. Settings = 4
  55993. }
  55994. /**
  55995. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55996. * what is happening in your scene
  55997. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55998. */
  55999. export class DebugLayer {
  56000. /**
  56001. * Define the url to get the inspector script from.
  56002. * By default it uses the babylonjs CDN.
  56003. * @ignoreNaming
  56004. */
  56005. static InspectorURL: string;
  56006. private _scene;
  56007. private BJSINSPECTOR;
  56008. private _onPropertyChangedObservable?;
  56009. /**
  56010. * Observable triggered when a property is changed through the inspector.
  56011. */
  56012. get onPropertyChangedObservable(): any;
  56013. /**
  56014. * Instantiates a new debug layer.
  56015. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56016. * what is happening in your scene
  56017. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56018. * @param scene Defines the scene to inspect
  56019. */
  56020. constructor(scene: Scene);
  56021. /** Creates the inspector window. */
  56022. private _createInspector;
  56023. /**
  56024. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56025. * @param entity defines the entity to select
  56026. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56027. */
  56028. select(entity: any, lineContainerTitles?: string | string[]): void;
  56029. /** Get the inspector from bundle or global */
  56030. private _getGlobalInspector;
  56031. /**
  56032. * Get if the inspector is visible or not.
  56033. * @returns true if visible otherwise, false
  56034. */
  56035. isVisible(): boolean;
  56036. /**
  56037. * Hide the inspector and close its window.
  56038. */
  56039. hide(): void;
  56040. /**
  56041. * Update the scene in the inspector
  56042. */
  56043. setAsActiveScene(): void;
  56044. /**
  56045. * Launch the debugLayer.
  56046. * @param config Define the configuration of the inspector
  56047. * @return a promise fulfilled when the debug layer is visible
  56048. */
  56049. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56050. }
  56051. }
  56052. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56053. import { Nullable } from "babylonjs/types";
  56054. import { Scene } from "babylonjs/scene";
  56055. import { Vector4 } from "babylonjs/Maths/math.vector";
  56056. import { Color4 } from "babylonjs/Maths/math.color";
  56057. import { Mesh } from "babylonjs/Meshes/mesh";
  56058. /**
  56059. * Class containing static functions to help procedurally build meshes
  56060. */
  56061. export class BoxBuilder {
  56062. /**
  56063. * Creates a box mesh
  56064. * * The parameter `size` sets the size (float) of each box side (default 1)
  56065. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56066. * * 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)
  56067. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56071. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56072. * @param name defines the name of the mesh
  56073. * @param options defines the options used to create the mesh
  56074. * @param scene defines the hosting scene
  56075. * @returns the box mesh
  56076. */
  56077. static CreateBox(name: string, options: {
  56078. size?: number;
  56079. width?: number;
  56080. height?: number;
  56081. depth?: number;
  56082. faceUV?: Vector4[];
  56083. faceColors?: Color4[];
  56084. sideOrientation?: number;
  56085. frontUVs?: Vector4;
  56086. backUVs?: Vector4;
  56087. wrap?: boolean;
  56088. topBaseAt?: number;
  56089. bottomBaseAt?: number;
  56090. updatable?: boolean;
  56091. }, scene?: Nullable<Scene>): Mesh;
  56092. }
  56093. }
  56094. declare module "babylonjs/Debug/physicsViewer" {
  56095. import { Nullable } from "babylonjs/types";
  56096. import { Scene } from "babylonjs/scene";
  56097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56098. import { Mesh } from "babylonjs/Meshes/mesh";
  56099. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56100. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56101. /**
  56102. * Used to show the physics impostor around the specific mesh
  56103. */
  56104. export class PhysicsViewer {
  56105. /** @hidden */
  56106. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56107. /** @hidden */
  56108. protected _meshes: Array<Nullable<AbstractMesh>>;
  56109. /** @hidden */
  56110. protected _scene: Nullable<Scene>;
  56111. /** @hidden */
  56112. protected _numMeshes: number;
  56113. /** @hidden */
  56114. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56115. private _renderFunction;
  56116. private _utilityLayer;
  56117. private _debugBoxMesh;
  56118. private _debugSphereMesh;
  56119. private _debugCylinderMesh;
  56120. private _debugMaterial;
  56121. private _debugMeshMeshes;
  56122. /**
  56123. * Creates a new PhysicsViewer
  56124. * @param scene defines the hosting scene
  56125. */
  56126. constructor(scene: Scene);
  56127. /** @hidden */
  56128. protected _updateDebugMeshes(): void;
  56129. /**
  56130. * Renders a specified physic impostor
  56131. * @param impostor defines the impostor to render
  56132. * @param targetMesh defines the mesh represented by the impostor
  56133. * @returns the new debug mesh used to render the impostor
  56134. */
  56135. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56136. /**
  56137. * Hides a specified physic impostor
  56138. * @param impostor defines the impostor to hide
  56139. */
  56140. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56141. private _getDebugMaterial;
  56142. private _getDebugBoxMesh;
  56143. private _getDebugSphereMesh;
  56144. private _getDebugCylinderMesh;
  56145. private _getDebugMeshMesh;
  56146. private _getDebugMesh;
  56147. /** Releases all resources */
  56148. dispose(): void;
  56149. }
  56150. }
  56151. declare module "babylonjs/Debug/rayHelper" {
  56152. import { Nullable } from "babylonjs/types";
  56153. import { Ray } from "babylonjs/Culling/ray";
  56154. import { Vector3 } from "babylonjs/Maths/math.vector";
  56155. import { Color3 } from "babylonjs/Maths/math.color";
  56156. import { Scene } from "babylonjs/scene";
  56157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56158. import "babylonjs/Meshes/Builders/linesBuilder";
  56159. /**
  56160. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56161. * in order to better appreciate the issue one might have.
  56162. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56163. */
  56164. export class RayHelper {
  56165. /**
  56166. * Defines the ray we are currently tryin to visualize.
  56167. */
  56168. ray: Nullable<Ray>;
  56169. private _renderPoints;
  56170. private _renderLine;
  56171. private _renderFunction;
  56172. private _scene;
  56173. private _onAfterRenderObserver;
  56174. private _onAfterStepObserver;
  56175. private _attachedToMesh;
  56176. private _meshSpaceDirection;
  56177. private _meshSpaceOrigin;
  56178. /**
  56179. * Helper function to create a colored helper in a scene in one line.
  56180. * @param ray Defines the ray we are currently tryin to visualize
  56181. * @param scene Defines the scene the ray is used in
  56182. * @param color Defines the color we want to see the ray in
  56183. * @returns The newly created ray helper.
  56184. */
  56185. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56186. /**
  56187. * Instantiate a new ray helper.
  56188. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56189. * in order to better appreciate the issue one might have.
  56190. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56191. * @param ray Defines the ray we are currently tryin to visualize
  56192. */
  56193. constructor(ray: Ray);
  56194. /**
  56195. * Shows the ray we are willing to debug.
  56196. * @param scene Defines the scene the ray needs to be rendered in
  56197. * @param color Defines the color the ray needs to be rendered in
  56198. */
  56199. show(scene: Scene, color?: Color3): void;
  56200. /**
  56201. * Hides the ray we are debugging.
  56202. */
  56203. hide(): void;
  56204. private _render;
  56205. /**
  56206. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56207. * @param mesh Defines the mesh we want the helper attached to
  56208. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56209. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56210. * @param length Defines the length of the ray
  56211. */
  56212. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56213. /**
  56214. * Detach the ray helper from the mesh it has previously been attached to.
  56215. */
  56216. detachFromMesh(): void;
  56217. private _updateToMesh;
  56218. /**
  56219. * Dispose the helper and release its associated resources.
  56220. */
  56221. dispose(): void;
  56222. }
  56223. }
  56224. declare module "babylonjs/Debug/ISkeletonViewer" {
  56225. import { Skeleton } from "babylonjs/Bones/skeleton";
  56226. import { Color3 } from "babylonjs/Maths/math.color";
  56227. /**
  56228. * Defines the options associated with the creation of a SkeletonViewer.
  56229. */
  56230. export interface ISkeletonViewerOptions {
  56231. /** Should the system pause animations before building the Viewer? */
  56232. pauseAnimations: boolean;
  56233. /** Should the system return the skeleton to rest before building? */
  56234. returnToRest: boolean;
  56235. /** public Display Mode of the Viewer */
  56236. displayMode: number;
  56237. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56238. displayOptions: ISkeletonViewerDisplayOptions;
  56239. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56240. computeBonesUsingShaders: boolean;
  56241. /** Flag ignore non weighted bones */
  56242. useAllBones: boolean;
  56243. }
  56244. /**
  56245. * Defines how to display the various bone meshes for the viewer.
  56246. */
  56247. export interface ISkeletonViewerDisplayOptions {
  56248. /** How far down to start tapering the bone spurs */
  56249. midStep?: number;
  56250. /** How big is the midStep? */
  56251. midStepFactor?: number;
  56252. /** Base for the Sphere Size */
  56253. sphereBaseSize?: number;
  56254. /** The ratio of the sphere to the longest bone in units */
  56255. sphereScaleUnit?: number;
  56256. /** Ratio for the Sphere Size */
  56257. sphereFactor?: number;
  56258. /** Whether a spur should attach its far end to the child bone position */
  56259. spurFollowsChild?: boolean;
  56260. /** Whether to show local axes or not */
  56261. showLocalAxes?: boolean;
  56262. /** Length of each local axis */
  56263. localAxesSize?: number;
  56264. }
  56265. /**
  56266. * Defines the constructor options for the BoneWeight Shader.
  56267. */
  56268. export interface IBoneWeightShaderOptions {
  56269. /** Skeleton to Map */
  56270. skeleton: Skeleton;
  56271. /** Colors for Uninfluenced bones */
  56272. colorBase?: Color3;
  56273. /** Colors for 0.0-0.25 Weight bones */
  56274. colorZero?: Color3;
  56275. /** Color for 0.25-0.5 Weight Influence */
  56276. colorQuarter?: Color3;
  56277. /** Color for 0.5-0.75 Weight Influence */
  56278. colorHalf?: Color3;
  56279. /** Color for 0.75-1 Weight Influence */
  56280. colorFull?: Color3;
  56281. /** Color for Zero Weight Influence */
  56282. targetBoneIndex?: number;
  56283. }
  56284. /**
  56285. * Simple structure of the gradient steps for the Color Map.
  56286. */
  56287. export interface ISkeletonMapShaderColorMapKnot {
  56288. /** Color of the Knot */
  56289. color: Color3;
  56290. /** Location of the Knot */
  56291. location: number;
  56292. }
  56293. /**
  56294. * Defines the constructor options for the SkeletonMap Shader.
  56295. */
  56296. export interface ISkeletonMapShaderOptions {
  56297. /** Skeleton to Map */
  56298. skeleton: Skeleton;
  56299. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56300. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56301. }
  56302. }
  56303. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56304. import { Nullable } from "babylonjs/types";
  56305. import { Scene } from "babylonjs/scene";
  56306. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56307. import { Color4 } from "babylonjs/Maths/math.color";
  56308. import { Mesh } from "babylonjs/Meshes/mesh";
  56309. /**
  56310. * Class containing static functions to help procedurally build meshes
  56311. */
  56312. export class RibbonBuilder {
  56313. /**
  56314. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56315. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56316. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56317. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56318. * * 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
  56319. * * 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
  56320. * * 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
  56321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56324. * * 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
  56325. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56326. * * 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
  56327. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56329. * @param name defines the name of the mesh
  56330. * @param options defines the options used to create the mesh
  56331. * @param scene defines the hosting scene
  56332. * @returns the ribbon mesh
  56333. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56334. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56335. */
  56336. static CreateRibbon(name: string, options: {
  56337. pathArray: Vector3[][];
  56338. closeArray?: boolean;
  56339. closePath?: boolean;
  56340. offset?: number;
  56341. updatable?: boolean;
  56342. sideOrientation?: number;
  56343. frontUVs?: Vector4;
  56344. backUVs?: Vector4;
  56345. instance?: Mesh;
  56346. invertUV?: boolean;
  56347. uvs?: Vector2[];
  56348. colors?: Color4[];
  56349. }, scene?: Nullable<Scene>): Mesh;
  56350. }
  56351. }
  56352. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56353. import { Nullable } from "babylonjs/types";
  56354. import { Scene } from "babylonjs/scene";
  56355. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56356. import { Mesh } from "babylonjs/Meshes/mesh";
  56357. /**
  56358. * Class containing static functions to help procedurally build meshes
  56359. */
  56360. export class ShapeBuilder {
  56361. /**
  56362. * 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.
  56363. * * 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.
  56364. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56365. * * 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.
  56366. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56367. * * 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
  56368. * * 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
  56369. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56374. * @param name defines the name of the mesh
  56375. * @param options defines the options used to create the mesh
  56376. * @param scene defines the hosting scene
  56377. * @returns the extruded shape mesh
  56378. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56380. */
  56381. static ExtrudeShape(name: string, options: {
  56382. shape: Vector3[];
  56383. path: Vector3[];
  56384. scale?: number;
  56385. rotation?: number;
  56386. cap?: number;
  56387. updatable?: boolean;
  56388. sideOrientation?: number;
  56389. frontUVs?: Vector4;
  56390. backUVs?: Vector4;
  56391. instance?: Mesh;
  56392. invertUV?: boolean;
  56393. }, scene?: Nullable<Scene>): Mesh;
  56394. /**
  56395. * Creates an custom extruded shape mesh.
  56396. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56397. * * 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.
  56398. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56399. * * 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
  56400. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56401. * * 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
  56402. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56403. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56404. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56405. * * 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
  56406. * * 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
  56407. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56412. * @param name defines the name of the mesh
  56413. * @param options defines the options used to create the mesh
  56414. * @param scene defines the hosting scene
  56415. * @returns the custom extruded shape mesh
  56416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56419. */
  56420. static ExtrudeShapeCustom(name: string, options: {
  56421. shape: Vector3[];
  56422. path: Vector3[];
  56423. scaleFunction?: any;
  56424. rotationFunction?: any;
  56425. ribbonCloseArray?: boolean;
  56426. ribbonClosePath?: boolean;
  56427. cap?: number;
  56428. updatable?: boolean;
  56429. sideOrientation?: number;
  56430. frontUVs?: Vector4;
  56431. backUVs?: Vector4;
  56432. instance?: Mesh;
  56433. invertUV?: boolean;
  56434. }, scene?: Nullable<Scene>): Mesh;
  56435. private static _ExtrudeShapeGeneric;
  56436. }
  56437. }
  56438. declare module "babylonjs/Debug/skeletonViewer" {
  56439. import { Color3 } from "babylonjs/Maths/math.color";
  56440. import { Scene } from "babylonjs/scene";
  56441. import { Nullable } from "babylonjs/types";
  56442. import { Skeleton } from "babylonjs/Bones/skeleton";
  56443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56444. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56445. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56446. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56447. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56448. /**
  56449. * Class used to render a debug view of a given skeleton
  56450. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56451. */
  56452. export class SkeletonViewer {
  56453. /** defines the skeleton to render */
  56454. skeleton: Skeleton;
  56455. /** defines the mesh attached to the skeleton */
  56456. mesh: AbstractMesh;
  56457. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56458. autoUpdateBonesMatrices: boolean;
  56459. /** defines the rendering group id to use with the viewer */
  56460. renderingGroupId: number;
  56461. /** is the options for the viewer */
  56462. options: Partial<ISkeletonViewerOptions>;
  56463. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56464. static readonly DISPLAY_LINES: number;
  56465. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56466. static readonly DISPLAY_SPHERES: number;
  56467. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56468. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56469. /** public static method to create a BoneWeight Shader
  56470. * @param options The constructor options
  56471. * @param scene The scene that the shader is scoped to
  56472. * @returns The created ShaderMaterial
  56473. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56474. */
  56475. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56476. /** public static method to create a BoneWeight Shader
  56477. * @param options The constructor options
  56478. * @param scene The scene that the shader is scoped to
  56479. * @returns The created ShaderMaterial
  56480. */
  56481. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56482. /** private static method to create a BoneWeight Shader
  56483. * @param size The size of the buffer to create (usually the bone count)
  56484. * @param colorMap The gradient data to generate
  56485. * @param scene The scene that the shader is scoped to
  56486. * @returns an Array of floats from the color gradient values
  56487. */
  56488. private static _CreateBoneMapColorBuffer;
  56489. /** If SkeletonViewer scene scope. */
  56490. private _scene;
  56491. /** Gets or sets the color used to render the skeleton */
  56492. color: Color3;
  56493. /** Array of the points of the skeleton fo the line view. */
  56494. private _debugLines;
  56495. /** The SkeletonViewers Mesh. */
  56496. private _debugMesh;
  56497. /** The local axes Meshes. */
  56498. private _localAxes;
  56499. /** If SkeletonViewer is enabled. */
  56500. private _isEnabled;
  56501. /** If SkeletonViewer is ready. */
  56502. private _ready;
  56503. /** SkeletonViewer render observable. */
  56504. private _obs;
  56505. /** The Utility Layer to render the gizmos in. */
  56506. private _utilityLayer;
  56507. private _boneIndices;
  56508. /** Gets the Scene. */
  56509. get scene(): Scene;
  56510. /** Gets the utilityLayer. */
  56511. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56512. /** Checks Ready Status. */
  56513. get isReady(): Boolean;
  56514. /** Sets Ready Status. */
  56515. set ready(value: boolean);
  56516. /** Gets the debugMesh */
  56517. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56518. /** Sets the debugMesh */
  56519. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56520. /** Gets the displayMode */
  56521. get displayMode(): number;
  56522. /** Sets the displayMode */
  56523. set displayMode(value: number);
  56524. /**
  56525. * Creates a new SkeletonViewer
  56526. * @param skeleton defines the skeleton to render
  56527. * @param mesh defines the mesh attached to the skeleton
  56528. * @param scene defines the hosting scene
  56529. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56530. * @param renderingGroupId defines the rendering group id to use with the viewer
  56531. * @param options All of the extra constructor options for the SkeletonViewer
  56532. */
  56533. constructor(
  56534. /** defines the skeleton to render */
  56535. skeleton: Skeleton,
  56536. /** defines the mesh attached to the skeleton */
  56537. mesh: AbstractMesh,
  56538. /** The Scene scope*/
  56539. scene: Scene,
  56540. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56541. autoUpdateBonesMatrices?: boolean,
  56542. /** defines the rendering group id to use with the viewer */
  56543. renderingGroupId?: number,
  56544. /** is the options for the viewer */
  56545. options?: Partial<ISkeletonViewerOptions>);
  56546. /** The Dynamic bindings for the update functions */
  56547. private _bindObs;
  56548. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56549. update(): void;
  56550. /** Gets or sets a boolean indicating if the viewer is enabled */
  56551. set isEnabled(value: boolean);
  56552. get isEnabled(): boolean;
  56553. private _getBonePosition;
  56554. private _getLinesForBonesWithLength;
  56555. private _getLinesForBonesNoLength;
  56556. /** function to revert the mesh and scene back to the initial state. */
  56557. private _revert;
  56558. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56559. private _getAbsoluteBindPoseToRef;
  56560. /** function to build and bind sphere joint points and spur bone representations. */
  56561. private _buildSpheresAndSpurs;
  56562. private _buildLocalAxes;
  56563. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56564. private _displayLinesUpdate;
  56565. /** Changes the displayMode of the skeleton viewer
  56566. * @param mode The displayMode numerical value
  56567. */
  56568. changeDisplayMode(mode: number): void;
  56569. /** Sets a display option of the skeleton viewer
  56570. *
  56571. * | Option | Type | Default | Description |
  56572. * | ---------------- | ------- | ------- | ----------- |
  56573. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56574. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56575. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56576. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56577. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56578. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56579. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56580. *
  56581. * @param option String of the option name
  56582. * @param value The numerical option value
  56583. */
  56584. changeDisplayOptions(option: string, value: number): void;
  56585. /** Release associated resources */
  56586. dispose(): void;
  56587. }
  56588. }
  56589. declare module "babylonjs/Debug/index" {
  56590. export * from "babylonjs/Debug/axesViewer";
  56591. export * from "babylonjs/Debug/boneAxesViewer";
  56592. export * from "babylonjs/Debug/debugLayer";
  56593. export * from "babylonjs/Debug/physicsViewer";
  56594. export * from "babylonjs/Debug/rayHelper";
  56595. export * from "babylonjs/Debug/skeletonViewer";
  56596. export * from "babylonjs/Debug/ISkeletonViewer";
  56597. }
  56598. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56599. /**
  56600. * Enum for Device Types
  56601. */
  56602. export enum DeviceType {
  56603. /** Generic */
  56604. Generic = 0,
  56605. /** Keyboard */
  56606. Keyboard = 1,
  56607. /** Mouse */
  56608. Mouse = 2,
  56609. /** Touch Pointers */
  56610. Touch = 3,
  56611. /** PS4 Dual Shock */
  56612. DualShock = 4,
  56613. /** Xbox */
  56614. Xbox = 5,
  56615. /** Switch Controller */
  56616. Switch = 6
  56617. }
  56618. /**
  56619. * Enum for All Pointers (Touch/Mouse)
  56620. */
  56621. export enum PointerInput {
  56622. /** Horizontal Axis */
  56623. Horizontal = 0,
  56624. /** Vertical Axis */
  56625. Vertical = 1,
  56626. /** Left Click or Touch */
  56627. LeftClick = 2,
  56628. /** Middle Click */
  56629. MiddleClick = 3,
  56630. /** Right Click */
  56631. RightClick = 4,
  56632. /** Browser Back */
  56633. BrowserBack = 5,
  56634. /** Browser Forward */
  56635. BrowserForward = 6
  56636. }
  56637. /**
  56638. * Enum for Dual Shock Gamepad
  56639. */
  56640. export enum DualShockInput {
  56641. /** Cross */
  56642. Cross = 0,
  56643. /** Circle */
  56644. Circle = 1,
  56645. /** Square */
  56646. Square = 2,
  56647. /** Triangle */
  56648. Triangle = 3,
  56649. /** L1 */
  56650. L1 = 4,
  56651. /** R1 */
  56652. R1 = 5,
  56653. /** L2 */
  56654. L2 = 6,
  56655. /** R2 */
  56656. R2 = 7,
  56657. /** Share */
  56658. Share = 8,
  56659. /** Options */
  56660. Options = 9,
  56661. /** L3 */
  56662. L3 = 10,
  56663. /** R3 */
  56664. R3 = 11,
  56665. /** DPadUp */
  56666. DPadUp = 12,
  56667. /** DPadDown */
  56668. DPadDown = 13,
  56669. /** DPadLeft */
  56670. DPadLeft = 14,
  56671. /** DRight */
  56672. DPadRight = 15,
  56673. /** Home */
  56674. Home = 16,
  56675. /** TouchPad */
  56676. TouchPad = 17,
  56677. /** LStickXAxis */
  56678. LStickXAxis = 18,
  56679. /** LStickYAxis */
  56680. LStickYAxis = 19,
  56681. /** RStickXAxis */
  56682. RStickXAxis = 20,
  56683. /** RStickYAxis */
  56684. RStickYAxis = 21
  56685. }
  56686. /**
  56687. * Enum for Xbox Gamepad
  56688. */
  56689. export enum XboxInput {
  56690. /** A */
  56691. A = 0,
  56692. /** B */
  56693. B = 1,
  56694. /** X */
  56695. X = 2,
  56696. /** Y */
  56697. Y = 3,
  56698. /** LB */
  56699. LB = 4,
  56700. /** RB */
  56701. RB = 5,
  56702. /** LT */
  56703. LT = 6,
  56704. /** RT */
  56705. RT = 7,
  56706. /** Back */
  56707. Back = 8,
  56708. /** Start */
  56709. Start = 9,
  56710. /** LS */
  56711. LS = 10,
  56712. /** RS */
  56713. RS = 11,
  56714. /** DPadUp */
  56715. DPadUp = 12,
  56716. /** DPadDown */
  56717. DPadDown = 13,
  56718. /** DPadLeft */
  56719. DPadLeft = 14,
  56720. /** DRight */
  56721. DPadRight = 15,
  56722. /** Home */
  56723. Home = 16,
  56724. /** LStickXAxis */
  56725. LStickXAxis = 17,
  56726. /** LStickYAxis */
  56727. LStickYAxis = 18,
  56728. /** RStickXAxis */
  56729. RStickXAxis = 19,
  56730. /** RStickYAxis */
  56731. RStickYAxis = 20
  56732. }
  56733. /**
  56734. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56735. */
  56736. export enum SwitchInput {
  56737. /** B */
  56738. B = 0,
  56739. /** A */
  56740. A = 1,
  56741. /** Y */
  56742. Y = 2,
  56743. /** X */
  56744. X = 3,
  56745. /** L */
  56746. L = 4,
  56747. /** R */
  56748. R = 5,
  56749. /** ZL */
  56750. ZL = 6,
  56751. /** ZR */
  56752. ZR = 7,
  56753. /** Minus */
  56754. Minus = 8,
  56755. /** Plus */
  56756. Plus = 9,
  56757. /** LS */
  56758. LS = 10,
  56759. /** RS */
  56760. RS = 11,
  56761. /** DPadUp */
  56762. DPadUp = 12,
  56763. /** DPadDown */
  56764. DPadDown = 13,
  56765. /** DPadLeft */
  56766. DPadLeft = 14,
  56767. /** DRight */
  56768. DPadRight = 15,
  56769. /** Home */
  56770. Home = 16,
  56771. /** Capture */
  56772. Capture = 17,
  56773. /** LStickXAxis */
  56774. LStickXAxis = 18,
  56775. /** LStickYAxis */
  56776. LStickYAxis = 19,
  56777. /** RStickXAxis */
  56778. RStickXAxis = 20,
  56779. /** RStickYAxis */
  56780. RStickYAxis = 21
  56781. }
  56782. }
  56783. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56784. import { Engine } from "babylonjs/Engines/engine";
  56785. import { IDisposable } from "babylonjs/scene";
  56786. import { Nullable } from "babylonjs/types";
  56787. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56788. /**
  56789. * This class will take all inputs from Keyboard, Pointer, and
  56790. * any Gamepads and provide a polling system that all devices
  56791. * will use. This class assumes that there will only be one
  56792. * pointer device and one keyboard.
  56793. */
  56794. export class DeviceInputSystem implements IDisposable {
  56795. /**
  56796. * Callback to be triggered when a device is connected
  56797. */
  56798. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56799. /**
  56800. * Callback to be triggered when a device is disconnected
  56801. */
  56802. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56803. /**
  56804. * Callback to be triggered when event driven input is updated
  56805. */
  56806. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56807. private _inputs;
  56808. private _gamepads;
  56809. private _keyboardActive;
  56810. private _pointerActive;
  56811. private _elementToAttachTo;
  56812. private _keyboardDownEvent;
  56813. private _keyboardUpEvent;
  56814. private _pointerMoveEvent;
  56815. private _pointerDownEvent;
  56816. private _pointerUpEvent;
  56817. private _gamepadConnectedEvent;
  56818. private _gamepadDisconnectedEvent;
  56819. private static _MAX_KEYCODES;
  56820. private static _MAX_POINTER_INPUTS;
  56821. private constructor();
  56822. /**
  56823. * Creates a new DeviceInputSystem instance
  56824. * @param engine Engine to pull input element from
  56825. * @returns The new instance
  56826. */
  56827. static Create(engine: Engine): DeviceInputSystem;
  56828. /**
  56829. * Checks for current device input value, given an id and input index
  56830. * @param deviceName Id of connected device
  56831. * @param inputIndex Index of device input
  56832. * @returns Current value of input
  56833. */
  56834. /**
  56835. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56836. * @param deviceType Enum specifiying device type
  56837. * @param deviceSlot "Slot" or index that device is referenced in
  56838. * @param inputIndex Id of input to be checked
  56839. * @returns Current value of input
  56840. */
  56841. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56842. /**
  56843. * Dispose of all the eventlisteners
  56844. */
  56845. dispose(): void;
  56846. /**
  56847. * Add device and inputs to device array
  56848. * @param deviceType Enum specifiying device type
  56849. * @param deviceSlot "Slot" or index that device is referenced in
  56850. * @param numberOfInputs Number of input entries to create for given device
  56851. */
  56852. private _registerDevice;
  56853. /**
  56854. * Given a specific device name, remove that device from the device map
  56855. * @param deviceType Enum specifiying device type
  56856. * @param deviceSlot "Slot" or index that device is referenced in
  56857. */
  56858. private _unregisterDevice;
  56859. /**
  56860. * Handle all actions that come from keyboard interaction
  56861. */
  56862. private _handleKeyActions;
  56863. /**
  56864. * Handle all actions that come from pointer interaction
  56865. */
  56866. private _handlePointerActions;
  56867. /**
  56868. * Handle all actions that come from gamepad interaction
  56869. */
  56870. private _handleGamepadActions;
  56871. /**
  56872. * Update all non-event based devices with each frame
  56873. * @param deviceType Enum specifiying device type
  56874. * @param deviceSlot "Slot" or index that device is referenced in
  56875. * @param inputIndex Id of input to be checked
  56876. */
  56877. private _updateDevice;
  56878. /**
  56879. * Gets DeviceType from the device name
  56880. * @param deviceName Name of Device from DeviceInputSystem
  56881. * @returns DeviceType enum value
  56882. */
  56883. private _getGamepadDeviceType;
  56884. }
  56885. }
  56886. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  56887. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56888. /**
  56889. * Type to handle enforcement of inputs
  56890. */
  56891. 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;
  56892. }
  56893. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  56894. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  56895. import { Engine } from "babylonjs/Engines/engine";
  56896. import { IDisposable } from "babylonjs/scene";
  56897. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56898. import { Nullable } from "babylonjs/types";
  56899. import { Observable } from "babylonjs/Misc/observable";
  56900. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  56901. /**
  56902. * Class that handles all input for a specific device
  56903. */
  56904. export class DeviceSource<T extends DeviceType> {
  56905. /** Type of device */
  56906. readonly deviceType: DeviceType;
  56907. /** "Slot" or index that device is referenced in */
  56908. readonly deviceSlot: number;
  56909. /**
  56910. * Observable to handle device input changes per device
  56911. */
  56912. readonly onInputChangedObservable: Observable<{
  56913. inputIndex: DeviceInput<T>;
  56914. previousState: Nullable<number>;
  56915. currentState: Nullable<number>;
  56916. }>;
  56917. private readonly _deviceInputSystem;
  56918. /**
  56919. * Default Constructor
  56920. * @param deviceInputSystem Reference to DeviceInputSystem
  56921. * @param deviceType Type of device
  56922. * @param deviceSlot "Slot" or index that device is referenced in
  56923. */
  56924. constructor(deviceInputSystem: DeviceInputSystem,
  56925. /** Type of device */
  56926. deviceType: DeviceType,
  56927. /** "Slot" or index that device is referenced in */
  56928. deviceSlot?: number);
  56929. /**
  56930. * Get input for specific input
  56931. * @param inputIndex index of specific input on device
  56932. * @returns Input value from DeviceInputSystem
  56933. */
  56934. getInput(inputIndex: DeviceInput<T>): number;
  56935. }
  56936. /**
  56937. * Class to keep track of devices
  56938. */
  56939. export class DeviceSourceManager implements IDisposable {
  56940. /**
  56941. * Observable to be triggered when before a device is connected
  56942. */
  56943. readonly onBeforeDeviceConnectedObservable: Observable<{
  56944. deviceType: DeviceType;
  56945. deviceSlot: number;
  56946. }>;
  56947. /**
  56948. * Observable to be triggered when before a device is disconnected
  56949. */
  56950. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  56951. deviceType: DeviceType;
  56952. deviceSlot: number;
  56953. }>;
  56954. /**
  56955. * Observable to be triggered when after a device is connected
  56956. */
  56957. readonly onAfterDeviceConnectedObservable: Observable<{
  56958. deviceType: DeviceType;
  56959. deviceSlot: number;
  56960. }>;
  56961. /**
  56962. * Observable to be triggered when after a device is disconnected
  56963. */
  56964. readonly onAfterDeviceDisconnectedObservable: Observable<{
  56965. deviceType: DeviceType;
  56966. deviceSlot: number;
  56967. }>;
  56968. private readonly _devices;
  56969. private readonly _firstDevice;
  56970. private readonly _deviceInputSystem;
  56971. /**
  56972. * Default Constructor
  56973. * @param engine engine to pull input element from
  56974. */
  56975. constructor(engine: Engine);
  56976. /**
  56977. * Gets a DeviceSource, given a type and slot
  56978. * @param deviceType Enum specifying device type
  56979. * @param deviceSlot "Slot" or index that device is referenced in
  56980. * @returns DeviceSource object
  56981. */
  56982. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56983. /**
  56984. * Gets an array of DeviceSource objects for a given device type
  56985. * @param deviceType Enum specifying device type
  56986. * @returns Array of DeviceSource objects
  56987. */
  56988. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56989. /**
  56990. * Dispose of DeviceInputSystem and other parts
  56991. */
  56992. dispose(): void;
  56993. /**
  56994. * Function to add device name to device list
  56995. * @param deviceType Enum specifying device type
  56996. * @param deviceSlot "Slot" or index that device is referenced in
  56997. */
  56998. private _addDevice;
  56999. /**
  57000. * Function to remove device name to device list
  57001. * @param deviceType Enum specifying device type
  57002. * @param deviceSlot "Slot" or index that device is referenced in
  57003. */
  57004. private _removeDevice;
  57005. /**
  57006. * Updates array storing first connected device of each type
  57007. * @param type Type of Device
  57008. */
  57009. private _updateFirstDevices;
  57010. }
  57011. }
  57012. declare module "babylonjs/DeviceInput/index" {
  57013. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57014. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57015. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57016. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57017. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57018. }
  57019. declare module "babylonjs/Engines/nullEngine" {
  57020. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57021. import { Engine } from "babylonjs/Engines/engine";
  57022. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57023. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57024. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57025. import { Effect } from "babylonjs/Materials/effect";
  57026. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57027. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57028. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57029. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57030. /**
  57031. * Options to create the null engine
  57032. */
  57033. export class NullEngineOptions {
  57034. /**
  57035. * Render width (Default: 512)
  57036. */
  57037. renderWidth: number;
  57038. /**
  57039. * Render height (Default: 256)
  57040. */
  57041. renderHeight: number;
  57042. /**
  57043. * Texture size (Default: 512)
  57044. */
  57045. textureSize: number;
  57046. /**
  57047. * If delta time between frames should be constant
  57048. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57049. */
  57050. deterministicLockstep: boolean;
  57051. /**
  57052. * Maximum about of steps between frames (Default: 4)
  57053. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57054. */
  57055. lockstepMaxSteps: number;
  57056. /**
  57057. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57058. */
  57059. useHighPrecisionMatrix?: boolean;
  57060. }
  57061. /**
  57062. * The null engine class provides support for headless version of babylon.js.
  57063. * This can be used in server side scenario or for testing purposes
  57064. */
  57065. export class NullEngine extends Engine {
  57066. private _options;
  57067. /**
  57068. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57069. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57070. * @returns true if engine is in deterministic lock step mode
  57071. */
  57072. isDeterministicLockStep(): boolean;
  57073. /**
  57074. * Gets the max steps when engine is running in deterministic lock step
  57075. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57076. * @returns the max steps
  57077. */
  57078. getLockstepMaxSteps(): number;
  57079. /**
  57080. * Gets the current hardware scaling level.
  57081. * By default the hardware scaling level is computed from the window device ratio.
  57082. * 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.
  57083. * @returns a number indicating the current hardware scaling level
  57084. */
  57085. getHardwareScalingLevel(): number;
  57086. constructor(options?: NullEngineOptions);
  57087. /**
  57088. * Creates a vertex buffer
  57089. * @param vertices the data for the vertex buffer
  57090. * @returns the new WebGL static buffer
  57091. */
  57092. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57093. /**
  57094. * Creates a new index buffer
  57095. * @param indices defines the content of the index buffer
  57096. * @param updatable defines if the index buffer must be updatable
  57097. * @returns a new webGL buffer
  57098. */
  57099. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57100. /**
  57101. * Clear the current render buffer or the current render target (if any is set up)
  57102. * @param color defines the color to use
  57103. * @param backBuffer defines if the back buffer must be cleared
  57104. * @param depth defines if the depth buffer must be cleared
  57105. * @param stencil defines if the stencil buffer must be cleared
  57106. */
  57107. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57108. /**
  57109. * Gets the current render width
  57110. * @param useScreen defines if screen size must be used (or the current render target if any)
  57111. * @returns a number defining the current render width
  57112. */
  57113. getRenderWidth(useScreen?: boolean): number;
  57114. /**
  57115. * Gets the current render height
  57116. * @param useScreen defines if screen size must be used (or the current render target if any)
  57117. * @returns a number defining the current render height
  57118. */
  57119. getRenderHeight(useScreen?: boolean): number;
  57120. /**
  57121. * Set the WebGL's viewport
  57122. * @param viewport defines the viewport element to be used
  57123. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57124. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57125. */
  57126. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57127. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57128. /**
  57129. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57130. * @param pipelineContext defines the pipeline context to use
  57131. * @param uniformsNames defines the list of uniform names
  57132. * @returns an array of webGL uniform locations
  57133. */
  57134. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57135. /**
  57136. * Gets the lsit of active attributes for a given webGL program
  57137. * @param pipelineContext defines the pipeline context to use
  57138. * @param attributesNames defines the list of attribute names to get
  57139. * @returns an array of indices indicating the offset of each attribute
  57140. */
  57141. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57142. /**
  57143. * Binds an effect to the webGL context
  57144. * @param effect defines the effect to bind
  57145. */
  57146. bindSamplers(effect: Effect): void;
  57147. /**
  57148. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57149. * @param effect defines the effect to activate
  57150. */
  57151. enableEffect(effect: Effect): void;
  57152. /**
  57153. * Set various states to the webGL context
  57154. * @param culling defines backface culling state
  57155. * @param zOffset defines the value to apply to zOffset (0 by default)
  57156. * @param force defines if states must be applied even if cache is up to date
  57157. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57158. */
  57159. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57160. /**
  57161. * Set the value of an uniform to an array of int32
  57162. * @param uniform defines the webGL uniform location where to store the value
  57163. * @param array defines the array of int32 to store
  57164. * @returns true if value was set
  57165. */
  57166. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57167. /**
  57168. * Set the value of an uniform to an array of int32 (stored as vec2)
  57169. * @param uniform defines the webGL uniform location where to store the value
  57170. * @param array defines the array of int32 to store
  57171. * @returns true if value was set
  57172. */
  57173. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57174. /**
  57175. * Set the value of an uniform to an array of int32 (stored as vec3)
  57176. * @param uniform defines the webGL uniform location where to store the value
  57177. * @param array defines the array of int32 to store
  57178. * @returns true if value was set
  57179. */
  57180. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57181. /**
  57182. * Set the value of an uniform to an array of int32 (stored as vec4)
  57183. * @param uniform defines the webGL uniform location where to store the value
  57184. * @param array defines the array of int32 to store
  57185. * @returns true if value was set
  57186. */
  57187. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57188. /**
  57189. * Set the value of an uniform to an array of float32
  57190. * @param uniform defines the webGL uniform location where to store the value
  57191. * @param array defines the array of float32 to store
  57192. * @returns true if value was set
  57193. */
  57194. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57195. /**
  57196. * Set the value of an uniform to an array of float32 (stored as vec2)
  57197. * @param uniform defines the webGL uniform location where to store the value
  57198. * @param array defines the array of float32 to store
  57199. * @returns true if value was set
  57200. */
  57201. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57202. /**
  57203. * Set the value of an uniform to an array of float32 (stored as vec3)
  57204. * @param uniform defines the webGL uniform location where to store the value
  57205. * @param array defines the array of float32 to store
  57206. * @returns true if value was set
  57207. */
  57208. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57209. /**
  57210. * Set the value of an uniform to an array of float32 (stored as vec4)
  57211. * @param uniform defines the webGL uniform location where to store the value
  57212. * @param array defines the array of float32 to store
  57213. * @returns true if value was set
  57214. */
  57215. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57216. /**
  57217. * Set the value of an uniform to an array of number
  57218. * @param uniform defines the webGL uniform location where to store the value
  57219. * @param array defines the array of number to store
  57220. * @returns true if value was set
  57221. */
  57222. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57223. /**
  57224. * Set the value of an uniform to an array of number (stored as vec2)
  57225. * @param uniform defines the webGL uniform location where to store the value
  57226. * @param array defines the array of number to store
  57227. * @returns true if value was set
  57228. */
  57229. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57230. /**
  57231. * Set the value of an uniform to an array of number (stored as vec3)
  57232. * @param uniform defines the webGL uniform location where to store the value
  57233. * @param array defines the array of number to store
  57234. * @returns true if value was set
  57235. */
  57236. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57237. /**
  57238. * Set the value of an uniform to an array of number (stored as vec4)
  57239. * @param uniform defines the webGL uniform location where to store the value
  57240. * @param array defines the array of number to store
  57241. * @returns true if value was set
  57242. */
  57243. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57244. /**
  57245. * Set the value of an uniform to an array of float32 (stored as matrices)
  57246. * @param uniform defines the webGL uniform location where to store the value
  57247. * @param matrices defines the array of float32 to store
  57248. * @returns true if value was set
  57249. */
  57250. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57251. /**
  57252. * Set the value of an uniform to a matrix (3x3)
  57253. * @param uniform defines the webGL uniform location where to store the value
  57254. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57255. * @returns true if value was set
  57256. */
  57257. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57258. /**
  57259. * Set the value of an uniform to a matrix (2x2)
  57260. * @param uniform defines the webGL uniform location where to store the value
  57261. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57262. * @returns true if value was set
  57263. */
  57264. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57265. /**
  57266. * Set the value of an uniform to a number (float)
  57267. * @param uniform defines the webGL uniform location where to store the value
  57268. * @param value defines the float number to store
  57269. * @returns true if value was set
  57270. */
  57271. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57272. /**
  57273. * Set the value of an uniform to a vec2
  57274. * @param uniform defines the webGL uniform location where to store the value
  57275. * @param x defines the 1st component of the value
  57276. * @param y defines the 2nd component of the value
  57277. * @returns true if value was set
  57278. */
  57279. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57280. /**
  57281. * Set the value of an uniform to a vec3
  57282. * @param uniform defines the webGL uniform location where to store the value
  57283. * @param x defines the 1st component of the value
  57284. * @param y defines the 2nd component of the value
  57285. * @param z defines the 3rd component of the value
  57286. * @returns true if value was set
  57287. */
  57288. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57289. /**
  57290. * Set the value of an uniform to a boolean
  57291. * @param uniform defines the webGL uniform location where to store the value
  57292. * @param bool defines the boolean to store
  57293. * @returns true if value was set
  57294. */
  57295. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57296. /**
  57297. * Set the value of an uniform to a vec4
  57298. * @param uniform defines the webGL uniform location where to store the value
  57299. * @param x defines the 1st component of the value
  57300. * @param y defines the 2nd component of the value
  57301. * @param z defines the 3rd component of the value
  57302. * @param w defines the 4th component of the value
  57303. * @returns true if value was set
  57304. */
  57305. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57306. /**
  57307. * Sets the current alpha mode
  57308. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57309. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57310. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57311. */
  57312. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57313. /**
  57314. * Bind webGl buffers directly to the webGL context
  57315. * @param vertexBuffers defines the vertex buffer to bind
  57316. * @param indexBuffer defines the index buffer to bind
  57317. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57318. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57319. * @param effect defines the effect associated with the vertex buffer
  57320. */
  57321. bindBuffers(vertexBuffers: {
  57322. [key: string]: VertexBuffer;
  57323. }, indexBuffer: DataBuffer, effect: Effect): void;
  57324. /**
  57325. * Force the entire cache to be cleared
  57326. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57327. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57328. */
  57329. wipeCaches(bruteForce?: boolean): void;
  57330. /**
  57331. * Send a draw order
  57332. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57333. * @param indexStart defines the starting index
  57334. * @param indexCount defines the number of index to draw
  57335. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57336. */
  57337. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57338. /**
  57339. * Draw a list of indexed primitives
  57340. * @param fillMode defines the primitive to use
  57341. * @param indexStart defines the starting index
  57342. * @param indexCount defines the number of index to draw
  57343. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57344. */
  57345. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57346. /**
  57347. * Draw a list of unindexed primitives
  57348. * @param fillMode defines the primitive to use
  57349. * @param verticesStart defines the index of first vertex to draw
  57350. * @param verticesCount defines the count of vertices to draw
  57351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57352. */
  57353. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57354. /** @hidden */
  57355. _createTexture(): WebGLTexture;
  57356. /** @hidden */
  57357. _releaseTexture(texture: InternalTexture): void;
  57358. /**
  57359. * Usually called from Texture.ts.
  57360. * Passed information to create a WebGLTexture
  57361. * @param urlArg defines a value which contains one of the following:
  57362. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57363. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57364. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57365. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57366. * @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)
  57367. * @param scene needed for loading to the correct scene
  57368. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57369. * @param onLoad optional callback to be called upon successful completion
  57370. * @param onError optional callback to be called upon failure
  57371. * @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
  57372. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57373. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57374. * @param forcedExtension defines the extension to use to pick the right loader
  57375. * @param mimeType defines an optional mime type
  57376. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57377. */
  57378. 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;
  57379. /**
  57380. * Creates a new render target texture
  57381. * @param size defines the size of the texture
  57382. * @param options defines the options used to create the texture
  57383. * @returns a new render target texture stored in an InternalTexture
  57384. */
  57385. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57386. /**
  57387. * Update the sampling mode of a given texture
  57388. * @param samplingMode defines the required sampling mode
  57389. * @param texture defines the texture to update
  57390. */
  57391. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57392. /**
  57393. * Binds the frame buffer to the specified texture.
  57394. * @param texture The texture to render to or null for the default canvas
  57395. * @param faceIndex The face of the texture to render to in case of cube texture
  57396. * @param requiredWidth The width of the target to render to
  57397. * @param requiredHeight The height of the target to render to
  57398. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57399. * @param lodLevel defines le lod level to bind to the frame buffer
  57400. */
  57401. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57402. /**
  57403. * Unbind the current render target texture from the webGL context
  57404. * @param texture defines the render target texture to unbind
  57405. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57406. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57407. */
  57408. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57409. /**
  57410. * Creates a dynamic vertex buffer
  57411. * @param vertices the data for the dynamic vertex buffer
  57412. * @returns the new WebGL dynamic buffer
  57413. */
  57414. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57415. /**
  57416. * Update the content of a dynamic texture
  57417. * @param texture defines the texture to update
  57418. * @param canvas defines the canvas containing the source
  57419. * @param invertY defines if data must be stored with Y axis inverted
  57420. * @param premulAlpha defines if alpha is stored as premultiplied
  57421. * @param format defines the format of the data
  57422. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57423. */
  57424. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57425. /**
  57426. * Gets a boolean indicating if all created effects are ready
  57427. * @returns true if all effects are ready
  57428. */
  57429. areAllEffectsReady(): boolean;
  57430. /**
  57431. * @hidden
  57432. * Get the current error code of the webGL context
  57433. * @returns the error code
  57434. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57435. */
  57436. getError(): number;
  57437. /** @hidden */
  57438. _getUnpackAlignement(): number;
  57439. /** @hidden */
  57440. _unpackFlipY(value: boolean): void;
  57441. /**
  57442. * Update a dynamic index buffer
  57443. * @param indexBuffer defines the target index buffer
  57444. * @param indices defines the data to update
  57445. * @param offset defines the offset in the target index buffer where update should start
  57446. */
  57447. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57448. /**
  57449. * Updates a dynamic vertex buffer.
  57450. * @param vertexBuffer the vertex buffer to update
  57451. * @param vertices the data used to update the vertex buffer
  57452. * @param byteOffset the byte offset of the data (optional)
  57453. * @param byteLength the byte length of the data (optional)
  57454. */
  57455. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57456. /** @hidden */
  57457. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57458. /** @hidden */
  57459. _bindTexture(channel: number, texture: InternalTexture): void;
  57460. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57461. /**
  57462. * 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
  57463. */
  57464. releaseEffects(): void;
  57465. displayLoadingUI(): void;
  57466. hideLoadingUI(): void;
  57467. /** @hidden */
  57468. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57469. /** @hidden */
  57470. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57471. /** @hidden */
  57472. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57473. /** @hidden */
  57474. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57475. }
  57476. }
  57477. declare module "babylonjs/Instrumentation/timeToken" {
  57478. import { Nullable } from "babylonjs/types";
  57479. /**
  57480. * @hidden
  57481. **/
  57482. export class _TimeToken {
  57483. _startTimeQuery: Nullable<WebGLQuery>;
  57484. _endTimeQuery: Nullable<WebGLQuery>;
  57485. _timeElapsedQuery: Nullable<WebGLQuery>;
  57486. _timeElapsedQueryEnded: boolean;
  57487. }
  57488. }
  57489. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57490. import { Nullable, int } from "babylonjs/types";
  57491. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57492. /** @hidden */
  57493. export class _OcclusionDataStorage {
  57494. /** @hidden */
  57495. occlusionInternalRetryCounter: number;
  57496. /** @hidden */
  57497. isOcclusionQueryInProgress: boolean;
  57498. /** @hidden */
  57499. isOccluded: boolean;
  57500. /** @hidden */
  57501. occlusionRetryCount: number;
  57502. /** @hidden */
  57503. occlusionType: number;
  57504. /** @hidden */
  57505. occlusionQueryAlgorithmType: number;
  57506. }
  57507. module "babylonjs/Engines/engine" {
  57508. interface Engine {
  57509. /**
  57510. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57511. * @return the new query
  57512. */
  57513. createQuery(): WebGLQuery;
  57514. /**
  57515. * Delete and release a webGL query
  57516. * @param query defines the query to delete
  57517. * @return the current engine
  57518. */
  57519. deleteQuery(query: WebGLQuery): Engine;
  57520. /**
  57521. * Check if a given query has resolved and got its value
  57522. * @param query defines the query to check
  57523. * @returns true if the query got its value
  57524. */
  57525. isQueryResultAvailable(query: WebGLQuery): boolean;
  57526. /**
  57527. * Gets the value of a given query
  57528. * @param query defines the query to check
  57529. * @returns the value of the query
  57530. */
  57531. getQueryResult(query: WebGLQuery): number;
  57532. /**
  57533. * Initiates an occlusion query
  57534. * @param algorithmType defines the algorithm to use
  57535. * @param query defines the query to use
  57536. * @returns the current engine
  57537. * @see https://doc.babylonjs.com/features/occlusionquery
  57538. */
  57539. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57540. /**
  57541. * Ends an occlusion query
  57542. * @see https://doc.babylonjs.com/features/occlusionquery
  57543. * @param algorithmType defines the algorithm to use
  57544. * @returns the current engine
  57545. */
  57546. endOcclusionQuery(algorithmType: number): Engine;
  57547. /**
  57548. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57549. * Please note that only one query can be issued at a time
  57550. * @returns a time token used to track the time span
  57551. */
  57552. startTimeQuery(): Nullable<_TimeToken>;
  57553. /**
  57554. * Ends a time query
  57555. * @param token defines the token used to measure the time span
  57556. * @returns the time spent (in ns)
  57557. */
  57558. endTimeQuery(token: _TimeToken): int;
  57559. /** @hidden */
  57560. _currentNonTimestampToken: Nullable<_TimeToken>;
  57561. /** @hidden */
  57562. _createTimeQuery(): WebGLQuery;
  57563. /** @hidden */
  57564. _deleteTimeQuery(query: WebGLQuery): void;
  57565. /** @hidden */
  57566. _getGlAlgorithmType(algorithmType: number): number;
  57567. /** @hidden */
  57568. _getTimeQueryResult(query: WebGLQuery): any;
  57569. /** @hidden */
  57570. _getTimeQueryAvailability(query: WebGLQuery): any;
  57571. }
  57572. }
  57573. module "babylonjs/Meshes/abstractMesh" {
  57574. interface AbstractMesh {
  57575. /**
  57576. * Backing filed
  57577. * @hidden
  57578. */
  57579. __occlusionDataStorage: _OcclusionDataStorage;
  57580. /**
  57581. * Access property
  57582. * @hidden
  57583. */
  57584. _occlusionDataStorage: _OcclusionDataStorage;
  57585. /**
  57586. * 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.
  57587. * The default value is -1 which means don't break the query and wait till the result
  57588. * @see https://doc.babylonjs.com/features/occlusionquery
  57589. */
  57590. occlusionRetryCount: number;
  57591. /**
  57592. * 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:
  57593. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57594. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57595. * * 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.
  57596. * @see https://doc.babylonjs.com/features/occlusionquery
  57597. */
  57598. occlusionType: number;
  57599. /**
  57600. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57601. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57602. * * 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.
  57603. * @see https://doc.babylonjs.com/features/occlusionquery
  57604. */
  57605. occlusionQueryAlgorithmType: number;
  57606. /**
  57607. * 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
  57608. * @see https://doc.babylonjs.com/features/occlusionquery
  57609. */
  57610. isOccluded: boolean;
  57611. /**
  57612. * Flag to check the progress status of the query
  57613. * @see https://doc.babylonjs.com/features/occlusionquery
  57614. */
  57615. isOcclusionQueryInProgress: boolean;
  57616. }
  57617. }
  57618. }
  57619. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57620. import { Nullable } from "babylonjs/types";
  57621. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57622. /** @hidden */
  57623. export var _forceTransformFeedbackToBundle: boolean;
  57624. module "babylonjs/Engines/engine" {
  57625. interface Engine {
  57626. /**
  57627. * Creates a webGL transform feedback object
  57628. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57629. * @returns the webGL transform feedback object
  57630. */
  57631. createTransformFeedback(): WebGLTransformFeedback;
  57632. /**
  57633. * Delete a webGL transform feedback object
  57634. * @param value defines the webGL transform feedback object to delete
  57635. */
  57636. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57637. /**
  57638. * Bind a webGL transform feedback object to the webgl context
  57639. * @param value defines the webGL transform feedback object to bind
  57640. */
  57641. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57642. /**
  57643. * Begins a transform feedback operation
  57644. * @param usePoints defines if points or triangles must be used
  57645. */
  57646. beginTransformFeedback(usePoints: boolean): void;
  57647. /**
  57648. * Ends a transform feedback operation
  57649. */
  57650. endTransformFeedback(): void;
  57651. /**
  57652. * Specify the varyings to use with transform feedback
  57653. * @param program defines the associated webGL program
  57654. * @param value defines the list of strings representing the varying names
  57655. */
  57656. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57657. /**
  57658. * Bind a webGL buffer for a transform feedback operation
  57659. * @param value defines the webGL buffer to bind
  57660. */
  57661. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57662. }
  57663. }
  57664. }
  57665. declare module "babylonjs/Engines/Extensions/engine.views" {
  57666. import { Camera } from "babylonjs/Cameras/camera";
  57667. import { Nullable } from "babylonjs/types";
  57668. /**
  57669. * Class used to define an additional view for the engine
  57670. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57671. */
  57672. export class EngineView {
  57673. /** Defines the canvas where to render the view */
  57674. target: HTMLCanvasElement;
  57675. /** Defines an optional camera used to render the view (will use active camera else) */
  57676. camera?: Camera;
  57677. }
  57678. module "babylonjs/Engines/engine" {
  57679. interface Engine {
  57680. /**
  57681. * Gets or sets the HTML element to use for attaching events
  57682. */
  57683. inputElement: Nullable<HTMLElement>;
  57684. /**
  57685. * Gets the current engine view
  57686. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57687. */
  57688. activeView: Nullable<EngineView>;
  57689. /** Gets or sets the list of views */
  57690. views: EngineView[];
  57691. /**
  57692. * Register a new child canvas
  57693. * @param canvas defines the canvas to register
  57694. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57695. * @returns the associated view
  57696. */
  57697. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57698. /**
  57699. * Remove a registered child canvas
  57700. * @param canvas defines the canvas to remove
  57701. * @returns the current engine
  57702. */
  57703. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57704. }
  57705. }
  57706. }
  57707. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57708. import { Nullable } from "babylonjs/types";
  57709. module "babylonjs/Engines/engine" {
  57710. interface Engine {
  57711. /** @hidden */
  57712. _excludedCompressedTextures: string[];
  57713. /** @hidden */
  57714. _textureFormatInUse: string;
  57715. /**
  57716. * Gets the list of texture formats supported
  57717. */
  57718. readonly texturesSupported: Array<string>;
  57719. /**
  57720. * Gets the texture format in use
  57721. */
  57722. readonly textureFormatInUse: Nullable<string>;
  57723. /**
  57724. * Set the compressed texture extensions or file names to skip.
  57725. *
  57726. * @param skippedFiles defines the list of those texture files you want to skip
  57727. * Example: [".dds", ".env", "myfile.png"]
  57728. */
  57729. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57730. /**
  57731. * Set the compressed texture format to use, based on the formats you have, and the formats
  57732. * supported by the hardware / browser.
  57733. *
  57734. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57735. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57736. * to API arguments needed to compressed textures. This puts the burden on the container
  57737. * generator to house the arcane code for determining these for current & future formats.
  57738. *
  57739. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57740. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57741. *
  57742. * Note: The result of this call is not taken into account when a texture is base64.
  57743. *
  57744. * @param formatsAvailable defines the list of those format families you have created
  57745. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57746. *
  57747. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57748. * @returns The extension selected.
  57749. */
  57750. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57751. }
  57752. }
  57753. }
  57754. declare module "babylonjs/Engines/Extensions/index" {
  57755. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57756. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57757. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57758. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57759. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57760. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57761. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57762. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57763. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57764. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57765. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57766. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57767. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57768. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57769. export * from "babylonjs/Engines/Extensions/engine.views";
  57770. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57771. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57772. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57773. }
  57774. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57775. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57776. /** @hidden */
  57777. export var rgbdEncodePixelShader: {
  57778. name: string;
  57779. shader: string;
  57780. };
  57781. }
  57782. declare module "babylonjs/Misc/environmentTextureTools" {
  57783. import { Nullable } from "babylonjs/types";
  57784. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57785. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57787. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57788. import "babylonjs/Engines/Extensions/engine.readTexture";
  57789. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57790. import "babylonjs/Shaders/rgbdEncode.fragment";
  57791. import "babylonjs/Shaders/rgbdDecode.fragment";
  57792. /**
  57793. * Raw texture data and descriptor sufficient for WebGL texture upload
  57794. */
  57795. export interface EnvironmentTextureInfo {
  57796. /**
  57797. * Version of the environment map
  57798. */
  57799. version: number;
  57800. /**
  57801. * Width of image
  57802. */
  57803. width: number;
  57804. /**
  57805. * Irradiance information stored in the file.
  57806. */
  57807. irradiance: any;
  57808. /**
  57809. * Specular information stored in the file.
  57810. */
  57811. specular: any;
  57812. }
  57813. /**
  57814. * Defines One Image in the file. It requires only the position in the file
  57815. * as well as the length.
  57816. */
  57817. interface BufferImageData {
  57818. /**
  57819. * Length of the image data.
  57820. */
  57821. length: number;
  57822. /**
  57823. * Position of the data from the null terminator delimiting the end of the JSON.
  57824. */
  57825. position: number;
  57826. }
  57827. /**
  57828. * Defines the specular data enclosed in the file.
  57829. * This corresponds to the version 1 of the data.
  57830. */
  57831. export interface EnvironmentTextureSpecularInfoV1 {
  57832. /**
  57833. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57834. */
  57835. specularDataPosition?: number;
  57836. /**
  57837. * This contains all the images data needed to reconstruct the cubemap.
  57838. */
  57839. mipmaps: Array<BufferImageData>;
  57840. /**
  57841. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  57842. */
  57843. lodGenerationScale: number;
  57844. }
  57845. /**
  57846. * Sets of helpers addressing the serialization and deserialization of environment texture
  57847. * stored in a BabylonJS env file.
  57848. * Those files are usually stored as .env files.
  57849. */
  57850. export class EnvironmentTextureTools {
  57851. /**
  57852. * Magic number identifying the env file.
  57853. */
  57854. private static _MagicBytes;
  57855. /**
  57856. * Gets the environment info from an env file.
  57857. * @param data The array buffer containing the .env bytes.
  57858. * @returns the environment file info (the json header) if successfully parsed.
  57859. */
  57860. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  57861. /**
  57862. * Creates an environment texture from a loaded cube texture.
  57863. * @param texture defines the cube texture to convert in env file
  57864. * @return a promise containing the environment data if succesfull.
  57865. */
  57866. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  57867. /**
  57868. * Creates a JSON representation of the spherical data.
  57869. * @param texture defines the texture containing the polynomials
  57870. * @return the JSON representation of the spherical info
  57871. */
  57872. private static _CreateEnvTextureIrradiance;
  57873. /**
  57874. * Creates the ArrayBufferViews used for initializing environment texture image data.
  57875. * @param data the image data
  57876. * @param info parameters that determine what views will be created for accessing the underlying buffer
  57877. * @return the views described by info providing access to the underlying buffer
  57878. */
  57879. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  57880. /**
  57881. * Uploads the texture info contained in the env file to the GPU.
  57882. * @param texture defines the internal texture to upload to
  57883. * @param data defines the data to load
  57884. * @param info defines the texture info retrieved through the GetEnvInfo method
  57885. * @returns a promise
  57886. */
  57887. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  57888. private static _OnImageReadyAsync;
  57889. /**
  57890. * Uploads the levels of image data to the GPU.
  57891. * @param texture defines the internal texture to upload to
  57892. * @param imageData defines the array buffer views of image data [mipmap][face]
  57893. * @returns a promise
  57894. */
  57895. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57896. /**
  57897. * Uploads spherical polynomials information to the texture.
  57898. * @param texture defines the texture we are trying to upload the information to
  57899. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57900. */
  57901. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57902. /** @hidden */
  57903. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57904. }
  57905. }
  57906. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  57907. /**
  57908. * Class used to inline functions in shader code
  57909. */
  57910. export class ShaderCodeInliner {
  57911. private static readonly _RegexpFindFunctionNameAndType;
  57912. private _sourceCode;
  57913. private _functionDescr;
  57914. private _numMaxIterations;
  57915. /** Gets or sets the token used to mark the functions to inline */
  57916. inlineToken: string;
  57917. /** Gets or sets the debug mode */
  57918. debug: boolean;
  57919. /** Gets the code after the inlining process */
  57920. get code(): string;
  57921. /**
  57922. * Initializes the inliner
  57923. * @param sourceCode shader code source to inline
  57924. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57925. */
  57926. constructor(sourceCode: string, numMaxIterations?: number);
  57927. /**
  57928. * Start the processing of the shader code
  57929. */
  57930. processCode(): void;
  57931. private _collectFunctions;
  57932. private _processInlining;
  57933. private _extractBetweenMarkers;
  57934. private _skipWhitespaces;
  57935. private _removeComments;
  57936. private _replaceFunctionCallsByCode;
  57937. private _findBackward;
  57938. private _escapeRegExp;
  57939. private _replaceNames;
  57940. }
  57941. }
  57942. declare module "babylonjs/Engines/nativeEngine" {
  57943. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  57944. import { Engine } from "babylonjs/Engines/engine";
  57945. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57946. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57948. import { Effect } from "babylonjs/Materials/effect";
  57949. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57950. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  57951. import { IColor4Like } from "babylonjs/Maths/math.like";
  57952. import { Scene } from "babylonjs/scene";
  57953. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57954. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57955. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57956. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  57957. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  57958. /**
  57959. * Container for accessors for natively-stored mesh data buffers.
  57960. */
  57961. class NativeDataBuffer extends DataBuffer {
  57962. /**
  57963. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57964. */
  57965. nativeIndexBuffer?: any;
  57966. /**
  57967. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57968. */
  57969. nativeVertexBuffer?: any;
  57970. }
  57971. /** @hidden */
  57972. class NativeTexture extends InternalTexture {
  57973. getInternalTexture(): InternalTexture;
  57974. getViewCount(): number;
  57975. }
  57976. /** @hidden */
  57977. export class NativeEngine extends Engine {
  57978. private readonly _native;
  57979. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57980. private readonly INVALID_HANDLE;
  57981. private _boundBuffersVertexArray;
  57982. private _currentDepthTest;
  57983. getHardwareScalingLevel(): number;
  57984. constructor();
  57985. dispose(): void;
  57986. /**
  57987. * Can be used to override the current requestAnimationFrame requester.
  57988. * @hidden
  57989. */
  57990. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57991. /**
  57992. * Override default engine behavior.
  57993. * @param color
  57994. * @param backBuffer
  57995. * @param depth
  57996. * @param stencil
  57997. */
  57998. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57999. /**
  58000. * Gets host document
  58001. * @returns the host document object
  58002. */
  58003. getHostDocument(): Nullable<Document>;
  58004. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58005. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58006. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58007. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58008. [key: string]: VertexBuffer;
  58009. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58010. bindBuffers(vertexBuffers: {
  58011. [key: string]: VertexBuffer;
  58012. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58013. recordVertexArrayObject(vertexBuffers: {
  58014. [key: string]: VertexBuffer;
  58015. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58016. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58017. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58018. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58019. /**
  58020. * Draw a list of indexed primitives
  58021. * @param fillMode defines the primitive to use
  58022. * @param indexStart defines the starting index
  58023. * @param indexCount defines the number of index to draw
  58024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58025. */
  58026. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58027. /**
  58028. * Draw a list of unindexed primitives
  58029. * @param fillMode defines the primitive to use
  58030. * @param verticesStart defines the index of first vertex to draw
  58031. * @param verticesCount defines the count of vertices to draw
  58032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58033. */
  58034. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58035. createPipelineContext(): IPipelineContext;
  58036. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58037. /** @hidden */
  58038. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58039. /** @hidden */
  58040. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58041. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58042. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58043. protected _setProgram(program: WebGLProgram): void;
  58044. _releaseEffect(effect: Effect): void;
  58045. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58046. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58047. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58048. bindSamplers(effect: Effect): void;
  58049. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58050. getRenderWidth(useScreen?: boolean): number;
  58051. getRenderHeight(useScreen?: boolean): number;
  58052. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58053. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58054. /**
  58055. * Set the z offset to apply to current rendering
  58056. * @param value defines the offset to apply
  58057. */
  58058. setZOffset(value: number): void;
  58059. /**
  58060. * Gets the current value of the zOffset
  58061. * @returns the current zOffset state
  58062. */
  58063. getZOffset(): number;
  58064. /**
  58065. * Enable or disable depth buffering
  58066. * @param enable defines the state to set
  58067. */
  58068. setDepthBuffer(enable: boolean): void;
  58069. /**
  58070. * Gets a boolean indicating if depth writing is enabled
  58071. * @returns the current depth writing state
  58072. */
  58073. getDepthWrite(): boolean;
  58074. setDepthFunctionToGreater(): void;
  58075. setDepthFunctionToGreaterOrEqual(): void;
  58076. setDepthFunctionToLess(): void;
  58077. setDepthFunctionToLessOrEqual(): void;
  58078. /**
  58079. * Enable or disable depth writing
  58080. * @param enable defines the state to set
  58081. */
  58082. setDepthWrite(enable: boolean): void;
  58083. /**
  58084. * Enable or disable color writing
  58085. * @param enable defines the state to set
  58086. */
  58087. setColorWrite(enable: boolean): void;
  58088. /**
  58089. * Gets a boolean indicating if color writing is enabled
  58090. * @returns the current color writing state
  58091. */
  58092. getColorWrite(): boolean;
  58093. /**
  58094. * Sets alpha constants used by some alpha blending modes
  58095. * @param r defines the red component
  58096. * @param g defines the green component
  58097. * @param b defines the blue component
  58098. * @param a defines the alpha component
  58099. */
  58100. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58101. /**
  58102. * Sets the current alpha mode
  58103. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58104. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58105. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58106. */
  58107. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58108. /**
  58109. * Gets the current alpha mode
  58110. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58111. * @returns the current alpha mode
  58112. */
  58113. getAlphaMode(): number;
  58114. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58115. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58116. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58117. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58118. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58119. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58120. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58121. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58122. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58123. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58124. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58125. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58126. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58127. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58128. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58129. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58130. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58131. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58132. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58133. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58134. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58135. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58136. wipeCaches(bruteForce?: boolean): void;
  58137. _createTexture(): WebGLTexture;
  58138. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58139. /**
  58140. * Update the content of a dynamic texture
  58141. * @param texture defines the texture to update
  58142. * @param canvas defines the canvas containing the source
  58143. * @param invertY defines if data must be stored with Y axis inverted
  58144. * @param premulAlpha defines if alpha is stored as premultiplied
  58145. * @param format defines the format of the data
  58146. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58147. */
  58148. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58149. /**
  58150. * Usually called from Texture.ts.
  58151. * Passed information to create a WebGLTexture
  58152. * @param url defines a value which contains one of the following:
  58153. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58154. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58155. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58156. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58157. * @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)
  58158. * @param scene needed for loading to the correct scene
  58159. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58160. * @param onLoad optional callback to be called upon successful completion
  58161. * @param onError optional callback to be called upon failure
  58162. * @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
  58163. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58164. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58165. * @param forcedExtension defines the extension to use to pick the right loader
  58166. * @param mimeType defines an optional mime type
  58167. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58168. */
  58169. 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;
  58170. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58171. _releaseFramebufferObjects(texture: InternalTexture): void;
  58172. /**
  58173. * Creates a cube texture
  58174. * @param rootUrl defines the url where the files to load is located
  58175. * @param scene defines the current scene
  58176. * @param files defines the list of files to load (1 per face)
  58177. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58178. * @param onLoad defines an optional callback raised when the texture is loaded
  58179. * @param onError defines an optional callback raised if there is an issue to load the texture
  58180. * @param format defines the format of the data
  58181. * @param forcedExtension defines the extension to use to pick the right loader
  58182. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58183. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58184. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58185. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58186. * @returns the cube texture as an InternalTexture
  58187. */
  58188. 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;
  58189. createRenderTargetTexture(size: number | {
  58190. width: number;
  58191. height: number;
  58192. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58193. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58194. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58195. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58196. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58197. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58198. /**
  58199. * Updates a dynamic vertex buffer.
  58200. * @param vertexBuffer the vertex buffer to update
  58201. * @param data the data used to update the vertex buffer
  58202. * @param byteOffset the byte offset of the data (optional)
  58203. * @param byteLength the byte length of the data (optional)
  58204. */
  58205. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58206. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58207. private _updateAnisotropicLevel;
  58208. private _getAddressMode;
  58209. /** @hidden */
  58210. _bindTexture(channel: number, texture: InternalTexture): void;
  58211. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58212. releaseEffects(): void;
  58213. /** @hidden */
  58214. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58215. /** @hidden */
  58216. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58217. /** @hidden */
  58218. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58219. /** @hidden */
  58220. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58221. private _getNativeSamplingMode;
  58222. private _getNativeTextureFormat;
  58223. private _getNativeAlphaMode;
  58224. private _getNativeAttribType;
  58225. }
  58226. }
  58227. declare module "babylonjs/Engines/index" {
  58228. export * from "babylonjs/Engines/constants";
  58229. export * from "babylonjs/Engines/engineCapabilities";
  58230. export * from "babylonjs/Engines/instancingAttributeInfo";
  58231. export * from "babylonjs/Engines/thinEngine";
  58232. export * from "babylonjs/Engines/engine";
  58233. export * from "babylonjs/Engines/engineStore";
  58234. export * from "babylonjs/Engines/nullEngine";
  58235. export * from "babylonjs/Engines/Extensions/index";
  58236. export * from "babylonjs/Engines/IPipelineContext";
  58237. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58238. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58239. export * from "babylonjs/Engines/nativeEngine";
  58240. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58241. export * from "babylonjs/Engines/performanceConfigurator";
  58242. }
  58243. declare module "babylonjs/Events/clipboardEvents" {
  58244. /**
  58245. * Gather the list of clipboard event types as constants.
  58246. */
  58247. export class ClipboardEventTypes {
  58248. /**
  58249. * The clipboard event is fired when a copy command is active (pressed).
  58250. */
  58251. static readonly COPY: number;
  58252. /**
  58253. * The clipboard event is fired when a cut command is active (pressed).
  58254. */
  58255. static readonly CUT: number;
  58256. /**
  58257. * The clipboard event is fired when a paste command is active (pressed).
  58258. */
  58259. static readonly PASTE: number;
  58260. }
  58261. /**
  58262. * This class is used to store clipboard related info for the onClipboardObservable event.
  58263. */
  58264. export class ClipboardInfo {
  58265. /**
  58266. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58267. */
  58268. type: number;
  58269. /**
  58270. * Defines the related dom event
  58271. */
  58272. event: ClipboardEvent;
  58273. /**
  58274. *Creates an instance of ClipboardInfo.
  58275. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58276. * @param event Defines the related dom event
  58277. */
  58278. constructor(
  58279. /**
  58280. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58281. */
  58282. type: number,
  58283. /**
  58284. * Defines the related dom event
  58285. */
  58286. event: ClipboardEvent);
  58287. /**
  58288. * Get the clipboard event's type from the keycode.
  58289. * @param keyCode Defines the keyCode for the current keyboard event.
  58290. * @return {number}
  58291. */
  58292. static GetTypeFromCharacter(keyCode: number): number;
  58293. }
  58294. }
  58295. declare module "babylonjs/Events/index" {
  58296. export * from "babylonjs/Events/keyboardEvents";
  58297. export * from "babylonjs/Events/pointerEvents";
  58298. export * from "babylonjs/Events/clipboardEvents";
  58299. }
  58300. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58301. import { Scene } from "babylonjs/scene";
  58302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58303. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58304. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58305. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58306. /**
  58307. * Google Daydream controller
  58308. */
  58309. export class DaydreamController extends WebVRController {
  58310. /**
  58311. * Base Url for the controller model.
  58312. */
  58313. static MODEL_BASE_URL: string;
  58314. /**
  58315. * File name for the controller model.
  58316. */
  58317. static MODEL_FILENAME: string;
  58318. /**
  58319. * Gamepad Id prefix used to identify Daydream Controller.
  58320. */
  58321. static readonly GAMEPAD_ID_PREFIX: string;
  58322. /**
  58323. * Creates a new DaydreamController from a gamepad
  58324. * @param vrGamepad the gamepad that the controller should be created from
  58325. */
  58326. constructor(vrGamepad: any);
  58327. /**
  58328. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58329. * @param scene scene in which to add meshes
  58330. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58331. */
  58332. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58333. /**
  58334. * Called once for each button that changed state since the last frame
  58335. * @param buttonIdx Which button index changed
  58336. * @param state New state of the button
  58337. * @param changes Which properties on the state changed since last frame
  58338. */
  58339. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58340. }
  58341. }
  58342. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58343. import { Scene } from "babylonjs/scene";
  58344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58345. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58346. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58347. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58348. /**
  58349. * Gear VR Controller
  58350. */
  58351. export class GearVRController extends WebVRController {
  58352. /**
  58353. * Base Url for the controller model.
  58354. */
  58355. static MODEL_BASE_URL: string;
  58356. /**
  58357. * File name for the controller model.
  58358. */
  58359. static MODEL_FILENAME: string;
  58360. /**
  58361. * Gamepad Id prefix used to identify this controller.
  58362. */
  58363. static readonly GAMEPAD_ID_PREFIX: string;
  58364. private readonly _buttonIndexToObservableNameMap;
  58365. /**
  58366. * Creates a new GearVRController from a gamepad
  58367. * @param vrGamepad the gamepad that the controller should be created from
  58368. */
  58369. constructor(vrGamepad: any);
  58370. /**
  58371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58372. * @param scene scene in which to add meshes
  58373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58374. */
  58375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58376. /**
  58377. * Called once for each button that changed state since the last frame
  58378. * @param buttonIdx Which button index changed
  58379. * @param state New state of the button
  58380. * @param changes Which properties on the state changed since last frame
  58381. */
  58382. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58383. }
  58384. }
  58385. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58386. import { Scene } from "babylonjs/scene";
  58387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58388. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58389. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58390. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58391. /**
  58392. * Generic Controller
  58393. */
  58394. export class GenericController extends WebVRController {
  58395. /**
  58396. * Base Url for the controller model.
  58397. */
  58398. static readonly MODEL_BASE_URL: string;
  58399. /**
  58400. * File name for the controller model.
  58401. */
  58402. static readonly MODEL_FILENAME: string;
  58403. /**
  58404. * Creates a new GenericController from a gamepad
  58405. * @param vrGamepad the gamepad that the controller should be created from
  58406. */
  58407. constructor(vrGamepad: any);
  58408. /**
  58409. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58410. * @param scene scene in which to add meshes
  58411. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58412. */
  58413. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58414. /**
  58415. * Called once for each button that changed state since the last frame
  58416. * @param buttonIdx Which button index changed
  58417. * @param state New state of the button
  58418. * @param changes Which properties on the state changed since last frame
  58419. */
  58420. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58421. }
  58422. }
  58423. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58424. import { Observable } from "babylonjs/Misc/observable";
  58425. import { Scene } from "babylonjs/scene";
  58426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58427. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58428. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58429. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58430. /**
  58431. * Oculus Touch Controller
  58432. */
  58433. export class OculusTouchController extends WebVRController {
  58434. /**
  58435. * Base Url for the controller model.
  58436. */
  58437. static MODEL_BASE_URL: string;
  58438. /**
  58439. * File name for the left controller model.
  58440. */
  58441. static MODEL_LEFT_FILENAME: string;
  58442. /**
  58443. * File name for the right controller model.
  58444. */
  58445. static MODEL_RIGHT_FILENAME: string;
  58446. /**
  58447. * Base Url for the Quest controller model.
  58448. */
  58449. static QUEST_MODEL_BASE_URL: string;
  58450. /**
  58451. * @hidden
  58452. * If the controllers are running on a device that needs the updated Quest controller models
  58453. */
  58454. static _IsQuest: boolean;
  58455. /**
  58456. * Fired when the secondary trigger on this controller is modified
  58457. */
  58458. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58459. /**
  58460. * Fired when the thumb rest on this controller is modified
  58461. */
  58462. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58463. /**
  58464. * Creates a new OculusTouchController from a gamepad
  58465. * @param vrGamepad the gamepad that the controller should be created from
  58466. */
  58467. constructor(vrGamepad: any);
  58468. /**
  58469. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58470. * @param scene scene in which to add meshes
  58471. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58472. */
  58473. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58474. /**
  58475. * Fired when the A button on this controller is modified
  58476. */
  58477. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58478. /**
  58479. * Fired when the B button on this controller is modified
  58480. */
  58481. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58482. /**
  58483. * Fired when the X button on this controller is modified
  58484. */
  58485. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58486. /**
  58487. * Fired when the Y button on this controller is modified
  58488. */
  58489. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58490. /**
  58491. * Called once for each button that changed state since the last frame
  58492. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58493. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58494. * 2) secondary trigger (same)
  58495. * 3) A (right) X (left), touch, pressed = value
  58496. * 4) B / Y
  58497. * 5) thumb rest
  58498. * @param buttonIdx Which button index changed
  58499. * @param state New state of the button
  58500. * @param changes Which properties on the state changed since last frame
  58501. */
  58502. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58503. }
  58504. }
  58505. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58506. import { Scene } from "babylonjs/scene";
  58507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58508. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58509. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58510. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58511. import { Observable } from "babylonjs/Misc/observable";
  58512. /**
  58513. * Vive Controller
  58514. */
  58515. export class ViveController extends WebVRController {
  58516. /**
  58517. * Base Url for the controller model.
  58518. */
  58519. static MODEL_BASE_URL: string;
  58520. /**
  58521. * File name for the controller model.
  58522. */
  58523. static MODEL_FILENAME: string;
  58524. /**
  58525. * Creates a new ViveController from a gamepad
  58526. * @param vrGamepad the gamepad that the controller should be created from
  58527. */
  58528. constructor(vrGamepad: any);
  58529. /**
  58530. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58531. * @param scene scene in which to add meshes
  58532. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58533. */
  58534. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58535. /**
  58536. * Fired when the left button on this controller is modified
  58537. */
  58538. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58539. /**
  58540. * Fired when the right button on this controller is modified
  58541. */
  58542. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58543. /**
  58544. * Fired when the menu button on this controller is modified
  58545. */
  58546. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58547. /**
  58548. * Called once for each button that changed state since the last frame
  58549. * Vive mapping:
  58550. * 0: touchpad
  58551. * 1: trigger
  58552. * 2: left AND right buttons
  58553. * 3: menu button
  58554. * @param buttonIdx Which button index changed
  58555. * @param state New state of the button
  58556. * @param changes Which properties on the state changed since last frame
  58557. */
  58558. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58559. }
  58560. }
  58561. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58562. import { Observable } from "babylonjs/Misc/observable";
  58563. import { Scene } from "babylonjs/scene";
  58564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58565. import { Ray } from "babylonjs/Culling/ray";
  58566. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58567. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58568. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58569. /**
  58570. * Defines the WindowsMotionController object that the state of the windows motion controller
  58571. */
  58572. export class WindowsMotionController extends WebVRController {
  58573. /**
  58574. * The base url used to load the left and right controller models
  58575. */
  58576. static MODEL_BASE_URL: string;
  58577. /**
  58578. * The name of the left controller model file
  58579. */
  58580. static MODEL_LEFT_FILENAME: string;
  58581. /**
  58582. * The name of the right controller model file
  58583. */
  58584. static MODEL_RIGHT_FILENAME: string;
  58585. /**
  58586. * The controller name prefix for this controller type
  58587. */
  58588. static readonly GAMEPAD_ID_PREFIX: string;
  58589. /**
  58590. * The controller id pattern for this controller type
  58591. */
  58592. private static readonly GAMEPAD_ID_PATTERN;
  58593. private _loadedMeshInfo;
  58594. protected readonly _mapping: {
  58595. buttons: string[];
  58596. buttonMeshNames: {
  58597. trigger: string;
  58598. menu: string;
  58599. grip: string;
  58600. thumbstick: string;
  58601. trackpad: string;
  58602. };
  58603. buttonObservableNames: {
  58604. trigger: string;
  58605. menu: string;
  58606. grip: string;
  58607. thumbstick: string;
  58608. trackpad: string;
  58609. };
  58610. axisMeshNames: string[];
  58611. pointingPoseMeshName: string;
  58612. };
  58613. /**
  58614. * Fired when the trackpad on this controller is clicked
  58615. */
  58616. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58617. /**
  58618. * Fired when the trackpad on this controller is modified
  58619. */
  58620. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58621. /**
  58622. * The current x and y values of this controller's trackpad
  58623. */
  58624. trackpad: StickValues;
  58625. /**
  58626. * Creates a new WindowsMotionController from a gamepad
  58627. * @param vrGamepad the gamepad that the controller should be created from
  58628. */
  58629. constructor(vrGamepad: any);
  58630. /**
  58631. * Fired when the trigger on this controller is modified
  58632. */
  58633. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58634. /**
  58635. * Fired when the menu button on this controller is modified
  58636. */
  58637. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58638. /**
  58639. * Fired when the grip button on this controller is modified
  58640. */
  58641. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58642. /**
  58643. * Fired when the thumbstick button on this controller is modified
  58644. */
  58645. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58646. /**
  58647. * Fired when the touchpad button on this controller is modified
  58648. */
  58649. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58650. /**
  58651. * Fired when the touchpad values on this controller are modified
  58652. */
  58653. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58654. protected _updateTrackpad(): void;
  58655. /**
  58656. * Called once per frame by the engine.
  58657. */
  58658. update(): void;
  58659. /**
  58660. * Called once for each button that changed state since the last frame
  58661. * @param buttonIdx Which button index changed
  58662. * @param state New state of the button
  58663. * @param changes Which properties on the state changed since last frame
  58664. */
  58665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58666. /**
  58667. * Moves the buttons on the controller mesh based on their current state
  58668. * @param buttonName the name of the button to move
  58669. * @param buttonValue the value of the button which determines the buttons new position
  58670. */
  58671. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58672. /**
  58673. * Moves the axis on the controller mesh based on its current state
  58674. * @param axis the index of the axis
  58675. * @param axisValue the value of the axis which determines the meshes new position
  58676. * @hidden
  58677. */
  58678. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58679. /**
  58680. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58681. * @param scene scene in which to add meshes
  58682. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58683. */
  58684. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58685. /**
  58686. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58687. * can be transformed by button presses and axes values, based on this._mapping.
  58688. *
  58689. * @param scene scene in which the meshes exist
  58690. * @param meshes list of meshes that make up the controller model to process
  58691. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58692. */
  58693. private processModel;
  58694. private createMeshInfo;
  58695. /**
  58696. * Gets the ray of the controller in the direction the controller is pointing
  58697. * @param length the length the resulting ray should be
  58698. * @returns a ray in the direction the controller is pointing
  58699. */
  58700. getForwardRay(length?: number): Ray;
  58701. /**
  58702. * Disposes of the controller
  58703. */
  58704. dispose(): void;
  58705. }
  58706. /**
  58707. * This class represents a new windows motion controller in XR.
  58708. */
  58709. export class XRWindowsMotionController extends WindowsMotionController {
  58710. /**
  58711. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58712. */
  58713. protected readonly _mapping: {
  58714. buttons: string[];
  58715. buttonMeshNames: {
  58716. trigger: string;
  58717. menu: string;
  58718. grip: string;
  58719. thumbstick: string;
  58720. trackpad: string;
  58721. };
  58722. buttonObservableNames: {
  58723. trigger: string;
  58724. menu: string;
  58725. grip: string;
  58726. thumbstick: string;
  58727. trackpad: string;
  58728. };
  58729. axisMeshNames: string[];
  58730. pointingPoseMeshName: string;
  58731. };
  58732. /**
  58733. * Construct a new XR-Based windows motion controller
  58734. *
  58735. * @param gamepadInfo the gamepad object from the browser
  58736. */
  58737. constructor(gamepadInfo: any);
  58738. /**
  58739. * holds the thumbstick values (X,Y)
  58740. */
  58741. thumbstickValues: StickValues;
  58742. /**
  58743. * Fired when the thumbstick on this controller is clicked
  58744. */
  58745. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58746. /**
  58747. * Fired when the thumbstick on this controller is modified
  58748. */
  58749. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58750. /**
  58751. * Fired when the touchpad button on this controller is modified
  58752. */
  58753. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58754. /**
  58755. * Fired when the touchpad values on this controller are modified
  58756. */
  58757. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58758. /**
  58759. * Fired when the thumbstick button on this controller is modified
  58760. * here to prevent breaking changes
  58761. */
  58762. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58763. /**
  58764. * updating the thumbstick(!) and not the trackpad.
  58765. * This is named this way due to the difference between WebVR and XR and to avoid
  58766. * changing the parent class.
  58767. */
  58768. protected _updateTrackpad(): void;
  58769. /**
  58770. * Disposes the class with joy
  58771. */
  58772. dispose(): void;
  58773. }
  58774. }
  58775. declare module "babylonjs/Gamepads/Controllers/index" {
  58776. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58777. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58778. export * from "babylonjs/Gamepads/Controllers/genericController";
  58779. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58780. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58781. export * from "babylonjs/Gamepads/Controllers/viveController";
  58782. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58783. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58784. }
  58785. declare module "babylonjs/Gamepads/index" {
  58786. export * from "babylonjs/Gamepads/Controllers/index";
  58787. export * from "babylonjs/Gamepads/gamepad";
  58788. export * from "babylonjs/Gamepads/gamepadManager";
  58789. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58790. export * from "babylonjs/Gamepads/xboxGamepad";
  58791. export * from "babylonjs/Gamepads/dualShockGamepad";
  58792. }
  58793. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58794. import { Scene } from "babylonjs/scene";
  58795. import { Vector4 } from "babylonjs/Maths/math.vector";
  58796. import { Color4 } from "babylonjs/Maths/math.color";
  58797. import { Mesh } from "babylonjs/Meshes/mesh";
  58798. import { Nullable } from "babylonjs/types";
  58799. /**
  58800. * Class containing static functions to help procedurally build meshes
  58801. */
  58802. export class PolyhedronBuilder {
  58803. /**
  58804. * Creates a polyhedron mesh
  58805. * * 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
  58806. * * The parameter `size` (positive float, default 1) sets the polygon size
  58807. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58808. * * 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`
  58809. * * 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
  58810. * * 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)`)
  58811. * * 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
  58812. * * 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
  58813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58816. * @param name defines the name of the mesh
  58817. * @param options defines the options used to create the mesh
  58818. * @param scene defines the hosting scene
  58819. * @returns the polyhedron mesh
  58820. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58821. */
  58822. static CreatePolyhedron(name: string, options: {
  58823. type?: number;
  58824. size?: number;
  58825. sizeX?: number;
  58826. sizeY?: number;
  58827. sizeZ?: number;
  58828. custom?: any;
  58829. faceUV?: Vector4[];
  58830. faceColors?: Color4[];
  58831. flat?: boolean;
  58832. updatable?: boolean;
  58833. sideOrientation?: number;
  58834. frontUVs?: Vector4;
  58835. backUVs?: Vector4;
  58836. }, scene?: Nullable<Scene>): Mesh;
  58837. }
  58838. }
  58839. declare module "babylonjs/Gizmos/scaleGizmo" {
  58840. import { Observable } from "babylonjs/Misc/observable";
  58841. import { Nullable } from "babylonjs/types";
  58842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58843. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58844. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  58845. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58846. import { Node } from "babylonjs/node";
  58847. /**
  58848. * Gizmo that enables scaling a mesh along 3 axis
  58849. */
  58850. export class ScaleGizmo extends Gizmo {
  58851. /**
  58852. * Internal gizmo used for interactions on the x axis
  58853. */
  58854. xGizmo: AxisScaleGizmo;
  58855. /**
  58856. * Internal gizmo used for interactions on the y axis
  58857. */
  58858. yGizmo: AxisScaleGizmo;
  58859. /**
  58860. * Internal gizmo used for interactions on the z axis
  58861. */
  58862. zGizmo: AxisScaleGizmo;
  58863. /**
  58864. * Internal gizmo used to scale all axis equally
  58865. */
  58866. uniformScaleGizmo: AxisScaleGizmo;
  58867. private _meshAttached;
  58868. private _nodeAttached;
  58869. private _snapDistance;
  58870. private _uniformScalingMesh;
  58871. private _octahedron;
  58872. private _sensitivity;
  58873. /** Fires an event when any of it's sub gizmos are dragged */
  58874. onDragStartObservable: Observable<unknown>;
  58875. /** Fires an event when any of it's sub gizmos are released from dragging */
  58876. onDragEndObservable: Observable<unknown>;
  58877. get attachedMesh(): Nullable<AbstractMesh>;
  58878. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58879. get attachedNode(): Nullable<Node>;
  58880. set attachedNode(node: Nullable<Node>);
  58881. /**
  58882. * True when the mouse pointer is hovering a gizmo mesh
  58883. */
  58884. get isHovered(): boolean;
  58885. /**
  58886. * Creates a ScaleGizmo
  58887. * @param gizmoLayer The utility layer the gizmo will be added to
  58888. * @param thickness display gizmo axis thickness
  58889. */
  58890. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  58891. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58892. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58893. /**
  58894. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58895. */
  58896. set snapDistance(value: number);
  58897. get snapDistance(): number;
  58898. /**
  58899. * Ratio for the scale of the gizmo (Default: 1)
  58900. */
  58901. set scaleRatio(value: number);
  58902. get scaleRatio(): number;
  58903. /**
  58904. * Sensitivity factor for dragging (Default: 1)
  58905. */
  58906. set sensitivity(value: number);
  58907. get sensitivity(): number;
  58908. /**
  58909. * Disposes of the gizmo
  58910. */
  58911. dispose(): void;
  58912. }
  58913. }
  58914. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  58915. import { Observable } from "babylonjs/Misc/observable";
  58916. import { Nullable } from "babylonjs/types";
  58917. import { Vector3 } from "babylonjs/Maths/math.vector";
  58918. import { Node } from "babylonjs/node";
  58919. import { Mesh } from "babylonjs/Meshes/mesh";
  58920. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  58921. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58922. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58923. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  58924. import { Color3 } from "babylonjs/Maths/math.color";
  58925. /**
  58926. * Single axis scale gizmo
  58927. */
  58928. export class AxisScaleGizmo extends Gizmo {
  58929. /**
  58930. * Drag behavior responsible for the gizmos dragging interactions
  58931. */
  58932. dragBehavior: PointerDragBehavior;
  58933. private _pointerObserver;
  58934. /**
  58935. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58936. */
  58937. snapDistance: number;
  58938. /**
  58939. * Event that fires each time the gizmo snaps to a new location.
  58940. * * snapDistance is the the change in distance
  58941. */
  58942. onSnapObservable: Observable<{
  58943. snapDistance: number;
  58944. }>;
  58945. /**
  58946. * If the scaling operation should be done on all axis (default: false)
  58947. */
  58948. uniformScaling: boolean;
  58949. /**
  58950. * Custom sensitivity value for the drag strength
  58951. */
  58952. sensitivity: number;
  58953. private _isEnabled;
  58954. private _parent;
  58955. private _arrow;
  58956. private _coloredMaterial;
  58957. private _hoverMaterial;
  58958. /**
  58959. * Creates an AxisScaleGizmo
  58960. * @param gizmoLayer The utility layer the gizmo will be added to
  58961. * @param dragAxis The axis which the gizmo will be able to scale on
  58962. * @param color The color of the gizmo
  58963. * @param thickness display gizmo axis thickness
  58964. */
  58965. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  58966. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58967. /**
  58968. * If the gizmo is enabled
  58969. */
  58970. set isEnabled(value: boolean);
  58971. get isEnabled(): boolean;
  58972. /**
  58973. * Disposes of the gizmo
  58974. */
  58975. dispose(): void;
  58976. /**
  58977. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58978. * @param mesh The mesh to replace the default mesh of the gizmo
  58979. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58980. */
  58981. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58982. }
  58983. }
  58984. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  58985. import { Observable } from "babylonjs/Misc/observable";
  58986. import { Nullable } from "babylonjs/types";
  58987. import { Vector3 } from "babylonjs/Maths/math.vector";
  58988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58989. import { Mesh } from "babylonjs/Meshes/mesh";
  58990. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58991. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58992. import { Color3 } from "babylonjs/Maths/math.color";
  58993. import "babylonjs/Meshes/Builders/boxBuilder";
  58994. /**
  58995. * Bounding box gizmo
  58996. */
  58997. export class BoundingBoxGizmo extends Gizmo {
  58998. private _lineBoundingBox;
  58999. private _rotateSpheresParent;
  59000. private _scaleBoxesParent;
  59001. private _boundingDimensions;
  59002. private _renderObserver;
  59003. private _pointerObserver;
  59004. private _scaleDragSpeed;
  59005. private _tmpQuaternion;
  59006. private _tmpVector;
  59007. private _tmpRotationMatrix;
  59008. /**
  59009. * 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)
  59010. */
  59011. ignoreChildren: boolean;
  59012. /**
  59013. * 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)
  59014. */
  59015. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59016. /**
  59017. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59018. */
  59019. rotationSphereSize: number;
  59020. /**
  59021. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59022. */
  59023. scaleBoxSize: number;
  59024. /**
  59025. * 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)
  59026. */
  59027. fixedDragMeshScreenSize: boolean;
  59028. /**
  59029. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59030. */
  59031. fixedDragMeshScreenSizeDistanceFactor: number;
  59032. /**
  59033. * Fired when a rotation sphere or scale box is dragged
  59034. */
  59035. onDragStartObservable: Observable<{}>;
  59036. /**
  59037. * Fired when a scale box is dragged
  59038. */
  59039. onScaleBoxDragObservable: Observable<{}>;
  59040. /**
  59041. * Fired when a scale box drag is ended
  59042. */
  59043. onScaleBoxDragEndObservable: Observable<{}>;
  59044. /**
  59045. * Fired when a rotation sphere is dragged
  59046. */
  59047. onRotationSphereDragObservable: Observable<{}>;
  59048. /**
  59049. * Fired when a rotation sphere drag is ended
  59050. */
  59051. onRotationSphereDragEndObservable: Observable<{}>;
  59052. /**
  59053. * 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)
  59054. */
  59055. scalePivot: Nullable<Vector3>;
  59056. /**
  59057. * Mesh used as a pivot to rotate the attached node
  59058. */
  59059. private _anchorMesh;
  59060. private _existingMeshScale;
  59061. private _dragMesh;
  59062. private pointerDragBehavior;
  59063. private coloredMaterial;
  59064. private hoverColoredMaterial;
  59065. /**
  59066. * Sets the color of the bounding box gizmo
  59067. * @param color the color to set
  59068. */
  59069. setColor(color: Color3): void;
  59070. /**
  59071. * Creates an BoundingBoxGizmo
  59072. * @param gizmoLayer The utility layer the gizmo will be added to
  59073. * @param color The color of the gizmo
  59074. */
  59075. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59076. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59077. private _selectNode;
  59078. /**
  59079. * Updates the bounding box information for the Gizmo
  59080. */
  59081. updateBoundingBox(): void;
  59082. private _updateRotationSpheres;
  59083. private _updateScaleBoxes;
  59084. /**
  59085. * Enables rotation on the specified axis and disables rotation on the others
  59086. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59087. */
  59088. setEnabledRotationAxis(axis: string): void;
  59089. /**
  59090. * Enables/disables scaling
  59091. * @param enable if scaling should be enabled
  59092. * @param homogeneousScaling defines if scaling should only be homogeneous
  59093. */
  59094. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59095. private _updateDummy;
  59096. /**
  59097. * Enables a pointer drag behavior on the bounding box of the gizmo
  59098. */
  59099. enableDragBehavior(): void;
  59100. /**
  59101. * Disposes of the gizmo
  59102. */
  59103. dispose(): void;
  59104. /**
  59105. * 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)
  59106. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59107. * @returns the bounding box mesh with the passed in mesh as a child
  59108. */
  59109. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59110. /**
  59111. * CustomMeshes are not supported by this gizmo
  59112. * @param mesh The mesh to replace the default mesh of the gizmo
  59113. */
  59114. setCustomMesh(mesh: Mesh): void;
  59115. }
  59116. }
  59117. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59118. import { Observable } from "babylonjs/Misc/observable";
  59119. import { Nullable } from "babylonjs/types";
  59120. import { Vector3 } from "babylonjs/Maths/math.vector";
  59121. import { Color3 } from "babylonjs/Maths/math.color";
  59122. import { Node } from "babylonjs/node";
  59123. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59124. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59125. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59126. import "babylonjs/Meshes/Builders/linesBuilder";
  59127. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59128. /**
  59129. * Single plane rotation gizmo
  59130. */
  59131. export class PlaneRotationGizmo extends Gizmo {
  59132. /**
  59133. * Drag behavior responsible for the gizmos dragging interactions
  59134. */
  59135. dragBehavior: PointerDragBehavior;
  59136. private _pointerObserver;
  59137. /**
  59138. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59139. */
  59140. snapDistance: number;
  59141. /**
  59142. * Event that fires each time the gizmo snaps to a new location.
  59143. * * snapDistance is the the change in distance
  59144. */
  59145. onSnapObservable: Observable<{
  59146. snapDistance: number;
  59147. }>;
  59148. private _isEnabled;
  59149. private _parent;
  59150. /**
  59151. * Creates a PlaneRotationGizmo
  59152. * @param gizmoLayer The utility layer the gizmo will be added to
  59153. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59154. * @param color The color of the gizmo
  59155. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59156. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59157. * @param thickness display gizmo axis thickness
  59158. */
  59159. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59160. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59161. /**
  59162. * If the gizmo is enabled
  59163. */
  59164. set isEnabled(value: boolean);
  59165. get isEnabled(): boolean;
  59166. /**
  59167. * Disposes of the gizmo
  59168. */
  59169. dispose(): void;
  59170. }
  59171. }
  59172. declare module "babylonjs/Gizmos/rotationGizmo" {
  59173. import { Observable } from "babylonjs/Misc/observable";
  59174. import { Nullable } from "babylonjs/types";
  59175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59176. import { Mesh } from "babylonjs/Meshes/mesh";
  59177. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59178. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59179. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59180. import { Node } from "babylonjs/node";
  59181. /**
  59182. * Gizmo that enables rotating a mesh along 3 axis
  59183. */
  59184. export class RotationGizmo extends Gizmo {
  59185. /**
  59186. * Internal gizmo used for interactions on the x axis
  59187. */
  59188. xGizmo: PlaneRotationGizmo;
  59189. /**
  59190. * Internal gizmo used for interactions on the y axis
  59191. */
  59192. yGizmo: PlaneRotationGizmo;
  59193. /**
  59194. * Internal gizmo used for interactions on the z axis
  59195. */
  59196. zGizmo: PlaneRotationGizmo;
  59197. /** Fires an event when any of it's sub gizmos are dragged */
  59198. onDragStartObservable: Observable<unknown>;
  59199. /** Fires an event when any of it's sub gizmos are released from dragging */
  59200. onDragEndObservable: Observable<unknown>;
  59201. private _meshAttached;
  59202. private _nodeAttached;
  59203. get attachedMesh(): Nullable<AbstractMesh>;
  59204. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59205. get attachedNode(): Nullable<Node>;
  59206. set attachedNode(node: Nullable<Node>);
  59207. /**
  59208. * True when the mouse pointer is hovering a gizmo mesh
  59209. */
  59210. get isHovered(): boolean;
  59211. /**
  59212. * Creates a RotationGizmo
  59213. * @param gizmoLayer The utility layer the gizmo will be added to
  59214. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59215. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59216. * @param thickness display gizmo axis thickness
  59217. */
  59218. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59219. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59220. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59221. /**
  59222. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59223. */
  59224. set snapDistance(value: number);
  59225. get snapDistance(): number;
  59226. /**
  59227. * Ratio for the scale of the gizmo (Default: 1)
  59228. */
  59229. set scaleRatio(value: number);
  59230. get scaleRatio(): number;
  59231. /**
  59232. * Disposes of the gizmo
  59233. */
  59234. dispose(): void;
  59235. /**
  59236. * CustomMeshes are not supported by this gizmo
  59237. * @param mesh The mesh to replace the default mesh of the gizmo
  59238. */
  59239. setCustomMesh(mesh: Mesh): void;
  59240. }
  59241. }
  59242. declare module "babylonjs/Gizmos/gizmoManager" {
  59243. import { Observable } from "babylonjs/Misc/observable";
  59244. import { Nullable } from "babylonjs/types";
  59245. import { Scene, IDisposable } from "babylonjs/scene";
  59246. import { Node } from "babylonjs/node";
  59247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59248. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59249. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59250. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59251. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59252. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59253. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59254. /**
  59255. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59256. */
  59257. export class GizmoManager implements IDisposable {
  59258. private scene;
  59259. /**
  59260. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59261. */
  59262. gizmos: {
  59263. positionGizmo: Nullable<PositionGizmo>;
  59264. rotationGizmo: Nullable<RotationGizmo>;
  59265. scaleGizmo: Nullable<ScaleGizmo>;
  59266. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59267. };
  59268. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59269. clearGizmoOnEmptyPointerEvent: boolean;
  59270. /** Fires an event when the manager is attached to a mesh */
  59271. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59272. /** Fires an event when the manager is attached to a node */
  59273. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59274. private _gizmosEnabled;
  59275. private _pointerObserver;
  59276. private _attachedMesh;
  59277. private _attachedNode;
  59278. private _boundingBoxColor;
  59279. private _defaultUtilityLayer;
  59280. private _defaultKeepDepthUtilityLayer;
  59281. private _thickness;
  59282. /**
  59283. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59284. */
  59285. boundingBoxDragBehavior: SixDofDragBehavior;
  59286. /**
  59287. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59288. */
  59289. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59290. /**
  59291. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59292. */
  59293. attachableNodes: Nullable<Array<Node>>;
  59294. /**
  59295. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59296. */
  59297. usePointerToAttachGizmos: boolean;
  59298. /**
  59299. * Utility layer that the bounding box gizmo belongs to
  59300. */
  59301. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59302. /**
  59303. * Utility layer that all gizmos besides bounding box belong to
  59304. */
  59305. get utilityLayer(): UtilityLayerRenderer;
  59306. /**
  59307. * True when the mouse pointer is hovering a gizmo mesh
  59308. */
  59309. get isHovered(): boolean;
  59310. /**
  59311. * Instatiates a gizmo manager
  59312. * @param scene the scene to overlay the gizmos on top of
  59313. * @param thickness display gizmo axis thickness
  59314. */
  59315. constructor(scene: Scene, thickness?: number);
  59316. /**
  59317. * Attaches a set of gizmos to the specified mesh
  59318. * @param mesh The mesh the gizmo's should be attached to
  59319. */
  59320. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59321. /**
  59322. * Attaches a set of gizmos to the specified node
  59323. * @param node The node the gizmo's should be attached to
  59324. */
  59325. attachToNode(node: Nullable<Node>): void;
  59326. /**
  59327. * If the position gizmo is enabled
  59328. */
  59329. set positionGizmoEnabled(value: boolean);
  59330. get positionGizmoEnabled(): boolean;
  59331. /**
  59332. * If the rotation gizmo is enabled
  59333. */
  59334. set rotationGizmoEnabled(value: boolean);
  59335. get rotationGizmoEnabled(): boolean;
  59336. /**
  59337. * If the scale gizmo is enabled
  59338. */
  59339. set scaleGizmoEnabled(value: boolean);
  59340. get scaleGizmoEnabled(): boolean;
  59341. /**
  59342. * If the boundingBox gizmo is enabled
  59343. */
  59344. set boundingBoxGizmoEnabled(value: boolean);
  59345. get boundingBoxGizmoEnabled(): boolean;
  59346. /**
  59347. * Disposes of the gizmo manager
  59348. */
  59349. dispose(): void;
  59350. }
  59351. }
  59352. declare module "babylonjs/Lights/directionalLight" {
  59353. import { Camera } from "babylonjs/Cameras/camera";
  59354. import { Scene } from "babylonjs/scene";
  59355. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59357. import { Light } from "babylonjs/Lights/light";
  59358. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59359. import { Effect } from "babylonjs/Materials/effect";
  59360. /**
  59361. * A directional light is defined by a direction (what a surprise!).
  59362. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59363. * 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.
  59364. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59365. */
  59366. export class DirectionalLight extends ShadowLight {
  59367. private _shadowFrustumSize;
  59368. /**
  59369. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59370. */
  59371. get shadowFrustumSize(): number;
  59372. /**
  59373. * Specifies a fix frustum size for the shadow generation.
  59374. */
  59375. set shadowFrustumSize(value: number);
  59376. private _shadowOrthoScale;
  59377. /**
  59378. * Gets the shadow projection scale against the optimal computed one.
  59379. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59380. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59381. */
  59382. get shadowOrthoScale(): number;
  59383. /**
  59384. * Sets the shadow projection scale against the optimal computed one.
  59385. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59386. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59387. */
  59388. set shadowOrthoScale(value: number);
  59389. /**
  59390. * Automatically compute the projection matrix to best fit (including all the casters)
  59391. * on each frame.
  59392. */
  59393. autoUpdateExtends: boolean;
  59394. /**
  59395. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59396. * on each frame. autoUpdateExtends must be set to true for this to work
  59397. */
  59398. autoCalcShadowZBounds: boolean;
  59399. private _orthoLeft;
  59400. private _orthoRight;
  59401. private _orthoTop;
  59402. private _orthoBottom;
  59403. /**
  59404. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59405. * The directional light is emitted from everywhere in the given direction.
  59406. * It can cast shadows.
  59407. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59408. * @param name The friendly name of the light
  59409. * @param direction The direction of the light
  59410. * @param scene The scene the light belongs to
  59411. */
  59412. constructor(name: string, direction: Vector3, scene: Scene);
  59413. /**
  59414. * Returns the string "DirectionalLight".
  59415. * @return The class name
  59416. */
  59417. getClassName(): string;
  59418. /**
  59419. * Returns the integer 1.
  59420. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59421. */
  59422. getTypeID(): number;
  59423. /**
  59424. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59425. * Returns the DirectionalLight Shadow projection matrix.
  59426. */
  59427. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59428. /**
  59429. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59430. * Returns the DirectionalLight Shadow projection matrix.
  59431. */
  59432. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59433. /**
  59434. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59435. * Returns the DirectionalLight Shadow projection matrix.
  59436. */
  59437. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59438. protected _buildUniformLayout(): void;
  59439. /**
  59440. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59441. * @param effect The effect to update
  59442. * @param lightIndex The index of the light in the effect to update
  59443. * @returns The directional light
  59444. */
  59445. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59446. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59447. /**
  59448. * Gets the minZ used for shadow according to both the scene and the light.
  59449. *
  59450. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59451. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59452. * @param activeCamera The camera we are returning the min for
  59453. * @returns the depth min z
  59454. */
  59455. getDepthMinZ(activeCamera: Camera): number;
  59456. /**
  59457. * Gets the maxZ used for shadow according to both the scene and the light.
  59458. *
  59459. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59460. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59461. * @param activeCamera The camera we are returning the max for
  59462. * @returns the depth max z
  59463. */
  59464. getDepthMaxZ(activeCamera: Camera): number;
  59465. /**
  59466. * Prepares the list of defines specific to the light type.
  59467. * @param defines the list of defines
  59468. * @param lightIndex defines the index of the light for the effect
  59469. */
  59470. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59471. }
  59472. }
  59473. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59474. import { Mesh } from "babylonjs/Meshes/mesh";
  59475. /**
  59476. * Class containing static functions to help procedurally build meshes
  59477. */
  59478. export class HemisphereBuilder {
  59479. /**
  59480. * Creates a hemisphere mesh
  59481. * @param name defines the name of the mesh
  59482. * @param options defines the options used to create the mesh
  59483. * @param scene defines the hosting scene
  59484. * @returns the hemisphere mesh
  59485. */
  59486. static CreateHemisphere(name: string, options: {
  59487. segments?: number;
  59488. diameter?: number;
  59489. sideOrientation?: number;
  59490. }, scene: any): Mesh;
  59491. }
  59492. }
  59493. declare module "babylonjs/Lights/spotLight" {
  59494. import { Nullable } from "babylonjs/types";
  59495. import { Scene } from "babylonjs/scene";
  59496. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59498. import { Effect } from "babylonjs/Materials/effect";
  59499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59500. import { Light } from "babylonjs/Lights/light";
  59501. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59502. /**
  59503. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59504. * These values define a cone of light starting from the position, emitting toward the direction.
  59505. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59506. * and the exponent defines the speed of the decay of the light with distance (reach).
  59507. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59508. */
  59509. export class SpotLight extends ShadowLight {
  59510. private _angle;
  59511. private _innerAngle;
  59512. private _cosHalfAngle;
  59513. private _lightAngleScale;
  59514. private _lightAngleOffset;
  59515. /**
  59516. * Gets the cone angle of the spot light in Radians.
  59517. */
  59518. get angle(): number;
  59519. /**
  59520. * Sets the cone angle of the spot light in Radians.
  59521. */
  59522. set angle(value: number);
  59523. /**
  59524. * Only used in gltf falloff mode, this defines the angle where
  59525. * the directional falloff will start before cutting at angle which could be seen
  59526. * as outer angle.
  59527. */
  59528. get innerAngle(): number;
  59529. /**
  59530. * Only used in gltf falloff mode, this defines the angle where
  59531. * the directional falloff will start before cutting at angle which could be seen
  59532. * as outer angle.
  59533. */
  59534. set innerAngle(value: number);
  59535. private _shadowAngleScale;
  59536. /**
  59537. * Allows scaling the angle of the light for shadow generation only.
  59538. */
  59539. get shadowAngleScale(): number;
  59540. /**
  59541. * Allows scaling the angle of the light for shadow generation only.
  59542. */
  59543. set shadowAngleScale(value: number);
  59544. /**
  59545. * The light decay speed with the distance from the emission spot.
  59546. */
  59547. exponent: number;
  59548. private _projectionTextureMatrix;
  59549. /**
  59550. * Allows reading the projecton texture
  59551. */
  59552. get projectionTextureMatrix(): Matrix;
  59553. protected _projectionTextureLightNear: number;
  59554. /**
  59555. * Gets the near clip of the Spotlight for texture projection.
  59556. */
  59557. get projectionTextureLightNear(): number;
  59558. /**
  59559. * Sets the near clip of the Spotlight for texture projection.
  59560. */
  59561. set projectionTextureLightNear(value: number);
  59562. protected _projectionTextureLightFar: number;
  59563. /**
  59564. * Gets the far clip of the Spotlight for texture projection.
  59565. */
  59566. get projectionTextureLightFar(): number;
  59567. /**
  59568. * Sets the far clip of the Spotlight for texture projection.
  59569. */
  59570. set projectionTextureLightFar(value: number);
  59571. protected _projectionTextureUpDirection: Vector3;
  59572. /**
  59573. * Gets the Up vector of the Spotlight for texture projection.
  59574. */
  59575. get projectionTextureUpDirection(): Vector3;
  59576. /**
  59577. * Sets the Up vector of the Spotlight for texture projection.
  59578. */
  59579. set projectionTextureUpDirection(value: Vector3);
  59580. private _projectionTexture;
  59581. /**
  59582. * Gets the projection texture of the light.
  59583. */
  59584. get projectionTexture(): Nullable<BaseTexture>;
  59585. /**
  59586. * Sets the projection texture of the light.
  59587. */
  59588. set projectionTexture(value: Nullable<BaseTexture>);
  59589. private _projectionTextureViewLightDirty;
  59590. private _projectionTextureProjectionLightDirty;
  59591. private _projectionTextureDirty;
  59592. private _projectionTextureViewTargetVector;
  59593. private _projectionTextureViewLightMatrix;
  59594. private _projectionTextureProjectionLightMatrix;
  59595. private _projectionTextureScalingMatrix;
  59596. /**
  59597. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59598. * It can cast shadows.
  59599. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59600. * @param name The light friendly name
  59601. * @param position The position of the spot light in the scene
  59602. * @param direction The direction of the light in the scene
  59603. * @param angle The cone angle of the light in Radians
  59604. * @param exponent The light decay speed with the distance from the emission spot
  59605. * @param scene The scene the lights belongs to
  59606. */
  59607. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59608. /**
  59609. * Returns the string "SpotLight".
  59610. * @returns the class name
  59611. */
  59612. getClassName(): string;
  59613. /**
  59614. * Returns the integer 2.
  59615. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59616. */
  59617. getTypeID(): number;
  59618. /**
  59619. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59620. */
  59621. protected _setDirection(value: Vector3): void;
  59622. /**
  59623. * Overrides the position setter to recompute the projection texture view light Matrix.
  59624. */
  59625. protected _setPosition(value: Vector3): void;
  59626. /**
  59627. * 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.
  59628. * Returns the SpotLight.
  59629. */
  59630. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59631. protected _computeProjectionTextureViewLightMatrix(): void;
  59632. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59633. /**
  59634. * Main function for light texture projection matrix computing.
  59635. */
  59636. protected _computeProjectionTextureMatrix(): void;
  59637. protected _buildUniformLayout(): void;
  59638. private _computeAngleValues;
  59639. /**
  59640. * Sets the passed Effect "effect" with the Light textures.
  59641. * @param effect The effect to update
  59642. * @param lightIndex The index of the light in the effect to update
  59643. * @returns The light
  59644. */
  59645. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59646. /**
  59647. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59648. * @param effect The effect to update
  59649. * @param lightIndex The index of the light in the effect to update
  59650. * @returns The spot light
  59651. */
  59652. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59653. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59654. /**
  59655. * Disposes the light and the associated resources.
  59656. */
  59657. dispose(): void;
  59658. /**
  59659. * Prepares the list of defines specific to the light type.
  59660. * @param defines the list of defines
  59661. * @param lightIndex defines the index of the light for the effect
  59662. */
  59663. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59664. }
  59665. }
  59666. declare module "babylonjs/Gizmos/lightGizmo" {
  59667. import { Nullable } from "babylonjs/types";
  59668. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59669. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59670. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59671. import { Light } from "babylonjs/Lights/light";
  59672. import { Observable } from "babylonjs/Misc/observable";
  59673. /**
  59674. * Gizmo that enables viewing a light
  59675. */
  59676. export class LightGizmo extends Gizmo {
  59677. private _lightMesh;
  59678. private _material;
  59679. private _cachedPosition;
  59680. private _cachedForward;
  59681. private _attachedMeshParent;
  59682. private _pointerObserver;
  59683. /**
  59684. * Event that fires each time the gizmo is clicked
  59685. */
  59686. onClickedObservable: Observable<Light>;
  59687. /**
  59688. * Creates a LightGizmo
  59689. * @param gizmoLayer The utility layer the gizmo will be added to
  59690. */
  59691. constructor(gizmoLayer?: UtilityLayerRenderer);
  59692. private _light;
  59693. /**
  59694. * The light that the gizmo is attached to
  59695. */
  59696. set light(light: Nullable<Light>);
  59697. get light(): Nullable<Light>;
  59698. /**
  59699. * Gets the material used to render the light gizmo
  59700. */
  59701. get material(): StandardMaterial;
  59702. /**
  59703. * @hidden
  59704. * Updates the gizmo to match the attached mesh's position/rotation
  59705. */
  59706. protected _update(): void;
  59707. private static _Scale;
  59708. /**
  59709. * Creates the lines for a light mesh
  59710. */
  59711. private static _CreateLightLines;
  59712. /**
  59713. * Disposes of the light gizmo
  59714. */
  59715. dispose(): void;
  59716. private static _CreateHemisphericLightMesh;
  59717. private static _CreatePointLightMesh;
  59718. private static _CreateSpotLightMesh;
  59719. private static _CreateDirectionalLightMesh;
  59720. }
  59721. }
  59722. declare module "babylonjs/Gizmos/cameraGizmo" {
  59723. import { Nullable } from "babylonjs/types";
  59724. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59725. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59726. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59727. import { Camera } from "babylonjs/Cameras/camera";
  59728. import { Observable } from "babylonjs/Misc/observable";
  59729. /**
  59730. * Gizmo that enables viewing a camera
  59731. */
  59732. export class CameraGizmo extends Gizmo {
  59733. private _cameraMesh;
  59734. private _cameraLinesMesh;
  59735. private _material;
  59736. private _pointerObserver;
  59737. /**
  59738. * Event that fires each time the gizmo is clicked
  59739. */
  59740. onClickedObservable: Observable<Camera>;
  59741. /**
  59742. * Creates a CameraGizmo
  59743. * @param gizmoLayer The utility layer the gizmo will be added to
  59744. */
  59745. constructor(gizmoLayer?: UtilityLayerRenderer);
  59746. private _camera;
  59747. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59748. get displayFrustum(): boolean;
  59749. set displayFrustum(value: boolean);
  59750. /**
  59751. * The camera that the gizmo is attached to
  59752. */
  59753. set camera(camera: Nullable<Camera>);
  59754. get camera(): Nullable<Camera>;
  59755. /**
  59756. * Gets the material used to render the camera gizmo
  59757. */
  59758. get material(): StandardMaterial;
  59759. /**
  59760. * @hidden
  59761. * Updates the gizmo to match the attached mesh's position/rotation
  59762. */
  59763. protected _update(): void;
  59764. private static _Scale;
  59765. private _invProjection;
  59766. /**
  59767. * Disposes of the camera gizmo
  59768. */
  59769. dispose(): void;
  59770. private static _CreateCameraMesh;
  59771. private static _CreateCameraFrustum;
  59772. }
  59773. }
  59774. declare module "babylonjs/Gizmos/index" {
  59775. export * from "babylonjs/Gizmos/axisDragGizmo";
  59776. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59777. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59778. export * from "babylonjs/Gizmos/gizmo";
  59779. export * from "babylonjs/Gizmos/gizmoManager";
  59780. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59781. export * from "babylonjs/Gizmos/positionGizmo";
  59782. export * from "babylonjs/Gizmos/rotationGizmo";
  59783. export * from "babylonjs/Gizmos/scaleGizmo";
  59784. export * from "babylonjs/Gizmos/lightGizmo";
  59785. export * from "babylonjs/Gizmos/cameraGizmo";
  59786. export * from "babylonjs/Gizmos/planeDragGizmo";
  59787. }
  59788. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59789. /** @hidden */
  59790. export var backgroundFragmentDeclaration: {
  59791. name: string;
  59792. shader: string;
  59793. };
  59794. }
  59795. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59796. /** @hidden */
  59797. export var backgroundUboDeclaration: {
  59798. name: string;
  59799. shader: string;
  59800. };
  59801. }
  59802. declare module "babylonjs/Shaders/background.fragment" {
  59803. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59804. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59805. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59806. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59807. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59808. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59809. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59810. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59811. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59812. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59813. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59814. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59815. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59816. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59817. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59818. /** @hidden */
  59819. export var backgroundPixelShader: {
  59820. name: string;
  59821. shader: string;
  59822. };
  59823. }
  59824. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59825. /** @hidden */
  59826. export var backgroundVertexDeclaration: {
  59827. name: string;
  59828. shader: string;
  59829. };
  59830. }
  59831. declare module "babylonjs/Shaders/background.vertex" {
  59832. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59833. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59837. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59838. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59839. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59840. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59841. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59842. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59843. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59844. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59845. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59846. /** @hidden */
  59847. export var backgroundVertexShader: {
  59848. name: string;
  59849. shader: string;
  59850. };
  59851. }
  59852. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  59853. import { Nullable, int, float } from "babylonjs/types";
  59854. import { Scene } from "babylonjs/scene";
  59855. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59858. import { Mesh } from "babylonjs/Meshes/mesh";
  59859. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59860. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59861. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59863. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  59864. import { Color3 } from "babylonjs/Maths/math.color";
  59865. import "babylonjs/Shaders/background.fragment";
  59866. import "babylonjs/Shaders/background.vertex";
  59867. /**
  59868. * Background material used to create an efficient environement around your scene.
  59869. */
  59870. export class BackgroundMaterial extends PushMaterial {
  59871. /**
  59872. * Standard reflectance value at parallel view angle.
  59873. */
  59874. static StandardReflectance0: number;
  59875. /**
  59876. * Standard reflectance value at grazing angle.
  59877. */
  59878. static StandardReflectance90: number;
  59879. protected _primaryColor: Color3;
  59880. /**
  59881. * Key light Color (multiply against the environement texture)
  59882. */
  59883. primaryColor: Color3;
  59884. protected __perceptualColor: Nullable<Color3>;
  59885. /**
  59886. * Experimental Internal Use Only.
  59887. *
  59888. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  59889. * This acts as a helper to set the primary color to a more "human friendly" value.
  59890. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  59891. * output color as close as possible from the chosen value.
  59892. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  59893. * part of lighting setup.)
  59894. */
  59895. get _perceptualColor(): Nullable<Color3>;
  59896. set _perceptualColor(value: Nullable<Color3>);
  59897. protected _primaryColorShadowLevel: float;
  59898. /**
  59899. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  59900. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  59901. */
  59902. get primaryColorShadowLevel(): float;
  59903. set primaryColorShadowLevel(value: float);
  59904. protected _primaryColorHighlightLevel: float;
  59905. /**
  59906. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  59907. * The primary color is used at the level chosen to define what the white area would look.
  59908. */
  59909. get primaryColorHighlightLevel(): float;
  59910. set primaryColorHighlightLevel(value: float);
  59911. protected _reflectionTexture: Nullable<BaseTexture>;
  59912. /**
  59913. * Reflection Texture used in the material.
  59914. * Should be author in a specific way for the best result (refer to the documentation).
  59915. */
  59916. reflectionTexture: Nullable<BaseTexture>;
  59917. protected _reflectionBlur: float;
  59918. /**
  59919. * Reflection Texture level of blur.
  59920. *
  59921. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  59922. * texture twice.
  59923. */
  59924. reflectionBlur: float;
  59925. protected _diffuseTexture: Nullable<BaseTexture>;
  59926. /**
  59927. * Diffuse Texture used in the material.
  59928. * Should be author in a specific way for the best result (refer to the documentation).
  59929. */
  59930. diffuseTexture: Nullable<BaseTexture>;
  59931. protected _shadowLights: Nullable<IShadowLight[]>;
  59932. /**
  59933. * Specify the list of lights casting shadow on the material.
  59934. * All scene shadow lights will be included if null.
  59935. */
  59936. shadowLights: Nullable<IShadowLight[]>;
  59937. protected _shadowLevel: float;
  59938. /**
  59939. * Helps adjusting the shadow to a softer level if required.
  59940. * 0 means black shadows and 1 means no shadows.
  59941. */
  59942. shadowLevel: float;
  59943. protected _sceneCenter: Vector3;
  59944. /**
  59945. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  59946. * It is usually zero but might be interesting to modify according to your setup.
  59947. */
  59948. sceneCenter: Vector3;
  59949. protected _opacityFresnel: boolean;
  59950. /**
  59951. * This helps specifying that the material is falling off to the sky box at grazing angle.
  59952. * This helps ensuring a nice transition when the camera goes under the ground.
  59953. */
  59954. opacityFresnel: boolean;
  59955. protected _reflectionFresnel: boolean;
  59956. /**
  59957. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  59958. * This helps adding a mirror texture on the ground.
  59959. */
  59960. reflectionFresnel: boolean;
  59961. protected _reflectionFalloffDistance: number;
  59962. /**
  59963. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  59964. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  59965. */
  59966. reflectionFalloffDistance: number;
  59967. protected _reflectionAmount: number;
  59968. /**
  59969. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  59970. */
  59971. reflectionAmount: number;
  59972. protected _reflectionReflectance0: number;
  59973. /**
  59974. * This specifies the weight of the reflection at grazing angle.
  59975. */
  59976. reflectionReflectance0: number;
  59977. protected _reflectionReflectance90: number;
  59978. /**
  59979. * This specifies the weight of the reflection at a perpendicular point of view.
  59980. */
  59981. reflectionReflectance90: number;
  59982. /**
  59983. * Sets the reflection reflectance fresnel values according to the default standard
  59984. * empirically know to work well :-)
  59985. */
  59986. set reflectionStandardFresnelWeight(value: number);
  59987. protected _useRGBColor: boolean;
  59988. /**
  59989. * Helps to directly use the maps channels instead of their level.
  59990. */
  59991. useRGBColor: boolean;
  59992. protected _enableNoise: boolean;
  59993. /**
  59994. * This helps reducing the banding effect that could occur on the background.
  59995. */
  59996. enableNoise: boolean;
  59997. /**
  59998. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59999. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60000. * Recommended to be keep at 1.0 except for special cases.
  60001. */
  60002. get fovMultiplier(): number;
  60003. set fovMultiplier(value: number);
  60004. private _fovMultiplier;
  60005. /**
  60006. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60007. */
  60008. useEquirectangularFOV: boolean;
  60009. private _maxSimultaneousLights;
  60010. /**
  60011. * Number of Simultaneous lights allowed on the material.
  60012. */
  60013. maxSimultaneousLights: int;
  60014. private _shadowOnly;
  60015. /**
  60016. * Make the material only render shadows
  60017. */
  60018. shadowOnly: boolean;
  60019. /**
  60020. * Default configuration related to image processing available in the Background Material.
  60021. */
  60022. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60023. /**
  60024. * Keep track of the image processing observer to allow dispose and replace.
  60025. */
  60026. private _imageProcessingObserver;
  60027. /**
  60028. * Attaches a new image processing configuration to the PBR Material.
  60029. * @param configuration (if null the scene configuration will be use)
  60030. */
  60031. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60032. /**
  60033. * Gets the image processing configuration used either in this material.
  60034. */
  60035. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60036. /**
  60037. * Sets the Default image processing configuration used either in the this material.
  60038. *
  60039. * If sets to null, the scene one is in use.
  60040. */
  60041. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60042. /**
  60043. * Gets wether the color curves effect is enabled.
  60044. */
  60045. get cameraColorCurvesEnabled(): boolean;
  60046. /**
  60047. * Sets wether the color curves effect is enabled.
  60048. */
  60049. set cameraColorCurvesEnabled(value: boolean);
  60050. /**
  60051. * Gets wether the color grading effect is enabled.
  60052. */
  60053. get cameraColorGradingEnabled(): boolean;
  60054. /**
  60055. * Gets wether the color grading effect is enabled.
  60056. */
  60057. set cameraColorGradingEnabled(value: boolean);
  60058. /**
  60059. * Gets wether tonemapping is enabled or not.
  60060. */
  60061. get cameraToneMappingEnabled(): boolean;
  60062. /**
  60063. * Sets wether tonemapping is enabled or not
  60064. */
  60065. set cameraToneMappingEnabled(value: boolean);
  60066. /**
  60067. * The camera exposure used on this material.
  60068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60069. * This corresponds to a photographic exposure.
  60070. */
  60071. get cameraExposure(): float;
  60072. /**
  60073. * The camera exposure used on this material.
  60074. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60075. * This corresponds to a photographic exposure.
  60076. */
  60077. set cameraExposure(value: float);
  60078. /**
  60079. * Gets The camera contrast used on this material.
  60080. */
  60081. get cameraContrast(): float;
  60082. /**
  60083. * Sets The camera contrast used on this material.
  60084. */
  60085. set cameraContrast(value: float);
  60086. /**
  60087. * Gets the Color Grading 2D Lookup Texture.
  60088. */
  60089. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60090. /**
  60091. * Sets the Color Grading 2D Lookup Texture.
  60092. */
  60093. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60094. /**
  60095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60097. * 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;
  60098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60099. */
  60100. get cameraColorCurves(): Nullable<ColorCurves>;
  60101. /**
  60102. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60103. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60104. * 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;
  60105. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60106. */
  60107. set cameraColorCurves(value: Nullable<ColorCurves>);
  60108. /**
  60109. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60110. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60111. */
  60112. switchToBGR: boolean;
  60113. private _renderTargets;
  60114. private _reflectionControls;
  60115. private _white;
  60116. private _primaryShadowColor;
  60117. private _primaryHighlightColor;
  60118. /**
  60119. * Instantiates a Background Material in the given scene
  60120. * @param name The friendly name of the material
  60121. * @param scene The scene to add the material to
  60122. */
  60123. constructor(name: string, scene: Scene);
  60124. /**
  60125. * Gets a boolean indicating that current material needs to register RTT
  60126. */
  60127. get hasRenderTargetTextures(): boolean;
  60128. /**
  60129. * The entire material has been created in order to prevent overdraw.
  60130. * @returns false
  60131. */
  60132. needAlphaTesting(): boolean;
  60133. /**
  60134. * The entire material has been created in order to prevent overdraw.
  60135. * @returns true if blending is enable
  60136. */
  60137. needAlphaBlending(): boolean;
  60138. /**
  60139. * Checks wether the material is ready to be rendered for a given mesh.
  60140. * @param mesh The mesh to render
  60141. * @param subMesh The submesh to check against
  60142. * @param useInstances Specify wether or not the material is used with instances
  60143. * @returns true if all the dependencies are ready (Textures, Effects...)
  60144. */
  60145. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60146. /**
  60147. * Compute the primary color according to the chosen perceptual color.
  60148. */
  60149. private _computePrimaryColorFromPerceptualColor;
  60150. /**
  60151. * Compute the highlights and shadow colors according to their chosen levels.
  60152. */
  60153. private _computePrimaryColors;
  60154. /**
  60155. * Build the uniform buffer used in the material.
  60156. */
  60157. buildUniformLayout(): void;
  60158. /**
  60159. * Unbind the material.
  60160. */
  60161. unbind(): void;
  60162. /**
  60163. * Bind only the world matrix to the material.
  60164. * @param world The world matrix to bind.
  60165. */
  60166. bindOnlyWorldMatrix(world: Matrix): void;
  60167. /**
  60168. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60169. * @param world The world matrix to bind.
  60170. * @param subMesh The submesh to bind for.
  60171. */
  60172. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60173. /**
  60174. * Checks to see if a texture is used in the material.
  60175. * @param texture - Base texture to use.
  60176. * @returns - Boolean specifying if a texture is used in the material.
  60177. */
  60178. hasTexture(texture: BaseTexture): boolean;
  60179. /**
  60180. * Dispose the material.
  60181. * @param forceDisposeEffect Force disposal of the associated effect.
  60182. * @param forceDisposeTextures Force disposal of the associated textures.
  60183. */
  60184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60185. /**
  60186. * Clones the material.
  60187. * @param name The cloned name.
  60188. * @returns The cloned material.
  60189. */
  60190. clone(name: string): BackgroundMaterial;
  60191. /**
  60192. * Serializes the current material to its JSON representation.
  60193. * @returns The JSON representation.
  60194. */
  60195. serialize(): any;
  60196. /**
  60197. * Gets the class name of the material
  60198. * @returns "BackgroundMaterial"
  60199. */
  60200. getClassName(): string;
  60201. /**
  60202. * Parse a JSON input to create back a background material.
  60203. * @param source The JSON data to parse
  60204. * @param scene The scene to create the parsed material in
  60205. * @param rootUrl The root url of the assets the material depends upon
  60206. * @returns the instantiated BackgroundMaterial.
  60207. */
  60208. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60209. }
  60210. }
  60211. declare module "babylonjs/Helpers/environmentHelper" {
  60212. import { Observable } from "babylonjs/Misc/observable";
  60213. import { Nullable } from "babylonjs/types";
  60214. import { Scene } from "babylonjs/scene";
  60215. import { Vector3 } from "babylonjs/Maths/math.vector";
  60216. import { Color3 } from "babylonjs/Maths/math.color";
  60217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60218. import { Mesh } from "babylonjs/Meshes/mesh";
  60219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60220. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60221. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60222. import "babylonjs/Meshes/Builders/planeBuilder";
  60223. import "babylonjs/Meshes/Builders/boxBuilder";
  60224. /**
  60225. * Represents the different options available during the creation of
  60226. * a Environment helper.
  60227. *
  60228. * This can control the default ground, skybox and image processing setup of your scene.
  60229. */
  60230. export interface IEnvironmentHelperOptions {
  60231. /**
  60232. * Specifies whether or not to create a ground.
  60233. * True by default.
  60234. */
  60235. createGround: boolean;
  60236. /**
  60237. * Specifies the ground size.
  60238. * 15 by default.
  60239. */
  60240. groundSize: number;
  60241. /**
  60242. * The texture used on the ground for the main color.
  60243. * Comes from the BabylonJS CDN by default.
  60244. *
  60245. * Remarks: Can be either a texture or a url.
  60246. */
  60247. groundTexture: string | BaseTexture;
  60248. /**
  60249. * The color mixed in the ground texture by default.
  60250. * BabylonJS clearColor by default.
  60251. */
  60252. groundColor: Color3;
  60253. /**
  60254. * Specifies the ground opacity.
  60255. * 1 by default.
  60256. */
  60257. groundOpacity: number;
  60258. /**
  60259. * Enables the ground to receive shadows.
  60260. * True by default.
  60261. */
  60262. enableGroundShadow: boolean;
  60263. /**
  60264. * Helps preventing the shadow to be fully black on the ground.
  60265. * 0.5 by default.
  60266. */
  60267. groundShadowLevel: number;
  60268. /**
  60269. * Creates a mirror texture attach to the ground.
  60270. * false by default.
  60271. */
  60272. enableGroundMirror: boolean;
  60273. /**
  60274. * Specifies the ground mirror size ratio.
  60275. * 0.3 by default as the default kernel is 64.
  60276. */
  60277. groundMirrorSizeRatio: number;
  60278. /**
  60279. * Specifies the ground mirror blur kernel size.
  60280. * 64 by default.
  60281. */
  60282. groundMirrorBlurKernel: number;
  60283. /**
  60284. * Specifies the ground mirror visibility amount.
  60285. * 1 by default
  60286. */
  60287. groundMirrorAmount: number;
  60288. /**
  60289. * Specifies the ground mirror reflectance weight.
  60290. * This uses the standard weight of the background material to setup the fresnel effect
  60291. * of the mirror.
  60292. * 1 by default.
  60293. */
  60294. groundMirrorFresnelWeight: number;
  60295. /**
  60296. * Specifies the ground mirror Falloff distance.
  60297. * This can helps reducing the size of the reflection.
  60298. * 0 by Default.
  60299. */
  60300. groundMirrorFallOffDistance: number;
  60301. /**
  60302. * Specifies the ground mirror texture type.
  60303. * Unsigned Int by Default.
  60304. */
  60305. groundMirrorTextureType: number;
  60306. /**
  60307. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60308. * the shown objects.
  60309. */
  60310. groundYBias: number;
  60311. /**
  60312. * Specifies whether or not to create a skybox.
  60313. * True by default.
  60314. */
  60315. createSkybox: boolean;
  60316. /**
  60317. * Specifies the skybox size.
  60318. * 20 by default.
  60319. */
  60320. skyboxSize: number;
  60321. /**
  60322. * The texture used on the skybox for the main color.
  60323. * Comes from the BabylonJS CDN by default.
  60324. *
  60325. * Remarks: Can be either a texture or a url.
  60326. */
  60327. skyboxTexture: string | BaseTexture;
  60328. /**
  60329. * The color mixed in the skybox texture by default.
  60330. * BabylonJS clearColor by default.
  60331. */
  60332. skyboxColor: Color3;
  60333. /**
  60334. * The background rotation around the Y axis of the scene.
  60335. * This helps aligning the key lights of your scene with the background.
  60336. * 0 by default.
  60337. */
  60338. backgroundYRotation: number;
  60339. /**
  60340. * Compute automatically the size of the elements to best fit with the scene.
  60341. */
  60342. sizeAuto: boolean;
  60343. /**
  60344. * Default position of the rootMesh if autoSize is not true.
  60345. */
  60346. rootPosition: Vector3;
  60347. /**
  60348. * Sets up the image processing in the scene.
  60349. * true by default.
  60350. */
  60351. setupImageProcessing: boolean;
  60352. /**
  60353. * The texture used as your environment texture in the scene.
  60354. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60355. *
  60356. * Remarks: Can be either a texture or a url.
  60357. */
  60358. environmentTexture: string | BaseTexture;
  60359. /**
  60360. * The value of the exposure to apply to the scene.
  60361. * 0.6 by default if setupImageProcessing is true.
  60362. */
  60363. cameraExposure: number;
  60364. /**
  60365. * The value of the contrast to apply to the scene.
  60366. * 1.6 by default if setupImageProcessing is true.
  60367. */
  60368. cameraContrast: number;
  60369. /**
  60370. * Specifies whether or not tonemapping should be enabled in the scene.
  60371. * true by default if setupImageProcessing is true.
  60372. */
  60373. toneMappingEnabled: boolean;
  60374. }
  60375. /**
  60376. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60377. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60378. * It also helps with the default setup of your imageProcessing configuration.
  60379. */
  60380. export class EnvironmentHelper {
  60381. /**
  60382. * Default ground texture URL.
  60383. */
  60384. private static _groundTextureCDNUrl;
  60385. /**
  60386. * Default skybox texture URL.
  60387. */
  60388. private static _skyboxTextureCDNUrl;
  60389. /**
  60390. * Default environment texture URL.
  60391. */
  60392. private static _environmentTextureCDNUrl;
  60393. /**
  60394. * Creates the default options for the helper.
  60395. */
  60396. private static _getDefaultOptions;
  60397. private _rootMesh;
  60398. /**
  60399. * Gets the root mesh created by the helper.
  60400. */
  60401. get rootMesh(): Mesh;
  60402. private _skybox;
  60403. /**
  60404. * Gets the skybox created by the helper.
  60405. */
  60406. get skybox(): Nullable<Mesh>;
  60407. private _skyboxTexture;
  60408. /**
  60409. * Gets the skybox texture created by the helper.
  60410. */
  60411. get skyboxTexture(): Nullable<BaseTexture>;
  60412. private _skyboxMaterial;
  60413. /**
  60414. * Gets the skybox material created by the helper.
  60415. */
  60416. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60417. private _ground;
  60418. /**
  60419. * Gets the ground mesh created by the helper.
  60420. */
  60421. get ground(): Nullable<Mesh>;
  60422. private _groundTexture;
  60423. /**
  60424. * Gets the ground texture created by the helper.
  60425. */
  60426. get groundTexture(): Nullable<BaseTexture>;
  60427. private _groundMirror;
  60428. /**
  60429. * Gets the ground mirror created by the helper.
  60430. */
  60431. get groundMirror(): Nullable<MirrorTexture>;
  60432. /**
  60433. * Gets the ground mirror render list to helps pushing the meshes
  60434. * you wish in the ground reflection.
  60435. */
  60436. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60437. private _groundMaterial;
  60438. /**
  60439. * Gets the ground material created by the helper.
  60440. */
  60441. get groundMaterial(): Nullable<BackgroundMaterial>;
  60442. /**
  60443. * Stores the creation options.
  60444. */
  60445. private readonly _scene;
  60446. private _options;
  60447. /**
  60448. * This observable will be notified with any error during the creation of the environment,
  60449. * mainly texture creation errors.
  60450. */
  60451. onErrorObservable: Observable<{
  60452. message?: string;
  60453. exception?: any;
  60454. }>;
  60455. /**
  60456. * constructor
  60457. * @param options Defines the options we want to customize the helper
  60458. * @param scene The scene to add the material to
  60459. */
  60460. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60461. /**
  60462. * Updates the background according to the new options
  60463. * @param options
  60464. */
  60465. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60466. /**
  60467. * Sets the primary color of all the available elements.
  60468. * @param color the main color to affect to the ground and the background
  60469. */
  60470. setMainColor(color: Color3): void;
  60471. /**
  60472. * Setup the image processing according to the specified options.
  60473. */
  60474. private _setupImageProcessing;
  60475. /**
  60476. * Setup the environment texture according to the specified options.
  60477. */
  60478. private _setupEnvironmentTexture;
  60479. /**
  60480. * Setup the background according to the specified options.
  60481. */
  60482. private _setupBackground;
  60483. /**
  60484. * Get the scene sizes according to the setup.
  60485. */
  60486. private _getSceneSize;
  60487. /**
  60488. * Setup the ground according to the specified options.
  60489. */
  60490. private _setupGround;
  60491. /**
  60492. * Setup the ground material according to the specified options.
  60493. */
  60494. private _setupGroundMaterial;
  60495. /**
  60496. * Setup the ground diffuse texture according to the specified options.
  60497. */
  60498. private _setupGroundDiffuseTexture;
  60499. /**
  60500. * Setup the ground mirror texture according to the specified options.
  60501. */
  60502. private _setupGroundMirrorTexture;
  60503. /**
  60504. * Setup the ground to receive the mirror texture.
  60505. */
  60506. private _setupMirrorInGroundMaterial;
  60507. /**
  60508. * Setup the skybox according to the specified options.
  60509. */
  60510. private _setupSkybox;
  60511. /**
  60512. * Setup the skybox material according to the specified options.
  60513. */
  60514. private _setupSkyboxMaterial;
  60515. /**
  60516. * Setup the skybox reflection texture according to the specified options.
  60517. */
  60518. private _setupSkyboxReflectionTexture;
  60519. private _errorHandler;
  60520. /**
  60521. * Dispose all the elements created by the Helper.
  60522. */
  60523. dispose(): void;
  60524. }
  60525. }
  60526. declare module "babylonjs/Helpers/textureDome" {
  60527. import { Scene } from "babylonjs/scene";
  60528. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60529. import { Mesh } from "babylonjs/Meshes/mesh";
  60530. import { Texture } from "babylonjs/Materials/Textures/texture";
  60531. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60532. import "babylonjs/Meshes/Builders/sphereBuilder";
  60533. import { Nullable } from "babylonjs/types";
  60534. import { Observable } from "babylonjs/Misc/observable";
  60535. /**
  60536. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60537. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60538. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60539. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60540. */
  60541. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60542. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60543. /**
  60544. * Define the source as a Monoscopic panoramic 360/180.
  60545. */
  60546. static readonly MODE_MONOSCOPIC: number;
  60547. /**
  60548. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60549. */
  60550. static readonly MODE_TOPBOTTOM: number;
  60551. /**
  60552. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60553. */
  60554. static readonly MODE_SIDEBYSIDE: number;
  60555. private _halfDome;
  60556. protected _useDirectMapping: boolean;
  60557. /**
  60558. * The texture being displayed on the sphere
  60559. */
  60560. protected _texture: T;
  60561. /**
  60562. * Gets the texture being displayed on the sphere
  60563. */
  60564. get texture(): T;
  60565. /**
  60566. * Sets the texture being displayed on the sphere
  60567. */
  60568. set texture(newTexture: T);
  60569. /**
  60570. * The skybox material
  60571. */
  60572. protected _material: BackgroundMaterial;
  60573. /**
  60574. * The surface used for the dome
  60575. */
  60576. protected _mesh: Mesh;
  60577. /**
  60578. * Gets the mesh used for the dome.
  60579. */
  60580. get mesh(): Mesh;
  60581. /**
  60582. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60583. */
  60584. private _halfDomeMask;
  60585. /**
  60586. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60587. * Also see the options.resolution property.
  60588. */
  60589. get fovMultiplier(): number;
  60590. set fovMultiplier(value: number);
  60591. protected _textureMode: number;
  60592. /**
  60593. * Gets or set the current texture mode for the texture. It can be:
  60594. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60595. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60596. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60597. */
  60598. get textureMode(): number;
  60599. /**
  60600. * Sets the current texture mode for the texture. It can be:
  60601. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60602. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60603. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60604. */
  60605. set textureMode(value: number);
  60606. /**
  60607. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60608. */
  60609. get halfDome(): boolean;
  60610. /**
  60611. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60612. */
  60613. set halfDome(enabled: boolean);
  60614. /**
  60615. * Oberserver used in Stereoscopic VR Mode.
  60616. */
  60617. private _onBeforeCameraRenderObserver;
  60618. /**
  60619. * Observable raised when an error occured while loading the 360 image
  60620. */
  60621. onLoadErrorObservable: Observable<string>;
  60622. /**
  60623. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60624. * @param name Element's name, child elements will append suffixes for their own names.
  60625. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60626. * @param options An object containing optional or exposed sub element properties
  60627. */
  60628. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60629. resolution?: number;
  60630. clickToPlay?: boolean;
  60631. autoPlay?: boolean;
  60632. loop?: boolean;
  60633. size?: number;
  60634. poster?: string;
  60635. faceForward?: boolean;
  60636. useDirectMapping?: boolean;
  60637. halfDomeMode?: boolean;
  60638. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60639. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60640. protected _changeTextureMode(value: number): void;
  60641. /**
  60642. * Releases resources associated with this node.
  60643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60645. */
  60646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60647. }
  60648. }
  60649. declare module "babylonjs/Helpers/photoDome" {
  60650. import { Scene } from "babylonjs/scene";
  60651. import { Texture } from "babylonjs/Materials/Textures/texture";
  60652. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60653. /**
  60654. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60655. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60656. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60657. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60658. */
  60659. export class PhotoDome extends TextureDome<Texture> {
  60660. /**
  60661. * Define the image as a Monoscopic panoramic 360 image.
  60662. */
  60663. static readonly MODE_MONOSCOPIC: number;
  60664. /**
  60665. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60666. */
  60667. static readonly MODE_TOPBOTTOM: number;
  60668. /**
  60669. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60670. */
  60671. static readonly MODE_SIDEBYSIDE: number;
  60672. /**
  60673. * Gets or sets the texture being displayed on the sphere
  60674. */
  60675. get photoTexture(): Texture;
  60676. /**
  60677. * sets the texture being displayed on the sphere
  60678. */
  60679. set photoTexture(value: Texture);
  60680. /**
  60681. * Gets the current video mode for the video. It can be:
  60682. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60683. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60684. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60685. */
  60686. get imageMode(): number;
  60687. /**
  60688. * Sets the current video mode for the video. It can be:
  60689. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60690. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60691. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60692. */
  60693. set imageMode(value: number);
  60694. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60695. }
  60696. }
  60697. declare module "babylonjs/Misc/dds" {
  60698. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60699. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60700. import { Nullable } from "babylonjs/types";
  60701. import { Scene } from "babylonjs/scene";
  60702. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60703. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60704. /**
  60705. * Direct draw surface info
  60706. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60707. */
  60708. export interface DDSInfo {
  60709. /**
  60710. * Width of the texture
  60711. */
  60712. width: number;
  60713. /**
  60714. * Width of the texture
  60715. */
  60716. height: number;
  60717. /**
  60718. * Number of Mipmaps for the texture
  60719. * @see https://en.wikipedia.org/wiki/Mipmap
  60720. */
  60721. mipmapCount: number;
  60722. /**
  60723. * If the textures format is a known fourCC format
  60724. * @see https://www.fourcc.org/
  60725. */
  60726. isFourCC: boolean;
  60727. /**
  60728. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60729. */
  60730. isRGB: boolean;
  60731. /**
  60732. * If the texture is a lumincance format
  60733. */
  60734. isLuminance: boolean;
  60735. /**
  60736. * If this is a cube texture
  60737. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60738. */
  60739. isCube: boolean;
  60740. /**
  60741. * If the texture is a compressed format eg. FOURCC_DXT1
  60742. */
  60743. isCompressed: boolean;
  60744. /**
  60745. * The dxgiFormat of the texture
  60746. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60747. */
  60748. dxgiFormat: number;
  60749. /**
  60750. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60751. */
  60752. textureType: number;
  60753. /**
  60754. * Sphericle polynomial created for the dds texture
  60755. */
  60756. sphericalPolynomial?: SphericalPolynomial;
  60757. }
  60758. /**
  60759. * Class used to provide DDS decompression tools
  60760. */
  60761. export class DDSTools {
  60762. /**
  60763. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60764. */
  60765. static StoreLODInAlphaChannel: boolean;
  60766. /**
  60767. * Gets DDS information from an array buffer
  60768. * @param data defines the array buffer view to read data from
  60769. * @returns the DDS information
  60770. */
  60771. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60772. private static _FloatView;
  60773. private static _Int32View;
  60774. private static _ToHalfFloat;
  60775. private static _FromHalfFloat;
  60776. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60777. private static _GetHalfFloatRGBAArrayBuffer;
  60778. private static _GetFloatRGBAArrayBuffer;
  60779. private static _GetFloatAsUIntRGBAArrayBuffer;
  60780. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60781. private static _GetRGBAArrayBuffer;
  60782. private static _ExtractLongWordOrder;
  60783. private static _GetRGBArrayBuffer;
  60784. private static _GetLuminanceArrayBuffer;
  60785. /**
  60786. * Uploads DDS Levels to a Babylon Texture
  60787. * @hidden
  60788. */
  60789. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60790. }
  60791. module "babylonjs/Engines/thinEngine" {
  60792. interface ThinEngine {
  60793. /**
  60794. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60795. * @param rootUrl defines the url where the file to load is located
  60796. * @param scene defines the current scene
  60797. * @param lodScale defines scale to apply to the mip map selection
  60798. * @param lodOffset defines offset to apply to the mip map selection
  60799. * @param onLoad defines an optional callback raised when the texture is loaded
  60800. * @param onError defines an optional callback raised if there is an issue to load the texture
  60801. * @param format defines the format of the data
  60802. * @param forcedExtension defines the extension to use to pick the right loader
  60803. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60804. * @returns the cube texture as an InternalTexture
  60805. */
  60806. 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;
  60807. }
  60808. }
  60809. }
  60810. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60811. import { Nullable } from "babylonjs/types";
  60812. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60813. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60814. /**
  60815. * Implementation of the DDS Texture Loader.
  60816. * @hidden
  60817. */
  60818. export class _DDSTextureLoader implements IInternalTextureLoader {
  60819. /**
  60820. * Defines wether the loader supports cascade loading the different faces.
  60821. */
  60822. readonly supportCascades: boolean;
  60823. /**
  60824. * This returns if the loader support the current file information.
  60825. * @param extension defines the file extension of the file being loaded
  60826. * @returns true if the loader can load the specified file
  60827. */
  60828. canLoad(extension: string): boolean;
  60829. /**
  60830. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60831. * @param data contains the texture data
  60832. * @param texture defines the BabylonJS internal texture
  60833. * @param createPolynomials will be true if polynomials have been requested
  60834. * @param onLoad defines the callback to trigger once the texture is ready
  60835. * @param onError defines the callback to trigger in case of error
  60836. */
  60837. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60838. /**
  60839. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60840. * @param data contains the texture data
  60841. * @param texture defines the BabylonJS internal texture
  60842. * @param callback defines the method to call once ready to upload
  60843. */
  60844. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60845. }
  60846. }
  60847. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60848. import { Nullable } from "babylonjs/types";
  60849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60850. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60851. /**
  60852. * Implementation of the ENV Texture Loader.
  60853. * @hidden
  60854. */
  60855. export class _ENVTextureLoader implements IInternalTextureLoader {
  60856. /**
  60857. * Defines wether the loader supports cascade loading the different faces.
  60858. */
  60859. readonly supportCascades: boolean;
  60860. /**
  60861. * This returns if the loader support the current file information.
  60862. * @param extension defines the file extension of the file being loaded
  60863. * @returns true if the loader can load the specified file
  60864. */
  60865. canLoad(extension: string): boolean;
  60866. /**
  60867. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60868. * @param data contains the texture data
  60869. * @param texture defines the BabylonJS internal texture
  60870. * @param createPolynomials will be true if polynomials have been requested
  60871. * @param onLoad defines the callback to trigger once the texture is ready
  60872. * @param onError defines the callback to trigger in case of error
  60873. */
  60874. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60875. /**
  60876. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60877. * @param data contains the texture data
  60878. * @param texture defines the BabylonJS internal texture
  60879. * @param callback defines the method to call once ready to upload
  60880. */
  60881. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60882. }
  60883. }
  60884. declare module "babylonjs/Misc/khronosTextureContainer" {
  60885. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60886. /**
  60887. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60888. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60889. */
  60890. export class KhronosTextureContainer {
  60891. /** contents of the KTX container file */
  60892. data: ArrayBufferView;
  60893. private static HEADER_LEN;
  60894. private static COMPRESSED_2D;
  60895. private static COMPRESSED_3D;
  60896. private static TEX_2D;
  60897. private static TEX_3D;
  60898. /**
  60899. * Gets the openGL type
  60900. */
  60901. glType: number;
  60902. /**
  60903. * Gets the openGL type size
  60904. */
  60905. glTypeSize: number;
  60906. /**
  60907. * Gets the openGL format
  60908. */
  60909. glFormat: number;
  60910. /**
  60911. * Gets the openGL internal format
  60912. */
  60913. glInternalFormat: number;
  60914. /**
  60915. * Gets the base internal format
  60916. */
  60917. glBaseInternalFormat: number;
  60918. /**
  60919. * Gets image width in pixel
  60920. */
  60921. pixelWidth: number;
  60922. /**
  60923. * Gets image height in pixel
  60924. */
  60925. pixelHeight: number;
  60926. /**
  60927. * Gets image depth in pixels
  60928. */
  60929. pixelDepth: number;
  60930. /**
  60931. * Gets the number of array elements
  60932. */
  60933. numberOfArrayElements: number;
  60934. /**
  60935. * Gets the number of faces
  60936. */
  60937. numberOfFaces: number;
  60938. /**
  60939. * Gets the number of mipmap levels
  60940. */
  60941. numberOfMipmapLevels: number;
  60942. /**
  60943. * Gets the bytes of key value data
  60944. */
  60945. bytesOfKeyValueData: number;
  60946. /**
  60947. * Gets the load type
  60948. */
  60949. loadType: number;
  60950. /**
  60951. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60952. */
  60953. isInvalid: boolean;
  60954. /**
  60955. * Creates a new KhronosTextureContainer
  60956. * @param data contents of the KTX container file
  60957. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60958. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60959. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60960. */
  60961. constructor(
  60962. /** contents of the KTX container file */
  60963. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60964. /**
  60965. * Uploads KTX content to a Babylon Texture.
  60966. * It is assumed that the texture has already been created & is currently bound
  60967. * @hidden
  60968. */
  60969. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60970. private _upload2DCompressedLevels;
  60971. /**
  60972. * Checks if the given data starts with a KTX file identifier.
  60973. * @param data the data to check
  60974. * @returns true if the data is a KTX file or false otherwise
  60975. */
  60976. static IsValid(data: ArrayBufferView): boolean;
  60977. }
  60978. }
  60979. declare module "babylonjs/Misc/workerPool" {
  60980. import { IDisposable } from "babylonjs/scene";
  60981. /**
  60982. * Helper class to push actions to a pool of workers.
  60983. */
  60984. export class WorkerPool implements IDisposable {
  60985. private _workerInfos;
  60986. private _pendingActions;
  60987. /**
  60988. * Constructor
  60989. * @param workers Array of workers to use for actions
  60990. */
  60991. constructor(workers: Array<Worker>);
  60992. /**
  60993. * Terminates all workers and clears any pending actions.
  60994. */
  60995. dispose(): void;
  60996. /**
  60997. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60998. * pended until a worker has completed its action.
  60999. * @param action The action to perform. Call onComplete when the action is complete.
  61000. */
  61001. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61002. private _execute;
  61003. }
  61004. }
  61005. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61006. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61007. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61008. /**
  61009. * Class for loading KTX2 files
  61010. */
  61011. export class KhronosTextureContainer2 {
  61012. private static _WorkerPoolPromise?;
  61013. private static _Initialized;
  61014. private static _Ktx2Decoder;
  61015. /**
  61016. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61017. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61018. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61019. * Urls you can change:
  61020. * URLConfig.jsDecoderModule
  61021. * URLConfig.wasmUASTCToASTC
  61022. * URLConfig.wasmUASTCToBC7
  61023. * URLConfig.jsMSCTranscoder
  61024. * URLConfig.wasmMSCTranscoder
  61025. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61026. */
  61027. static URLConfig: {
  61028. jsDecoderModule: string;
  61029. wasmUASTCToASTC: null;
  61030. wasmUASTCToBC7: null;
  61031. jsMSCTranscoder: null;
  61032. wasmMSCTranscoder: null;
  61033. };
  61034. /**
  61035. * Default number of workers used to handle data decoding
  61036. */
  61037. static DefaultNumWorkers: number;
  61038. private static GetDefaultNumWorkers;
  61039. private _engine;
  61040. private static _CreateWorkerPool;
  61041. /**
  61042. * Constructor
  61043. * @param engine The engine to use
  61044. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61045. */
  61046. constructor(engine: ThinEngine, numWorkers?: number);
  61047. /** @hidden */
  61048. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  61049. /**
  61050. * Stop all async operations and release resources.
  61051. */
  61052. dispose(): void;
  61053. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61054. /**
  61055. * Checks if the given data starts with a KTX2 file identifier.
  61056. * @param data the data to check
  61057. * @returns true if the data is a KTX2 file or false otherwise
  61058. */
  61059. static IsValid(data: ArrayBufferView): boolean;
  61060. }
  61061. }
  61062. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61063. import { Nullable } from "babylonjs/types";
  61064. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61065. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61066. /**
  61067. * Implementation of the KTX Texture Loader.
  61068. * @hidden
  61069. */
  61070. export class _KTXTextureLoader implements IInternalTextureLoader {
  61071. /**
  61072. * Defines wether the loader supports cascade loading the different faces.
  61073. */
  61074. readonly supportCascades: boolean;
  61075. /**
  61076. * This returns if the loader support the current file information.
  61077. * @param extension defines the file extension of the file being loaded
  61078. * @param mimeType defines the optional mime type of the file being loaded
  61079. * @returns true if the loader can load the specified file
  61080. */
  61081. canLoad(extension: string, mimeType?: string): boolean;
  61082. /**
  61083. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61084. * @param data contains the texture data
  61085. * @param texture defines the BabylonJS internal texture
  61086. * @param createPolynomials will be true if polynomials have been requested
  61087. * @param onLoad defines the callback to trigger once the texture is ready
  61088. * @param onError defines the callback to trigger in case of error
  61089. */
  61090. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61091. /**
  61092. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61093. * @param data contains the texture data
  61094. * @param texture defines the BabylonJS internal texture
  61095. * @param callback defines the method to call once ready to upload
  61096. */
  61097. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  61098. }
  61099. }
  61100. declare module "babylonjs/Helpers/sceneHelpers" {
  61101. import { Nullable } from "babylonjs/types";
  61102. import { Mesh } from "babylonjs/Meshes/mesh";
  61103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61104. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61105. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61106. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61107. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61108. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61109. import "babylonjs/Meshes/Builders/boxBuilder";
  61110. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61111. /** @hidden */
  61112. export var _forceSceneHelpersToBundle: boolean;
  61113. module "babylonjs/scene" {
  61114. interface Scene {
  61115. /**
  61116. * Creates a default light for the scene.
  61117. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61118. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61119. */
  61120. createDefaultLight(replace?: boolean): void;
  61121. /**
  61122. * Creates a default camera for the scene.
  61123. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61124. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61125. * @param replace has default false, when true replaces the active camera in the scene
  61126. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61127. */
  61128. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61129. /**
  61130. * Creates a default camera and a default light.
  61131. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61132. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61133. * @param replace has the default false, when true replaces the active camera/light in the scene
  61134. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61135. */
  61136. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61137. /**
  61138. * Creates a new sky box
  61139. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61140. * @param environmentTexture defines the texture to use as environment texture
  61141. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61142. * @param scale defines the overall scale of the skybox
  61143. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61144. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61145. * @returns a new mesh holding the sky box
  61146. */
  61147. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61148. /**
  61149. * Creates a new environment
  61150. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61151. * @param options defines the options you can use to configure the environment
  61152. * @returns the new EnvironmentHelper
  61153. */
  61154. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61155. /**
  61156. * Creates a new VREXperienceHelper
  61157. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61158. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61159. * @returns a new VREXperienceHelper
  61160. */
  61161. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61162. /**
  61163. * Creates a new WebXRDefaultExperience
  61164. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61165. * @param options experience options
  61166. * @returns a promise for a new WebXRDefaultExperience
  61167. */
  61168. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61169. }
  61170. }
  61171. }
  61172. declare module "babylonjs/Helpers/videoDome" {
  61173. import { Scene } from "babylonjs/scene";
  61174. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61175. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61176. /**
  61177. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61178. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61179. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61180. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61181. */
  61182. export class VideoDome extends TextureDome<VideoTexture> {
  61183. /**
  61184. * Define the video source as a Monoscopic panoramic 360 video.
  61185. */
  61186. static readonly MODE_MONOSCOPIC: number;
  61187. /**
  61188. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61189. */
  61190. static readonly MODE_TOPBOTTOM: number;
  61191. /**
  61192. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61193. */
  61194. static readonly MODE_SIDEBYSIDE: number;
  61195. /**
  61196. * Get the video texture associated with this video dome
  61197. */
  61198. get videoTexture(): VideoTexture;
  61199. /**
  61200. * Get the video mode of this dome
  61201. */
  61202. get videoMode(): number;
  61203. /**
  61204. * Set the video mode of this dome.
  61205. * @see textureMode
  61206. */
  61207. set videoMode(value: number);
  61208. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61209. }
  61210. }
  61211. declare module "babylonjs/Helpers/index" {
  61212. export * from "babylonjs/Helpers/environmentHelper";
  61213. export * from "babylonjs/Helpers/photoDome";
  61214. export * from "babylonjs/Helpers/sceneHelpers";
  61215. export * from "babylonjs/Helpers/videoDome";
  61216. }
  61217. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61218. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61219. import { IDisposable } from "babylonjs/scene";
  61220. import { Engine } from "babylonjs/Engines/engine";
  61221. /**
  61222. * This class can be used to get instrumentation data from a Babylon engine
  61223. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61224. */
  61225. export class EngineInstrumentation implements IDisposable {
  61226. /**
  61227. * Define the instrumented engine.
  61228. */
  61229. engine: Engine;
  61230. private _captureGPUFrameTime;
  61231. private _gpuFrameTimeToken;
  61232. private _gpuFrameTime;
  61233. private _captureShaderCompilationTime;
  61234. private _shaderCompilationTime;
  61235. private _onBeginFrameObserver;
  61236. private _onEndFrameObserver;
  61237. private _onBeforeShaderCompilationObserver;
  61238. private _onAfterShaderCompilationObserver;
  61239. /**
  61240. * Gets the perf counter used for GPU frame time
  61241. */
  61242. get gpuFrameTimeCounter(): PerfCounter;
  61243. /**
  61244. * Gets the GPU frame time capture status
  61245. */
  61246. get captureGPUFrameTime(): boolean;
  61247. /**
  61248. * Enable or disable the GPU frame time capture
  61249. */
  61250. set captureGPUFrameTime(value: boolean);
  61251. /**
  61252. * Gets the perf counter used for shader compilation time
  61253. */
  61254. get shaderCompilationTimeCounter(): PerfCounter;
  61255. /**
  61256. * Gets the shader compilation time capture status
  61257. */
  61258. get captureShaderCompilationTime(): boolean;
  61259. /**
  61260. * Enable or disable the shader compilation time capture
  61261. */
  61262. set captureShaderCompilationTime(value: boolean);
  61263. /**
  61264. * Instantiates a new engine instrumentation.
  61265. * This class can be used to get instrumentation data from a Babylon engine
  61266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61267. * @param engine Defines the engine to instrument
  61268. */
  61269. constructor(
  61270. /**
  61271. * Define the instrumented engine.
  61272. */
  61273. engine: Engine);
  61274. /**
  61275. * Dispose and release associated resources.
  61276. */
  61277. dispose(): void;
  61278. }
  61279. }
  61280. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61281. import { Scene, IDisposable } from "babylonjs/scene";
  61282. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61283. /**
  61284. * This class can be used to get instrumentation data from a Babylon engine
  61285. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61286. */
  61287. export class SceneInstrumentation implements IDisposable {
  61288. /**
  61289. * Defines the scene to instrument
  61290. */
  61291. scene: Scene;
  61292. private _captureActiveMeshesEvaluationTime;
  61293. private _activeMeshesEvaluationTime;
  61294. private _captureRenderTargetsRenderTime;
  61295. private _renderTargetsRenderTime;
  61296. private _captureFrameTime;
  61297. private _frameTime;
  61298. private _captureRenderTime;
  61299. private _renderTime;
  61300. private _captureInterFrameTime;
  61301. private _interFrameTime;
  61302. private _captureParticlesRenderTime;
  61303. private _particlesRenderTime;
  61304. private _captureSpritesRenderTime;
  61305. private _spritesRenderTime;
  61306. private _capturePhysicsTime;
  61307. private _physicsTime;
  61308. private _captureAnimationsTime;
  61309. private _animationsTime;
  61310. private _captureCameraRenderTime;
  61311. private _cameraRenderTime;
  61312. private _onBeforeActiveMeshesEvaluationObserver;
  61313. private _onAfterActiveMeshesEvaluationObserver;
  61314. private _onBeforeRenderTargetsRenderObserver;
  61315. private _onAfterRenderTargetsRenderObserver;
  61316. private _onAfterRenderObserver;
  61317. private _onBeforeDrawPhaseObserver;
  61318. private _onAfterDrawPhaseObserver;
  61319. private _onBeforeAnimationsObserver;
  61320. private _onBeforeParticlesRenderingObserver;
  61321. private _onAfterParticlesRenderingObserver;
  61322. private _onBeforeSpritesRenderingObserver;
  61323. private _onAfterSpritesRenderingObserver;
  61324. private _onBeforePhysicsObserver;
  61325. private _onAfterPhysicsObserver;
  61326. private _onAfterAnimationsObserver;
  61327. private _onBeforeCameraRenderObserver;
  61328. private _onAfterCameraRenderObserver;
  61329. /**
  61330. * Gets the perf counter used for active meshes evaluation time
  61331. */
  61332. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61333. /**
  61334. * Gets the active meshes evaluation time capture status
  61335. */
  61336. get captureActiveMeshesEvaluationTime(): boolean;
  61337. /**
  61338. * Enable or disable the active meshes evaluation time capture
  61339. */
  61340. set captureActiveMeshesEvaluationTime(value: boolean);
  61341. /**
  61342. * Gets the perf counter used for render targets render time
  61343. */
  61344. get renderTargetsRenderTimeCounter(): PerfCounter;
  61345. /**
  61346. * Gets the render targets render time capture status
  61347. */
  61348. get captureRenderTargetsRenderTime(): boolean;
  61349. /**
  61350. * Enable or disable the render targets render time capture
  61351. */
  61352. set captureRenderTargetsRenderTime(value: boolean);
  61353. /**
  61354. * Gets the perf counter used for particles render time
  61355. */
  61356. get particlesRenderTimeCounter(): PerfCounter;
  61357. /**
  61358. * Gets the particles render time capture status
  61359. */
  61360. get captureParticlesRenderTime(): boolean;
  61361. /**
  61362. * Enable or disable the particles render time capture
  61363. */
  61364. set captureParticlesRenderTime(value: boolean);
  61365. /**
  61366. * Gets the perf counter used for sprites render time
  61367. */
  61368. get spritesRenderTimeCounter(): PerfCounter;
  61369. /**
  61370. * Gets the sprites render time capture status
  61371. */
  61372. get captureSpritesRenderTime(): boolean;
  61373. /**
  61374. * Enable or disable the sprites render time capture
  61375. */
  61376. set captureSpritesRenderTime(value: boolean);
  61377. /**
  61378. * Gets the perf counter used for physics time
  61379. */
  61380. get physicsTimeCounter(): PerfCounter;
  61381. /**
  61382. * Gets the physics time capture status
  61383. */
  61384. get capturePhysicsTime(): boolean;
  61385. /**
  61386. * Enable or disable the physics time capture
  61387. */
  61388. set capturePhysicsTime(value: boolean);
  61389. /**
  61390. * Gets the perf counter used for animations time
  61391. */
  61392. get animationsTimeCounter(): PerfCounter;
  61393. /**
  61394. * Gets the animations time capture status
  61395. */
  61396. get captureAnimationsTime(): boolean;
  61397. /**
  61398. * Enable or disable the animations time capture
  61399. */
  61400. set captureAnimationsTime(value: boolean);
  61401. /**
  61402. * Gets the perf counter used for frame time capture
  61403. */
  61404. get frameTimeCounter(): PerfCounter;
  61405. /**
  61406. * Gets the frame time capture status
  61407. */
  61408. get captureFrameTime(): boolean;
  61409. /**
  61410. * Enable or disable the frame time capture
  61411. */
  61412. set captureFrameTime(value: boolean);
  61413. /**
  61414. * Gets the perf counter used for inter-frames time capture
  61415. */
  61416. get interFrameTimeCounter(): PerfCounter;
  61417. /**
  61418. * Gets the inter-frames time capture status
  61419. */
  61420. get captureInterFrameTime(): boolean;
  61421. /**
  61422. * Enable or disable the inter-frames time capture
  61423. */
  61424. set captureInterFrameTime(value: boolean);
  61425. /**
  61426. * Gets the perf counter used for render time capture
  61427. */
  61428. get renderTimeCounter(): PerfCounter;
  61429. /**
  61430. * Gets the render time capture status
  61431. */
  61432. get captureRenderTime(): boolean;
  61433. /**
  61434. * Enable or disable the render time capture
  61435. */
  61436. set captureRenderTime(value: boolean);
  61437. /**
  61438. * Gets the perf counter used for camera render time capture
  61439. */
  61440. get cameraRenderTimeCounter(): PerfCounter;
  61441. /**
  61442. * Gets the camera render time capture status
  61443. */
  61444. get captureCameraRenderTime(): boolean;
  61445. /**
  61446. * Enable or disable the camera render time capture
  61447. */
  61448. set captureCameraRenderTime(value: boolean);
  61449. /**
  61450. * Gets the perf counter used for draw calls
  61451. */
  61452. get drawCallsCounter(): PerfCounter;
  61453. /**
  61454. * Instantiates a new scene instrumentation.
  61455. * This class can be used to get instrumentation data from a Babylon engine
  61456. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61457. * @param scene Defines the scene to instrument
  61458. */
  61459. constructor(
  61460. /**
  61461. * Defines the scene to instrument
  61462. */
  61463. scene: Scene);
  61464. /**
  61465. * Dispose and release associated resources.
  61466. */
  61467. dispose(): void;
  61468. }
  61469. }
  61470. declare module "babylonjs/Instrumentation/index" {
  61471. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61472. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61473. export * from "babylonjs/Instrumentation/timeToken";
  61474. }
  61475. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61476. /** @hidden */
  61477. export var glowMapGenerationPixelShader: {
  61478. name: string;
  61479. shader: string;
  61480. };
  61481. }
  61482. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61483. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61486. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61488. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61489. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61490. /** @hidden */
  61491. export var glowMapGenerationVertexShader: {
  61492. name: string;
  61493. shader: string;
  61494. };
  61495. }
  61496. declare module "babylonjs/Layers/effectLayer" {
  61497. import { Observable } from "babylonjs/Misc/observable";
  61498. import { Nullable } from "babylonjs/types";
  61499. import { Camera } from "babylonjs/Cameras/camera";
  61500. import { Scene } from "babylonjs/scene";
  61501. import { ISize } from "babylonjs/Maths/math.size";
  61502. import { Color4 } from "babylonjs/Maths/math.color";
  61503. import { Engine } from "babylonjs/Engines/engine";
  61504. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61506. import { Mesh } from "babylonjs/Meshes/mesh";
  61507. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61509. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61510. import { Effect } from "babylonjs/Materials/effect";
  61511. import { Material } from "babylonjs/Materials/material";
  61512. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61513. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61514. /**
  61515. * Effect layer options. This helps customizing the behaviour
  61516. * of the effect layer.
  61517. */
  61518. export interface IEffectLayerOptions {
  61519. /**
  61520. * Multiplication factor apply to the canvas size to compute the render target size
  61521. * used to generated the objects (the smaller the faster).
  61522. */
  61523. mainTextureRatio: number;
  61524. /**
  61525. * Enforces a fixed size texture to ensure effect stability across devices.
  61526. */
  61527. mainTextureFixedSize?: number;
  61528. /**
  61529. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61530. */
  61531. alphaBlendingMode: number;
  61532. /**
  61533. * The camera attached to the layer.
  61534. */
  61535. camera: Nullable<Camera>;
  61536. /**
  61537. * The rendering group to draw the layer in.
  61538. */
  61539. renderingGroupId: number;
  61540. }
  61541. /**
  61542. * The effect layer Helps adding post process effect blended with the main pass.
  61543. *
  61544. * This can be for instance use to generate glow or higlight effects on the scene.
  61545. *
  61546. * The effect layer class can not be used directly and is intented to inherited from to be
  61547. * customized per effects.
  61548. */
  61549. export abstract class EffectLayer {
  61550. private _vertexBuffers;
  61551. private _indexBuffer;
  61552. private _cachedDefines;
  61553. private _effectLayerMapGenerationEffect;
  61554. private _effectLayerOptions;
  61555. private _mergeEffect;
  61556. protected _scene: Scene;
  61557. protected _engine: Engine;
  61558. protected _maxSize: number;
  61559. protected _mainTextureDesiredSize: ISize;
  61560. protected _mainTexture: RenderTargetTexture;
  61561. protected _shouldRender: boolean;
  61562. protected _postProcesses: PostProcess[];
  61563. protected _textures: BaseTexture[];
  61564. protected _emissiveTextureAndColor: {
  61565. texture: Nullable<BaseTexture>;
  61566. color: Color4;
  61567. };
  61568. /**
  61569. * The name of the layer
  61570. */
  61571. name: string;
  61572. /**
  61573. * The clear color of the texture used to generate the glow map.
  61574. */
  61575. neutralColor: Color4;
  61576. /**
  61577. * Specifies whether the highlight layer is enabled or not.
  61578. */
  61579. isEnabled: boolean;
  61580. /**
  61581. * Gets the camera attached to the layer.
  61582. */
  61583. get camera(): Nullable<Camera>;
  61584. /**
  61585. * Gets the rendering group id the layer should render in.
  61586. */
  61587. get renderingGroupId(): number;
  61588. set renderingGroupId(renderingGroupId: number);
  61589. /**
  61590. * An event triggered when the effect layer has been disposed.
  61591. */
  61592. onDisposeObservable: Observable<EffectLayer>;
  61593. /**
  61594. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61595. */
  61596. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61597. /**
  61598. * An event triggered when the generated texture is being merged in the scene.
  61599. */
  61600. onBeforeComposeObservable: Observable<EffectLayer>;
  61601. /**
  61602. * An event triggered when the mesh is rendered into the effect render target.
  61603. */
  61604. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61605. /**
  61606. * An event triggered after the mesh has been rendered into the effect render target.
  61607. */
  61608. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61609. /**
  61610. * An event triggered when the generated texture has been merged in the scene.
  61611. */
  61612. onAfterComposeObservable: Observable<EffectLayer>;
  61613. /**
  61614. * An event triggered when the efffect layer changes its size.
  61615. */
  61616. onSizeChangedObservable: Observable<EffectLayer>;
  61617. /** @hidden */
  61618. static _SceneComponentInitialization: (scene: Scene) => void;
  61619. /**
  61620. * Instantiates a new effect Layer and references it in the scene.
  61621. * @param name The name of the layer
  61622. * @param scene The scene to use the layer in
  61623. */
  61624. constructor(
  61625. /** The Friendly of the effect in the scene */
  61626. name: string, scene: Scene);
  61627. /**
  61628. * Get the effect name of the layer.
  61629. * @return The effect name
  61630. */
  61631. abstract getEffectName(): string;
  61632. /**
  61633. * Checks for the readiness of the element composing the layer.
  61634. * @param subMesh the mesh to check for
  61635. * @param useInstances specify whether or not to use instances to render the mesh
  61636. * @return true if ready otherwise, false
  61637. */
  61638. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61639. /**
  61640. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61641. * @returns true if the effect requires stencil during the main canvas render pass.
  61642. */
  61643. abstract needStencil(): boolean;
  61644. /**
  61645. * Create the merge effect. This is the shader use to blit the information back
  61646. * to the main canvas at the end of the scene rendering.
  61647. * @returns The effect containing the shader used to merge the effect on the main canvas
  61648. */
  61649. protected abstract _createMergeEffect(): Effect;
  61650. /**
  61651. * Creates the render target textures and post processes used in the effect layer.
  61652. */
  61653. protected abstract _createTextureAndPostProcesses(): void;
  61654. /**
  61655. * Implementation specific of rendering the generating effect on the main canvas.
  61656. * @param effect The effect used to render through
  61657. */
  61658. protected abstract _internalRender(effect: Effect): void;
  61659. /**
  61660. * Sets the required values for both the emissive texture and and the main color.
  61661. */
  61662. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61663. /**
  61664. * Free any resources and references associated to a mesh.
  61665. * Internal use
  61666. * @param mesh The mesh to free.
  61667. */
  61668. abstract _disposeMesh(mesh: Mesh): void;
  61669. /**
  61670. * Serializes this layer (Glow or Highlight for example)
  61671. * @returns a serialized layer object
  61672. */
  61673. abstract serialize?(): any;
  61674. /**
  61675. * Initializes the effect layer with the required options.
  61676. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61677. */
  61678. protected _init(options: Partial<IEffectLayerOptions>): void;
  61679. /**
  61680. * Generates the index buffer of the full screen quad blending to the main canvas.
  61681. */
  61682. private _generateIndexBuffer;
  61683. /**
  61684. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61685. */
  61686. private _generateVertexBuffer;
  61687. /**
  61688. * Sets the main texture desired size which is the closest power of two
  61689. * of the engine canvas size.
  61690. */
  61691. private _setMainTextureSize;
  61692. /**
  61693. * Creates the main texture for the effect layer.
  61694. */
  61695. protected _createMainTexture(): void;
  61696. /**
  61697. * Adds specific effects defines.
  61698. * @param defines The defines to add specifics to.
  61699. */
  61700. protected _addCustomEffectDefines(defines: string[]): void;
  61701. /**
  61702. * Checks for the readiness of the element composing the layer.
  61703. * @param subMesh the mesh to check for
  61704. * @param useInstances specify whether or not to use instances to render the mesh
  61705. * @param emissiveTexture the associated emissive texture used to generate the glow
  61706. * @return true if ready otherwise, false
  61707. */
  61708. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61709. /**
  61710. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61711. */
  61712. render(): void;
  61713. /**
  61714. * Determine if a given mesh will be used in the current effect.
  61715. * @param mesh mesh to test
  61716. * @returns true if the mesh will be used
  61717. */
  61718. hasMesh(mesh: AbstractMesh): boolean;
  61719. /**
  61720. * Returns true if the layer contains information to display, otherwise false.
  61721. * @returns true if the glow layer should be rendered
  61722. */
  61723. shouldRender(): boolean;
  61724. /**
  61725. * Returns true if the mesh should render, otherwise false.
  61726. * @param mesh The mesh to render
  61727. * @returns true if it should render otherwise false
  61728. */
  61729. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61730. /**
  61731. * Returns true if the mesh can be rendered, otherwise false.
  61732. * @param mesh The mesh to render
  61733. * @param material The material used on the mesh
  61734. * @returns true if it can be rendered otherwise false
  61735. */
  61736. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61737. /**
  61738. * Returns true if the mesh should render, otherwise false.
  61739. * @param mesh The mesh to render
  61740. * @returns true if it should render otherwise false
  61741. */
  61742. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61743. /**
  61744. * Renders the submesh passed in parameter to the generation map.
  61745. */
  61746. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61747. /**
  61748. * Defines whether the current material of the mesh should be use to render the effect.
  61749. * @param mesh defines the current mesh to render
  61750. */
  61751. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61752. /**
  61753. * Rebuild the required buffers.
  61754. * @hidden Internal use only.
  61755. */
  61756. _rebuild(): void;
  61757. /**
  61758. * Dispose only the render target textures and post process.
  61759. */
  61760. private _disposeTextureAndPostProcesses;
  61761. /**
  61762. * Dispose the highlight layer and free resources.
  61763. */
  61764. dispose(): void;
  61765. /**
  61766. * Gets the class name of the effect layer
  61767. * @returns the string with the class name of the effect layer
  61768. */
  61769. getClassName(): string;
  61770. /**
  61771. * Creates an effect layer from parsed effect layer data
  61772. * @param parsedEffectLayer defines effect layer data
  61773. * @param scene defines the current scene
  61774. * @param rootUrl defines the root URL containing the effect layer information
  61775. * @returns a parsed effect Layer
  61776. */
  61777. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61778. }
  61779. }
  61780. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61781. import { Scene } from "babylonjs/scene";
  61782. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61783. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61784. import { AbstractScene } from "babylonjs/abstractScene";
  61785. module "babylonjs/abstractScene" {
  61786. interface AbstractScene {
  61787. /**
  61788. * The list of effect layers (highlights/glow) added to the scene
  61789. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61790. * @see https://doc.babylonjs.com/how_to/glow_layer
  61791. */
  61792. effectLayers: Array<EffectLayer>;
  61793. /**
  61794. * Removes the given effect layer from this scene.
  61795. * @param toRemove defines the effect layer to remove
  61796. * @returns the index of the removed effect layer
  61797. */
  61798. removeEffectLayer(toRemove: EffectLayer): number;
  61799. /**
  61800. * Adds the given effect layer to this scene
  61801. * @param newEffectLayer defines the effect layer to add
  61802. */
  61803. addEffectLayer(newEffectLayer: EffectLayer): void;
  61804. }
  61805. }
  61806. /**
  61807. * Defines the layer scene component responsible to manage any effect layers
  61808. * in a given scene.
  61809. */
  61810. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61811. /**
  61812. * The component name helpfull to identify the component in the list of scene components.
  61813. */
  61814. readonly name: string;
  61815. /**
  61816. * The scene the component belongs to.
  61817. */
  61818. scene: Scene;
  61819. private _engine;
  61820. private _renderEffects;
  61821. private _needStencil;
  61822. private _previousStencilState;
  61823. /**
  61824. * Creates a new instance of the component for the given scene
  61825. * @param scene Defines the scene to register the component in
  61826. */
  61827. constructor(scene: Scene);
  61828. /**
  61829. * Registers the component in a given scene
  61830. */
  61831. register(): void;
  61832. /**
  61833. * Rebuilds the elements related to this component in case of
  61834. * context lost for instance.
  61835. */
  61836. rebuild(): void;
  61837. /**
  61838. * Serializes the component data to the specified json object
  61839. * @param serializationObject The object to serialize to
  61840. */
  61841. serialize(serializationObject: any): void;
  61842. /**
  61843. * Adds all the elements from the container to the scene
  61844. * @param container the container holding the elements
  61845. */
  61846. addFromContainer(container: AbstractScene): void;
  61847. /**
  61848. * Removes all the elements in the container from the scene
  61849. * @param container contains the elements to remove
  61850. * @param dispose if the removed element should be disposed (default: false)
  61851. */
  61852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61853. /**
  61854. * Disposes the component and the associated ressources.
  61855. */
  61856. dispose(): void;
  61857. private _isReadyForMesh;
  61858. private _renderMainTexture;
  61859. private _setStencil;
  61860. private _setStencilBack;
  61861. private _draw;
  61862. private _drawCamera;
  61863. private _drawRenderingGroup;
  61864. }
  61865. }
  61866. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61867. /** @hidden */
  61868. export var glowMapMergePixelShader: {
  61869. name: string;
  61870. shader: string;
  61871. };
  61872. }
  61873. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61874. /** @hidden */
  61875. export var glowMapMergeVertexShader: {
  61876. name: string;
  61877. shader: string;
  61878. };
  61879. }
  61880. declare module "babylonjs/Layers/glowLayer" {
  61881. import { Nullable } from "babylonjs/types";
  61882. import { Camera } from "babylonjs/Cameras/camera";
  61883. import { Scene } from "babylonjs/scene";
  61884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61886. import { Mesh } from "babylonjs/Meshes/mesh";
  61887. import { Texture } from "babylonjs/Materials/Textures/texture";
  61888. import { Effect } from "babylonjs/Materials/effect";
  61889. import { Material } from "babylonjs/Materials/material";
  61890. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61891. import { Color4 } from "babylonjs/Maths/math.color";
  61892. import "babylonjs/Shaders/glowMapMerge.fragment";
  61893. import "babylonjs/Shaders/glowMapMerge.vertex";
  61894. import "babylonjs/Layers/effectLayerSceneComponent";
  61895. module "babylonjs/abstractScene" {
  61896. interface AbstractScene {
  61897. /**
  61898. * Return a the first highlight layer of the scene with a given name.
  61899. * @param name The name of the highlight layer to look for.
  61900. * @return The highlight layer if found otherwise null.
  61901. */
  61902. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61903. }
  61904. }
  61905. /**
  61906. * Glow layer options. This helps customizing the behaviour
  61907. * of the glow layer.
  61908. */
  61909. export interface IGlowLayerOptions {
  61910. /**
  61911. * Multiplication factor apply to the canvas size to compute the render target size
  61912. * used to generated the glowing objects (the smaller the faster).
  61913. */
  61914. mainTextureRatio: number;
  61915. /**
  61916. * Enforces a fixed size texture to ensure resize independant blur.
  61917. */
  61918. mainTextureFixedSize?: number;
  61919. /**
  61920. * How big is the kernel of the blur texture.
  61921. */
  61922. blurKernelSize: number;
  61923. /**
  61924. * The camera attached to the layer.
  61925. */
  61926. camera: Nullable<Camera>;
  61927. /**
  61928. * Enable MSAA by chosing the number of samples.
  61929. */
  61930. mainTextureSamples?: number;
  61931. /**
  61932. * The rendering group to draw the layer in.
  61933. */
  61934. renderingGroupId: number;
  61935. }
  61936. /**
  61937. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61938. *
  61939. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61940. *
  61941. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61942. */
  61943. export class GlowLayer extends EffectLayer {
  61944. /**
  61945. * Effect Name of the layer.
  61946. */
  61947. static readonly EffectName: string;
  61948. /**
  61949. * The default blur kernel size used for the glow.
  61950. */
  61951. static DefaultBlurKernelSize: number;
  61952. /**
  61953. * The default texture size ratio used for the glow.
  61954. */
  61955. static DefaultTextureRatio: number;
  61956. /**
  61957. * Sets the kernel size of the blur.
  61958. */
  61959. set blurKernelSize(value: number);
  61960. /**
  61961. * Gets the kernel size of the blur.
  61962. */
  61963. get blurKernelSize(): number;
  61964. /**
  61965. * Sets the glow intensity.
  61966. */
  61967. set intensity(value: number);
  61968. /**
  61969. * Gets the glow intensity.
  61970. */
  61971. get intensity(): number;
  61972. private _options;
  61973. private _intensity;
  61974. private _horizontalBlurPostprocess1;
  61975. private _verticalBlurPostprocess1;
  61976. private _horizontalBlurPostprocess2;
  61977. private _verticalBlurPostprocess2;
  61978. private _blurTexture1;
  61979. private _blurTexture2;
  61980. private _postProcesses1;
  61981. private _postProcesses2;
  61982. private _includedOnlyMeshes;
  61983. private _excludedMeshes;
  61984. private _meshesUsingTheirOwnMaterials;
  61985. /**
  61986. * Callback used to let the user override the color selection on a per mesh basis
  61987. */
  61988. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61989. /**
  61990. * Callback used to let the user override the texture selection on a per mesh basis
  61991. */
  61992. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61993. /**
  61994. * Instantiates a new glow Layer and references it to the scene.
  61995. * @param name The name of the layer
  61996. * @param scene The scene to use the layer in
  61997. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61998. */
  61999. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62000. /**
  62001. * Get the effect name of the layer.
  62002. * @return The effect name
  62003. */
  62004. getEffectName(): string;
  62005. /**
  62006. * Create the merge effect. This is the shader use to blit the information back
  62007. * to the main canvas at the end of the scene rendering.
  62008. */
  62009. protected _createMergeEffect(): Effect;
  62010. /**
  62011. * Creates the render target textures and post processes used in the glow layer.
  62012. */
  62013. protected _createTextureAndPostProcesses(): void;
  62014. /**
  62015. * Checks for the readiness of the element composing the layer.
  62016. * @param subMesh the mesh to check for
  62017. * @param useInstances specify wether or not to use instances to render the mesh
  62018. * @param emissiveTexture the associated emissive texture used to generate the glow
  62019. * @return true if ready otherwise, false
  62020. */
  62021. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62022. /**
  62023. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62024. */
  62025. needStencil(): boolean;
  62026. /**
  62027. * Returns true if the mesh can be rendered, otherwise false.
  62028. * @param mesh The mesh to render
  62029. * @param material The material used on the mesh
  62030. * @returns true if it can be rendered otherwise false
  62031. */
  62032. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62033. /**
  62034. * Implementation specific of rendering the generating effect on the main canvas.
  62035. * @param effect The effect used to render through
  62036. */
  62037. protected _internalRender(effect: Effect): void;
  62038. /**
  62039. * Sets the required values for both the emissive texture and and the main color.
  62040. */
  62041. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62042. /**
  62043. * Returns true if the mesh should render, otherwise false.
  62044. * @param mesh The mesh to render
  62045. * @returns true if it should render otherwise false
  62046. */
  62047. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62048. /**
  62049. * Adds specific effects defines.
  62050. * @param defines The defines to add specifics to.
  62051. */
  62052. protected _addCustomEffectDefines(defines: string[]): void;
  62053. /**
  62054. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62055. * @param mesh The mesh to exclude from the glow layer
  62056. */
  62057. addExcludedMesh(mesh: Mesh): void;
  62058. /**
  62059. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62060. * @param mesh The mesh to remove
  62061. */
  62062. removeExcludedMesh(mesh: Mesh): void;
  62063. /**
  62064. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62065. * @param mesh The mesh to include in the glow layer
  62066. */
  62067. addIncludedOnlyMesh(mesh: Mesh): void;
  62068. /**
  62069. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62070. * @param mesh The mesh to remove
  62071. */
  62072. removeIncludedOnlyMesh(mesh: Mesh): void;
  62073. /**
  62074. * Determine if a given mesh will be used in the glow layer
  62075. * @param mesh The mesh to test
  62076. * @returns true if the mesh will be highlighted by the current glow layer
  62077. */
  62078. hasMesh(mesh: AbstractMesh): boolean;
  62079. /**
  62080. * Defines whether the current material of the mesh should be use to render the effect.
  62081. * @param mesh defines the current mesh to render
  62082. */
  62083. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62084. /**
  62085. * Add a mesh to be rendered through its own material and not with emissive only.
  62086. * @param mesh The mesh for which we need to use its material
  62087. */
  62088. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62089. /**
  62090. * Remove a mesh from being rendered through its own material and not with emissive only.
  62091. * @param mesh The mesh for which we need to not use its material
  62092. */
  62093. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62094. /**
  62095. * Free any resources and references associated to a mesh.
  62096. * Internal use
  62097. * @param mesh The mesh to free.
  62098. * @hidden
  62099. */
  62100. _disposeMesh(mesh: Mesh): void;
  62101. /**
  62102. * Gets the class name of the effect layer
  62103. * @returns the string with the class name of the effect layer
  62104. */
  62105. getClassName(): string;
  62106. /**
  62107. * Serializes this glow layer
  62108. * @returns a serialized glow layer object
  62109. */
  62110. serialize(): any;
  62111. /**
  62112. * Creates a Glow Layer from parsed glow layer data
  62113. * @param parsedGlowLayer defines glow layer data
  62114. * @param scene defines the current scene
  62115. * @param rootUrl defines the root URL containing the glow layer information
  62116. * @returns a parsed Glow Layer
  62117. */
  62118. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62119. }
  62120. }
  62121. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62122. /** @hidden */
  62123. export var glowBlurPostProcessPixelShader: {
  62124. name: string;
  62125. shader: string;
  62126. };
  62127. }
  62128. declare module "babylonjs/Layers/highlightLayer" {
  62129. import { Observable } from "babylonjs/Misc/observable";
  62130. import { Nullable } from "babylonjs/types";
  62131. import { Camera } from "babylonjs/Cameras/camera";
  62132. import { Scene } from "babylonjs/scene";
  62133. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62135. import { Mesh } from "babylonjs/Meshes/mesh";
  62136. import { Effect } from "babylonjs/Materials/effect";
  62137. import { Material } from "babylonjs/Materials/material";
  62138. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62139. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62140. import "babylonjs/Shaders/glowMapMerge.fragment";
  62141. import "babylonjs/Shaders/glowMapMerge.vertex";
  62142. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62143. module "babylonjs/abstractScene" {
  62144. interface AbstractScene {
  62145. /**
  62146. * Return a the first highlight layer of the scene with a given name.
  62147. * @param name The name of the highlight layer to look for.
  62148. * @return The highlight layer if found otherwise null.
  62149. */
  62150. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62151. }
  62152. }
  62153. /**
  62154. * Highlight layer options. This helps customizing the behaviour
  62155. * of the highlight layer.
  62156. */
  62157. export interface IHighlightLayerOptions {
  62158. /**
  62159. * Multiplication factor apply to the canvas size to compute the render target size
  62160. * used to generated the glowing objects (the smaller the faster).
  62161. */
  62162. mainTextureRatio: number;
  62163. /**
  62164. * Enforces a fixed size texture to ensure resize independant blur.
  62165. */
  62166. mainTextureFixedSize?: number;
  62167. /**
  62168. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62169. * of the picture to blur (the smaller the faster).
  62170. */
  62171. blurTextureSizeRatio: number;
  62172. /**
  62173. * How big in texel of the blur texture is the vertical blur.
  62174. */
  62175. blurVerticalSize: number;
  62176. /**
  62177. * How big in texel of the blur texture is the horizontal blur.
  62178. */
  62179. blurHorizontalSize: number;
  62180. /**
  62181. * Alpha blending mode used to apply the blur. Default is combine.
  62182. */
  62183. alphaBlendingMode: number;
  62184. /**
  62185. * The camera attached to the layer.
  62186. */
  62187. camera: Nullable<Camera>;
  62188. /**
  62189. * Should we display highlight as a solid stroke?
  62190. */
  62191. isStroke?: boolean;
  62192. /**
  62193. * The rendering group to draw the layer in.
  62194. */
  62195. renderingGroupId: number;
  62196. }
  62197. /**
  62198. * The highlight layer Helps adding a glow effect around a mesh.
  62199. *
  62200. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62201. * glowy meshes to your scene.
  62202. *
  62203. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62204. */
  62205. export class HighlightLayer extends EffectLayer {
  62206. name: string;
  62207. /**
  62208. * Effect Name of the highlight layer.
  62209. */
  62210. static readonly EffectName: string;
  62211. /**
  62212. * The neutral color used during the preparation of the glow effect.
  62213. * This is black by default as the blend operation is a blend operation.
  62214. */
  62215. static NeutralColor: Color4;
  62216. /**
  62217. * Stencil value used for glowing meshes.
  62218. */
  62219. static GlowingMeshStencilReference: number;
  62220. /**
  62221. * Stencil value used for the other meshes in the scene.
  62222. */
  62223. static NormalMeshStencilReference: number;
  62224. /**
  62225. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62226. */
  62227. innerGlow: boolean;
  62228. /**
  62229. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62230. */
  62231. outerGlow: boolean;
  62232. /**
  62233. * Specifies the horizontal size of the blur.
  62234. */
  62235. set blurHorizontalSize(value: number);
  62236. /**
  62237. * Specifies the vertical size of the blur.
  62238. */
  62239. set blurVerticalSize(value: number);
  62240. /**
  62241. * Gets the horizontal size of the blur.
  62242. */
  62243. get blurHorizontalSize(): number;
  62244. /**
  62245. * Gets the vertical size of the blur.
  62246. */
  62247. get blurVerticalSize(): number;
  62248. /**
  62249. * An event triggered when the highlight layer is being blurred.
  62250. */
  62251. onBeforeBlurObservable: Observable<HighlightLayer>;
  62252. /**
  62253. * An event triggered when the highlight layer has been blurred.
  62254. */
  62255. onAfterBlurObservable: Observable<HighlightLayer>;
  62256. private _instanceGlowingMeshStencilReference;
  62257. private _options;
  62258. private _downSamplePostprocess;
  62259. private _horizontalBlurPostprocess;
  62260. private _verticalBlurPostprocess;
  62261. private _blurTexture;
  62262. private _meshes;
  62263. private _excludedMeshes;
  62264. /**
  62265. * Instantiates a new highlight Layer and references it to the scene..
  62266. * @param name The name of the layer
  62267. * @param scene The scene to use the layer in
  62268. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62269. */
  62270. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62271. /**
  62272. * Get the effect name of the layer.
  62273. * @return The effect name
  62274. */
  62275. getEffectName(): string;
  62276. /**
  62277. * Create the merge effect. This is the shader use to blit the information back
  62278. * to the main canvas at the end of the scene rendering.
  62279. */
  62280. protected _createMergeEffect(): Effect;
  62281. /**
  62282. * Creates the render target textures and post processes used in the highlight layer.
  62283. */
  62284. protected _createTextureAndPostProcesses(): void;
  62285. /**
  62286. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62287. */
  62288. needStencil(): boolean;
  62289. /**
  62290. * Checks for the readiness of the element composing the layer.
  62291. * @param subMesh the mesh to check for
  62292. * @param useInstances specify wether or not to use instances to render the mesh
  62293. * @param emissiveTexture the associated emissive texture used to generate the glow
  62294. * @return true if ready otherwise, false
  62295. */
  62296. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62297. /**
  62298. * Implementation specific of rendering the generating effect on the main canvas.
  62299. * @param effect The effect used to render through
  62300. */
  62301. protected _internalRender(effect: Effect): void;
  62302. /**
  62303. * Returns true if the layer contains information to display, otherwise false.
  62304. */
  62305. shouldRender(): boolean;
  62306. /**
  62307. * Returns true if the mesh should render, otherwise false.
  62308. * @param mesh The mesh to render
  62309. * @returns true if it should render otherwise false
  62310. */
  62311. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62312. /**
  62313. * Returns true if the mesh can be rendered, otherwise false.
  62314. * @param mesh The mesh to render
  62315. * @param material The material used on the mesh
  62316. * @returns true if it can be rendered otherwise false
  62317. */
  62318. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62319. /**
  62320. * Adds specific effects defines.
  62321. * @param defines The defines to add specifics to.
  62322. */
  62323. protected _addCustomEffectDefines(defines: string[]): void;
  62324. /**
  62325. * Sets the required values for both the emissive texture and and the main color.
  62326. */
  62327. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62328. /**
  62329. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62330. * @param mesh The mesh to exclude from the highlight layer
  62331. */
  62332. addExcludedMesh(mesh: Mesh): void;
  62333. /**
  62334. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62335. * @param mesh The mesh to highlight
  62336. */
  62337. removeExcludedMesh(mesh: Mesh): void;
  62338. /**
  62339. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62340. * @param mesh mesh to test
  62341. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62342. */
  62343. hasMesh(mesh: AbstractMesh): boolean;
  62344. /**
  62345. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62346. * @param mesh The mesh to highlight
  62347. * @param color The color of the highlight
  62348. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62349. */
  62350. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62351. /**
  62352. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62353. * @param mesh The mesh to highlight
  62354. */
  62355. removeMesh(mesh: Mesh): void;
  62356. /**
  62357. * Remove all the meshes currently referenced in the highlight layer
  62358. */
  62359. removeAllMeshes(): void;
  62360. /**
  62361. * Force the stencil to the normal expected value for none glowing parts
  62362. */
  62363. private _defaultStencilReference;
  62364. /**
  62365. * Free any resources and references associated to a mesh.
  62366. * Internal use
  62367. * @param mesh The mesh to free.
  62368. * @hidden
  62369. */
  62370. _disposeMesh(mesh: Mesh): void;
  62371. /**
  62372. * Dispose the highlight layer and free resources.
  62373. */
  62374. dispose(): void;
  62375. /**
  62376. * Gets the class name of the effect layer
  62377. * @returns the string with the class name of the effect layer
  62378. */
  62379. getClassName(): string;
  62380. /**
  62381. * Serializes this Highlight layer
  62382. * @returns a serialized Highlight layer object
  62383. */
  62384. serialize(): any;
  62385. /**
  62386. * Creates a Highlight layer from parsed Highlight layer data
  62387. * @param parsedHightlightLayer defines the Highlight layer data
  62388. * @param scene defines the current scene
  62389. * @param rootUrl defines the root URL containing the Highlight layer information
  62390. * @returns a parsed Highlight layer
  62391. */
  62392. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62393. }
  62394. }
  62395. declare module "babylonjs/Layers/layerSceneComponent" {
  62396. import { Scene } from "babylonjs/scene";
  62397. import { ISceneComponent } from "babylonjs/sceneComponent";
  62398. import { Layer } from "babylonjs/Layers/layer";
  62399. import { AbstractScene } from "babylonjs/abstractScene";
  62400. module "babylonjs/abstractScene" {
  62401. interface AbstractScene {
  62402. /**
  62403. * The list of layers (background and foreground) of the scene
  62404. */
  62405. layers: Array<Layer>;
  62406. }
  62407. }
  62408. /**
  62409. * Defines the layer scene component responsible to manage any layers
  62410. * in a given scene.
  62411. */
  62412. export class LayerSceneComponent implements ISceneComponent {
  62413. /**
  62414. * The component name helpfull to identify the component in the list of scene components.
  62415. */
  62416. readonly name: string;
  62417. /**
  62418. * The scene the component belongs to.
  62419. */
  62420. scene: Scene;
  62421. private _engine;
  62422. /**
  62423. * Creates a new instance of the component for the given scene
  62424. * @param scene Defines the scene to register the component in
  62425. */
  62426. constructor(scene: Scene);
  62427. /**
  62428. * Registers the component in a given scene
  62429. */
  62430. register(): void;
  62431. /**
  62432. * Rebuilds the elements related to this component in case of
  62433. * context lost for instance.
  62434. */
  62435. rebuild(): void;
  62436. /**
  62437. * Disposes the component and the associated ressources.
  62438. */
  62439. dispose(): void;
  62440. private _draw;
  62441. private _drawCameraPredicate;
  62442. private _drawCameraBackground;
  62443. private _drawCameraForeground;
  62444. private _drawRenderTargetPredicate;
  62445. private _drawRenderTargetBackground;
  62446. private _drawRenderTargetForeground;
  62447. /**
  62448. * Adds all the elements from the container to the scene
  62449. * @param container the container holding the elements
  62450. */
  62451. addFromContainer(container: AbstractScene): void;
  62452. /**
  62453. * Removes all the elements in the container from the scene
  62454. * @param container contains the elements to remove
  62455. * @param dispose if the removed element should be disposed (default: false)
  62456. */
  62457. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62458. }
  62459. }
  62460. declare module "babylonjs/Shaders/layer.fragment" {
  62461. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62462. /** @hidden */
  62463. export var layerPixelShader: {
  62464. name: string;
  62465. shader: string;
  62466. };
  62467. }
  62468. declare module "babylonjs/Shaders/layer.vertex" {
  62469. /** @hidden */
  62470. export var layerVertexShader: {
  62471. name: string;
  62472. shader: string;
  62473. };
  62474. }
  62475. declare module "babylonjs/Layers/layer" {
  62476. import { Observable } from "babylonjs/Misc/observable";
  62477. import { Nullable } from "babylonjs/types";
  62478. import { Scene } from "babylonjs/scene";
  62479. import { Vector2 } from "babylonjs/Maths/math.vector";
  62480. import { Color4 } from "babylonjs/Maths/math.color";
  62481. import { Texture } from "babylonjs/Materials/Textures/texture";
  62482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62483. import "babylonjs/Shaders/layer.fragment";
  62484. import "babylonjs/Shaders/layer.vertex";
  62485. /**
  62486. * This represents a full screen 2d layer.
  62487. * This can be useful to display a picture in the background of your scene for instance.
  62488. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62489. */
  62490. export class Layer {
  62491. /**
  62492. * Define the name of the layer.
  62493. */
  62494. name: string;
  62495. /**
  62496. * Define the texture the layer should display.
  62497. */
  62498. texture: Nullable<Texture>;
  62499. /**
  62500. * Is the layer in background or foreground.
  62501. */
  62502. isBackground: boolean;
  62503. /**
  62504. * Define the color of the layer (instead of texture).
  62505. */
  62506. color: Color4;
  62507. /**
  62508. * Define the scale of the layer in order to zoom in out of the texture.
  62509. */
  62510. scale: Vector2;
  62511. /**
  62512. * Define an offset for the layer in order to shift the texture.
  62513. */
  62514. offset: Vector2;
  62515. /**
  62516. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62517. */
  62518. alphaBlendingMode: number;
  62519. /**
  62520. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62521. * Alpha test will not mix with the background color in case of transparency.
  62522. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62523. */
  62524. alphaTest: boolean;
  62525. /**
  62526. * Define a mask to restrict the layer to only some of the scene cameras.
  62527. */
  62528. layerMask: number;
  62529. /**
  62530. * Define the list of render target the layer is visible into.
  62531. */
  62532. renderTargetTextures: RenderTargetTexture[];
  62533. /**
  62534. * Define if the layer is only used in renderTarget or if it also
  62535. * renders in the main frame buffer of the canvas.
  62536. */
  62537. renderOnlyInRenderTargetTextures: boolean;
  62538. private _scene;
  62539. private _vertexBuffers;
  62540. private _indexBuffer;
  62541. private _effect;
  62542. private _previousDefines;
  62543. /**
  62544. * An event triggered when the layer is disposed.
  62545. */
  62546. onDisposeObservable: Observable<Layer>;
  62547. private _onDisposeObserver;
  62548. /**
  62549. * Back compatibility with callback before the onDisposeObservable existed.
  62550. * The set callback will be triggered when the layer has been disposed.
  62551. */
  62552. set onDispose(callback: () => void);
  62553. /**
  62554. * An event triggered before rendering the scene
  62555. */
  62556. onBeforeRenderObservable: Observable<Layer>;
  62557. private _onBeforeRenderObserver;
  62558. /**
  62559. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62560. * The set callback will be triggered just before rendering the layer.
  62561. */
  62562. set onBeforeRender(callback: () => void);
  62563. /**
  62564. * An event triggered after rendering the scene
  62565. */
  62566. onAfterRenderObservable: Observable<Layer>;
  62567. private _onAfterRenderObserver;
  62568. /**
  62569. * Back compatibility with callback before the onAfterRenderObservable existed.
  62570. * The set callback will be triggered just after rendering the layer.
  62571. */
  62572. set onAfterRender(callback: () => void);
  62573. /**
  62574. * Instantiates a new layer.
  62575. * This represents a full screen 2d layer.
  62576. * This can be useful to display a picture in the background of your scene for instance.
  62577. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62578. * @param name Define the name of the layer in the scene
  62579. * @param imgUrl Define the url of the texture to display in the layer
  62580. * @param scene Define the scene the layer belongs to
  62581. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62582. * @param color Defines a color for the layer
  62583. */
  62584. constructor(
  62585. /**
  62586. * Define the name of the layer.
  62587. */
  62588. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62589. private _createIndexBuffer;
  62590. /** @hidden */
  62591. _rebuild(): void;
  62592. /**
  62593. * Renders the layer in the scene.
  62594. */
  62595. render(): void;
  62596. /**
  62597. * Disposes and releases the associated ressources.
  62598. */
  62599. dispose(): void;
  62600. }
  62601. }
  62602. declare module "babylonjs/Layers/index" {
  62603. export * from "babylonjs/Layers/effectLayer";
  62604. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62605. export * from "babylonjs/Layers/glowLayer";
  62606. export * from "babylonjs/Layers/highlightLayer";
  62607. export * from "babylonjs/Layers/layer";
  62608. export * from "babylonjs/Layers/layerSceneComponent";
  62609. }
  62610. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62611. /** @hidden */
  62612. export var lensFlarePixelShader: {
  62613. name: string;
  62614. shader: string;
  62615. };
  62616. }
  62617. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62618. /** @hidden */
  62619. export var lensFlareVertexShader: {
  62620. name: string;
  62621. shader: string;
  62622. };
  62623. }
  62624. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62625. import { Scene } from "babylonjs/scene";
  62626. import { Vector3 } from "babylonjs/Maths/math.vector";
  62627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62628. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62629. import "babylonjs/Shaders/lensFlare.fragment";
  62630. import "babylonjs/Shaders/lensFlare.vertex";
  62631. import { Viewport } from "babylonjs/Maths/math.viewport";
  62632. /**
  62633. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62634. * It is usually composed of several `lensFlare`.
  62635. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62636. */
  62637. export class LensFlareSystem {
  62638. /**
  62639. * Define the name of the lens flare system
  62640. */
  62641. name: string;
  62642. /**
  62643. * List of lens flares used in this system.
  62644. */
  62645. lensFlares: LensFlare[];
  62646. /**
  62647. * Define a limit from the border the lens flare can be visible.
  62648. */
  62649. borderLimit: number;
  62650. /**
  62651. * Define a viewport border we do not want to see the lens flare in.
  62652. */
  62653. viewportBorder: number;
  62654. /**
  62655. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62656. */
  62657. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62658. /**
  62659. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62660. */
  62661. layerMask: number;
  62662. /**
  62663. * Define the id of the lens flare system in the scene.
  62664. * (equal to name by default)
  62665. */
  62666. id: string;
  62667. private _scene;
  62668. private _emitter;
  62669. private _vertexBuffers;
  62670. private _indexBuffer;
  62671. private _effect;
  62672. private _positionX;
  62673. private _positionY;
  62674. private _isEnabled;
  62675. /** @hidden */
  62676. static _SceneComponentInitialization: (scene: Scene) => void;
  62677. /**
  62678. * Instantiates a lens flare system.
  62679. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62680. * It is usually composed of several `lensFlare`.
  62681. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62682. * @param name Define the name of the lens flare system in the scene
  62683. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62684. * @param scene Define the scene the lens flare system belongs to
  62685. */
  62686. constructor(
  62687. /**
  62688. * Define the name of the lens flare system
  62689. */
  62690. name: string, emitter: any, scene: Scene);
  62691. /**
  62692. * Define if the lens flare system is enabled.
  62693. */
  62694. get isEnabled(): boolean;
  62695. set isEnabled(value: boolean);
  62696. /**
  62697. * Get the scene the effects belongs to.
  62698. * @returns the scene holding the lens flare system
  62699. */
  62700. getScene(): Scene;
  62701. /**
  62702. * Get the emitter of the lens flare system.
  62703. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62704. * @returns the emitter of the lens flare system
  62705. */
  62706. getEmitter(): any;
  62707. /**
  62708. * Set the emitter of the lens flare system.
  62709. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62710. * @param newEmitter Define the new emitter of the system
  62711. */
  62712. setEmitter(newEmitter: any): void;
  62713. /**
  62714. * Get the lens flare system emitter position.
  62715. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62716. * @returns the position
  62717. */
  62718. getEmitterPosition(): Vector3;
  62719. /**
  62720. * @hidden
  62721. */
  62722. computeEffectivePosition(globalViewport: Viewport): boolean;
  62723. /** @hidden */
  62724. _isVisible(): boolean;
  62725. /**
  62726. * @hidden
  62727. */
  62728. render(): boolean;
  62729. /**
  62730. * Dispose and release the lens flare with its associated resources.
  62731. */
  62732. dispose(): void;
  62733. /**
  62734. * Parse a lens flare system from a JSON repressentation
  62735. * @param parsedLensFlareSystem Define the JSON to parse
  62736. * @param scene Define the scene the parsed system should be instantiated in
  62737. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62738. * @returns the parsed system
  62739. */
  62740. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62741. /**
  62742. * Serialize the current Lens Flare System into a JSON representation.
  62743. * @returns the serialized JSON
  62744. */
  62745. serialize(): any;
  62746. }
  62747. }
  62748. declare module "babylonjs/LensFlares/lensFlare" {
  62749. import { Nullable } from "babylonjs/types";
  62750. import { Color3 } from "babylonjs/Maths/math.color";
  62751. import { Texture } from "babylonjs/Materials/Textures/texture";
  62752. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62753. /**
  62754. * This represents one of the lens effect in a `lensFlareSystem`.
  62755. * It controls one of the indiviual texture used in the effect.
  62756. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62757. */
  62758. export class LensFlare {
  62759. /**
  62760. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62761. */
  62762. size: number;
  62763. /**
  62764. * 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.
  62765. */
  62766. position: number;
  62767. /**
  62768. * Define the lens color.
  62769. */
  62770. color: Color3;
  62771. /**
  62772. * Define the lens texture.
  62773. */
  62774. texture: Nullable<Texture>;
  62775. /**
  62776. * Define the alpha mode to render this particular lens.
  62777. */
  62778. alphaMode: number;
  62779. private _system;
  62780. /**
  62781. * Creates a new Lens Flare.
  62782. * This represents one of the lens effect in a `lensFlareSystem`.
  62783. * It controls one of the indiviual texture used in the effect.
  62784. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62785. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62786. * @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.
  62787. * @param color Define the lens color
  62788. * @param imgUrl Define the lens texture url
  62789. * @param system Define the `lensFlareSystem` this flare is part of
  62790. * @returns The newly created Lens Flare
  62791. */
  62792. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62793. /**
  62794. * Instantiates a new Lens Flare.
  62795. * This represents one of the lens effect in a `lensFlareSystem`.
  62796. * It controls one of the indiviual texture used in the effect.
  62797. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62798. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62799. * @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.
  62800. * @param color Define the lens color
  62801. * @param imgUrl Define the lens texture url
  62802. * @param system Define the `lensFlareSystem` this flare is part of
  62803. */
  62804. constructor(
  62805. /**
  62806. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62807. */
  62808. size: number,
  62809. /**
  62810. * 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.
  62811. */
  62812. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62813. /**
  62814. * Dispose and release the lens flare with its associated resources.
  62815. */
  62816. dispose(): void;
  62817. }
  62818. }
  62819. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62820. import { Nullable } from "babylonjs/types";
  62821. import { Scene } from "babylonjs/scene";
  62822. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62823. import { AbstractScene } from "babylonjs/abstractScene";
  62824. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62825. module "babylonjs/abstractScene" {
  62826. interface AbstractScene {
  62827. /**
  62828. * The list of lens flare system added to the scene
  62829. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62830. */
  62831. lensFlareSystems: Array<LensFlareSystem>;
  62832. /**
  62833. * Removes the given lens flare system from this scene.
  62834. * @param toRemove The lens flare system to remove
  62835. * @returns The index of the removed lens flare system
  62836. */
  62837. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62838. /**
  62839. * Adds the given lens flare system to this scene
  62840. * @param newLensFlareSystem The lens flare system to add
  62841. */
  62842. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62843. /**
  62844. * Gets a lens flare system using its name
  62845. * @param name defines the name to look for
  62846. * @returns the lens flare system or null if not found
  62847. */
  62848. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62849. /**
  62850. * Gets a lens flare system using its id
  62851. * @param id defines the id to look for
  62852. * @returns the lens flare system or null if not found
  62853. */
  62854. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62855. }
  62856. }
  62857. /**
  62858. * Defines the lens flare scene component responsible to manage any lens flares
  62859. * in a given scene.
  62860. */
  62861. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62862. /**
  62863. * The component name helpfull to identify the component in the list of scene components.
  62864. */
  62865. readonly name: string;
  62866. /**
  62867. * The scene the component belongs to.
  62868. */
  62869. scene: Scene;
  62870. /**
  62871. * Creates a new instance of the component for the given scene
  62872. * @param scene Defines the scene to register the component in
  62873. */
  62874. constructor(scene: Scene);
  62875. /**
  62876. * Registers the component in a given scene
  62877. */
  62878. register(): void;
  62879. /**
  62880. * Rebuilds the elements related to this component in case of
  62881. * context lost for instance.
  62882. */
  62883. rebuild(): void;
  62884. /**
  62885. * Adds all the elements from the container to the scene
  62886. * @param container the container holding the elements
  62887. */
  62888. addFromContainer(container: AbstractScene): void;
  62889. /**
  62890. * Removes all the elements in the container from the scene
  62891. * @param container contains the elements to remove
  62892. * @param dispose if the removed element should be disposed (default: false)
  62893. */
  62894. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62895. /**
  62896. * Serializes the component data to the specified json object
  62897. * @param serializationObject The object to serialize to
  62898. */
  62899. serialize(serializationObject: any): void;
  62900. /**
  62901. * Disposes the component and the associated ressources.
  62902. */
  62903. dispose(): void;
  62904. private _draw;
  62905. }
  62906. }
  62907. declare module "babylonjs/LensFlares/index" {
  62908. export * from "babylonjs/LensFlares/lensFlare";
  62909. export * from "babylonjs/LensFlares/lensFlareSystem";
  62910. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62911. }
  62912. declare module "babylonjs/Shaders/depth.fragment" {
  62913. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62914. /** @hidden */
  62915. export var depthPixelShader: {
  62916. name: string;
  62917. shader: string;
  62918. };
  62919. }
  62920. declare module "babylonjs/Shaders/depth.vertex" {
  62921. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62924. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62926. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62927. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62928. /** @hidden */
  62929. export var depthVertexShader: {
  62930. name: string;
  62931. shader: string;
  62932. };
  62933. }
  62934. declare module "babylonjs/Rendering/depthRenderer" {
  62935. import { Nullable } from "babylonjs/types";
  62936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62937. import { Scene } from "babylonjs/scene";
  62938. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62939. import { Camera } from "babylonjs/Cameras/camera";
  62940. import "babylonjs/Shaders/depth.fragment";
  62941. import "babylonjs/Shaders/depth.vertex";
  62942. /**
  62943. * This represents a depth renderer in Babylon.
  62944. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62945. */
  62946. export class DepthRenderer {
  62947. private _scene;
  62948. private _depthMap;
  62949. private _effect;
  62950. private readonly _storeNonLinearDepth;
  62951. private readonly _clearColor;
  62952. /** Get if the depth renderer is using packed depth or not */
  62953. readonly isPacked: boolean;
  62954. private _cachedDefines;
  62955. private _camera;
  62956. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62957. enabled: boolean;
  62958. /**
  62959. * Specifiess that the depth renderer will only be used within
  62960. * the camera it is created for.
  62961. * This can help forcing its rendering during the camera processing.
  62962. */
  62963. useOnlyInActiveCamera: boolean;
  62964. /** @hidden */
  62965. static _SceneComponentInitialization: (scene: Scene) => void;
  62966. /**
  62967. * Instantiates a depth renderer
  62968. * @param scene The scene the renderer belongs to
  62969. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62970. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62971. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62972. */
  62973. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62974. /**
  62975. * Creates the depth rendering effect and checks if the effect is ready.
  62976. * @param subMesh The submesh to be used to render the depth map of
  62977. * @param useInstances If multiple world instances should be used
  62978. * @returns if the depth renderer is ready to render the depth map
  62979. */
  62980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62981. /**
  62982. * Gets the texture which the depth map will be written to.
  62983. * @returns The depth map texture
  62984. */
  62985. getDepthMap(): RenderTargetTexture;
  62986. /**
  62987. * Disposes of the depth renderer.
  62988. */
  62989. dispose(): void;
  62990. }
  62991. }
  62992. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62993. /** @hidden */
  62994. export var minmaxReduxPixelShader: {
  62995. name: string;
  62996. shader: string;
  62997. };
  62998. }
  62999. declare module "babylonjs/Misc/minMaxReducer" {
  63000. import { Nullable } from "babylonjs/types";
  63001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63002. import { Camera } from "babylonjs/Cameras/camera";
  63003. import { Observer } from "babylonjs/Misc/observable";
  63004. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63005. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63006. import { Observable } from "babylonjs/Misc/observable";
  63007. import "babylonjs/Shaders/minmaxRedux.fragment";
  63008. /**
  63009. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63010. * and maximum values from all values of the texture.
  63011. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63012. * The source values are read from the red channel of the texture.
  63013. */
  63014. export class MinMaxReducer {
  63015. /**
  63016. * Observable triggered when the computation has been performed
  63017. */
  63018. onAfterReductionPerformed: Observable<{
  63019. min: number;
  63020. max: number;
  63021. }>;
  63022. protected _camera: Camera;
  63023. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63024. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63025. protected _postProcessManager: PostProcessManager;
  63026. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63027. protected _forceFullscreenViewport: boolean;
  63028. /**
  63029. * Creates a min/max reducer
  63030. * @param camera The camera to use for the post processes
  63031. */
  63032. constructor(camera: Camera);
  63033. /**
  63034. * Gets the texture used to read the values from.
  63035. */
  63036. get sourceTexture(): Nullable<RenderTargetTexture>;
  63037. /**
  63038. * Sets the source texture to read the values from.
  63039. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63040. * because in such textures '1' value must not be taken into account to compute the maximum
  63041. * as this value is used to clear the texture.
  63042. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63043. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63044. * @param depthRedux Indicates if the texture is a depth texture or not
  63045. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63046. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63047. */
  63048. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63049. /**
  63050. * Defines the refresh rate of the computation.
  63051. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63052. */
  63053. get refreshRate(): number;
  63054. set refreshRate(value: number);
  63055. protected _activated: boolean;
  63056. /**
  63057. * Gets the activation status of the reducer
  63058. */
  63059. get activated(): boolean;
  63060. /**
  63061. * Activates the reduction computation.
  63062. * When activated, the observers registered in onAfterReductionPerformed are
  63063. * called after the compuation is performed
  63064. */
  63065. activate(): void;
  63066. /**
  63067. * Deactivates the reduction computation.
  63068. */
  63069. deactivate(): void;
  63070. /**
  63071. * Disposes the min/max reducer
  63072. * @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.
  63073. */
  63074. dispose(disposeAll?: boolean): void;
  63075. }
  63076. }
  63077. declare module "babylonjs/Misc/depthReducer" {
  63078. import { Nullable } from "babylonjs/types";
  63079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63080. import { Camera } from "babylonjs/Cameras/camera";
  63081. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63082. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63083. /**
  63084. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63085. */
  63086. export class DepthReducer extends MinMaxReducer {
  63087. private _depthRenderer;
  63088. private _depthRendererId;
  63089. /**
  63090. * Gets the depth renderer used for the computation.
  63091. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63092. */
  63093. get depthRenderer(): Nullable<DepthRenderer>;
  63094. /**
  63095. * Creates a depth reducer
  63096. * @param camera The camera used to render the depth texture
  63097. */
  63098. constructor(camera: Camera);
  63099. /**
  63100. * Sets the depth renderer to use to generate the depth map
  63101. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63102. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63103. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63104. */
  63105. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63106. /** @hidden */
  63107. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63108. /**
  63109. * Activates the reduction computation.
  63110. * When activated, the observers registered in onAfterReductionPerformed are
  63111. * called after the compuation is performed
  63112. */
  63113. activate(): void;
  63114. /**
  63115. * Deactivates the reduction computation.
  63116. */
  63117. deactivate(): void;
  63118. /**
  63119. * Disposes the depth reducer
  63120. * @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.
  63121. */
  63122. dispose(disposeAll?: boolean): void;
  63123. }
  63124. }
  63125. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63126. import { Nullable } from "babylonjs/types";
  63127. import { Scene } from "babylonjs/scene";
  63128. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63131. import { Effect } from "babylonjs/Materials/effect";
  63132. import "babylonjs/Shaders/shadowMap.fragment";
  63133. import "babylonjs/Shaders/shadowMap.vertex";
  63134. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63135. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63136. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63137. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63138. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63139. /**
  63140. * A CSM implementation allowing casting shadows on large scenes.
  63141. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63142. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63143. */
  63144. export class CascadedShadowGenerator extends ShadowGenerator {
  63145. private static readonly frustumCornersNDCSpace;
  63146. /**
  63147. * Name of the CSM class
  63148. */
  63149. static CLASSNAME: string;
  63150. /**
  63151. * Defines the default number of cascades used by the CSM.
  63152. */
  63153. static readonly DEFAULT_CASCADES_COUNT: number;
  63154. /**
  63155. * Defines the minimum number of cascades used by the CSM.
  63156. */
  63157. static readonly MIN_CASCADES_COUNT: number;
  63158. /**
  63159. * Defines the maximum number of cascades used by the CSM.
  63160. */
  63161. static readonly MAX_CASCADES_COUNT: number;
  63162. protected _validateFilter(filter: number): number;
  63163. /**
  63164. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63165. */
  63166. penumbraDarkness: number;
  63167. private _numCascades;
  63168. /**
  63169. * Gets or set the number of cascades used by the CSM.
  63170. */
  63171. get numCascades(): number;
  63172. set numCascades(value: number);
  63173. /**
  63174. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63175. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63176. */
  63177. stabilizeCascades: boolean;
  63178. private _freezeShadowCastersBoundingInfo;
  63179. private _freezeShadowCastersBoundingInfoObservable;
  63180. /**
  63181. * Enables or disables the shadow casters bounding info computation.
  63182. * If your shadow casters don't move, you can disable this feature.
  63183. * If it is enabled, the bounding box computation is done every frame.
  63184. */
  63185. get freezeShadowCastersBoundingInfo(): boolean;
  63186. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63187. private _scbiMin;
  63188. private _scbiMax;
  63189. protected _computeShadowCastersBoundingInfo(): void;
  63190. protected _shadowCastersBoundingInfo: BoundingInfo;
  63191. /**
  63192. * Gets or sets the shadow casters bounding info.
  63193. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63194. * so that the system won't overwrite the bounds you provide
  63195. */
  63196. get shadowCastersBoundingInfo(): BoundingInfo;
  63197. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63198. protected _breaksAreDirty: boolean;
  63199. protected _minDistance: number;
  63200. protected _maxDistance: number;
  63201. /**
  63202. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63203. *
  63204. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63205. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63206. * @param min minimal distance for the breaks (default to 0.)
  63207. * @param max maximal distance for the breaks (default to 1.)
  63208. */
  63209. setMinMaxDistance(min: number, max: number): void;
  63210. /** Gets the minimal distance used in the cascade break computation */
  63211. get minDistance(): number;
  63212. /** Gets the maximal distance used in the cascade break computation */
  63213. get maxDistance(): number;
  63214. /**
  63215. * Gets the class name of that object
  63216. * @returns "CascadedShadowGenerator"
  63217. */
  63218. getClassName(): string;
  63219. private _cascadeMinExtents;
  63220. private _cascadeMaxExtents;
  63221. /**
  63222. * Gets a cascade minimum extents
  63223. * @param cascadeIndex index of the cascade
  63224. * @returns the minimum cascade extents
  63225. */
  63226. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63227. /**
  63228. * Gets a cascade maximum extents
  63229. * @param cascadeIndex index of the cascade
  63230. * @returns the maximum cascade extents
  63231. */
  63232. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63233. private _cascades;
  63234. private _currentLayer;
  63235. private _viewSpaceFrustumsZ;
  63236. private _viewMatrices;
  63237. private _projectionMatrices;
  63238. private _transformMatrices;
  63239. private _transformMatricesAsArray;
  63240. private _frustumLengths;
  63241. private _lightSizeUVCorrection;
  63242. private _depthCorrection;
  63243. private _frustumCornersWorldSpace;
  63244. private _frustumCenter;
  63245. private _shadowCameraPos;
  63246. private _shadowMaxZ;
  63247. /**
  63248. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63249. * It defaults to camera.maxZ
  63250. */
  63251. get shadowMaxZ(): number;
  63252. /**
  63253. * Sets the shadow max z distance.
  63254. */
  63255. set shadowMaxZ(value: number);
  63256. protected _debug: boolean;
  63257. /**
  63258. * Gets or sets the debug flag.
  63259. * When enabled, the cascades are materialized by different colors on the screen.
  63260. */
  63261. get debug(): boolean;
  63262. set debug(dbg: boolean);
  63263. private _depthClamp;
  63264. /**
  63265. * Gets or sets the depth clamping value.
  63266. *
  63267. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63268. * to account for the shadow casters far away.
  63269. *
  63270. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63271. */
  63272. get depthClamp(): boolean;
  63273. set depthClamp(value: boolean);
  63274. private _cascadeBlendPercentage;
  63275. /**
  63276. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63277. * It defaults to 0.1 (10% blending).
  63278. */
  63279. get cascadeBlendPercentage(): number;
  63280. set cascadeBlendPercentage(value: number);
  63281. private _lambda;
  63282. /**
  63283. * Gets or set the lambda parameter.
  63284. * This parameter is used to split the camera frustum and create the cascades.
  63285. * 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.
  63286. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63287. */
  63288. get lambda(): number;
  63289. set lambda(value: number);
  63290. /**
  63291. * Gets the view matrix corresponding to a given cascade
  63292. * @param cascadeNum cascade to retrieve the view matrix from
  63293. * @returns the cascade view matrix
  63294. */
  63295. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63296. /**
  63297. * Gets the projection matrix corresponding to a given cascade
  63298. * @param cascadeNum cascade to retrieve the projection matrix from
  63299. * @returns the cascade projection matrix
  63300. */
  63301. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63302. /**
  63303. * Gets the transformation matrix corresponding to a given cascade
  63304. * @param cascadeNum cascade to retrieve the transformation matrix from
  63305. * @returns the cascade transformation matrix
  63306. */
  63307. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63308. private _depthRenderer;
  63309. /**
  63310. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63311. *
  63312. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63313. *
  63314. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63315. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63316. * @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
  63317. */
  63318. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63319. private _depthReducer;
  63320. private _autoCalcDepthBounds;
  63321. /**
  63322. * Gets or sets the autoCalcDepthBounds property.
  63323. *
  63324. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63325. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63326. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63327. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63328. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63329. */
  63330. get autoCalcDepthBounds(): boolean;
  63331. set autoCalcDepthBounds(value: boolean);
  63332. /**
  63333. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63334. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63335. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63336. * for setting the refresh rate on the renderer yourself!
  63337. */
  63338. get autoCalcDepthBoundsRefreshRate(): number;
  63339. set autoCalcDepthBoundsRefreshRate(value: number);
  63340. /**
  63341. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63342. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63343. * you change the camera near/far planes!
  63344. */
  63345. splitFrustum(): void;
  63346. private _splitFrustum;
  63347. private _computeMatrices;
  63348. private _computeFrustumInWorldSpace;
  63349. private _computeCascadeFrustum;
  63350. /**
  63351. * Support test.
  63352. */
  63353. static get IsSupported(): boolean;
  63354. /** @hidden */
  63355. static _SceneComponentInitialization: (scene: Scene) => void;
  63356. /**
  63357. * Creates a Cascaded Shadow Generator object.
  63358. * A ShadowGenerator is the required tool to use the shadows.
  63359. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63360. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63361. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63362. * @param light The directional light object generating the shadows.
  63363. * @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.
  63364. */
  63365. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63366. protected _initializeGenerator(): void;
  63367. protected _createTargetRenderTexture(): void;
  63368. protected _initializeShadowMap(): void;
  63369. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63370. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63371. /**
  63372. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63373. * @param defines Defines of the material we want to update
  63374. * @param lightIndex Index of the light in the enabled light list of the material
  63375. */
  63376. prepareDefines(defines: any, lightIndex: number): void;
  63377. /**
  63378. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63379. * defined in the generator but impacting the effect).
  63380. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63381. * @param effect The effect we are binfing the information for
  63382. */
  63383. bindShadowLight(lightIndex: string, effect: Effect): void;
  63384. /**
  63385. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63386. * (eq to view projection * shadow projection matrices)
  63387. * @returns The transform matrix used to create the shadow map
  63388. */
  63389. getTransformMatrix(): Matrix;
  63390. /**
  63391. * Disposes the ShadowGenerator.
  63392. * Returns nothing.
  63393. */
  63394. dispose(): void;
  63395. /**
  63396. * Serializes the shadow generator setup to a json object.
  63397. * @returns The serialized JSON object
  63398. */
  63399. serialize(): any;
  63400. /**
  63401. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63402. * @param parsedShadowGenerator The JSON object to parse
  63403. * @param scene The scene to create the shadow map for
  63404. * @returns The parsed shadow generator
  63405. */
  63406. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63407. }
  63408. }
  63409. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63410. import { Scene } from "babylonjs/scene";
  63411. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63412. import { AbstractScene } from "babylonjs/abstractScene";
  63413. /**
  63414. * Defines the shadow generator component responsible to manage any shadow generators
  63415. * in a given scene.
  63416. */
  63417. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63418. /**
  63419. * The component name helpfull to identify the component in the list of scene components.
  63420. */
  63421. readonly name: string;
  63422. /**
  63423. * The scene the component belongs to.
  63424. */
  63425. scene: Scene;
  63426. /**
  63427. * Creates a new instance of the component for the given scene
  63428. * @param scene Defines the scene to register the component in
  63429. */
  63430. constructor(scene: Scene);
  63431. /**
  63432. * Registers the component in a given scene
  63433. */
  63434. register(): void;
  63435. /**
  63436. * Rebuilds the elements related to this component in case of
  63437. * context lost for instance.
  63438. */
  63439. rebuild(): void;
  63440. /**
  63441. * Serializes the component data to the specified json object
  63442. * @param serializationObject The object to serialize to
  63443. */
  63444. serialize(serializationObject: any): void;
  63445. /**
  63446. * Adds all the elements from the container to the scene
  63447. * @param container the container holding the elements
  63448. */
  63449. addFromContainer(container: AbstractScene): void;
  63450. /**
  63451. * Removes all the elements in the container from the scene
  63452. * @param container contains the elements to remove
  63453. * @param dispose if the removed element should be disposed (default: false)
  63454. */
  63455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63456. /**
  63457. * Rebuilds the elements related to this component in case of
  63458. * context lost for instance.
  63459. */
  63460. dispose(): void;
  63461. private _gatherRenderTargets;
  63462. }
  63463. }
  63464. declare module "babylonjs/Lights/Shadows/index" {
  63465. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63466. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63467. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63468. }
  63469. declare module "babylonjs/Lights/pointLight" {
  63470. import { Scene } from "babylonjs/scene";
  63471. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63473. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63474. import { Effect } from "babylonjs/Materials/effect";
  63475. /**
  63476. * A point light is a light defined by an unique point in world space.
  63477. * The light is emitted in every direction from this point.
  63478. * A good example of a point light is a standard light bulb.
  63479. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63480. */
  63481. export class PointLight extends ShadowLight {
  63482. private _shadowAngle;
  63483. /**
  63484. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63485. * This specifies what angle the shadow will use to be created.
  63486. *
  63487. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63488. */
  63489. get shadowAngle(): number;
  63490. /**
  63491. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63492. * This specifies what angle the shadow will use to be created.
  63493. *
  63494. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63495. */
  63496. set shadowAngle(value: number);
  63497. /**
  63498. * Gets the direction if it has been set.
  63499. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63500. */
  63501. get direction(): Vector3;
  63502. /**
  63503. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63504. */
  63505. set direction(value: Vector3);
  63506. /**
  63507. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63508. * A PointLight emits the light in every direction.
  63509. * It can cast shadows.
  63510. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63511. * ```javascript
  63512. * var pointLight = new PointLight("pl", camera.position, scene);
  63513. * ```
  63514. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63515. * @param name The light friendly name
  63516. * @param position The position of the point light in the scene
  63517. * @param scene The scene the lights belongs to
  63518. */
  63519. constructor(name: string, position: Vector3, scene: Scene);
  63520. /**
  63521. * Returns the string "PointLight"
  63522. * @returns the class name
  63523. */
  63524. getClassName(): string;
  63525. /**
  63526. * Returns the integer 0.
  63527. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63528. */
  63529. getTypeID(): number;
  63530. /**
  63531. * Specifies wether or not the shadowmap should be a cube texture.
  63532. * @returns true if the shadowmap needs to be a cube texture.
  63533. */
  63534. needCube(): boolean;
  63535. /**
  63536. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63537. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63538. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63539. */
  63540. getShadowDirection(faceIndex?: number): Vector3;
  63541. /**
  63542. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63543. * - fov = PI / 2
  63544. * - aspect ratio : 1.0
  63545. * - z-near and far equal to the active camera minZ and maxZ.
  63546. * Returns the PointLight.
  63547. */
  63548. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63549. protected _buildUniformLayout(): void;
  63550. /**
  63551. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63552. * @param effect The effect to update
  63553. * @param lightIndex The index of the light in the effect to update
  63554. * @returns The point light
  63555. */
  63556. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63557. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63558. /**
  63559. * Prepares the list of defines specific to the light type.
  63560. * @param defines the list of defines
  63561. * @param lightIndex defines the index of the light for the effect
  63562. */
  63563. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63564. }
  63565. }
  63566. declare module "babylonjs/Lights/index" {
  63567. export * from "babylonjs/Lights/light";
  63568. export * from "babylonjs/Lights/shadowLight";
  63569. export * from "babylonjs/Lights/Shadows/index";
  63570. export * from "babylonjs/Lights/directionalLight";
  63571. export * from "babylonjs/Lights/hemisphericLight";
  63572. export * from "babylonjs/Lights/pointLight";
  63573. export * from "babylonjs/Lights/spotLight";
  63574. }
  63575. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63576. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63577. /**
  63578. * Header information of HDR texture files.
  63579. */
  63580. export interface HDRInfo {
  63581. /**
  63582. * The height of the texture in pixels.
  63583. */
  63584. height: number;
  63585. /**
  63586. * The width of the texture in pixels.
  63587. */
  63588. width: number;
  63589. /**
  63590. * The index of the beginning of the data in the binary file.
  63591. */
  63592. dataPosition: number;
  63593. }
  63594. /**
  63595. * This groups tools to convert HDR texture to native colors array.
  63596. */
  63597. export class HDRTools {
  63598. private static Ldexp;
  63599. private static Rgbe2float;
  63600. private static readStringLine;
  63601. /**
  63602. * Reads header information from an RGBE texture stored in a native array.
  63603. * More information on this format are available here:
  63604. * https://en.wikipedia.org/wiki/RGBE_image_format
  63605. *
  63606. * @param uint8array The binary file stored in native array.
  63607. * @return The header information.
  63608. */
  63609. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63610. /**
  63611. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63612. * This RGBE texture needs to store the information as a panorama.
  63613. *
  63614. * More information on this format are available here:
  63615. * https://en.wikipedia.org/wiki/RGBE_image_format
  63616. *
  63617. * @param buffer The binary file stored in an array buffer.
  63618. * @param size The expected size of the extracted cubemap.
  63619. * @return The Cube Map information.
  63620. */
  63621. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63622. /**
  63623. * Returns the pixels data extracted from an RGBE texture.
  63624. * This pixels will be stored left to right up to down in the R G B order in one array.
  63625. *
  63626. * More information on this format are available here:
  63627. * https://en.wikipedia.org/wiki/RGBE_image_format
  63628. *
  63629. * @param uint8array The binary file stored in an array buffer.
  63630. * @param hdrInfo The header information of the file.
  63631. * @return The pixels data in RGB right to left up to down order.
  63632. */
  63633. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63634. private static RGBE_ReadPixels_RLE;
  63635. private static RGBE_ReadPixels_NOT_RLE;
  63636. }
  63637. }
  63638. declare module "babylonjs/Materials/effectRenderer" {
  63639. import { Nullable } from "babylonjs/types";
  63640. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63642. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63643. import { Viewport } from "babylonjs/Maths/math.viewport";
  63644. import { Observable } from "babylonjs/Misc/observable";
  63645. import { Effect } from "babylonjs/Materials/effect";
  63646. import "babylonjs/Shaders/postprocess.vertex";
  63647. /**
  63648. * Effect Render Options
  63649. */
  63650. export interface IEffectRendererOptions {
  63651. /**
  63652. * Defines the vertices positions.
  63653. */
  63654. positions?: number[];
  63655. /**
  63656. * Defines the indices.
  63657. */
  63658. indices?: number[];
  63659. }
  63660. /**
  63661. * Helper class to render one or more effects.
  63662. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63663. */
  63664. export class EffectRenderer {
  63665. private engine;
  63666. private static _DefaultOptions;
  63667. private _vertexBuffers;
  63668. private _indexBuffer;
  63669. private _fullscreenViewport;
  63670. /**
  63671. * Creates an effect renderer
  63672. * @param engine the engine to use for rendering
  63673. * @param options defines the options of the effect renderer
  63674. */
  63675. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63676. /**
  63677. * Sets the current viewport in normalized coordinates 0-1
  63678. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63679. */
  63680. setViewport(viewport?: Viewport): void;
  63681. /**
  63682. * Binds the embedded attributes buffer to the effect.
  63683. * @param effect Defines the effect to bind the attributes for
  63684. */
  63685. bindBuffers(effect: Effect): void;
  63686. /**
  63687. * Sets the current effect wrapper to use during draw.
  63688. * The effect needs to be ready before calling this api.
  63689. * This also sets the default full screen position attribute.
  63690. * @param effectWrapper Defines the effect to draw with
  63691. */
  63692. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63693. /**
  63694. * Restores engine states
  63695. */
  63696. restoreStates(): void;
  63697. /**
  63698. * Draws a full screen quad.
  63699. */
  63700. draw(): void;
  63701. private isRenderTargetTexture;
  63702. /**
  63703. * renders one or more effects to a specified texture
  63704. * @param effectWrapper the effect to renderer
  63705. * @param outputTexture texture to draw to, if null it will render to the screen.
  63706. */
  63707. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63708. /**
  63709. * Disposes of the effect renderer
  63710. */
  63711. dispose(): void;
  63712. }
  63713. /**
  63714. * Options to create an EffectWrapper
  63715. */
  63716. interface EffectWrapperCreationOptions {
  63717. /**
  63718. * Engine to use to create the effect
  63719. */
  63720. engine: ThinEngine;
  63721. /**
  63722. * Fragment shader for the effect
  63723. */
  63724. fragmentShader: string;
  63725. /**
  63726. * Use the shader store instead of direct source code
  63727. */
  63728. useShaderStore?: boolean;
  63729. /**
  63730. * Vertex shader for the effect
  63731. */
  63732. vertexShader?: string;
  63733. /**
  63734. * Attributes to use in the shader
  63735. */
  63736. attributeNames?: Array<string>;
  63737. /**
  63738. * Uniforms to use in the shader
  63739. */
  63740. uniformNames?: Array<string>;
  63741. /**
  63742. * Texture sampler names to use in the shader
  63743. */
  63744. samplerNames?: Array<string>;
  63745. /**
  63746. * Defines to use in the shader
  63747. */
  63748. defines?: Array<string>;
  63749. /**
  63750. * Callback when effect is compiled
  63751. */
  63752. onCompiled?: Nullable<(effect: Effect) => void>;
  63753. /**
  63754. * The friendly name of the effect displayed in Spector.
  63755. */
  63756. name?: string;
  63757. }
  63758. /**
  63759. * Wraps an effect to be used for rendering
  63760. */
  63761. export class EffectWrapper {
  63762. /**
  63763. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63764. */
  63765. onApplyObservable: Observable<{}>;
  63766. /**
  63767. * The underlying effect
  63768. */
  63769. effect: Effect;
  63770. /**
  63771. * Creates an effect to be renderer
  63772. * @param creationOptions options to create the effect
  63773. */
  63774. constructor(creationOptions: EffectWrapperCreationOptions);
  63775. /**
  63776. * Disposes of the effect wrapper
  63777. */
  63778. dispose(): void;
  63779. }
  63780. }
  63781. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63782. /** @hidden */
  63783. export var hdrFilteringVertexShader: {
  63784. name: string;
  63785. shader: string;
  63786. };
  63787. }
  63788. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63789. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63790. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63791. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63792. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63793. /** @hidden */
  63794. export var hdrFilteringPixelShader: {
  63795. name: string;
  63796. shader: string;
  63797. };
  63798. }
  63799. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63800. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63801. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63802. import { Nullable } from "babylonjs/types";
  63803. import "babylonjs/Shaders/hdrFiltering.vertex";
  63804. import "babylonjs/Shaders/hdrFiltering.fragment";
  63805. /**
  63806. * Options for texture filtering
  63807. */
  63808. interface IHDRFilteringOptions {
  63809. /**
  63810. * Scales pixel intensity for the input HDR map.
  63811. */
  63812. hdrScale?: number;
  63813. /**
  63814. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63815. */
  63816. quality?: number;
  63817. }
  63818. /**
  63819. * Filters HDR maps to get correct renderings of PBR reflections
  63820. */
  63821. export class HDRFiltering {
  63822. private _engine;
  63823. private _effectRenderer;
  63824. private _effectWrapper;
  63825. private _lodGenerationOffset;
  63826. private _lodGenerationScale;
  63827. /**
  63828. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63829. * you care about baking speed.
  63830. */
  63831. quality: number;
  63832. /**
  63833. * Scales pixel intensity for the input HDR map.
  63834. */
  63835. hdrScale: number;
  63836. /**
  63837. * Instantiates HDR filter for reflection maps
  63838. *
  63839. * @param engine Thin engine
  63840. * @param options Options
  63841. */
  63842. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63843. private _createRenderTarget;
  63844. private _prefilterInternal;
  63845. private _createEffect;
  63846. /**
  63847. * Get a value indicating if the filter is ready to be used
  63848. * @param texture Texture to filter
  63849. * @returns true if the filter is ready
  63850. */
  63851. isReady(texture: BaseTexture): boolean;
  63852. /**
  63853. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63854. * Prefiltering will be invoked at the end of next rendering pass.
  63855. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63856. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63857. * @param texture Texture to filter
  63858. * @param onFinished Callback when filtering is done
  63859. * @return Promise called when prefiltering is done
  63860. */
  63861. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63862. }
  63863. }
  63864. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63865. import { Nullable } from "babylonjs/types";
  63866. import { Scene } from "babylonjs/scene";
  63867. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63869. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63870. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63871. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63872. /**
  63873. * This represents a texture coming from an HDR input.
  63874. *
  63875. * The only supported format is currently panorama picture stored in RGBE format.
  63876. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63877. */
  63878. export class HDRCubeTexture extends BaseTexture {
  63879. private static _facesMapping;
  63880. private _generateHarmonics;
  63881. private _noMipmap;
  63882. private _prefilterOnLoad;
  63883. private _textureMatrix;
  63884. private _size;
  63885. private _onLoad;
  63886. private _onError;
  63887. /**
  63888. * The texture URL.
  63889. */
  63890. url: string;
  63891. protected _isBlocking: boolean;
  63892. /**
  63893. * Sets wether or not the texture is blocking during loading.
  63894. */
  63895. set isBlocking(value: boolean);
  63896. /**
  63897. * Gets wether or not the texture is blocking during loading.
  63898. */
  63899. get isBlocking(): boolean;
  63900. protected _rotationY: number;
  63901. /**
  63902. * Sets texture matrix rotation angle around Y axis in radians.
  63903. */
  63904. set rotationY(value: number);
  63905. /**
  63906. * Gets texture matrix rotation angle around Y axis radians.
  63907. */
  63908. get rotationY(): number;
  63909. /**
  63910. * Gets or sets the center of the bounding box associated with the cube texture
  63911. * It must define where the camera used to render the texture was set
  63912. */
  63913. boundingBoxPosition: Vector3;
  63914. private _boundingBoxSize;
  63915. /**
  63916. * Gets or sets the size of the bounding box associated with the cube texture
  63917. * When defined, the cubemap will switch to local mode
  63918. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63919. * @example https://www.babylonjs-playground.com/#RNASML
  63920. */
  63921. set boundingBoxSize(value: Vector3);
  63922. get boundingBoxSize(): Vector3;
  63923. /**
  63924. * Instantiates an HDRTexture from the following parameters.
  63925. *
  63926. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63927. * @param sceneOrEngine The scene or engine the texture will be used in
  63928. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63929. * @param noMipmap Forces to not generate the mipmap if true
  63930. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63931. * @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)
  63932. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63933. */
  63934. 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>);
  63935. /**
  63936. * Get the current class name of the texture useful for serialization or dynamic coding.
  63937. * @returns "HDRCubeTexture"
  63938. */
  63939. getClassName(): string;
  63940. /**
  63941. * Occurs when the file is raw .hdr file.
  63942. */
  63943. private loadTexture;
  63944. clone(): HDRCubeTexture;
  63945. delayLoad(): void;
  63946. /**
  63947. * Get the texture reflection matrix used to rotate/transform the reflection.
  63948. * @returns the reflection matrix
  63949. */
  63950. getReflectionTextureMatrix(): Matrix;
  63951. /**
  63952. * Set the texture reflection matrix used to rotate/transform the reflection.
  63953. * @param value Define the reflection matrix to set
  63954. */
  63955. setReflectionTextureMatrix(value: Matrix): void;
  63956. /**
  63957. * Parses a JSON representation of an HDR Texture in order to create the texture
  63958. * @param parsedTexture Define the JSON representation
  63959. * @param scene Define the scene the texture should be created in
  63960. * @param rootUrl Define the root url in case we need to load relative dependencies
  63961. * @returns the newly created texture after parsing
  63962. */
  63963. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63964. serialize(): any;
  63965. }
  63966. }
  63967. declare module "babylonjs/Physics/physicsEngine" {
  63968. import { Nullable } from "babylonjs/types";
  63969. import { Vector3 } from "babylonjs/Maths/math.vector";
  63970. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63971. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63972. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63973. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63974. /**
  63975. * Class used to control physics engine
  63976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63977. */
  63978. export class PhysicsEngine implements IPhysicsEngine {
  63979. private _physicsPlugin;
  63980. /**
  63981. * Global value used to control the smallest number supported by the simulation
  63982. */
  63983. static Epsilon: number;
  63984. private _impostors;
  63985. private _joints;
  63986. private _subTimeStep;
  63987. /**
  63988. * Gets the gravity vector used by the simulation
  63989. */
  63990. gravity: Vector3;
  63991. /**
  63992. * Factory used to create the default physics plugin.
  63993. * @returns The default physics plugin
  63994. */
  63995. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63996. /**
  63997. * Creates a new Physics Engine
  63998. * @param gravity defines the gravity vector used by the simulation
  63999. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64000. */
  64001. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64002. /**
  64003. * Sets the gravity vector used by the simulation
  64004. * @param gravity defines the gravity vector to use
  64005. */
  64006. setGravity(gravity: Vector3): void;
  64007. /**
  64008. * Set the time step of the physics engine.
  64009. * Default is 1/60.
  64010. * To slow it down, enter 1/600 for example.
  64011. * To speed it up, 1/30
  64012. * @param newTimeStep defines the new timestep to apply to this world.
  64013. */
  64014. setTimeStep(newTimeStep?: number): void;
  64015. /**
  64016. * Get the time step of the physics engine.
  64017. * @returns the current time step
  64018. */
  64019. getTimeStep(): number;
  64020. /**
  64021. * Set the sub time step of the physics engine.
  64022. * Default is 0 meaning there is no sub steps
  64023. * To increase physics resolution precision, set a small value (like 1 ms)
  64024. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64025. */
  64026. setSubTimeStep(subTimeStep?: number): void;
  64027. /**
  64028. * Get the sub time step of the physics engine.
  64029. * @returns the current sub time step
  64030. */
  64031. getSubTimeStep(): number;
  64032. /**
  64033. * Release all resources
  64034. */
  64035. dispose(): void;
  64036. /**
  64037. * Gets the name of the current physics plugin
  64038. * @returns the name of the plugin
  64039. */
  64040. getPhysicsPluginName(): string;
  64041. /**
  64042. * Adding a new impostor for the impostor tracking.
  64043. * This will be done by the impostor itself.
  64044. * @param impostor the impostor to add
  64045. */
  64046. addImpostor(impostor: PhysicsImpostor): void;
  64047. /**
  64048. * Remove an impostor from the engine.
  64049. * This impostor and its mesh will not longer be updated by the physics engine.
  64050. * @param impostor the impostor to remove
  64051. */
  64052. removeImpostor(impostor: PhysicsImpostor): void;
  64053. /**
  64054. * Add a joint to the physics engine
  64055. * @param mainImpostor defines the main impostor to which the joint is added.
  64056. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64057. * @param joint defines the joint that will connect both impostors.
  64058. */
  64059. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64060. /**
  64061. * Removes a joint from the simulation
  64062. * @param mainImpostor defines the impostor used with the joint
  64063. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64064. * @param joint defines the joint to remove
  64065. */
  64066. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64067. /**
  64068. * Called by the scene. No need to call it.
  64069. * @param delta defines the timespam between frames
  64070. */
  64071. _step(delta: number): void;
  64072. /**
  64073. * Gets the current plugin used to run the simulation
  64074. * @returns current plugin
  64075. */
  64076. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64077. /**
  64078. * Gets the list of physic impostors
  64079. * @returns an array of PhysicsImpostor
  64080. */
  64081. getImpostors(): Array<PhysicsImpostor>;
  64082. /**
  64083. * Gets the impostor for a physics enabled object
  64084. * @param object defines the object impersonated by the impostor
  64085. * @returns the PhysicsImpostor or null if not found
  64086. */
  64087. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64088. /**
  64089. * Gets the impostor for a physics body object
  64090. * @param body defines physics body used by the impostor
  64091. * @returns the PhysicsImpostor or null if not found
  64092. */
  64093. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64094. /**
  64095. * Does a raycast in the physics world
  64096. * @param from when should the ray start?
  64097. * @param to when should the ray end?
  64098. * @returns PhysicsRaycastResult
  64099. */
  64100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64101. }
  64102. }
  64103. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64104. import { Nullable } from "babylonjs/types";
  64105. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64107. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64108. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64109. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64110. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64111. /** @hidden */
  64112. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64113. private _useDeltaForWorldStep;
  64114. world: any;
  64115. name: string;
  64116. private _physicsMaterials;
  64117. private _fixedTimeStep;
  64118. private _cannonRaycastResult;
  64119. private _raycastResult;
  64120. private _physicsBodysToRemoveAfterStep;
  64121. private _firstFrame;
  64122. BJSCANNON: any;
  64123. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64124. setGravity(gravity: Vector3): void;
  64125. setTimeStep(timeStep: number): void;
  64126. getTimeStep(): number;
  64127. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64128. private _removeMarkedPhysicsBodiesFromWorld;
  64129. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64130. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64131. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64132. private _processChildMeshes;
  64133. removePhysicsBody(impostor: PhysicsImpostor): void;
  64134. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64135. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64136. private _addMaterial;
  64137. private _checkWithEpsilon;
  64138. private _createShape;
  64139. private _createHeightmap;
  64140. private _minus90X;
  64141. private _plus90X;
  64142. private _tmpPosition;
  64143. private _tmpDeltaPosition;
  64144. private _tmpUnityRotation;
  64145. private _updatePhysicsBodyTransformation;
  64146. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64147. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64148. isSupported(): boolean;
  64149. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64150. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64151. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64152. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64153. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64154. getBodyMass(impostor: PhysicsImpostor): number;
  64155. getBodyFriction(impostor: PhysicsImpostor): number;
  64156. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64157. getBodyRestitution(impostor: PhysicsImpostor): number;
  64158. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64159. sleepBody(impostor: PhysicsImpostor): void;
  64160. wakeUpBody(impostor: PhysicsImpostor): void;
  64161. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64162. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64163. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64164. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64165. getRadius(impostor: PhysicsImpostor): number;
  64166. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64167. dispose(): void;
  64168. private _extendNamespace;
  64169. /**
  64170. * Does a raycast in the physics world
  64171. * @param from when should the ray start?
  64172. * @param to when should the ray end?
  64173. * @returns PhysicsRaycastResult
  64174. */
  64175. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64176. }
  64177. }
  64178. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64179. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64180. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64181. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64183. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64184. import { Nullable } from "babylonjs/types";
  64185. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64186. /** @hidden */
  64187. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64188. private _useDeltaForWorldStep;
  64189. world: any;
  64190. name: string;
  64191. BJSOIMO: any;
  64192. private _raycastResult;
  64193. private _fixedTimeStep;
  64194. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64195. setGravity(gravity: Vector3): void;
  64196. setTimeStep(timeStep: number): void;
  64197. getTimeStep(): number;
  64198. private _tmpImpostorsArray;
  64199. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64200. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64201. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64202. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64203. private _tmpPositionVector;
  64204. removePhysicsBody(impostor: PhysicsImpostor): void;
  64205. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64206. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64207. isSupported(): boolean;
  64208. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64209. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64210. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64211. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64212. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64213. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64214. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64215. getBodyMass(impostor: PhysicsImpostor): number;
  64216. getBodyFriction(impostor: PhysicsImpostor): number;
  64217. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64218. getBodyRestitution(impostor: PhysicsImpostor): number;
  64219. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64220. sleepBody(impostor: PhysicsImpostor): void;
  64221. wakeUpBody(impostor: PhysicsImpostor): void;
  64222. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64223. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64224. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64225. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64226. getRadius(impostor: PhysicsImpostor): number;
  64227. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64228. dispose(): void;
  64229. /**
  64230. * Does a raycast in the physics world
  64231. * @param from when should the ray start?
  64232. * @param to when should the ray end?
  64233. * @returns PhysicsRaycastResult
  64234. */
  64235. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64236. }
  64237. }
  64238. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64239. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64240. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64241. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64242. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64243. import { Nullable } from "babylonjs/types";
  64244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64245. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64246. /**
  64247. * AmmoJS Physics plugin
  64248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64249. * @see https://github.com/kripken/ammo.js/
  64250. */
  64251. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64252. private _useDeltaForWorldStep;
  64253. /**
  64254. * Reference to the Ammo library
  64255. */
  64256. bjsAMMO: any;
  64257. /**
  64258. * Created ammoJS world which physics bodies are added to
  64259. */
  64260. world: any;
  64261. /**
  64262. * Name of the plugin
  64263. */
  64264. name: string;
  64265. private _timeStep;
  64266. private _fixedTimeStep;
  64267. private _maxSteps;
  64268. private _tmpQuaternion;
  64269. private _tmpAmmoTransform;
  64270. private _tmpAmmoQuaternion;
  64271. private _tmpAmmoConcreteContactResultCallback;
  64272. private _collisionConfiguration;
  64273. private _dispatcher;
  64274. private _overlappingPairCache;
  64275. private _solver;
  64276. private _softBodySolver;
  64277. private _tmpAmmoVectorA;
  64278. private _tmpAmmoVectorB;
  64279. private _tmpAmmoVectorC;
  64280. private _tmpAmmoVectorD;
  64281. private _tmpContactCallbackResult;
  64282. private _tmpAmmoVectorRCA;
  64283. private _tmpAmmoVectorRCB;
  64284. private _raycastResult;
  64285. private static readonly DISABLE_COLLISION_FLAG;
  64286. private static readonly KINEMATIC_FLAG;
  64287. private static readonly DISABLE_DEACTIVATION_FLAG;
  64288. /**
  64289. * Initializes the ammoJS plugin
  64290. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64291. * @param ammoInjection can be used to inject your own ammo reference
  64292. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64293. */
  64294. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64295. /**
  64296. * Sets the gravity of the physics world (m/(s^2))
  64297. * @param gravity Gravity to set
  64298. */
  64299. setGravity(gravity: Vector3): void;
  64300. /**
  64301. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64302. * @param timeStep timestep to use in seconds
  64303. */
  64304. setTimeStep(timeStep: number): void;
  64305. /**
  64306. * 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)
  64307. * @param fixedTimeStep fixedTimeStep to use in seconds
  64308. */
  64309. setFixedTimeStep(fixedTimeStep: number): void;
  64310. /**
  64311. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64312. * @param maxSteps the maximum number of steps by the physics engine per frame
  64313. */
  64314. setMaxSteps(maxSteps: number): void;
  64315. /**
  64316. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64317. * @returns the current timestep in seconds
  64318. */
  64319. getTimeStep(): number;
  64320. /**
  64321. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64322. */
  64323. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64324. private _isImpostorInContact;
  64325. private _isImpostorPairInContact;
  64326. private _stepSimulation;
  64327. /**
  64328. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64329. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64330. * After the step the babylon meshes are set to the position of the physics imposters
  64331. * @param delta amount of time to step forward
  64332. * @param impostors array of imposters to update before/after the step
  64333. */
  64334. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64335. /**
  64336. * Update babylon mesh to match physics world object
  64337. * @param impostor imposter to match
  64338. */
  64339. private _afterSoftStep;
  64340. /**
  64341. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64342. * @param impostor imposter to match
  64343. */
  64344. private _ropeStep;
  64345. /**
  64346. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64347. * @param impostor imposter to match
  64348. */
  64349. private _softbodyOrClothStep;
  64350. private _tmpMatrix;
  64351. /**
  64352. * Applies an impulse on the imposter
  64353. * @param impostor imposter to apply impulse to
  64354. * @param force amount of force to be applied to the imposter
  64355. * @param contactPoint the location to apply the impulse on the imposter
  64356. */
  64357. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64358. /**
  64359. * Applies a force on the imposter
  64360. * @param impostor imposter to apply force
  64361. * @param force amount of force to be applied to the imposter
  64362. * @param contactPoint the location to apply the force on the imposter
  64363. */
  64364. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64365. /**
  64366. * Creates a physics body using the plugin
  64367. * @param impostor the imposter to create the physics body on
  64368. */
  64369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64370. /**
  64371. * Removes the physics body from the imposter and disposes of the body's memory
  64372. * @param impostor imposter to remove the physics body from
  64373. */
  64374. removePhysicsBody(impostor: PhysicsImpostor): void;
  64375. /**
  64376. * Generates a joint
  64377. * @param impostorJoint the imposter joint to create the joint with
  64378. */
  64379. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64380. /**
  64381. * Removes a joint
  64382. * @param impostorJoint the imposter joint to remove the joint from
  64383. */
  64384. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64385. private _addMeshVerts;
  64386. /**
  64387. * Initialise the soft body vertices to match its object's (mesh) vertices
  64388. * Softbody vertices (nodes) are in world space and to match this
  64389. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64390. * @param impostor to create the softbody for
  64391. */
  64392. private _softVertexData;
  64393. /**
  64394. * Create an impostor's soft body
  64395. * @param impostor to create the softbody for
  64396. */
  64397. private _createSoftbody;
  64398. /**
  64399. * Create cloth for an impostor
  64400. * @param impostor to create the softbody for
  64401. */
  64402. private _createCloth;
  64403. /**
  64404. * Create rope for an impostor
  64405. * @param impostor to create the softbody for
  64406. */
  64407. private _createRope;
  64408. /**
  64409. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64410. * @param impostor to create the custom physics shape for
  64411. */
  64412. private _createCustom;
  64413. private _addHullVerts;
  64414. private _createShape;
  64415. /**
  64416. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64417. * @param impostor imposter containing the physics body and babylon object
  64418. */
  64419. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64420. /**
  64421. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64422. * @param impostor imposter containing the physics body and babylon object
  64423. * @param newPosition new position
  64424. * @param newRotation new rotation
  64425. */
  64426. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64427. /**
  64428. * If this plugin is supported
  64429. * @returns true if its supported
  64430. */
  64431. isSupported(): boolean;
  64432. /**
  64433. * Sets the linear velocity of the physics body
  64434. * @param impostor imposter to set the velocity on
  64435. * @param velocity velocity to set
  64436. */
  64437. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64438. /**
  64439. * Sets the angular velocity of the physics body
  64440. * @param impostor imposter to set the velocity on
  64441. * @param velocity velocity to set
  64442. */
  64443. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64444. /**
  64445. * gets the linear velocity
  64446. * @param impostor imposter to get linear velocity from
  64447. * @returns linear velocity
  64448. */
  64449. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64450. /**
  64451. * gets the angular velocity
  64452. * @param impostor imposter to get angular velocity from
  64453. * @returns angular velocity
  64454. */
  64455. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64456. /**
  64457. * Sets the mass of physics body
  64458. * @param impostor imposter to set the mass on
  64459. * @param mass mass to set
  64460. */
  64461. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64462. /**
  64463. * Gets the mass of the physics body
  64464. * @param impostor imposter to get the mass from
  64465. * @returns mass
  64466. */
  64467. getBodyMass(impostor: PhysicsImpostor): number;
  64468. /**
  64469. * Gets friction of the impostor
  64470. * @param impostor impostor to get friction from
  64471. * @returns friction value
  64472. */
  64473. getBodyFriction(impostor: PhysicsImpostor): number;
  64474. /**
  64475. * Sets friction of the impostor
  64476. * @param impostor impostor to set friction on
  64477. * @param friction friction value
  64478. */
  64479. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64480. /**
  64481. * Gets restitution of the impostor
  64482. * @param impostor impostor to get restitution from
  64483. * @returns restitution value
  64484. */
  64485. getBodyRestitution(impostor: PhysicsImpostor): number;
  64486. /**
  64487. * Sets resitution of the impostor
  64488. * @param impostor impostor to set resitution on
  64489. * @param restitution resitution value
  64490. */
  64491. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64492. /**
  64493. * Gets pressure inside the impostor
  64494. * @param impostor impostor to get pressure from
  64495. * @returns pressure value
  64496. */
  64497. getBodyPressure(impostor: PhysicsImpostor): number;
  64498. /**
  64499. * Sets pressure inside a soft body impostor
  64500. * Cloth and rope must remain 0 pressure
  64501. * @param impostor impostor to set pressure on
  64502. * @param pressure pressure value
  64503. */
  64504. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64505. /**
  64506. * Gets stiffness of the impostor
  64507. * @param impostor impostor to get stiffness from
  64508. * @returns pressure value
  64509. */
  64510. getBodyStiffness(impostor: PhysicsImpostor): number;
  64511. /**
  64512. * Sets stiffness of the impostor
  64513. * @param impostor impostor to set stiffness on
  64514. * @param stiffness stiffness value from 0 to 1
  64515. */
  64516. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64517. /**
  64518. * Gets velocityIterations of the impostor
  64519. * @param impostor impostor to get velocity iterations from
  64520. * @returns velocityIterations value
  64521. */
  64522. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64523. /**
  64524. * Sets velocityIterations of the impostor
  64525. * @param impostor impostor to set velocity iterations on
  64526. * @param velocityIterations velocityIterations value
  64527. */
  64528. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64529. /**
  64530. * Gets positionIterations of the impostor
  64531. * @param impostor impostor to get position iterations from
  64532. * @returns positionIterations value
  64533. */
  64534. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64535. /**
  64536. * Sets positionIterations of the impostor
  64537. * @param impostor impostor to set position on
  64538. * @param positionIterations positionIterations value
  64539. */
  64540. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64541. /**
  64542. * Append an anchor to a cloth object
  64543. * @param impostor is the cloth impostor to add anchor to
  64544. * @param otherImpostor is the rigid impostor to anchor to
  64545. * @param width ratio across width from 0 to 1
  64546. * @param height ratio up height from 0 to 1
  64547. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64548. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64549. */
  64550. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64551. /**
  64552. * Append an hook to a rope object
  64553. * @param impostor is the rope impostor to add hook to
  64554. * @param otherImpostor is the rigid impostor to hook to
  64555. * @param length ratio along the rope from 0 to 1
  64556. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64557. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64558. */
  64559. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64560. /**
  64561. * Sleeps the physics body and stops it from being active
  64562. * @param impostor impostor to sleep
  64563. */
  64564. sleepBody(impostor: PhysicsImpostor): void;
  64565. /**
  64566. * Activates the physics body
  64567. * @param impostor impostor to activate
  64568. */
  64569. wakeUpBody(impostor: PhysicsImpostor): void;
  64570. /**
  64571. * Updates the distance parameters of the joint
  64572. * @param joint joint to update
  64573. * @param maxDistance maximum distance of the joint
  64574. * @param minDistance minimum distance of the joint
  64575. */
  64576. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64577. /**
  64578. * Sets a motor on the joint
  64579. * @param joint joint to set motor on
  64580. * @param speed speed of the motor
  64581. * @param maxForce maximum force of the motor
  64582. * @param motorIndex index of the motor
  64583. */
  64584. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64585. /**
  64586. * Sets the motors limit
  64587. * @param joint joint to set limit on
  64588. * @param upperLimit upper limit
  64589. * @param lowerLimit lower limit
  64590. */
  64591. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64592. /**
  64593. * Syncs the position and rotation of a mesh with the impostor
  64594. * @param mesh mesh to sync
  64595. * @param impostor impostor to update the mesh with
  64596. */
  64597. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64598. /**
  64599. * Gets the radius of the impostor
  64600. * @param impostor impostor to get radius from
  64601. * @returns the radius
  64602. */
  64603. getRadius(impostor: PhysicsImpostor): number;
  64604. /**
  64605. * Gets the box size of the impostor
  64606. * @param impostor impostor to get box size from
  64607. * @param result the resulting box size
  64608. */
  64609. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64610. /**
  64611. * Disposes of the impostor
  64612. */
  64613. dispose(): void;
  64614. /**
  64615. * Does a raycast in the physics world
  64616. * @param from when should the ray start?
  64617. * @param to when should the ray end?
  64618. * @returns PhysicsRaycastResult
  64619. */
  64620. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64621. }
  64622. }
  64623. declare module "babylonjs/Probes/reflectionProbe" {
  64624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64625. import { Vector3 } from "babylonjs/Maths/math.vector";
  64626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64627. import { Nullable } from "babylonjs/types";
  64628. import { Scene } from "babylonjs/scene";
  64629. module "babylonjs/abstractScene" {
  64630. interface AbstractScene {
  64631. /**
  64632. * The list of reflection probes added to the scene
  64633. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64634. */
  64635. reflectionProbes: Array<ReflectionProbe>;
  64636. /**
  64637. * Removes the given reflection probe from this scene.
  64638. * @param toRemove The reflection probe to remove
  64639. * @returns The index of the removed reflection probe
  64640. */
  64641. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64642. /**
  64643. * Adds the given reflection probe to this scene.
  64644. * @param newReflectionProbe The reflection probe to add
  64645. */
  64646. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64647. }
  64648. }
  64649. /**
  64650. * Class used to generate realtime reflection / refraction cube textures
  64651. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64652. */
  64653. export class ReflectionProbe {
  64654. /** defines the name of the probe */
  64655. name: string;
  64656. private _scene;
  64657. private _renderTargetTexture;
  64658. private _projectionMatrix;
  64659. private _viewMatrix;
  64660. private _target;
  64661. private _add;
  64662. private _attachedMesh;
  64663. private _invertYAxis;
  64664. /** Gets or sets probe position (center of the cube map) */
  64665. position: Vector3;
  64666. /**
  64667. * Creates a new reflection probe
  64668. * @param name defines the name of the probe
  64669. * @param size defines the texture resolution (for each face)
  64670. * @param scene defines the hosting scene
  64671. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64672. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64673. */
  64674. constructor(
  64675. /** defines the name of the probe */
  64676. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64677. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64678. get samples(): number;
  64679. set samples(value: number);
  64680. /** Gets or sets the refresh rate to use (on every frame by default) */
  64681. get refreshRate(): number;
  64682. set refreshRate(value: number);
  64683. /**
  64684. * Gets the hosting scene
  64685. * @returns a Scene
  64686. */
  64687. getScene(): Scene;
  64688. /** Gets the internal CubeTexture used to render to */
  64689. get cubeTexture(): RenderTargetTexture;
  64690. /** Gets the list of meshes to render */
  64691. get renderList(): Nullable<AbstractMesh[]>;
  64692. /**
  64693. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64694. * @param mesh defines the mesh to attach to
  64695. */
  64696. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64697. /**
  64698. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64699. * @param renderingGroupId The rendering group id corresponding to its index
  64700. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64701. */
  64702. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64703. /**
  64704. * Clean all associated resources
  64705. */
  64706. dispose(): void;
  64707. /**
  64708. * Converts the reflection probe information to a readable string for debug purpose.
  64709. * @param fullDetails Supports for multiple levels of logging within scene loading
  64710. * @returns the human readable reflection probe info
  64711. */
  64712. toString(fullDetails?: boolean): string;
  64713. /**
  64714. * Get the class name of the relfection probe.
  64715. * @returns "ReflectionProbe"
  64716. */
  64717. getClassName(): string;
  64718. /**
  64719. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64720. * @returns The JSON representation of the texture
  64721. */
  64722. serialize(): any;
  64723. /**
  64724. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64725. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64726. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64727. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64728. * @returns The parsed reflection probe if successful
  64729. */
  64730. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64731. }
  64732. }
  64733. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64734. /** @hidden */
  64735. export var _BabylonLoaderRegistered: boolean;
  64736. /**
  64737. * Helps setting up some configuration for the babylon file loader.
  64738. */
  64739. export class BabylonFileLoaderConfiguration {
  64740. /**
  64741. * The loader does not allow injecting custom physix engine into the plugins.
  64742. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64743. * So you could set this variable to your engine import to make it work.
  64744. */
  64745. static LoaderInjectedPhysicsEngine: any;
  64746. }
  64747. }
  64748. declare module "babylonjs/Loading/Plugins/index" {
  64749. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64750. }
  64751. declare module "babylonjs/Loading/index" {
  64752. export * from "babylonjs/Loading/loadingScreen";
  64753. export * from "babylonjs/Loading/Plugins/index";
  64754. export * from "babylonjs/Loading/sceneLoader";
  64755. export * from "babylonjs/Loading/sceneLoaderFlags";
  64756. }
  64757. declare module "babylonjs/Materials/Background/index" {
  64758. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64759. }
  64760. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64761. import { Scene } from "babylonjs/scene";
  64762. import { Color3 } from "babylonjs/Maths/math.color";
  64763. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64765. /**
  64766. * The Physically based simple base material of BJS.
  64767. *
  64768. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64769. * It is used as the base class for both the specGloss and metalRough conventions.
  64770. */
  64771. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64772. /**
  64773. * Number of Simultaneous lights allowed on the material.
  64774. */
  64775. maxSimultaneousLights: number;
  64776. /**
  64777. * If sets to true, disables all the lights affecting the material.
  64778. */
  64779. disableLighting: boolean;
  64780. /**
  64781. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64782. */
  64783. environmentTexture: BaseTexture;
  64784. /**
  64785. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64786. */
  64787. invertNormalMapX: boolean;
  64788. /**
  64789. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64790. */
  64791. invertNormalMapY: boolean;
  64792. /**
  64793. * Normal map used in the model.
  64794. */
  64795. normalTexture: BaseTexture;
  64796. /**
  64797. * Emissivie color used to self-illuminate the model.
  64798. */
  64799. emissiveColor: Color3;
  64800. /**
  64801. * Emissivie texture used to self-illuminate the model.
  64802. */
  64803. emissiveTexture: BaseTexture;
  64804. /**
  64805. * Occlusion Channel Strenght.
  64806. */
  64807. occlusionStrength: number;
  64808. /**
  64809. * Occlusion Texture of the material (adding extra occlusion effects).
  64810. */
  64811. occlusionTexture: BaseTexture;
  64812. /**
  64813. * Defines the alpha limits in alpha test mode.
  64814. */
  64815. alphaCutOff: number;
  64816. /**
  64817. * Gets the current double sided mode.
  64818. */
  64819. get doubleSided(): boolean;
  64820. /**
  64821. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64822. */
  64823. set doubleSided(value: boolean);
  64824. /**
  64825. * Stores the pre-calculated light information of a mesh in a texture.
  64826. */
  64827. lightmapTexture: BaseTexture;
  64828. /**
  64829. * If true, the light map contains occlusion information instead of lighting info.
  64830. */
  64831. useLightmapAsShadowmap: boolean;
  64832. /**
  64833. * Instantiates a new PBRMaterial instance.
  64834. *
  64835. * @param name The material name
  64836. * @param scene The scene the material will be use in.
  64837. */
  64838. constructor(name: string, scene: Scene);
  64839. getClassName(): string;
  64840. }
  64841. }
  64842. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64843. import { Scene } from "babylonjs/scene";
  64844. import { Color3 } from "babylonjs/Maths/math.color";
  64845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64846. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64847. /**
  64848. * The PBR material of BJS following the metal roughness convention.
  64849. *
  64850. * This fits to the PBR convention in the GLTF definition:
  64851. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64852. */
  64853. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64854. /**
  64855. * The base color has two different interpretations depending on the value of metalness.
  64856. * When the material is a metal, the base color is the specific measured reflectance value
  64857. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64858. * of the material.
  64859. */
  64860. baseColor: Color3;
  64861. /**
  64862. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64863. * well as opacity information in the alpha channel.
  64864. */
  64865. baseTexture: BaseTexture;
  64866. /**
  64867. * Specifies the metallic scalar value of the material.
  64868. * Can also be used to scale the metalness values of the metallic texture.
  64869. */
  64870. metallic: number;
  64871. /**
  64872. * Specifies the roughness scalar value of the material.
  64873. * Can also be used to scale the roughness values of the metallic texture.
  64874. */
  64875. roughness: number;
  64876. /**
  64877. * Texture containing both the metallic value in the B channel and the
  64878. * roughness value in the G channel to keep better precision.
  64879. */
  64880. metallicRoughnessTexture: BaseTexture;
  64881. /**
  64882. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64883. *
  64884. * @param name The material name
  64885. * @param scene The scene the material will be use in.
  64886. */
  64887. constructor(name: string, scene: Scene);
  64888. /**
  64889. * Return the currrent class name of the material.
  64890. */
  64891. getClassName(): string;
  64892. /**
  64893. * Makes a duplicate of the current material.
  64894. * @param name - name to use for the new material.
  64895. */
  64896. clone(name: string): PBRMetallicRoughnessMaterial;
  64897. /**
  64898. * Serialize the material to a parsable JSON object.
  64899. */
  64900. serialize(): any;
  64901. /**
  64902. * Parses a JSON object correponding to the serialize function.
  64903. */
  64904. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64905. }
  64906. }
  64907. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64908. import { Scene } from "babylonjs/scene";
  64909. import { Color3 } from "babylonjs/Maths/math.color";
  64910. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64911. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64912. /**
  64913. * The PBR material of BJS following the specular glossiness convention.
  64914. *
  64915. * This fits to the PBR convention in the GLTF definition:
  64916. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64917. */
  64918. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64919. /**
  64920. * Specifies the diffuse color of the material.
  64921. */
  64922. diffuseColor: Color3;
  64923. /**
  64924. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64925. * channel.
  64926. */
  64927. diffuseTexture: BaseTexture;
  64928. /**
  64929. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64930. */
  64931. specularColor: Color3;
  64932. /**
  64933. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64934. */
  64935. glossiness: number;
  64936. /**
  64937. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64938. */
  64939. specularGlossinessTexture: BaseTexture;
  64940. /**
  64941. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64942. *
  64943. * @param name The material name
  64944. * @param scene The scene the material will be use in.
  64945. */
  64946. constructor(name: string, scene: Scene);
  64947. /**
  64948. * Return the currrent class name of the material.
  64949. */
  64950. getClassName(): string;
  64951. /**
  64952. * Makes a duplicate of the current material.
  64953. * @param name - name to use for the new material.
  64954. */
  64955. clone(name: string): PBRSpecularGlossinessMaterial;
  64956. /**
  64957. * Serialize the material to a parsable JSON object.
  64958. */
  64959. serialize(): any;
  64960. /**
  64961. * Parses a JSON object correponding to the serialize function.
  64962. */
  64963. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64964. }
  64965. }
  64966. declare module "babylonjs/Materials/PBR/index" {
  64967. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64968. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64969. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64970. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64971. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64972. }
  64973. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64974. import { Nullable } from "babylonjs/types";
  64975. import { Scene } from "babylonjs/scene";
  64976. import { Matrix } from "babylonjs/Maths/math.vector";
  64977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64978. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64979. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64980. /**
  64981. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64982. * It can help converting any input color in a desired output one. This can then be used to create effects
  64983. * from sepia, black and white to sixties or futuristic rendering...
  64984. *
  64985. * The only supported format is currently 3dl.
  64986. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64987. */
  64988. export class ColorGradingTexture extends BaseTexture {
  64989. /**
  64990. * The texture URL.
  64991. */
  64992. url: string;
  64993. /**
  64994. * Empty line regex stored for GC.
  64995. */
  64996. private static _noneEmptyLineRegex;
  64997. private _textureMatrix;
  64998. private _onLoad;
  64999. /**
  65000. * Instantiates a ColorGradingTexture from the following parameters.
  65001. *
  65002. * @param url The location of the color gradind data (currently only supporting 3dl)
  65003. * @param sceneOrEngine The scene or engine the texture will be used in
  65004. * @param onLoad defines a callback triggered when the texture has been loaded
  65005. */
  65006. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65007. /**
  65008. * Fires the onload event from the constructor if requested.
  65009. */
  65010. private _triggerOnLoad;
  65011. /**
  65012. * Returns the texture matrix used in most of the material.
  65013. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65014. */
  65015. getTextureMatrix(): Matrix;
  65016. /**
  65017. * Occurs when the file being loaded is a .3dl LUT file.
  65018. */
  65019. private load3dlTexture;
  65020. /**
  65021. * Starts the loading process of the texture.
  65022. */
  65023. private loadTexture;
  65024. /**
  65025. * Clones the color gradind texture.
  65026. */
  65027. clone(): ColorGradingTexture;
  65028. /**
  65029. * Called during delayed load for textures.
  65030. */
  65031. delayLoad(): void;
  65032. /**
  65033. * Parses a color grading texture serialized by Babylon.
  65034. * @param parsedTexture The texture information being parsedTexture
  65035. * @param scene The scene to load the texture in
  65036. * @param rootUrl The root url of the data assets to load
  65037. * @return A color gradind texture
  65038. */
  65039. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65040. /**
  65041. * Serializes the LUT texture to json format.
  65042. */
  65043. serialize(): any;
  65044. }
  65045. }
  65046. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65048. import { Scene } from "babylonjs/scene";
  65049. import { Nullable } from "babylonjs/types";
  65050. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65051. /**
  65052. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65053. */
  65054. export class EquiRectangularCubeTexture extends BaseTexture {
  65055. /** The six faces of the cube. */
  65056. private static _FacesMapping;
  65057. private _noMipmap;
  65058. private _onLoad;
  65059. private _onError;
  65060. /** The size of the cubemap. */
  65061. private _size;
  65062. /** The buffer of the image. */
  65063. private _buffer;
  65064. /** The width of the input image. */
  65065. private _width;
  65066. /** The height of the input image. */
  65067. private _height;
  65068. /** The URL to the image. */
  65069. url: string;
  65070. /**
  65071. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65072. * @param url The location of the image
  65073. * @param scene The scene the texture will be used in
  65074. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65075. * @param noMipmap Forces to not generate the mipmap if true
  65076. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65077. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65078. * @param onLoad — defines a callback called when texture is loaded
  65079. * @param onError — defines a callback called if there is an error
  65080. */
  65081. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65082. /**
  65083. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65084. */
  65085. private loadImage;
  65086. /**
  65087. * Convert the image buffer into a cubemap and create a CubeTexture.
  65088. */
  65089. private loadTexture;
  65090. /**
  65091. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65092. * @param buffer The ArrayBuffer that should be converted.
  65093. * @returns The buffer as Float32Array.
  65094. */
  65095. private getFloat32ArrayFromArrayBuffer;
  65096. /**
  65097. * Get the current class name of the texture useful for serialization or dynamic coding.
  65098. * @returns "EquiRectangularCubeTexture"
  65099. */
  65100. getClassName(): string;
  65101. /**
  65102. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65103. * @returns A clone of the current EquiRectangularCubeTexture.
  65104. */
  65105. clone(): EquiRectangularCubeTexture;
  65106. }
  65107. }
  65108. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65109. import { Nullable } from "babylonjs/types";
  65110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65111. import { Matrix } from "babylonjs/Maths/math.vector";
  65112. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65113. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65114. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65115. import { Scene } from "babylonjs/scene";
  65116. /**
  65117. * Defines the options related to the creation of an HtmlElementTexture
  65118. */
  65119. export interface IHtmlElementTextureOptions {
  65120. /**
  65121. * Defines wether mip maps should be created or not.
  65122. */
  65123. generateMipMaps?: boolean;
  65124. /**
  65125. * Defines the sampling mode of the texture.
  65126. */
  65127. samplingMode?: number;
  65128. /**
  65129. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65130. */
  65131. engine: Nullable<ThinEngine>;
  65132. /**
  65133. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65134. */
  65135. scene: Nullable<Scene>;
  65136. }
  65137. /**
  65138. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65139. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65140. * is automatically managed.
  65141. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65142. * in your application.
  65143. *
  65144. * As the update is not automatic, you need to call them manually.
  65145. */
  65146. export class HtmlElementTexture extends BaseTexture {
  65147. /**
  65148. * The texture URL.
  65149. */
  65150. element: HTMLVideoElement | HTMLCanvasElement;
  65151. private static readonly DefaultOptions;
  65152. private _textureMatrix;
  65153. private _isVideo;
  65154. private _generateMipMaps;
  65155. private _samplingMode;
  65156. /**
  65157. * Instantiates a HtmlElementTexture from the following parameters.
  65158. *
  65159. * @param name Defines the name of the texture
  65160. * @param element Defines the video or canvas the texture is filled with
  65161. * @param options Defines the other none mandatory texture creation options
  65162. */
  65163. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65164. private _createInternalTexture;
  65165. /**
  65166. * Returns the texture matrix used in most of the material.
  65167. */
  65168. getTextureMatrix(): Matrix;
  65169. /**
  65170. * Updates the content of the texture.
  65171. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65172. */
  65173. update(invertY?: Nullable<boolean>): void;
  65174. }
  65175. }
  65176. declare module "babylonjs/Misc/tga" {
  65177. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65178. /**
  65179. * Based on jsTGALoader - Javascript loader for TGA file
  65180. * By Vincent Thibault
  65181. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65182. */
  65183. export class TGATools {
  65184. private static _TYPE_INDEXED;
  65185. private static _TYPE_RGB;
  65186. private static _TYPE_GREY;
  65187. private static _TYPE_RLE_INDEXED;
  65188. private static _TYPE_RLE_RGB;
  65189. private static _TYPE_RLE_GREY;
  65190. private static _ORIGIN_MASK;
  65191. private static _ORIGIN_SHIFT;
  65192. private static _ORIGIN_BL;
  65193. private static _ORIGIN_BR;
  65194. private static _ORIGIN_UL;
  65195. private static _ORIGIN_UR;
  65196. /**
  65197. * Gets the header of a TGA file
  65198. * @param data defines the TGA data
  65199. * @returns the header
  65200. */
  65201. static GetTGAHeader(data: Uint8Array): any;
  65202. /**
  65203. * Uploads TGA content to a Babylon Texture
  65204. * @hidden
  65205. */
  65206. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65207. /** @hidden */
  65208. 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;
  65209. /** @hidden */
  65210. 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;
  65211. /** @hidden */
  65212. 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;
  65213. /** @hidden */
  65214. 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;
  65215. /** @hidden */
  65216. 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;
  65217. /** @hidden */
  65218. 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;
  65219. }
  65220. }
  65221. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65222. import { Nullable } from "babylonjs/types";
  65223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65224. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65225. /**
  65226. * Implementation of the TGA Texture Loader.
  65227. * @hidden
  65228. */
  65229. export class _TGATextureLoader implements IInternalTextureLoader {
  65230. /**
  65231. * Defines wether the loader supports cascade loading the different faces.
  65232. */
  65233. readonly supportCascades: boolean;
  65234. /**
  65235. * This returns if the loader support the current file information.
  65236. * @param extension defines the file extension of the file being loaded
  65237. * @returns true if the loader can load the specified file
  65238. */
  65239. canLoad(extension: string): boolean;
  65240. /**
  65241. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65242. * @param data contains the texture data
  65243. * @param texture defines the BabylonJS internal texture
  65244. * @param createPolynomials will be true if polynomials have been requested
  65245. * @param onLoad defines the callback to trigger once the texture is ready
  65246. * @param onError defines the callback to trigger in case of error
  65247. */
  65248. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65249. /**
  65250. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65251. * @param data contains the texture data
  65252. * @param texture defines the BabylonJS internal texture
  65253. * @param callback defines the method to call once ready to upload
  65254. */
  65255. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65256. }
  65257. }
  65258. declare module "babylonjs/Misc/basis" {
  65259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65260. /**
  65261. * Info about the .basis files
  65262. */
  65263. class BasisFileInfo {
  65264. /**
  65265. * If the file has alpha
  65266. */
  65267. hasAlpha: boolean;
  65268. /**
  65269. * Info about each image of the basis file
  65270. */
  65271. images: Array<{
  65272. levels: Array<{
  65273. width: number;
  65274. height: number;
  65275. transcodedPixels: ArrayBufferView;
  65276. }>;
  65277. }>;
  65278. }
  65279. /**
  65280. * Result of transcoding a basis file
  65281. */
  65282. class TranscodeResult {
  65283. /**
  65284. * Info about the .basis file
  65285. */
  65286. fileInfo: BasisFileInfo;
  65287. /**
  65288. * Format to use when loading the file
  65289. */
  65290. format: number;
  65291. }
  65292. /**
  65293. * Configuration options for the Basis transcoder
  65294. */
  65295. export class BasisTranscodeConfiguration {
  65296. /**
  65297. * Supported compression formats used to determine the supported output format of the transcoder
  65298. */
  65299. supportedCompressionFormats?: {
  65300. /**
  65301. * etc1 compression format
  65302. */
  65303. etc1?: boolean;
  65304. /**
  65305. * s3tc compression format
  65306. */
  65307. s3tc?: boolean;
  65308. /**
  65309. * pvrtc compression format
  65310. */
  65311. pvrtc?: boolean;
  65312. /**
  65313. * etc2 compression format
  65314. */
  65315. etc2?: boolean;
  65316. };
  65317. /**
  65318. * If mipmap levels should be loaded for transcoded images (Default: true)
  65319. */
  65320. loadMipmapLevels?: boolean;
  65321. /**
  65322. * Index of a single image to load (Default: all images)
  65323. */
  65324. loadSingleImage?: number;
  65325. }
  65326. /**
  65327. * Used to load .Basis files
  65328. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65329. */
  65330. export class BasisTools {
  65331. private static _IgnoreSupportedFormats;
  65332. /**
  65333. * URL to use when loading the basis transcoder
  65334. */
  65335. static JSModuleURL: string;
  65336. /**
  65337. * URL to use when loading the wasm module for the transcoder
  65338. */
  65339. static WasmModuleURL: string;
  65340. /**
  65341. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65342. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65343. * @returns internal format corresponding to the Basis format
  65344. */
  65345. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65346. private static _WorkerPromise;
  65347. private static _Worker;
  65348. private static _actionId;
  65349. private static _CreateWorkerAsync;
  65350. /**
  65351. * Transcodes a loaded image file to compressed pixel data
  65352. * @param data image data to transcode
  65353. * @param config configuration options for the transcoding
  65354. * @returns a promise resulting in the transcoded image
  65355. */
  65356. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65357. /**
  65358. * Loads a texture from the transcode result
  65359. * @param texture texture load to
  65360. * @param transcodeResult the result of transcoding the basis file to load from
  65361. */
  65362. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65363. }
  65364. }
  65365. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65366. import { Nullable } from "babylonjs/types";
  65367. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65368. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65369. /**
  65370. * Loader for .basis file format
  65371. */
  65372. export class _BasisTextureLoader implements IInternalTextureLoader {
  65373. /**
  65374. * Defines whether the loader supports cascade loading the different faces.
  65375. */
  65376. readonly supportCascades: boolean;
  65377. /**
  65378. * This returns if the loader support the current file information.
  65379. * @param extension defines the file extension of the file being loaded
  65380. * @returns true if the loader can load the specified file
  65381. */
  65382. canLoad(extension: string): boolean;
  65383. /**
  65384. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65385. * @param data contains the texture data
  65386. * @param texture defines the BabylonJS internal texture
  65387. * @param createPolynomials will be true if polynomials have been requested
  65388. * @param onLoad defines the callback to trigger once the texture is ready
  65389. * @param onError defines the callback to trigger in case of error
  65390. */
  65391. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65392. /**
  65393. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65394. * @param data contains the texture data
  65395. * @param texture defines the BabylonJS internal texture
  65396. * @param callback defines the method to call once ready to upload
  65397. */
  65398. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65399. }
  65400. }
  65401. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65402. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65403. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65404. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65405. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65406. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65407. }
  65408. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65409. import { Vector2 } from "babylonjs/Maths/math.vector";
  65410. /**
  65411. * Defines the basic options interface of a TexturePacker Frame
  65412. */
  65413. export interface ITexturePackerFrame {
  65414. /**
  65415. * The frame ID
  65416. */
  65417. id: number;
  65418. /**
  65419. * The frames Scale
  65420. */
  65421. scale: Vector2;
  65422. /**
  65423. * The Frames offset
  65424. */
  65425. offset: Vector2;
  65426. }
  65427. /**
  65428. * This is a support class for frame Data on texture packer sets.
  65429. */
  65430. export class TexturePackerFrame implements ITexturePackerFrame {
  65431. /**
  65432. * The frame ID
  65433. */
  65434. id: number;
  65435. /**
  65436. * The frames Scale
  65437. */
  65438. scale: Vector2;
  65439. /**
  65440. * The Frames offset
  65441. */
  65442. offset: Vector2;
  65443. /**
  65444. * Initializes a texture package frame.
  65445. * @param id The numerical frame identifier
  65446. * @param scale Scalar Vector2 for UV frame
  65447. * @param offset Vector2 for the frame position in UV units.
  65448. * @returns TexturePackerFrame
  65449. */
  65450. constructor(id: number, scale: Vector2, offset: Vector2);
  65451. }
  65452. }
  65453. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65455. import { Scene } from "babylonjs/scene";
  65456. import { Nullable } from "babylonjs/types";
  65457. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65458. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65459. /**
  65460. * Defines the basic options interface of a TexturePacker
  65461. */
  65462. export interface ITexturePackerOptions {
  65463. /**
  65464. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65465. */
  65466. map?: string[];
  65467. /**
  65468. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65469. */
  65470. uvsIn?: string;
  65471. /**
  65472. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65473. */
  65474. uvsOut?: string;
  65475. /**
  65476. * number representing the layout style. Defaults to LAYOUT_STRIP
  65477. */
  65478. layout?: number;
  65479. /**
  65480. * number of columns if using custom column count layout(2). This defaults to 4.
  65481. */
  65482. colnum?: number;
  65483. /**
  65484. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65485. */
  65486. updateInputMeshes?: boolean;
  65487. /**
  65488. * boolean flag to dispose all the source textures. Defaults to true.
  65489. */
  65490. disposeSources?: boolean;
  65491. /**
  65492. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65493. */
  65494. fillBlanks?: boolean;
  65495. /**
  65496. * string value representing the context fill style color. Defaults to 'black'.
  65497. */
  65498. customFillColor?: string;
  65499. /**
  65500. * Width and Height Value of each Frame in the TexturePacker Sets
  65501. */
  65502. frameSize?: number;
  65503. /**
  65504. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65505. */
  65506. paddingRatio?: number;
  65507. /**
  65508. * Number that declares the fill method for the padding gutter.
  65509. */
  65510. paddingMode?: number;
  65511. /**
  65512. * If in SUBUV_COLOR padding mode what color to use.
  65513. */
  65514. paddingColor?: Color3 | Color4;
  65515. }
  65516. /**
  65517. * Defines the basic interface of a TexturePacker JSON File
  65518. */
  65519. export interface ITexturePackerJSON {
  65520. /**
  65521. * The frame ID
  65522. */
  65523. name: string;
  65524. /**
  65525. * The base64 channel data
  65526. */
  65527. sets: any;
  65528. /**
  65529. * The options of the Packer
  65530. */
  65531. options: ITexturePackerOptions;
  65532. /**
  65533. * The frame data of the Packer
  65534. */
  65535. frames: Array<number>;
  65536. }
  65537. /**
  65538. * This is a support class that generates a series of packed texture sets.
  65539. * @see https://doc.babylonjs.com/babylon101/materials
  65540. */
  65541. export class TexturePacker {
  65542. /** Packer Layout Constant 0 */
  65543. static readonly LAYOUT_STRIP: number;
  65544. /** Packer Layout Constant 1 */
  65545. static readonly LAYOUT_POWER2: number;
  65546. /** Packer Layout Constant 2 */
  65547. static readonly LAYOUT_COLNUM: number;
  65548. /** Packer Layout Constant 0 */
  65549. static readonly SUBUV_WRAP: number;
  65550. /** Packer Layout Constant 1 */
  65551. static readonly SUBUV_EXTEND: number;
  65552. /** Packer Layout Constant 2 */
  65553. static readonly SUBUV_COLOR: number;
  65554. /** The Name of the Texture Package */
  65555. name: string;
  65556. /** The scene scope of the TexturePacker */
  65557. scene: Scene;
  65558. /** The Meshes to target */
  65559. meshes: AbstractMesh[];
  65560. /** Arguments passed with the Constructor */
  65561. options: ITexturePackerOptions;
  65562. /** The promise that is started upon initialization */
  65563. promise: Nullable<Promise<TexturePacker | string>>;
  65564. /** The Container object for the channel sets that are generated */
  65565. sets: object;
  65566. /** The Container array for the frames that are generated */
  65567. frames: TexturePackerFrame[];
  65568. /** The expected number of textures the system is parsing. */
  65569. private _expecting;
  65570. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65571. private _paddingValue;
  65572. /**
  65573. * Initializes a texture package series from an array of meshes or a single mesh.
  65574. * @param name The name of the package
  65575. * @param meshes The target meshes to compose the package from
  65576. * @param options The arguments that texture packer should follow while building.
  65577. * @param scene The scene which the textures are scoped to.
  65578. * @returns TexturePacker
  65579. */
  65580. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65581. /**
  65582. * Starts the package process
  65583. * @param resolve The promises resolution function
  65584. * @returns TexturePacker
  65585. */
  65586. private _createFrames;
  65587. /**
  65588. * Calculates the Size of the Channel Sets
  65589. * @returns Vector2
  65590. */
  65591. private _calculateSize;
  65592. /**
  65593. * Calculates the UV data for the frames.
  65594. * @param baseSize the base frameSize
  65595. * @param padding the base frame padding
  65596. * @param dtSize size of the Dynamic Texture for that channel
  65597. * @param dtUnits is 1/dtSize
  65598. * @param update flag to update the input meshes
  65599. */
  65600. private _calculateMeshUVFrames;
  65601. /**
  65602. * Calculates the frames Offset.
  65603. * @param index of the frame
  65604. * @returns Vector2
  65605. */
  65606. private _getFrameOffset;
  65607. /**
  65608. * Updates a Mesh to the frame data
  65609. * @param mesh that is the target
  65610. * @param frameID or the frame index
  65611. */
  65612. private _updateMeshUV;
  65613. /**
  65614. * Updates a Meshes materials to use the texture packer channels
  65615. * @param m is the mesh to target
  65616. * @param force all channels on the packer to be set.
  65617. */
  65618. private _updateTextureReferences;
  65619. /**
  65620. * Public method to set a Mesh to a frame
  65621. * @param m that is the target
  65622. * @param frameID or the frame index
  65623. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65624. */
  65625. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65626. /**
  65627. * Starts the async promise to compile the texture packer.
  65628. * @returns Promise<void>
  65629. */
  65630. processAsync(): Promise<void>;
  65631. /**
  65632. * Disposes all textures associated with this packer
  65633. */
  65634. dispose(): void;
  65635. /**
  65636. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65637. * @param imageType is the image type to use.
  65638. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65639. */
  65640. download(imageType?: string, quality?: number): void;
  65641. /**
  65642. * Public method to load a texturePacker JSON file.
  65643. * @param data of the JSON file in string format.
  65644. */
  65645. updateFromJSON(data: string): void;
  65646. }
  65647. }
  65648. declare module "babylonjs/Materials/Textures/Packer/index" {
  65649. export * from "babylonjs/Materials/Textures/Packer/packer";
  65650. export * from "babylonjs/Materials/Textures/Packer/frame";
  65651. }
  65652. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65653. import { Scene } from "babylonjs/scene";
  65654. import { Texture } from "babylonjs/Materials/Textures/texture";
  65655. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65656. /**
  65657. * 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.
  65658. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65659. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65660. */
  65661. export class CustomProceduralTexture extends ProceduralTexture {
  65662. private _animate;
  65663. private _time;
  65664. private _config;
  65665. private _texturePath;
  65666. /**
  65667. * Instantiates a new Custom Procedural Texture.
  65668. * 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.
  65669. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65670. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65671. * @param name Define the name of the texture
  65672. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65673. * @param size Define the size of the texture to create
  65674. * @param scene Define the scene the texture belongs to
  65675. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65676. * @param generateMipMaps Define if the texture should creates mip maps or not
  65677. */
  65678. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65679. private _loadJson;
  65680. /**
  65681. * Is the texture ready to be used ? (rendered at least once)
  65682. * @returns true if ready, otherwise, false.
  65683. */
  65684. isReady(): boolean;
  65685. /**
  65686. * Render the texture to its associated render target.
  65687. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65688. */
  65689. render(useCameraPostProcess?: boolean): void;
  65690. /**
  65691. * Update the list of dependant textures samplers in the shader.
  65692. */
  65693. updateTextures(): void;
  65694. /**
  65695. * Update the uniform values of the procedural texture in the shader.
  65696. */
  65697. updateShaderUniforms(): void;
  65698. /**
  65699. * Define if the texture animates or not.
  65700. */
  65701. get animate(): boolean;
  65702. set animate(value: boolean);
  65703. }
  65704. }
  65705. declare module "babylonjs/Shaders/noise.fragment" {
  65706. /** @hidden */
  65707. export var noisePixelShader: {
  65708. name: string;
  65709. shader: string;
  65710. };
  65711. }
  65712. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65713. import { Nullable } from "babylonjs/types";
  65714. import { Scene } from "babylonjs/scene";
  65715. import { Texture } from "babylonjs/Materials/Textures/texture";
  65716. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65717. import "babylonjs/Shaders/noise.fragment";
  65718. /**
  65719. * Class used to generate noise procedural textures
  65720. */
  65721. export class NoiseProceduralTexture extends ProceduralTexture {
  65722. /** Gets or sets the start time (default is 0) */
  65723. time: number;
  65724. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65725. brightness: number;
  65726. /** Defines the number of octaves to process */
  65727. octaves: number;
  65728. /** Defines the level of persistence (0.8 by default) */
  65729. persistence: number;
  65730. /** Gets or sets animation speed factor (default is 1) */
  65731. animationSpeedFactor: number;
  65732. /**
  65733. * Creates a new NoiseProceduralTexture
  65734. * @param name defines the name fo the texture
  65735. * @param size defines the size of the texture (default is 256)
  65736. * @param scene defines the hosting scene
  65737. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65738. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65739. */
  65740. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65741. private _updateShaderUniforms;
  65742. protected _getDefines(): string;
  65743. /** Generate the current state of the procedural texture */
  65744. render(useCameraPostProcess?: boolean): void;
  65745. /**
  65746. * Serializes this noise procedural texture
  65747. * @returns a serialized noise procedural texture object
  65748. */
  65749. serialize(): any;
  65750. /**
  65751. * Clone the texture.
  65752. * @returns the cloned texture
  65753. */
  65754. clone(): NoiseProceduralTexture;
  65755. /**
  65756. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65757. * @param parsedTexture defines parsed texture data
  65758. * @param scene defines the current scene
  65759. * @param rootUrl defines the root URL containing noise procedural texture information
  65760. * @returns a parsed NoiseProceduralTexture
  65761. */
  65762. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65763. }
  65764. }
  65765. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65766. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65767. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65768. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65769. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65770. }
  65771. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65772. import { Nullable } from "babylonjs/types";
  65773. import { Scene } from "babylonjs/scene";
  65774. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65776. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65777. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65778. /**
  65779. * Raw cube texture where the raw buffers are passed in
  65780. */
  65781. export class RawCubeTexture extends CubeTexture {
  65782. /**
  65783. * Creates a cube texture where the raw buffers are passed in.
  65784. * @param scene defines the scene the texture is attached to
  65785. * @param data defines the array of data to use to create each face
  65786. * @param size defines the size of the textures
  65787. * @param format defines the format of the data
  65788. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65789. * @param generateMipMaps defines if the engine should generate the mip levels
  65790. * @param invertY defines if data must be stored with Y axis inverted
  65791. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65792. * @param compression defines the compression used (null by default)
  65793. */
  65794. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65795. /**
  65796. * Updates the raw cube texture.
  65797. * @param data defines the data to store
  65798. * @param format defines the data format
  65799. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65800. * @param invertY defines if data must be stored with Y axis inverted
  65801. * @param compression defines the compression used (null by default)
  65802. * @param level defines which level of the texture to update
  65803. */
  65804. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65805. /**
  65806. * Updates a raw cube texture with RGBD encoded data.
  65807. * @param data defines the array of data [mipmap][face] to use to create each face
  65808. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65809. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65810. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65811. * @returns a promsie that resolves when the operation is complete
  65812. */
  65813. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65814. /**
  65815. * Clones the raw cube texture.
  65816. * @return a new cube texture
  65817. */
  65818. clone(): CubeTexture;
  65819. /** @hidden */
  65820. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65821. }
  65822. }
  65823. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65824. import { Scene } from "babylonjs/scene";
  65825. import { Texture } from "babylonjs/Materials/Textures/texture";
  65826. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65827. /**
  65828. * Class used to store 2D array textures containing user data
  65829. */
  65830. export class RawTexture2DArray extends Texture {
  65831. /** Gets or sets the texture format to use */
  65832. format: number;
  65833. /**
  65834. * Create a new RawTexture2DArray
  65835. * @param data defines the data of the texture
  65836. * @param width defines the width of the texture
  65837. * @param height defines the height of the texture
  65838. * @param depth defines the number of layers of the texture
  65839. * @param format defines the texture format to use
  65840. * @param scene defines the hosting scene
  65841. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65842. * @param invertY defines if texture must be stored with Y axis inverted
  65843. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65844. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65845. */
  65846. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65847. /** Gets or sets the texture format to use */
  65848. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65849. /**
  65850. * Update the texture with new data
  65851. * @param data defines the data to store in the texture
  65852. */
  65853. update(data: ArrayBufferView): void;
  65854. }
  65855. }
  65856. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65857. import { Scene } from "babylonjs/scene";
  65858. import { Texture } from "babylonjs/Materials/Textures/texture";
  65859. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65860. /**
  65861. * Class used to store 3D textures containing user data
  65862. */
  65863. export class RawTexture3D extends Texture {
  65864. /** Gets or sets the texture format to use */
  65865. format: number;
  65866. /**
  65867. * Create a new RawTexture3D
  65868. * @param data defines the data of the texture
  65869. * @param width defines the width of the texture
  65870. * @param height defines the height of the texture
  65871. * @param depth defines the depth of the texture
  65872. * @param format defines the texture format to use
  65873. * @param scene defines the hosting scene
  65874. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65875. * @param invertY defines if texture must be stored with Y axis inverted
  65876. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65877. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65878. */
  65879. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65880. /** Gets or sets the texture format to use */
  65881. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65882. /**
  65883. * Update the texture with new data
  65884. * @param data defines the data to store in the texture
  65885. */
  65886. update(data: ArrayBufferView): void;
  65887. }
  65888. }
  65889. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65890. import { Scene } from "babylonjs/scene";
  65891. import { Plane } from "babylonjs/Maths/math.plane";
  65892. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65893. /**
  65894. * Creates a refraction texture used by refraction channel of the standard material.
  65895. * It is like a mirror but to see through a material.
  65896. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65897. */
  65898. export class RefractionTexture extends RenderTargetTexture {
  65899. /**
  65900. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65901. * 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.
  65902. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65903. */
  65904. refractionPlane: Plane;
  65905. /**
  65906. * Define how deep under the surface we should see.
  65907. */
  65908. depth: number;
  65909. /**
  65910. * Creates a refraction texture used by refraction channel of the standard material.
  65911. * It is like a mirror but to see through a material.
  65912. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65913. * @param name Define the texture name
  65914. * @param size Define the size of the underlying texture
  65915. * @param scene Define the scene the refraction belongs to
  65916. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65917. */
  65918. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65919. /**
  65920. * Clone the refraction texture.
  65921. * @returns the cloned texture
  65922. */
  65923. clone(): RefractionTexture;
  65924. /**
  65925. * Serialize the texture to a JSON representation you could use in Parse later on
  65926. * @returns the serialized JSON representation
  65927. */
  65928. serialize(): any;
  65929. }
  65930. }
  65931. declare module "babylonjs/Materials/Textures/index" {
  65932. export * from "babylonjs/Materials/Textures/baseTexture";
  65933. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65934. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65935. export * from "babylonjs/Materials/Textures/cubeTexture";
  65936. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65937. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65938. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65939. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65940. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65941. export * from "babylonjs/Materials/Textures/internalTexture";
  65942. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65943. export * from "babylonjs/Materials/Textures/Loaders/index";
  65944. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65945. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65946. export * from "babylonjs/Materials/Textures/Packer/index";
  65947. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65948. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65949. export * from "babylonjs/Materials/Textures/rawTexture";
  65950. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65951. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65952. export * from "babylonjs/Materials/Textures/refractionTexture";
  65953. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65954. export * from "babylonjs/Materials/Textures/texture";
  65955. export * from "babylonjs/Materials/Textures/videoTexture";
  65956. }
  65957. declare module "babylonjs/Materials/Node/Enums/index" {
  65958. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65959. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65960. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65961. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65962. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65963. }
  65964. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65968. import { Mesh } from "babylonjs/Meshes/mesh";
  65969. import { Effect } from "babylonjs/Materials/effect";
  65970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65971. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65972. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65973. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65974. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65975. /**
  65976. * Block used to add support for vertex skinning (bones)
  65977. */
  65978. export class BonesBlock extends NodeMaterialBlock {
  65979. /**
  65980. * Creates a new BonesBlock
  65981. * @param name defines the block name
  65982. */
  65983. constructor(name: string);
  65984. /**
  65985. * Initialize the block and prepare the context for build
  65986. * @param state defines the state that will be used for the build
  65987. */
  65988. initialize(state: NodeMaterialBuildState): void;
  65989. /**
  65990. * Gets the current class name
  65991. * @returns the class name
  65992. */
  65993. getClassName(): string;
  65994. /**
  65995. * Gets the matrix indices input component
  65996. */
  65997. get matricesIndices(): NodeMaterialConnectionPoint;
  65998. /**
  65999. * Gets the matrix weights input component
  66000. */
  66001. get matricesWeights(): NodeMaterialConnectionPoint;
  66002. /**
  66003. * Gets the extra matrix indices input component
  66004. */
  66005. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the extra matrix weights input component
  66008. */
  66009. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the world input component
  66012. */
  66013. get world(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the output component
  66016. */
  66017. get output(): NodeMaterialConnectionPoint;
  66018. autoConfigure(material: NodeMaterial): void;
  66019. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66022. protected _buildBlock(state: NodeMaterialBuildState): this;
  66023. }
  66024. }
  66025. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66026. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66028. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66030. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66031. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66032. /**
  66033. * Block used to add support for instances
  66034. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66035. */
  66036. export class InstancesBlock extends NodeMaterialBlock {
  66037. /**
  66038. * Creates a new InstancesBlock
  66039. * @param name defines the block name
  66040. */
  66041. constructor(name: string);
  66042. /**
  66043. * Gets the current class name
  66044. * @returns the class name
  66045. */
  66046. getClassName(): string;
  66047. /**
  66048. * Gets the first world row input component
  66049. */
  66050. get world0(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the second world row input component
  66053. */
  66054. get world1(): NodeMaterialConnectionPoint;
  66055. /**
  66056. * Gets the third world row input component
  66057. */
  66058. get world2(): NodeMaterialConnectionPoint;
  66059. /**
  66060. * Gets the forth world row input component
  66061. */
  66062. get world3(): NodeMaterialConnectionPoint;
  66063. /**
  66064. * Gets the world input component
  66065. */
  66066. get world(): NodeMaterialConnectionPoint;
  66067. /**
  66068. * Gets the output component
  66069. */
  66070. get output(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the isntanceID component
  66073. */
  66074. get instanceID(): NodeMaterialConnectionPoint;
  66075. autoConfigure(material: NodeMaterial): void;
  66076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66077. protected _buildBlock(state: NodeMaterialBuildState): this;
  66078. }
  66079. }
  66080. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66085. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66086. import { Effect } from "babylonjs/Materials/effect";
  66087. import { Mesh } from "babylonjs/Meshes/mesh";
  66088. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66089. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66090. /**
  66091. * Block used to add morph targets support to vertex shader
  66092. */
  66093. export class MorphTargetsBlock extends NodeMaterialBlock {
  66094. private _repeatableContentAnchor;
  66095. /**
  66096. * Create a new MorphTargetsBlock
  66097. * @param name defines the block name
  66098. */
  66099. constructor(name: string);
  66100. /**
  66101. * Gets the current class name
  66102. * @returns the class name
  66103. */
  66104. getClassName(): string;
  66105. /**
  66106. * Gets the position input component
  66107. */
  66108. get position(): NodeMaterialConnectionPoint;
  66109. /**
  66110. * Gets the normal input component
  66111. */
  66112. get normal(): NodeMaterialConnectionPoint;
  66113. /**
  66114. * Gets the tangent input component
  66115. */
  66116. get tangent(): NodeMaterialConnectionPoint;
  66117. /**
  66118. * Gets the tangent input component
  66119. */
  66120. get uv(): NodeMaterialConnectionPoint;
  66121. /**
  66122. * Gets the position output component
  66123. */
  66124. get positionOutput(): NodeMaterialConnectionPoint;
  66125. /**
  66126. * Gets the normal output component
  66127. */
  66128. get normalOutput(): NodeMaterialConnectionPoint;
  66129. /**
  66130. * Gets the tangent output component
  66131. */
  66132. get tangentOutput(): NodeMaterialConnectionPoint;
  66133. /**
  66134. * Gets the tangent output component
  66135. */
  66136. get uvOutput(): NodeMaterialConnectionPoint;
  66137. initialize(state: NodeMaterialBuildState): void;
  66138. autoConfigure(material: NodeMaterial): void;
  66139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66141. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66142. protected _buildBlock(state: NodeMaterialBuildState): this;
  66143. }
  66144. }
  66145. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66149. import { Nullable } from "babylonjs/types";
  66150. import { Scene } from "babylonjs/scene";
  66151. import { Effect } from "babylonjs/Materials/effect";
  66152. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66153. import { Mesh } from "babylonjs/Meshes/mesh";
  66154. import { Light } from "babylonjs/Lights/light";
  66155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66156. /**
  66157. * Block used to get data information from a light
  66158. */
  66159. export class LightInformationBlock extends NodeMaterialBlock {
  66160. private _lightDataUniformName;
  66161. private _lightColorUniformName;
  66162. private _lightTypeDefineName;
  66163. /**
  66164. * Gets or sets the light associated with this block
  66165. */
  66166. light: Nullable<Light>;
  66167. /**
  66168. * Creates a new LightInformationBlock
  66169. * @param name defines the block name
  66170. */
  66171. constructor(name: string);
  66172. /**
  66173. * Gets the current class name
  66174. * @returns the class name
  66175. */
  66176. getClassName(): string;
  66177. /**
  66178. * Gets the world position input component
  66179. */
  66180. get worldPosition(): NodeMaterialConnectionPoint;
  66181. /**
  66182. * Gets the direction output component
  66183. */
  66184. get direction(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the direction output component
  66187. */
  66188. get color(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the direction output component
  66191. */
  66192. get intensity(): NodeMaterialConnectionPoint;
  66193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66195. protected _buildBlock(state: NodeMaterialBuildState): this;
  66196. serialize(): any;
  66197. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66198. }
  66199. }
  66200. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66201. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66202. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66203. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66204. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66205. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66206. }
  66207. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66212. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66213. import { Effect } from "babylonjs/Materials/effect";
  66214. import { Mesh } from "babylonjs/Meshes/mesh";
  66215. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66216. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66217. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66218. /**
  66219. * Block used to add image processing support to fragment shader
  66220. */
  66221. export class ImageProcessingBlock extends NodeMaterialBlock {
  66222. /**
  66223. * Create a new ImageProcessingBlock
  66224. * @param name defines the block name
  66225. */
  66226. constructor(name: string);
  66227. /**
  66228. * Gets the current class name
  66229. * @returns the class name
  66230. */
  66231. getClassName(): string;
  66232. /**
  66233. * Gets the color input component
  66234. */
  66235. get color(): NodeMaterialConnectionPoint;
  66236. /**
  66237. * Gets the output component
  66238. */
  66239. get output(): NodeMaterialConnectionPoint;
  66240. /**
  66241. * Initialize the block and prepare the context for build
  66242. * @param state defines the state that will be used for the build
  66243. */
  66244. initialize(state: NodeMaterialBuildState): void;
  66245. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66246. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66247. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66248. protected _buildBlock(state: NodeMaterialBuildState): this;
  66249. }
  66250. }
  66251. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66255. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66257. import { Effect } from "babylonjs/Materials/effect";
  66258. import { Mesh } from "babylonjs/Meshes/mesh";
  66259. import { Scene } from "babylonjs/scene";
  66260. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66261. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66262. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66263. /**
  66264. * Block used to pertub normals based on a normal map
  66265. */
  66266. export class PerturbNormalBlock extends NodeMaterialBlock {
  66267. private _tangentSpaceParameterName;
  66268. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66269. invertX: boolean;
  66270. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66271. invertY: boolean;
  66272. /**
  66273. * Create a new PerturbNormalBlock
  66274. * @param name defines the block name
  66275. */
  66276. constructor(name: string);
  66277. /**
  66278. * Gets the current class name
  66279. * @returns the class name
  66280. */
  66281. getClassName(): string;
  66282. /**
  66283. * Gets the world position input component
  66284. */
  66285. get worldPosition(): NodeMaterialConnectionPoint;
  66286. /**
  66287. * Gets the world normal input component
  66288. */
  66289. get worldNormal(): NodeMaterialConnectionPoint;
  66290. /**
  66291. * Gets the world tangent input component
  66292. */
  66293. get worldTangent(): NodeMaterialConnectionPoint;
  66294. /**
  66295. * Gets the uv input component
  66296. */
  66297. get uv(): NodeMaterialConnectionPoint;
  66298. /**
  66299. * Gets the normal map color input component
  66300. */
  66301. get normalMapColor(): NodeMaterialConnectionPoint;
  66302. /**
  66303. * Gets the strength input component
  66304. */
  66305. get strength(): NodeMaterialConnectionPoint;
  66306. /**
  66307. * Gets the output component
  66308. */
  66309. get output(): NodeMaterialConnectionPoint;
  66310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66311. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66312. autoConfigure(material: NodeMaterial): void;
  66313. protected _buildBlock(state: NodeMaterialBuildState): this;
  66314. protected _dumpPropertiesCode(): string;
  66315. serialize(): any;
  66316. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66317. }
  66318. }
  66319. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66323. /**
  66324. * Block used to discard a pixel if a value is smaller than a cutoff
  66325. */
  66326. export class DiscardBlock extends NodeMaterialBlock {
  66327. /**
  66328. * Create a new DiscardBlock
  66329. * @param name defines the block name
  66330. */
  66331. constructor(name: string);
  66332. /**
  66333. * Gets the current class name
  66334. * @returns the class name
  66335. */
  66336. getClassName(): string;
  66337. /**
  66338. * Gets the color input component
  66339. */
  66340. get value(): NodeMaterialConnectionPoint;
  66341. /**
  66342. * Gets the cutoff input component
  66343. */
  66344. get cutoff(): NodeMaterialConnectionPoint;
  66345. protected _buildBlock(state: NodeMaterialBuildState): this;
  66346. }
  66347. }
  66348. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66352. /**
  66353. * Block used to test if the fragment shader is front facing
  66354. */
  66355. export class FrontFacingBlock extends NodeMaterialBlock {
  66356. /**
  66357. * Creates a new FrontFacingBlock
  66358. * @param name defines the block name
  66359. */
  66360. constructor(name: string);
  66361. /**
  66362. * Gets the current class name
  66363. * @returns the class name
  66364. */
  66365. getClassName(): string;
  66366. /**
  66367. * Gets the output component
  66368. */
  66369. get output(): NodeMaterialConnectionPoint;
  66370. protected _buildBlock(state: NodeMaterialBuildState): this;
  66371. }
  66372. }
  66373. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66377. /**
  66378. * Block used to get the derivative value on x and y of a given input
  66379. */
  66380. export class DerivativeBlock extends NodeMaterialBlock {
  66381. /**
  66382. * Create a new DerivativeBlock
  66383. * @param name defines the block name
  66384. */
  66385. constructor(name: string);
  66386. /**
  66387. * Gets the current class name
  66388. * @returns the class name
  66389. */
  66390. getClassName(): string;
  66391. /**
  66392. * Gets the input component
  66393. */
  66394. get input(): NodeMaterialConnectionPoint;
  66395. /**
  66396. * Gets the derivative output on x
  66397. */
  66398. get dx(): NodeMaterialConnectionPoint;
  66399. /**
  66400. * Gets the derivative output on y
  66401. */
  66402. get dy(): NodeMaterialConnectionPoint;
  66403. protected _buildBlock(state: NodeMaterialBuildState): this;
  66404. }
  66405. }
  66406. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66410. /**
  66411. * Block used to make gl_FragCoord available
  66412. */
  66413. export class FragCoordBlock extends NodeMaterialBlock {
  66414. /**
  66415. * Creates a new FragCoordBlock
  66416. * @param name defines the block name
  66417. */
  66418. constructor(name: string);
  66419. /**
  66420. * Gets the current class name
  66421. * @returns the class name
  66422. */
  66423. getClassName(): string;
  66424. /**
  66425. * Gets the xy component
  66426. */
  66427. get xy(): NodeMaterialConnectionPoint;
  66428. /**
  66429. * Gets the xyz component
  66430. */
  66431. get xyz(): NodeMaterialConnectionPoint;
  66432. /**
  66433. * Gets the xyzw component
  66434. */
  66435. get xyzw(): NodeMaterialConnectionPoint;
  66436. /**
  66437. * Gets the x component
  66438. */
  66439. get x(): NodeMaterialConnectionPoint;
  66440. /**
  66441. * Gets the y component
  66442. */
  66443. get y(): NodeMaterialConnectionPoint;
  66444. /**
  66445. * Gets the z component
  66446. */
  66447. get z(): NodeMaterialConnectionPoint;
  66448. /**
  66449. * Gets the w component
  66450. */
  66451. get output(): NodeMaterialConnectionPoint;
  66452. protected writeOutputs(state: NodeMaterialBuildState): string;
  66453. protected _buildBlock(state: NodeMaterialBuildState): this;
  66454. }
  66455. }
  66456. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66460. import { Effect } from "babylonjs/Materials/effect";
  66461. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66462. import { Mesh } from "babylonjs/Meshes/mesh";
  66463. /**
  66464. * Block used to get the screen sizes
  66465. */
  66466. export class ScreenSizeBlock extends NodeMaterialBlock {
  66467. private _varName;
  66468. private _scene;
  66469. /**
  66470. * Creates a new ScreenSizeBlock
  66471. * @param name defines the block name
  66472. */
  66473. constructor(name: string);
  66474. /**
  66475. * Gets the current class name
  66476. * @returns the class name
  66477. */
  66478. getClassName(): string;
  66479. /**
  66480. * Gets the xy component
  66481. */
  66482. get xy(): NodeMaterialConnectionPoint;
  66483. /**
  66484. * Gets the x component
  66485. */
  66486. get x(): NodeMaterialConnectionPoint;
  66487. /**
  66488. * Gets the y component
  66489. */
  66490. get y(): NodeMaterialConnectionPoint;
  66491. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66492. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66493. protected _buildBlock(state: NodeMaterialBuildState): this;
  66494. }
  66495. }
  66496. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66497. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66498. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66499. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66500. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66501. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66502. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66503. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66504. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66505. }
  66506. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66509. import { Mesh } from "babylonjs/Meshes/mesh";
  66510. import { Effect } from "babylonjs/Materials/effect";
  66511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66513. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66514. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66515. /**
  66516. * Block used to add support for scene fog
  66517. */
  66518. export class FogBlock extends NodeMaterialBlock {
  66519. private _fogDistanceName;
  66520. private _fogParameters;
  66521. /**
  66522. * Create a new FogBlock
  66523. * @param name defines the block name
  66524. */
  66525. constructor(name: string);
  66526. /**
  66527. * Gets the current class name
  66528. * @returns the class name
  66529. */
  66530. getClassName(): string;
  66531. /**
  66532. * Gets the world position input component
  66533. */
  66534. get worldPosition(): NodeMaterialConnectionPoint;
  66535. /**
  66536. * Gets the view input component
  66537. */
  66538. get view(): NodeMaterialConnectionPoint;
  66539. /**
  66540. * Gets the color input component
  66541. */
  66542. get input(): NodeMaterialConnectionPoint;
  66543. /**
  66544. * Gets the fog color input component
  66545. */
  66546. get fogColor(): NodeMaterialConnectionPoint;
  66547. /**
  66548. * Gets the output component
  66549. */
  66550. get output(): NodeMaterialConnectionPoint;
  66551. autoConfigure(material: NodeMaterial): void;
  66552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66553. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66554. protected _buildBlock(state: NodeMaterialBuildState): this;
  66555. }
  66556. }
  66557. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66562. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66563. import { Effect } from "babylonjs/Materials/effect";
  66564. import { Mesh } from "babylonjs/Meshes/mesh";
  66565. import { Light } from "babylonjs/Lights/light";
  66566. import { Nullable } from "babylonjs/types";
  66567. import { Scene } from "babylonjs/scene";
  66568. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66569. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66570. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66572. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66573. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66574. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66575. /**
  66576. * Block used to add light in the fragment shader
  66577. */
  66578. export class LightBlock extends NodeMaterialBlock {
  66579. private _lightId;
  66580. /**
  66581. * Gets or sets the light associated with this block
  66582. */
  66583. light: Nullable<Light>;
  66584. /**
  66585. * Create a new LightBlock
  66586. * @param name defines the block name
  66587. */
  66588. constructor(name: string);
  66589. /**
  66590. * Gets the current class name
  66591. * @returns the class name
  66592. */
  66593. getClassName(): string;
  66594. /**
  66595. * Gets the world position input component
  66596. */
  66597. get worldPosition(): NodeMaterialConnectionPoint;
  66598. /**
  66599. * Gets the world normal input component
  66600. */
  66601. get worldNormal(): NodeMaterialConnectionPoint;
  66602. /**
  66603. * Gets the camera (or eye) position component
  66604. */
  66605. get cameraPosition(): NodeMaterialConnectionPoint;
  66606. /**
  66607. * Gets the glossiness component
  66608. */
  66609. get glossiness(): NodeMaterialConnectionPoint;
  66610. /**
  66611. * Gets the glossinness power component
  66612. */
  66613. get glossPower(): NodeMaterialConnectionPoint;
  66614. /**
  66615. * Gets the diffuse color component
  66616. */
  66617. get diffuseColor(): NodeMaterialConnectionPoint;
  66618. /**
  66619. * Gets the specular color component
  66620. */
  66621. get specularColor(): NodeMaterialConnectionPoint;
  66622. /**
  66623. * Gets the diffuse output component
  66624. */
  66625. get diffuseOutput(): NodeMaterialConnectionPoint;
  66626. /**
  66627. * Gets the specular output component
  66628. */
  66629. get specularOutput(): NodeMaterialConnectionPoint;
  66630. /**
  66631. * Gets the shadow output component
  66632. */
  66633. get shadow(): NodeMaterialConnectionPoint;
  66634. autoConfigure(material: NodeMaterial): void;
  66635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66636. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66638. private _injectVertexCode;
  66639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66640. serialize(): any;
  66641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66642. }
  66643. }
  66644. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66647. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66648. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66649. /**
  66650. * Block used to read a reflection texture from a sampler
  66651. */
  66652. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66653. /**
  66654. * Create a new ReflectionTextureBlock
  66655. * @param name defines the block name
  66656. */
  66657. constructor(name: string);
  66658. /**
  66659. * Gets the current class name
  66660. * @returns the class name
  66661. */
  66662. getClassName(): string;
  66663. /**
  66664. * Gets the world position input component
  66665. */
  66666. get position(): NodeMaterialConnectionPoint;
  66667. /**
  66668. * Gets the world position input component
  66669. */
  66670. get worldPosition(): NodeMaterialConnectionPoint;
  66671. /**
  66672. * Gets the world normal input component
  66673. */
  66674. get worldNormal(): NodeMaterialConnectionPoint;
  66675. /**
  66676. * Gets the world input component
  66677. */
  66678. get world(): NodeMaterialConnectionPoint;
  66679. /**
  66680. * Gets the camera (or eye) position component
  66681. */
  66682. get cameraPosition(): NodeMaterialConnectionPoint;
  66683. /**
  66684. * Gets the view input component
  66685. */
  66686. get view(): NodeMaterialConnectionPoint;
  66687. /**
  66688. * Gets the rgb output component
  66689. */
  66690. get rgb(): NodeMaterialConnectionPoint;
  66691. /**
  66692. * Gets the rgba output component
  66693. */
  66694. get rgba(): NodeMaterialConnectionPoint;
  66695. /**
  66696. * Gets the r output component
  66697. */
  66698. get r(): NodeMaterialConnectionPoint;
  66699. /**
  66700. * Gets the g output component
  66701. */
  66702. get g(): NodeMaterialConnectionPoint;
  66703. /**
  66704. * Gets the b output component
  66705. */
  66706. get b(): NodeMaterialConnectionPoint;
  66707. /**
  66708. * Gets the a output component
  66709. */
  66710. get a(): NodeMaterialConnectionPoint;
  66711. autoConfigure(material: NodeMaterial): void;
  66712. protected _buildBlock(state: NodeMaterialBuildState): this;
  66713. }
  66714. }
  66715. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66716. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66717. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66718. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66719. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66720. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66721. }
  66722. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66723. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66724. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66725. }
  66726. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66728. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66729. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66730. /**
  66731. * Block used to add 2 vectors
  66732. */
  66733. export class AddBlock extends NodeMaterialBlock {
  66734. /**
  66735. * Creates a new AddBlock
  66736. * @param name defines the block name
  66737. */
  66738. constructor(name: string);
  66739. /**
  66740. * Gets the current class name
  66741. * @returns the class name
  66742. */
  66743. getClassName(): string;
  66744. /**
  66745. * Gets the left operand input component
  66746. */
  66747. get left(): NodeMaterialConnectionPoint;
  66748. /**
  66749. * Gets the right operand input component
  66750. */
  66751. get right(): NodeMaterialConnectionPoint;
  66752. /**
  66753. * Gets the output component
  66754. */
  66755. get output(): NodeMaterialConnectionPoint;
  66756. protected _buildBlock(state: NodeMaterialBuildState): this;
  66757. }
  66758. }
  66759. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66763. /**
  66764. * Block used to scale a vector by a float
  66765. */
  66766. export class ScaleBlock extends NodeMaterialBlock {
  66767. /**
  66768. * Creates a new ScaleBlock
  66769. * @param name defines the block name
  66770. */
  66771. constructor(name: string);
  66772. /**
  66773. * Gets the current class name
  66774. * @returns the class name
  66775. */
  66776. getClassName(): string;
  66777. /**
  66778. * Gets the input component
  66779. */
  66780. get input(): NodeMaterialConnectionPoint;
  66781. /**
  66782. * Gets the factor input component
  66783. */
  66784. get factor(): NodeMaterialConnectionPoint;
  66785. /**
  66786. * Gets the output component
  66787. */
  66788. get output(): NodeMaterialConnectionPoint;
  66789. protected _buildBlock(state: NodeMaterialBuildState): this;
  66790. }
  66791. }
  66792. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66796. import { Scene } from "babylonjs/scene";
  66797. /**
  66798. * Block used to clamp a float
  66799. */
  66800. export class ClampBlock extends NodeMaterialBlock {
  66801. /** Gets or sets the minimum range */
  66802. minimum: number;
  66803. /** Gets or sets the maximum range */
  66804. maximum: number;
  66805. /**
  66806. * Creates a new ClampBlock
  66807. * @param name defines the block name
  66808. */
  66809. constructor(name: string);
  66810. /**
  66811. * Gets the current class name
  66812. * @returns the class name
  66813. */
  66814. getClassName(): string;
  66815. /**
  66816. * Gets the value input component
  66817. */
  66818. get value(): NodeMaterialConnectionPoint;
  66819. /**
  66820. * Gets the output component
  66821. */
  66822. get output(): NodeMaterialConnectionPoint;
  66823. protected _buildBlock(state: NodeMaterialBuildState): this;
  66824. protected _dumpPropertiesCode(): string;
  66825. serialize(): any;
  66826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66827. }
  66828. }
  66829. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66833. /**
  66834. * Block used to apply a cross product between 2 vectors
  66835. */
  66836. export class CrossBlock extends NodeMaterialBlock {
  66837. /**
  66838. * Creates a new CrossBlock
  66839. * @param name defines the block name
  66840. */
  66841. constructor(name: string);
  66842. /**
  66843. * Gets the current class name
  66844. * @returns the class name
  66845. */
  66846. getClassName(): string;
  66847. /**
  66848. * Gets the left operand input component
  66849. */
  66850. get left(): NodeMaterialConnectionPoint;
  66851. /**
  66852. * Gets the right operand input component
  66853. */
  66854. get right(): NodeMaterialConnectionPoint;
  66855. /**
  66856. * Gets the output component
  66857. */
  66858. get output(): NodeMaterialConnectionPoint;
  66859. protected _buildBlock(state: NodeMaterialBuildState): this;
  66860. }
  66861. }
  66862. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66866. /**
  66867. * Block used to apply a dot product between 2 vectors
  66868. */
  66869. export class DotBlock extends NodeMaterialBlock {
  66870. /**
  66871. * Creates a new DotBlock
  66872. * @param name defines the block name
  66873. */
  66874. constructor(name: string);
  66875. /**
  66876. * Gets the current class name
  66877. * @returns the class name
  66878. */
  66879. getClassName(): string;
  66880. /**
  66881. * Gets the left operand input component
  66882. */
  66883. get left(): NodeMaterialConnectionPoint;
  66884. /**
  66885. * Gets the right operand input component
  66886. */
  66887. get right(): NodeMaterialConnectionPoint;
  66888. /**
  66889. * Gets the output component
  66890. */
  66891. get output(): NodeMaterialConnectionPoint;
  66892. protected _buildBlock(state: NodeMaterialBuildState): this;
  66893. }
  66894. }
  66895. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66899. /**
  66900. * Block used to normalize a vector
  66901. */
  66902. export class NormalizeBlock extends NodeMaterialBlock {
  66903. /**
  66904. * Creates a new NormalizeBlock
  66905. * @param name defines the block name
  66906. */
  66907. constructor(name: string);
  66908. /**
  66909. * Gets the current class name
  66910. * @returns the class name
  66911. */
  66912. getClassName(): string;
  66913. /**
  66914. * Gets the input component
  66915. */
  66916. get input(): NodeMaterialConnectionPoint;
  66917. /**
  66918. * Gets the output component
  66919. */
  66920. get output(): NodeMaterialConnectionPoint;
  66921. protected _buildBlock(state: NodeMaterialBuildState): this;
  66922. }
  66923. }
  66924. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66928. /**
  66929. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66930. */
  66931. export class ColorMergerBlock extends NodeMaterialBlock {
  66932. /**
  66933. * Create a new ColorMergerBlock
  66934. * @param name defines the block name
  66935. */
  66936. constructor(name: string);
  66937. /**
  66938. * Gets the current class name
  66939. * @returns the class name
  66940. */
  66941. getClassName(): string;
  66942. /**
  66943. * Gets the rgb component (input)
  66944. */
  66945. get rgbIn(): NodeMaterialConnectionPoint;
  66946. /**
  66947. * Gets the r component (input)
  66948. */
  66949. get r(): NodeMaterialConnectionPoint;
  66950. /**
  66951. * Gets the g component (input)
  66952. */
  66953. get g(): NodeMaterialConnectionPoint;
  66954. /**
  66955. * Gets the b component (input)
  66956. */
  66957. get b(): NodeMaterialConnectionPoint;
  66958. /**
  66959. * Gets the a component (input)
  66960. */
  66961. get a(): NodeMaterialConnectionPoint;
  66962. /**
  66963. * Gets the rgba component (output)
  66964. */
  66965. get rgba(): NodeMaterialConnectionPoint;
  66966. /**
  66967. * Gets the rgb component (output)
  66968. */
  66969. get rgbOut(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the rgb component (output)
  66972. * @deprecated Please use rgbOut instead.
  66973. */
  66974. get rgb(): NodeMaterialConnectionPoint;
  66975. protected _buildBlock(state: NodeMaterialBuildState): this;
  66976. }
  66977. }
  66978. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66982. /**
  66983. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66984. */
  66985. export class VectorSplitterBlock extends NodeMaterialBlock {
  66986. /**
  66987. * Create a new VectorSplitterBlock
  66988. * @param name defines the block name
  66989. */
  66990. constructor(name: string);
  66991. /**
  66992. * Gets the current class name
  66993. * @returns the class name
  66994. */
  66995. getClassName(): string;
  66996. /**
  66997. * Gets the xyzw component (input)
  66998. */
  66999. get xyzw(): NodeMaterialConnectionPoint;
  67000. /**
  67001. * Gets the xyz component (input)
  67002. */
  67003. get xyzIn(): NodeMaterialConnectionPoint;
  67004. /**
  67005. * Gets the xy component (input)
  67006. */
  67007. get xyIn(): NodeMaterialConnectionPoint;
  67008. /**
  67009. * Gets the xyz component (output)
  67010. */
  67011. get xyzOut(): NodeMaterialConnectionPoint;
  67012. /**
  67013. * Gets the xy component (output)
  67014. */
  67015. get xyOut(): NodeMaterialConnectionPoint;
  67016. /**
  67017. * Gets the x component (output)
  67018. */
  67019. get x(): NodeMaterialConnectionPoint;
  67020. /**
  67021. * Gets the y component (output)
  67022. */
  67023. get y(): NodeMaterialConnectionPoint;
  67024. /**
  67025. * Gets the z component (output)
  67026. */
  67027. get z(): NodeMaterialConnectionPoint;
  67028. /**
  67029. * Gets the w component (output)
  67030. */
  67031. get w(): NodeMaterialConnectionPoint;
  67032. protected _inputRename(name: string): string;
  67033. protected _outputRename(name: string): string;
  67034. protected _buildBlock(state: NodeMaterialBuildState): this;
  67035. }
  67036. }
  67037. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67041. /**
  67042. * Block used to lerp between 2 values
  67043. */
  67044. export class LerpBlock extends NodeMaterialBlock {
  67045. /**
  67046. * Creates a new LerpBlock
  67047. * @param name defines the block name
  67048. */
  67049. constructor(name: string);
  67050. /**
  67051. * Gets the current class name
  67052. * @returns the class name
  67053. */
  67054. getClassName(): string;
  67055. /**
  67056. * Gets the left operand input component
  67057. */
  67058. get left(): NodeMaterialConnectionPoint;
  67059. /**
  67060. * Gets the right operand input component
  67061. */
  67062. get right(): NodeMaterialConnectionPoint;
  67063. /**
  67064. * Gets the gradient operand input component
  67065. */
  67066. get gradient(): NodeMaterialConnectionPoint;
  67067. /**
  67068. * Gets the output component
  67069. */
  67070. get output(): NodeMaterialConnectionPoint;
  67071. protected _buildBlock(state: NodeMaterialBuildState): this;
  67072. }
  67073. }
  67074. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67078. /**
  67079. * Block used to divide 2 vectors
  67080. */
  67081. export class DivideBlock extends NodeMaterialBlock {
  67082. /**
  67083. * Creates a new DivideBlock
  67084. * @param name defines the block name
  67085. */
  67086. constructor(name: string);
  67087. /**
  67088. * Gets the current class name
  67089. * @returns the class name
  67090. */
  67091. getClassName(): string;
  67092. /**
  67093. * Gets the left operand input component
  67094. */
  67095. get left(): NodeMaterialConnectionPoint;
  67096. /**
  67097. * Gets the right operand input component
  67098. */
  67099. get right(): NodeMaterialConnectionPoint;
  67100. /**
  67101. * Gets the output component
  67102. */
  67103. get output(): NodeMaterialConnectionPoint;
  67104. protected _buildBlock(state: NodeMaterialBuildState): this;
  67105. }
  67106. }
  67107. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67111. /**
  67112. * Block used to subtract 2 vectors
  67113. */
  67114. export class SubtractBlock extends NodeMaterialBlock {
  67115. /**
  67116. * Creates a new SubtractBlock
  67117. * @param name defines the block name
  67118. */
  67119. constructor(name: string);
  67120. /**
  67121. * Gets the current class name
  67122. * @returns the class name
  67123. */
  67124. getClassName(): string;
  67125. /**
  67126. * Gets the left operand input component
  67127. */
  67128. get left(): NodeMaterialConnectionPoint;
  67129. /**
  67130. * Gets the right operand input component
  67131. */
  67132. get right(): NodeMaterialConnectionPoint;
  67133. /**
  67134. * Gets the output component
  67135. */
  67136. get output(): NodeMaterialConnectionPoint;
  67137. protected _buildBlock(state: NodeMaterialBuildState): this;
  67138. }
  67139. }
  67140. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67144. /**
  67145. * Block used to step a value
  67146. */
  67147. export class StepBlock extends NodeMaterialBlock {
  67148. /**
  67149. * Creates a new StepBlock
  67150. * @param name defines the block name
  67151. */
  67152. constructor(name: string);
  67153. /**
  67154. * Gets the current class name
  67155. * @returns the class name
  67156. */
  67157. getClassName(): string;
  67158. /**
  67159. * Gets the value operand input component
  67160. */
  67161. get value(): NodeMaterialConnectionPoint;
  67162. /**
  67163. * Gets the edge operand input component
  67164. */
  67165. get edge(): NodeMaterialConnectionPoint;
  67166. /**
  67167. * Gets the output component
  67168. */
  67169. get output(): NodeMaterialConnectionPoint;
  67170. protected _buildBlock(state: NodeMaterialBuildState): this;
  67171. }
  67172. }
  67173. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67177. /**
  67178. * Block used to get the opposite (1 - x) of a value
  67179. */
  67180. export class OneMinusBlock extends NodeMaterialBlock {
  67181. /**
  67182. * Creates a new OneMinusBlock
  67183. * @param name defines the block name
  67184. */
  67185. constructor(name: string);
  67186. /**
  67187. * Gets the current class name
  67188. * @returns the class name
  67189. */
  67190. getClassName(): string;
  67191. /**
  67192. * Gets the input component
  67193. */
  67194. get input(): NodeMaterialConnectionPoint;
  67195. /**
  67196. * Gets the output component
  67197. */
  67198. get output(): NodeMaterialConnectionPoint;
  67199. protected _buildBlock(state: NodeMaterialBuildState): this;
  67200. }
  67201. }
  67202. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67206. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67207. /**
  67208. * Block used to get the view direction
  67209. */
  67210. export class ViewDirectionBlock extends NodeMaterialBlock {
  67211. /**
  67212. * Creates a new ViewDirectionBlock
  67213. * @param name defines the block name
  67214. */
  67215. constructor(name: string);
  67216. /**
  67217. * Gets the current class name
  67218. * @returns the class name
  67219. */
  67220. getClassName(): string;
  67221. /**
  67222. * Gets the world position component
  67223. */
  67224. get worldPosition(): NodeMaterialConnectionPoint;
  67225. /**
  67226. * Gets the camera position component
  67227. */
  67228. get cameraPosition(): NodeMaterialConnectionPoint;
  67229. /**
  67230. * Gets the output component
  67231. */
  67232. get output(): NodeMaterialConnectionPoint;
  67233. autoConfigure(material: NodeMaterial): void;
  67234. protected _buildBlock(state: NodeMaterialBuildState): this;
  67235. }
  67236. }
  67237. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67239. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67240. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67241. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67242. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67243. /**
  67244. * Block used to compute fresnel value
  67245. */
  67246. export class FresnelBlock extends NodeMaterialBlock {
  67247. /**
  67248. * Create a new FresnelBlock
  67249. * @param name defines the block name
  67250. */
  67251. constructor(name: string);
  67252. /**
  67253. * Gets the current class name
  67254. * @returns the class name
  67255. */
  67256. getClassName(): string;
  67257. /**
  67258. * Gets the world normal input component
  67259. */
  67260. get worldNormal(): NodeMaterialConnectionPoint;
  67261. /**
  67262. * Gets the view direction input component
  67263. */
  67264. get viewDirection(): NodeMaterialConnectionPoint;
  67265. /**
  67266. * Gets the bias input component
  67267. */
  67268. get bias(): NodeMaterialConnectionPoint;
  67269. /**
  67270. * Gets the camera (or eye) position component
  67271. */
  67272. get power(): NodeMaterialConnectionPoint;
  67273. /**
  67274. * Gets the fresnel output component
  67275. */
  67276. get fresnel(): NodeMaterialConnectionPoint;
  67277. autoConfigure(material: NodeMaterial): void;
  67278. protected _buildBlock(state: NodeMaterialBuildState): this;
  67279. }
  67280. }
  67281. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67285. /**
  67286. * Block used to get the max of 2 values
  67287. */
  67288. export class MaxBlock extends NodeMaterialBlock {
  67289. /**
  67290. * Creates a new MaxBlock
  67291. * @param name defines the block name
  67292. */
  67293. constructor(name: string);
  67294. /**
  67295. * Gets the current class name
  67296. * @returns the class name
  67297. */
  67298. getClassName(): string;
  67299. /**
  67300. * Gets the left operand input component
  67301. */
  67302. get left(): NodeMaterialConnectionPoint;
  67303. /**
  67304. * Gets the right operand input component
  67305. */
  67306. get right(): NodeMaterialConnectionPoint;
  67307. /**
  67308. * Gets the output component
  67309. */
  67310. get output(): NodeMaterialConnectionPoint;
  67311. protected _buildBlock(state: NodeMaterialBuildState): this;
  67312. }
  67313. }
  67314. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67318. /**
  67319. * Block used to get the min of 2 values
  67320. */
  67321. export class MinBlock extends NodeMaterialBlock {
  67322. /**
  67323. * Creates a new MinBlock
  67324. * @param name defines the block name
  67325. */
  67326. constructor(name: string);
  67327. /**
  67328. * Gets the current class name
  67329. * @returns the class name
  67330. */
  67331. getClassName(): string;
  67332. /**
  67333. * Gets the left operand input component
  67334. */
  67335. get left(): NodeMaterialConnectionPoint;
  67336. /**
  67337. * Gets the right operand input component
  67338. */
  67339. get right(): NodeMaterialConnectionPoint;
  67340. /**
  67341. * Gets the output component
  67342. */
  67343. get output(): NodeMaterialConnectionPoint;
  67344. protected _buildBlock(state: NodeMaterialBuildState): this;
  67345. }
  67346. }
  67347. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67351. /**
  67352. * Block used to get the distance between 2 values
  67353. */
  67354. export class DistanceBlock extends NodeMaterialBlock {
  67355. /**
  67356. * Creates a new DistanceBlock
  67357. * @param name defines the block name
  67358. */
  67359. constructor(name: string);
  67360. /**
  67361. * Gets the current class name
  67362. * @returns the class name
  67363. */
  67364. getClassName(): string;
  67365. /**
  67366. * Gets the left operand input component
  67367. */
  67368. get left(): NodeMaterialConnectionPoint;
  67369. /**
  67370. * Gets the right operand input component
  67371. */
  67372. get right(): NodeMaterialConnectionPoint;
  67373. /**
  67374. * Gets the output component
  67375. */
  67376. get output(): NodeMaterialConnectionPoint;
  67377. protected _buildBlock(state: NodeMaterialBuildState): this;
  67378. }
  67379. }
  67380. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67384. /**
  67385. * Block used to get the length of a vector
  67386. */
  67387. export class LengthBlock extends NodeMaterialBlock {
  67388. /**
  67389. * Creates a new LengthBlock
  67390. * @param name defines the block name
  67391. */
  67392. constructor(name: string);
  67393. /**
  67394. * Gets the current class name
  67395. * @returns the class name
  67396. */
  67397. getClassName(): string;
  67398. /**
  67399. * Gets the value input component
  67400. */
  67401. get value(): NodeMaterialConnectionPoint;
  67402. /**
  67403. * Gets the output component
  67404. */
  67405. get output(): NodeMaterialConnectionPoint;
  67406. protected _buildBlock(state: NodeMaterialBuildState): this;
  67407. }
  67408. }
  67409. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67413. /**
  67414. * Block used to get negative version of a value (i.e. x * -1)
  67415. */
  67416. export class NegateBlock extends NodeMaterialBlock {
  67417. /**
  67418. * Creates a new NegateBlock
  67419. * @param name defines the block name
  67420. */
  67421. constructor(name: string);
  67422. /**
  67423. * Gets the current class name
  67424. * @returns the class name
  67425. */
  67426. getClassName(): string;
  67427. /**
  67428. * Gets the value input component
  67429. */
  67430. get value(): NodeMaterialConnectionPoint;
  67431. /**
  67432. * Gets the output component
  67433. */
  67434. get output(): NodeMaterialConnectionPoint;
  67435. protected _buildBlock(state: NodeMaterialBuildState): this;
  67436. }
  67437. }
  67438. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67442. /**
  67443. * Block used to get the value of the first parameter raised to the power of the second
  67444. */
  67445. export class PowBlock extends NodeMaterialBlock {
  67446. /**
  67447. * Creates a new PowBlock
  67448. * @param name defines the block name
  67449. */
  67450. constructor(name: string);
  67451. /**
  67452. * Gets the current class name
  67453. * @returns the class name
  67454. */
  67455. getClassName(): string;
  67456. /**
  67457. * Gets the value operand input component
  67458. */
  67459. get value(): NodeMaterialConnectionPoint;
  67460. /**
  67461. * Gets the power operand input component
  67462. */
  67463. get power(): NodeMaterialConnectionPoint;
  67464. /**
  67465. * Gets the output component
  67466. */
  67467. get output(): NodeMaterialConnectionPoint;
  67468. protected _buildBlock(state: NodeMaterialBuildState): this;
  67469. }
  67470. }
  67471. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67475. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67476. /**
  67477. * Block used to get a random number
  67478. */
  67479. export class RandomNumberBlock extends NodeMaterialBlock {
  67480. /**
  67481. * Creates a new RandomNumberBlock
  67482. * @param name defines the block name
  67483. */
  67484. constructor(name: string);
  67485. /**
  67486. * Gets the current class name
  67487. * @returns the class name
  67488. */
  67489. getClassName(): string;
  67490. /**
  67491. * Gets the seed input component
  67492. */
  67493. get seed(): NodeMaterialConnectionPoint;
  67494. /**
  67495. * Gets the output component
  67496. */
  67497. get output(): NodeMaterialConnectionPoint;
  67498. protected _buildBlock(state: NodeMaterialBuildState): this;
  67499. }
  67500. }
  67501. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67505. /**
  67506. * Block used to compute arc tangent of 2 values
  67507. */
  67508. export class ArcTan2Block extends NodeMaterialBlock {
  67509. /**
  67510. * Creates a new ArcTan2Block
  67511. * @param name defines the block name
  67512. */
  67513. constructor(name: string);
  67514. /**
  67515. * Gets the current class name
  67516. * @returns the class name
  67517. */
  67518. getClassName(): string;
  67519. /**
  67520. * Gets the x operand input component
  67521. */
  67522. get x(): NodeMaterialConnectionPoint;
  67523. /**
  67524. * Gets the y operand input component
  67525. */
  67526. get y(): NodeMaterialConnectionPoint;
  67527. /**
  67528. * Gets the output component
  67529. */
  67530. get output(): NodeMaterialConnectionPoint;
  67531. protected _buildBlock(state: NodeMaterialBuildState): this;
  67532. }
  67533. }
  67534. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67538. /**
  67539. * Block used to smooth step a value
  67540. */
  67541. export class SmoothStepBlock extends NodeMaterialBlock {
  67542. /**
  67543. * Creates a new SmoothStepBlock
  67544. * @param name defines the block name
  67545. */
  67546. constructor(name: string);
  67547. /**
  67548. * Gets the current class name
  67549. * @returns the class name
  67550. */
  67551. getClassName(): string;
  67552. /**
  67553. * Gets the value operand input component
  67554. */
  67555. get value(): NodeMaterialConnectionPoint;
  67556. /**
  67557. * Gets the first edge operand input component
  67558. */
  67559. get edge0(): NodeMaterialConnectionPoint;
  67560. /**
  67561. * Gets the second edge operand input component
  67562. */
  67563. get edge1(): NodeMaterialConnectionPoint;
  67564. /**
  67565. * Gets the output component
  67566. */
  67567. get output(): NodeMaterialConnectionPoint;
  67568. protected _buildBlock(state: NodeMaterialBuildState): this;
  67569. }
  67570. }
  67571. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67575. /**
  67576. * Block used to get the reciprocal (1 / x) of a value
  67577. */
  67578. export class ReciprocalBlock extends NodeMaterialBlock {
  67579. /**
  67580. * Creates a new ReciprocalBlock
  67581. * @param name defines the block name
  67582. */
  67583. constructor(name: string);
  67584. /**
  67585. * Gets the current class name
  67586. * @returns the class name
  67587. */
  67588. getClassName(): string;
  67589. /**
  67590. * Gets the input component
  67591. */
  67592. get input(): NodeMaterialConnectionPoint;
  67593. /**
  67594. * Gets the output component
  67595. */
  67596. get output(): NodeMaterialConnectionPoint;
  67597. protected _buildBlock(state: NodeMaterialBuildState): this;
  67598. }
  67599. }
  67600. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67604. /**
  67605. * Block used to replace a color by another one
  67606. */
  67607. export class ReplaceColorBlock extends NodeMaterialBlock {
  67608. /**
  67609. * Creates a new ReplaceColorBlock
  67610. * @param name defines the block name
  67611. */
  67612. constructor(name: string);
  67613. /**
  67614. * Gets the current class name
  67615. * @returns the class name
  67616. */
  67617. getClassName(): string;
  67618. /**
  67619. * Gets the value input component
  67620. */
  67621. get value(): NodeMaterialConnectionPoint;
  67622. /**
  67623. * Gets the reference input component
  67624. */
  67625. get reference(): NodeMaterialConnectionPoint;
  67626. /**
  67627. * Gets the distance input component
  67628. */
  67629. get distance(): NodeMaterialConnectionPoint;
  67630. /**
  67631. * Gets the replacement input component
  67632. */
  67633. get replacement(): NodeMaterialConnectionPoint;
  67634. /**
  67635. * Gets the output component
  67636. */
  67637. get output(): NodeMaterialConnectionPoint;
  67638. protected _buildBlock(state: NodeMaterialBuildState): this;
  67639. }
  67640. }
  67641. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67645. /**
  67646. * Block used to posterize a value
  67647. * @see https://en.wikipedia.org/wiki/Posterization
  67648. */
  67649. export class PosterizeBlock extends NodeMaterialBlock {
  67650. /**
  67651. * Creates a new PosterizeBlock
  67652. * @param name defines the block name
  67653. */
  67654. constructor(name: string);
  67655. /**
  67656. * Gets the current class name
  67657. * @returns the class name
  67658. */
  67659. getClassName(): string;
  67660. /**
  67661. * Gets the value input component
  67662. */
  67663. get value(): NodeMaterialConnectionPoint;
  67664. /**
  67665. * Gets the steps input component
  67666. */
  67667. get steps(): NodeMaterialConnectionPoint;
  67668. /**
  67669. * Gets the output component
  67670. */
  67671. get output(): NodeMaterialConnectionPoint;
  67672. protected _buildBlock(state: NodeMaterialBuildState): this;
  67673. }
  67674. }
  67675. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67679. import { Scene } from "babylonjs/scene";
  67680. /**
  67681. * Operations supported by the Wave block
  67682. */
  67683. export enum WaveBlockKind {
  67684. /** SawTooth */
  67685. SawTooth = 0,
  67686. /** Square */
  67687. Square = 1,
  67688. /** Triangle */
  67689. Triangle = 2
  67690. }
  67691. /**
  67692. * Block used to apply wave operation to floats
  67693. */
  67694. export class WaveBlock extends NodeMaterialBlock {
  67695. /**
  67696. * Gets or sets the kibnd of wave to be applied by the block
  67697. */
  67698. kind: WaveBlockKind;
  67699. /**
  67700. * Creates a new WaveBlock
  67701. * @param name defines the block name
  67702. */
  67703. constructor(name: string);
  67704. /**
  67705. * Gets the current class name
  67706. * @returns the class name
  67707. */
  67708. getClassName(): string;
  67709. /**
  67710. * Gets the input component
  67711. */
  67712. get input(): NodeMaterialConnectionPoint;
  67713. /**
  67714. * Gets the output component
  67715. */
  67716. get output(): NodeMaterialConnectionPoint;
  67717. protected _buildBlock(state: NodeMaterialBuildState): this;
  67718. serialize(): any;
  67719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67720. }
  67721. }
  67722. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67726. import { Color3 } from "babylonjs/Maths/math.color";
  67727. import { Scene } from "babylonjs/scene";
  67728. import { Observable } from "babylonjs/Misc/observable";
  67729. /**
  67730. * Class used to store a color step for the GradientBlock
  67731. */
  67732. export class GradientBlockColorStep {
  67733. private _step;
  67734. /**
  67735. * Gets value indicating which step this color is associated with (between 0 and 1)
  67736. */
  67737. get step(): number;
  67738. /**
  67739. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67740. */
  67741. set step(val: number);
  67742. private _color;
  67743. /**
  67744. * Gets the color associated with this step
  67745. */
  67746. get color(): Color3;
  67747. /**
  67748. * Sets the color associated with this step
  67749. */
  67750. set color(val: Color3);
  67751. /**
  67752. * Creates a new GradientBlockColorStep
  67753. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67754. * @param color defines the color associated with this step
  67755. */
  67756. constructor(step: number, color: Color3);
  67757. }
  67758. /**
  67759. * Block used to return a color from a gradient based on an input value between 0 and 1
  67760. */
  67761. export class GradientBlock extends NodeMaterialBlock {
  67762. /**
  67763. * Gets or sets the list of color steps
  67764. */
  67765. colorSteps: GradientBlockColorStep[];
  67766. /** Gets an observable raised when the value is changed */
  67767. onValueChangedObservable: Observable<GradientBlock>;
  67768. /** calls observable when the value is changed*/
  67769. colorStepsUpdated(): void;
  67770. /**
  67771. * Creates a new GradientBlock
  67772. * @param name defines the block name
  67773. */
  67774. constructor(name: string);
  67775. /**
  67776. * Gets the current class name
  67777. * @returns the class name
  67778. */
  67779. getClassName(): string;
  67780. /**
  67781. * Gets the gradient input component
  67782. */
  67783. get gradient(): NodeMaterialConnectionPoint;
  67784. /**
  67785. * Gets the output component
  67786. */
  67787. get output(): NodeMaterialConnectionPoint;
  67788. private _writeColorConstant;
  67789. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67790. serialize(): any;
  67791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67792. protected _dumpPropertiesCode(): string;
  67793. }
  67794. }
  67795. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67799. /**
  67800. * Block used to normalize lerp between 2 values
  67801. */
  67802. export class NLerpBlock extends NodeMaterialBlock {
  67803. /**
  67804. * Creates a new NLerpBlock
  67805. * @param name defines the block name
  67806. */
  67807. constructor(name: string);
  67808. /**
  67809. * Gets the current class name
  67810. * @returns the class name
  67811. */
  67812. getClassName(): string;
  67813. /**
  67814. * Gets the left operand input component
  67815. */
  67816. get left(): NodeMaterialConnectionPoint;
  67817. /**
  67818. * Gets the right operand input component
  67819. */
  67820. get right(): NodeMaterialConnectionPoint;
  67821. /**
  67822. * Gets the gradient operand input component
  67823. */
  67824. get gradient(): NodeMaterialConnectionPoint;
  67825. /**
  67826. * Gets the output component
  67827. */
  67828. get output(): NodeMaterialConnectionPoint;
  67829. protected _buildBlock(state: NodeMaterialBuildState): this;
  67830. }
  67831. }
  67832. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67836. import { Scene } from "babylonjs/scene";
  67837. /**
  67838. * block used to Generate a Worley Noise 3D Noise Pattern
  67839. */
  67840. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67841. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67842. manhattanDistance: boolean;
  67843. /**
  67844. * Creates a new WorleyNoise3DBlock
  67845. * @param name defines the block name
  67846. */
  67847. constructor(name: string);
  67848. /**
  67849. * Gets the current class name
  67850. * @returns the class name
  67851. */
  67852. getClassName(): string;
  67853. /**
  67854. * Gets the seed input component
  67855. */
  67856. get seed(): NodeMaterialConnectionPoint;
  67857. /**
  67858. * Gets the jitter input component
  67859. */
  67860. get jitter(): NodeMaterialConnectionPoint;
  67861. /**
  67862. * Gets the output component
  67863. */
  67864. get output(): NodeMaterialConnectionPoint;
  67865. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67866. /**
  67867. * Exposes the properties to the UI?
  67868. */
  67869. protected _dumpPropertiesCode(): string;
  67870. /**
  67871. * Exposes the properties to the Seralize?
  67872. */
  67873. serialize(): any;
  67874. /**
  67875. * Exposes the properties to the deseralize?
  67876. */
  67877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67878. }
  67879. }
  67880. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67884. /**
  67885. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67886. */
  67887. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67888. /**
  67889. * Creates a new SimplexPerlin3DBlock
  67890. * @param name defines the block name
  67891. */
  67892. constructor(name: string);
  67893. /**
  67894. * Gets the current class name
  67895. * @returns the class name
  67896. */
  67897. getClassName(): string;
  67898. /**
  67899. * Gets the seed operand input component
  67900. */
  67901. get seed(): NodeMaterialConnectionPoint;
  67902. /**
  67903. * Gets the output component
  67904. */
  67905. get output(): NodeMaterialConnectionPoint;
  67906. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67907. }
  67908. }
  67909. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67913. /**
  67914. * Block used to blend normals
  67915. */
  67916. export class NormalBlendBlock extends NodeMaterialBlock {
  67917. /**
  67918. * Creates a new NormalBlendBlock
  67919. * @param name defines the block name
  67920. */
  67921. constructor(name: string);
  67922. /**
  67923. * Gets the current class name
  67924. * @returns the class name
  67925. */
  67926. getClassName(): string;
  67927. /**
  67928. * Gets the first input component
  67929. */
  67930. get normalMap0(): NodeMaterialConnectionPoint;
  67931. /**
  67932. * Gets the second input component
  67933. */
  67934. get normalMap1(): NodeMaterialConnectionPoint;
  67935. /**
  67936. * Gets the output component
  67937. */
  67938. get output(): NodeMaterialConnectionPoint;
  67939. protected _buildBlock(state: NodeMaterialBuildState): this;
  67940. }
  67941. }
  67942. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67946. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67947. /**
  67948. * Block used to rotate a 2d vector by a given angle
  67949. */
  67950. export class Rotate2dBlock extends NodeMaterialBlock {
  67951. /**
  67952. * Creates a new Rotate2dBlock
  67953. * @param name defines the block name
  67954. */
  67955. constructor(name: string);
  67956. /**
  67957. * Gets the current class name
  67958. * @returns the class name
  67959. */
  67960. getClassName(): string;
  67961. /**
  67962. * Gets the input vector
  67963. */
  67964. get input(): NodeMaterialConnectionPoint;
  67965. /**
  67966. * Gets the input angle
  67967. */
  67968. get angle(): NodeMaterialConnectionPoint;
  67969. /**
  67970. * Gets the output component
  67971. */
  67972. get output(): NodeMaterialConnectionPoint;
  67973. autoConfigure(material: NodeMaterial): void;
  67974. protected _buildBlock(state: NodeMaterialBuildState): this;
  67975. }
  67976. }
  67977. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67981. /**
  67982. * Block used to get the reflected vector from a direction and a normal
  67983. */
  67984. export class ReflectBlock extends NodeMaterialBlock {
  67985. /**
  67986. * Creates a new ReflectBlock
  67987. * @param name defines the block name
  67988. */
  67989. constructor(name: string);
  67990. /**
  67991. * Gets the current class name
  67992. * @returns the class name
  67993. */
  67994. getClassName(): string;
  67995. /**
  67996. * Gets the incident component
  67997. */
  67998. get incident(): NodeMaterialConnectionPoint;
  67999. /**
  68000. * Gets the normal component
  68001. */
  68002. get normal(): NodeMaterialConnectionPoint;
  68003. /**
  68004. * Gets the output component
  68005. */
  68006. get output(): NodeMaterialConnectionPoint;
  68007. protected _buildBlock(state: NodeMaterialBuildState): this;
  68008. }
  68009. }
  68010. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68014. /**
  68015. * Block used to get the refracted vector from a direction and a normal
  68016. */
  68017. export class RefractBlock extends NodeMaterialBlock {
  68018. /**
  68019. * Creates a new RefractBlock
  68020. * @param name defines the block name
  68021. */
  68022. constructor(name: string);
  68023. /**
  68024. * Gets the current class name
  68025. * @returns the class name
  68026. */
  68027. getClassName(): string;
  68028. /**
  68029. * Gets the incident component
  68030. */
  68031. get incident(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the normal component
  68034. */
  68035. get normal(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the index of refraction component
  68038. */
  68039. get ior(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the output component
  68042. */
  68043. get output(): NodeMaterialConnectionPoint;
  68044. protected _buildBlock(state: NodeMaterialBuildState): this;
  68045. }
  68046. }
  68047. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68051. /**
  68052. * Block used to desaturate a color
  68053. */
  68054. export class DesaturateBlock extends NodeMaterialBlock {
  68055. /**
  68056. * Creates a new DesaturateBlock
  68057. * @param name defines the block name
  68058. */
  68059. constructor(name: string);
  68060. /**
  68061. * Gets the current class name
  68062. * @returns the class name
  68063. */
  68064. getClassName(): string;
  68065. /**
  68066. * Gets the color operand input component
  68067. */
  68068. get color(): NodeMaterialConnectionPoint;
  68069. /**
  68070. * Gets the level operand input component
  68071. */
  68072. get level(): NodeMaterialConnectionPoint;
  68073. /**
  68074. * Gets the output component
  68075. */
  68076. get output(): NodeMaterialConnectionPoint;
  68077. protected _buildBlock(state: NodeMaterialBuildState): this;
  68078. }
  68079. }
  68080. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68084. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68085. import { Nullable } from "babylonjs/types";
  68086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68087. import { Scene } from "babylonjs/scene";
  68088. /**
  68089. * Block used to implement the ambient occlusion module of the PBR material
  68090. */
  68091. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68092. /**
  68093. * Create a new AmbientOcclusionBlock
  68094. * @param name defines the block name
  68095. */
  68096. constructor(name: string);
  68097. /**
  68098. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68099. */
  68100. useAmbientInGrayScale: boolean;
  68101. /**
  68102. * Initialize the block and prepare the context for build
  68103. * @param state defines the state that will be used for the build
  68104. */
  68105. initialize(state: NodeMaterialBuildState): void;
  68106. /**
  68107. * Gets the current class name
  68108. * @returns the class name
  68109. */
  68110. getClassName(): string;
  68111. /**
  68112. * Gets the texture input component
  68113. */
  68114. get texture(): NodeMaterialConnectionPoint;
  68115. /**
  68116. * Gets the texture intensity component
  68117. */
  68118. get intensity(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the direct light intensity input component
  68121. */
  68122. get directLightIntensity(): NodeMaterialConnectionPoint;
  68123. /**
  68124. * Gets the ambient occlusion object output component
  68125. */
  68126. get ambientOcc(): NodeMaterialConnectionPoint;
  68127. /**
  68128. * Gets the main code of the block (fragment side)
  68129. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68130. * @returns the shader code
  68131. */
  68132. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68134. protected _buildBlock(state: NodeMaterialBuildState): this;
  68135. protected _dumpPropertiesCode(): string;
  68136. serialize(): any;
  68137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68138. }
  68139. }
  68140. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68143. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68144. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68146. import { Nullable } from "babylonjs/types";
  68147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68148. import { Mesh } from "babylonjs/Meshes/mesh";
  68149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68150. import { Effect } from "babylonjs/Materials/effect";
  68151. import { Scene } from "babylonjs/scene";
  68152. /**
  68153. * Block used to implement the reflection module of the PBR material
  68154. */
  68155. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68156. /** @hidden */
  68157. _defineLODReflectionAlpha: string;
  68158. /** @hidden */
  68159. _defineLinearSpecularReflection: string;
  68160. private _vEnvironmentIrradianceName;
  68161. /** @hidden */
  68162. _vReflectionMicrosurfaceInfosName: string;
  68163. /** @hidden */
  68164. _vReflectionInfosName: string;
  68165. /** @hidden */
  68166. _vReflectionFilteringInfoName: string;
  68167. private _scene;
  68168. /**
  68169. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68170. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68171. * It's less burden on the user side in the editor part.
  68172. */
  68173. /** @hidden */
  68174. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68175. /** @hidden */
  68176. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68177. /** @hidden */
  68178. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68179. /**
  68180. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68181. * diffuse part of the IBL.
  68182. */
  68183. useSphericalHarmonics: boolean;
  68184. /**
  68185. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68186. */
  68187. forceIrradianceInFragment: boolean;
  68188. /**
  68189. * Create a new ReflectionBlock
  68190. * @param name defines the block name
  68191. */
  68192. constructor(name: string);
  68193. /**
  68194. * Gets the current class name
  68195. * @returns the class name
  68196. */
  68197. getClassName(): string;
  68198. /**
  68199. * Gets the position input component
  68200. */
  68201. get position(): NodeMaterialConnectionPoint;
  68202. /**
  68203. * Gets the world position input component
  68204. */
  68205. get worldPosition(): NodeMaterialConnectionPoint;
  68206. /**
  68207. * Gets the world normal input component
  68208. */
  68209. get worldNormal(): NodeMaterialConnectionPoint;
  68210. /**
  68211. * Gets the world input component
  68212. */
  68213. get world(): NodeMaterialConnectionPoint;
  68214. /**
  68215. * Gets the camera (or eye) position component
  68216. */
  68217. get cameraPosition(): NodeMaterialConnectionPoint;
  68218. /**
  68219. * Gets the view input component
  68220. */
  68221. get view(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the color input component
  68224. */
  68225. get color(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the reflection object output component
  68228. */
  68229. get reflection(): NodeMaterialConnectionPoint;
  68230. /**
  68231. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68232. */
  68233. get hasTexture(): boolean;
  68234. /**
  68235. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68236. */
  68237. get reflectionColor(): string;
  68238. protected _getTexture(): Nullable<BaseTexture>;
  68239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68241. /**
  68242. * Gets the code to inject in the vertex shader
  68243. * @param state current state of the node material building
  68244. * @returns the shader code
  68245. */
  68246. handleVertexSide(state: NodeMaterialBuildState): string;
  68247. /**
  68248. * Gets the main code of the block (fragment side)
  68249. * @param state current state of the node material building
  68250. * @param normalVarName name of the existing variable corresponding to the normal
  68251. * @returns the shader code
  68252. */
  68253. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68254. protected _buildBlock(state: NodeMaterialBuildState): this;
  68255. protected _dumpPropertiesCode(): string;
  68256. serialize(): any;
  68257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68258. }
  68259. }
  68260. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68264. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68266. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68267. import { Scene } from "babylonjs/scene";
  68268. import { Nullable } from "babylonjs/types";
  68269. /**
  68270. * Block used to implement the sheen module of the PBR material
  68271. */
  68272. export class SheenBlock extends NodeMaterialBlock {
  68273. /**
  68274. * Create a new SheenBlock
  68275. * @param name defines the block name
  68276. */
  68277. constructor(name: string);
  68278. /**
  68279. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68280. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68281. * making it easier to setup and tweak the effect
  68282. */
  68283. albedoScaling: boolean;
  68284. /**
  68285. * Defines if the sheen is linked to the sheen color.
  68286. */
  68287. linkSheenWithAlbedo: boolean;
  68288. /**
  68289. * Initialize the block and prepare the context for build
  68290. * @param state defines the state that will be used for the build
  68291. */
  68292. initialize(state: NodeMaterialBuildState): void;
  68293. /**
  68294. * Gets the current class name
  68295. * @returns the class name
  68296. */
  68297. getClassName(): string;
  68298. /**
  68299. * Gets the intensity input component
  68300. */
  68301. get intensity(): NodeMaterialConnectionPoint;
  68302. /**
  68303. * Gets the color input component
  68304. */
  68305. get color(): NodeMaterialConnectionPoint;
  68306. /**
  68307. * Gets the roughness input component
  68308. */
  68309. get roughness(): NodeMaterialConnectionPoint;
  68310. /**
  68311. * Gets the sheen object output component
  68312. */
  68313. get sheen(): NodeMaterialConnectionPoint;
  68314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68315. /**
  68316. * Gets the main code of the block (fragment side)
  68317. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68318. * @returns the shader code
  68319. */
  68320. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68321. protected _buildBlock(state: NodeMaterialBuildState): this;
  68322. protected _dumpPropertiesCode(): string;
  68323. serialize(): any;
  68324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68325. }
  68326. }
  68327. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68328. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68333. import { Scene } from "babylonjs/scene";
  68334. import { Nullable } from "babylonjs/types";
  68335. import { Mesh } from "babylonjs/Meshes/mesh";
  68336. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68337. import { Effect } from "babylonjs/Materials/effect";
  68338. /**
  68339. * Block used to implement the reflectivity module of the PBR material
  68340. */
  68341. export class ReflectivityBlock extends NodeMaterialBlock {
  68342. private _metallicReflectanceColor;
  68343. private _metallicF0Factor;
  68344. /** @hidden */
  68345. _vMetallicReflectanceFactorsName: string;
  68346. /**
  68347. * The property below is set by the main PBR block prior to calling methods of this class.
  68348. */
  68349. /** @hidden */
  68350. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68351. /**
  68352. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68353. */
  68354. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68355. /**
  68356. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68357. */
  68358. useMetallnessFromMetallicTextureBlue: boolean;
  68359. /**
  68360. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68361. */
  68362. useRoughnessFromMetallicTextureAlpha: boolean;
  68363. /**
  68364. * Specifies if the metallic texture contains the roughness information in its green channel.
  68365. */
  68366. useRoughnessFromMetallicTextureGreen: boolean;
  68367. /**
  68368. * Create a new ReflectivityBlock
  68369. * @param name defines the block name
  68370. */
  68371. constructor(name: string);
  68372. /**
  68373. * Initialize the block and prepare the context for build
  68374. * @param state defines the state that will be used for the build
  68375. */
  68376. initialize(state: NodeMaterialBuildState): void;
  68377. /**
  68378. * Gets the current class name
  68379. * @returns the class name
  68380. */
  68381. getClassName(): string;
  68382. /**
  68383. * Gets the metallic input component
  68384. */
  68385. get metallic(): NodeMaterialConnectionPoint;
  68386. /**
  68387. * Gets the roughness input component
  68388. */
  68389. get roughness(): NodeMaterialConnectionPoint;
  68390. /**
  68391. * Gets the texture input component
  68392. */
  68393. get texture(): NodeMaterialConnectionPoint;
  68394. /**
  68395. * Gets the reflectivity object output component
  68396. */
  68397. get reflectivity(): NodeMaterialConnectionPoint;
  68398. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68399. /**
  68400. * Gets the main code of the block (fragment side)
  68401. * @param state current state of the node material building
  68402. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68403. * @returns the shader code
  68404. */
  68405. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68407. protected _buildBlock(state: NodeMaterialBuildState): this;
  68408. protected _dumpPropertiesCode(): string;
  68409. serialize(): any;
  68410. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68411. }
  68412. }
  68413. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68414. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68419. /**
  68420. * Block used to implement the anisotropy module of the PBR material
  68421. */
  68422. export class AnisotropyBlock extends NodeMaterialBlock {
  68423. /**
  68424. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68425. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68426. * It's less burden on the user side in the editor part.
  68427. */
  68428. /** @hidden */
  68429. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68430. /** @hidden */
  68431. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68432. /**
  68433. * Create a new AnisotropyBlock
  68434. * @param name defines the block name
  68435. */
  68436. constructor(name: string);
  68437. /**
  68438. * Initialize the block and prepare the context for build
  68439. * @param state defines the state that will be used for the build
  68440. */
  68441. initialize(state: NodeMaterialBuildState): void;
  68442. /**
  68443. * Gets the current class name
  68444. * @returns the class name
  68445. */
  68446. getClassName(): string;
  68447. /**
  68448. * Gets the intensity input component
  68449. */
  68450. get intensity(): NodeMaterialConnectionPoint;
  68451. /**
  68452. * Gets the direction input component
  68453. */
  68454. get direction(): NodeMaterialConnectionPoint;
  68455. /**
  68456. * Gets the texture input component
  68457. */
  68458. get texture(): NodeMaterialConnectionPoint;
  68459. /**
  68460. * Gets the uv input component
  68461. */
  68462. get uv(): NodeMaterialConnectionPoint;
  68463. /**
  68464. * Gets the worldTangent input component
  68465. */
  68466. get worldTangent(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the anisotropy object output component
  68469. */
  68470. get anisotropy(): NodeMaterialConnectionPoint;
  68471. private _generateTBNSpace;
  68472. /**
  68473. * Gets the main code of the block (fragment side)
  68474. * @param state current state of the node material building
  68475. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68476. * @returns the shader code
  68477. */
  68478. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68480. protected _buildBlock(state: NodeMaterialBuildState): this;
  68481. }
  68482. }
  68483. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68489. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68490. import { Nullable } from "babylonjs/types";
  68491. import { Mesh } from "babylonjs/Meshes/mesh";
  68492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68493. import { Effect } from "babylonjs/Materials/effect";
  68494. /**
  68495. * Block used to implement the clear coat module of the PBR material
  68496. */
  68497. export class ClearCoatBlock extends NodeMaterialBlock {
  68498. private _scene;
  68499. /**
  68500. * Create a new ClearCoatBlock
  68501. * @param name defines the block name
  68502. */
  68503. constructor(name: string);
  68504. /**
  68505. * Initialize the block and prepare the context for build
  68506. * @param state defines the state that will be used for the build
  68507. */
  68508. initialize(state: NodeMaterialBuildState): void;
  68509. /**
  68510. * Gets the current class name
  68511. * @returns the class name
  68512. */
  68513. getClassName(): string;
  68514. /**
  68515. * Gets the intensity input component
  68516. */
  68517. get intensity(): NodeMaterialConnectionPoint;
  68518. /**
  68519. * Gets the roughness input component
  68520. */
  68521. get roughness(): NodeMaterialConnectionPoint;
  68522. /**
  68523. * Gets the ior input component
  68524. */
  68525. get ior(): NodeMaterialConnectionPoint;
  68526. /**
  68527. * Gets the texture input component
  68528. */
  68529. get texture(): NodeMaterialConnectionPoint;
  68530. /**
  68531. * Gets the bump texture input component
  68532. */
  68533. get bumpTexture(): NodeMaterialConnectionPoint;
  68534. /**
  68535. * Gets the uv input component
  68536. */
  68537. get uv(): NodeMaterialConnectionPoint;
  68538. /**
  68539. * Gets the tint color input component
  68540. */
  68541. get tintColor(): NodeMaterialConnectionPoint;
  68542. /**
  68543. * Gets the tint "at distance" input component
  68544. */
  68545. get tintAtDistance(): NodeMaterialConnectionPoint;
  68546. /**
  68547. * Gets the tint thickness input component
  68548. */
  68549. get tintThickness(): NodeMaterialConnectionPoint;
  68550. /**
  68551. * Gets the world tangent input component
  68552. */
  68553. get worldTangent(): NodeMaterialConnectionPoint;
  68554. /**
  68555. * Gets the clear coat object output component
  68556. */
  68557. get clearcoat(): NodeMaterialConnectionPoint;
  68558. autoConfigure(material: NodeMaterial): void;
  68559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68560. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68561. private _generateTBNSpace;
  68562. /**
  68563. * Gets the main code of the block (fragment side)
  68564. * @param state current state of the node material building
  68565. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68566. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68567. * @param worldPosVarName name of the variable holding the world position
  68568. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68569. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68570. * @param worldNormalVarName name of the variable holding the world normal
  68571. * @returns the shader code
  68572. */
  68573. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68574. protected _buildBlock(state: NodeMaterialBuildState): this;
  68575. }
  68576. }
  68577. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68581. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68583. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68584. import { Nullable } from "babylonjs/types";
  68585. /**
  68586. * Block used to implement the sub surface module of the PBR material
  68587. */
  68588. export class SubSurfaceBlock extends NodeMaterialBlock {
  68589. /**
  68590. * Create a new SubSurfaceBlock
  68591. * @param name defines the block name
  68592. */
  68593. constructor(name: string);
  68594. /**
  68595. * Stores the intensity of the different subsurface effects in the thickness texture.
  68596. * * the green channel is the translucency intensity.
  68597. * * the blue channel is the scattering intensity.
  68598. * * the alpha channel is the refraction intensity.
  68599. */
  68600. useMaskFromThicknessTexture: boolean;
  68601. /**
  68602. * Initialize the block and prepare the context for build
  68603. * @param state defines the state that will be used for the build
  68604. */
  68605. initialize(state: NodeMaterialBuildState): void;
  68606. /**
  68607. * Gets the current class name
  68608. * @returns the class name
  68609. */
  68610. getClassName(): string;
  68611. /**
  68612. * Gets the min thickness input component
  68613. */
  68614. get minThickness(): NodeMaterialConnectionPoint;
  68615. /**
  68616. * Gets the max thickness input component
  68617. */
  68618. get maxThickness(): NodeMaterialConnectionPoint;
  68619. /**
  68620. * Gets the thickness texture component
  68621. */
  68622. get thicknessTexture(): NodeMaterialConnectionPoint;
  68623. /**
  68624. * Gets the tint color input component
  68625. */
  68626. get tintColor(): NodeMaterialConnectionPoint;
  68627. /**
  68628. * Gets the translucency intensity input component
  68629. */
  68630. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68631. /**
  68632. * Gets the translucency diffusion distance input component
  68633. */
  68634. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68635. /**
  68636. * Gets the refraction object parameters
  68637. */
  68638. get refraction(): NodeMaterialConnectionPoint;
  68639. /**
  68640. * Gets the sub surface object output component
  68641. */
  68642. get subsurface(): NodeMaterialConnectionPoint;
  68643. autoConfigure(material: NodeMaterial): void;
  68644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68645. /**
  68646. * Gets the main code of the block (fragment side)
  68647. * @param state current state of the node material building
  68648. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68649. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68650. * @param worldPosVarName name of the variable holding the world position
  68651. * @returns the shader code
  68652. */
  68653. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68654. protected _buildBlock(state: NodeMaterialBuildState): this;
  68655. }
  68656. }
  68657. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68661. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68662. import { Light } from "babylonjs/Lights/light";
  68663. import { Nullable } from "babylonjs/types";
  68664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68665. import { Effect } from "babylonjs/Materials/effect";
  68666. import { Mesh } from "babylonjs/Meshes/mesh";
  68667. import { Scene } from "babylonjs/scene";
  68668. /**
  68669. * Block used to implement the PBR metallic/roughness model
  68670. */
  68671. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68672. /**
  68673. * Gets or sets the light associated with this block
  68674. */
  68675. light: Nullable<Light>;
  68676. private _lightId;
  68677. private _scene;
  68678. private _environmentBRDFTexture;
  68679. private _environmentBrdfSamplerName;
  68680. private _vNormalWName;
  68681. private _invertNormalName;
  68682. /**
  68683. * Create a new ReflectionBlock
  68684. * @param name defines the block name
  68685. */
  68686. constructor(name: string);
  68687. /**
  68688. * Intensity of the direct lights e.g. the four lights available in your scene.
  68689. * This impacts both the direct diffuse and specular highlights.
  68690. */
  68691. directIntensity: number;
  68692. /**
  68693. * Intensity of the environment e.g. how much the environment will light the object
  68694. * either through harmonics for rough material or through the refelction for shiny ones.
  68695. */
  68696. environmentIntensity: number;
  68697. /**
  68698. * This is a special control allowing the reduction of the specular highlights coming from the
  68699. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68700. */
  68701. specularIntensity: number;
  68702. /**
  68703. * Defines the falloff type used in this material.
  68704. * It by default is Physical.
  68705. */
  68706. lightFalloff: number;
  68707. /**
  68708. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68709. */
  68710. useAlphaFromAlbedoTexture: boolean;
  68711. /**
  68712. * Specifies that alpha test should be used
  68713. */
  68714. useAlphaTest: boolean;
  68715. /**
  68716. * Defines the alpha limits in alpha test mode.
  68717. */
  68718. alphaTestCutoff: number;
  68719. /**
  68720. * Specifies that alpha blending should be used
  68721. */
  68722. useAlphaBlending: boolean;
  68723. /**
  68724. * Defines if the alpha value should be determined via the rgb values.
  68725. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68726. */
  68727. opacityRGB: boolean;
  68728. /**
  68729. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68730. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68731. */
  68732. useRadianceOverAlpha: boolean;
  68733. /**
  68734. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68735. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68736. */
  68737. useSpecularOverAlpha: boolean;
  68738. /**
  68739. * Enables specular anti aliasing in the PBR shader.
  68740. * It will both interacts on the Geometry for analytical and IBL lighting.
  68741. * It also prefilter the roughness map based on the bump values.
  68742. */
  68743. enableSpecularAntiAliasing: boolean;
  68744. /**
  68745. * Enables realtime filtering on the texture.
  68746. */
  68747. realTimeFiltering: boolean;
  68748. /**
  68749. * Quality switch for realtime filtering
  68750. */
  68751. realTimeFilteringQuality: number;
  68752. /**
  68753. * Defines if the material uses energy conservation.
  68754. */
  68755. useEnergyConservation: boolean;
  68756. /**
  68757. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68758. * too much the area relying on ambient texture to define their ambient occlusion.
  68759. */
  68760. useRadianceOcclusion: boolean;
  68761. /**
  68762. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68763. * makes the reflect vector face the model (under horizon).
  68764. */
  68765. useHorizonOcclusion: boolean;
  68766. /**
  68767. * If set to true, no lighting calculations will be applied.
  68768. */
  68769. unlit: boolean;
  68770. /**
  68771. * Force normal to face away from face.
  68772. */
  68773. forceNormalForward: boolean;
  68774. /**
  68775. * Defines the material debug mode.
  68776. * It helps seeing only some components of the material while troubleshooting.
  68777. */
  68778. debugMode: number;
  68779. /**
  68780. * Specify from where on screen the debug mode should start.
  68781. * The value goes from -1 (full screen) to 1 (not visible)
  68782. * It helps with side by side comparison against the final render
  68783. * This defaults to 0
  68784. */
  68785. debugLimit: number;
  68786. /**
  68787. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68788. * You can use the factor to better multiply the final value.
  68789. */
  68790. debugFactor: number;
  68791. /**
  68792. * Initialize the block and prepare the context for build
  68793. * @param state defines the state that will be used for the build
  68794. */
  68795. initialize(state: NodeMaterialBuildState): void;
  68796. /**
  68797. * Gets the current class name
  68798. * @returns the class name
  68799. */
  68800. getClassName(): string;
  68801. /**
  68802. * Gets the world position input component
  68803. */
  68804. get worldPosition(): NodeMaterialConnectionPoint;
  68805. /**
  68806. * Gets the world normal input component
  68807. */
  68808. get worldNormal(): NodeMaterialConnectionPoint;
  68809. /**
  68810. * Gets the perturbed normal input component
  68811. */
  68812. get perturbedNormal(): NodeMaterialConnectionPoint;
  68813. /**
  68814. * Gets the camera position input component
  68815. */
  68816. get cameraPosition(): NodeMaterialConnectionPoint;
  68817. /**
  68818. * Gets the base color input component
  68819. */
  68820. get baseColor(): NodeMaterialConnectionPoint;
  68821. /**
  68822. * Gets the opacity texture input component
  68823. */
  68824. get opacityTexture(): NodeMaterialConnectionPoint;
  68825. /**
  68826. * Gets the ambient color input component
  68827. */
  68828. get ambientColor(): NodeMaterialConnectionPoint;
  68829. /**
  68830. * Gets the reflectivity object parameters
  68831. */
  68832. get reflectivity(): NodeMaterialConnectionPoint;
  68833. /**
  68834. * Gets the ambient occlusion object parameters
  68835. */
  68836. get ambientOcc(): NodeMaterialConnectionPoint;
  68837. /**
  68838. * Gets the reflection object parameters
  68839. */
  68840. get reflection(): NodeMaterialConnectionPoint;
  68841. /**
  68842. * Gets the sheen object parameters
  68843. */
  68844. get sheen(): NodeMaterialConnectionPoint;
  68845. /**
  68846. * Gets the clear coat object parameters
  68847. */
  68848. get clearcoat(): NodeMaterialConnectionPoint;
  68849. /**
  68850. * Gets the sub surface object parameters
  68851. */
  68852. get subsurface(): NodeMaterialConnectionPoint;
  68853. /**
  68854. * Gets the anisotropy object parameters
  68855. */
  68856. get anisotropy(): NodeMaterialConnectionPoint;
  68857. /**
  68858. * Gets the ambient output component
  68859. */
  68860. get ambient(): NodeMaterialConnectionPoint;
  68861. /**
  68862. * Gets the diffuse output component
  68863. */
  68864. get diffuse(): NodeMaterialConnectionPoint;
  68865. /**
  68866. * Gets the specular output component
  68867. */
  68868. get specular(): NodeMaterialConnectionPoint;
  68869. /**
  68870. * Gets the sheen output component
  68871. */
  68872. get sheenDir(): NodeMaterialConnectionPoint;
  68873. /**
  68874. * Gets the clear coat output component
  68875. */
  68876. get clearcoatDir(): NodeMaterialConnectionPoint;
  68877. /**
  68878. * Gets the indirect diffuse output component
  68879. */
  68880. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68881. /**
  68882. * Gets the indirect specular output component
  68883. */
  68884. get specularIndirect(): NodeMaterialConnectionPoint;
  68885. /**
  68886. * Gets the indirect sheen output component
  68887. */
  68888. get sheenIndirect(): NodeMaterialConnectionPoint;
  68889. /**
  68890. * Gets the indirect clear coat output component
  68891. */
  68892. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68893. /**
  68894. * Gets the refraction output component
  68895. */
  68896. get refraction(): NodeMaterialConnectionPoint;
  68897. /**
  68898. * Gets the global lighting output component
  68899. */
  68900. get lighting(): NodeMaterialConnectionPoint;
  68901. /**
  68902. * Gets the shadow output component
  68903. */
  68904. get shadow(): NodeMaterialConnectionPoint;
  68905. /**
  68906. * Gets the alpha output component
  68907. */
  68908. get alpha(): NodeMaterialConnectionPoint;
  68909. autoConfigure(material: NodeMaterial): void;
  68910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68911. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68912. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68913. private _injectVertexCode;
  68914. /**
  68915. * Gets the code corresponding to the albedo/opacity module
  68916. * @returns the shader code
  68917. */
  68918. getAlbedoOpacityCode(): string;
  68919. protected _buildBlock(state: NodeMaterialBuildState): this;
  68920. protected _dumpPropertiesCode(): string;
  68921. serialize(): any;
  68922. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68923. }
  68924. }
  68925. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68926. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68927. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68928. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68929. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68930. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68931. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68932. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68933. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68934. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68935. }
  68936. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68937. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68938. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68939. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68940. }
  68941. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68945. /**
  68946. * Block used to compute value of one parameter modulo another
  68947. */
  68948. export class ModBlock extends NodeMaterialBlock {
  68949. /**
  68950. * Creates a new ModBlock
  68951. * @param name defines the block name
  68952. */
  68953. constructor(name: string);
  68954. /**
  68955. * Gets the current class name
  68956. * @returns the class name
  68957. */
  68958. getClassName(): string;
  68959. /**
  68960. * Gets the left operand input component
  68961. */
  68962. get left(): NodeMaterialConnectionPoint;
  68963. /**
  68964. * Gets the right operand input component
  68965. */
  68966. get right(): NodeMaterialConnectionPoint;
  68967. /**
  68968. * Gets the output component
  68969. */
  68970. get output(): NodeMaterialConnectionPoint;
  68971. protected _buildBlock(state: NodeMaterialBuildState): this;
  68972. }
  68973. }
  68974. declare module "babylonjs/Materials/Node/Blocks/index" {
  68975. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68976. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68977. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68978. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68979. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68980. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68981. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68982. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68983. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68984. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68985. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68986. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68987. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68988. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68989. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68990. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68991. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68992. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68993. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68994. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68995. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68996. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68997. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68998. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68999. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69000. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69001. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69002. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69003. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69004. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69005. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69006. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69007. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69008. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69009. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69010. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69011. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69012. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69013. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69014. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69015. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69016. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69017. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69018. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69019. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69020. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69021. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69022. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69023. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69024. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69025. }
  69026. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69027. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69028. }
  69029. declare module "babylonjs/Materials/Node/index" {
  69030. export * from "babylonjs/Materials/Node/Enums/index";
  69031. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69032. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69033. export * from "babylonjs/Materials/Node/nodeMaterial";
  69034. export * from "babylonjs/Materials/Node/Blocks/index";
  69035. export * from "babylonjs/Materials/Node/Optimizers/index";
  69036. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69037. }
  69038. declare module "babylonjs/Materials/index" {
  69039. export * from "babylonjs/Materials/Background/index";
  69040. export * from "babylonjs/Materials/colorCurves";
  69041. export * from "babylonjs/Materials/iEffectFallbacks";
  69042. export * from "babylonjs/Materials/effectFallbacks";
  69043. export * from "babylonjs/Materials/effect";
  69044. export * from "babylonjs/Materials/fresnelParameters";
  69045. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69046. export * from "babylonjs/Materials/material";
  69047. export * from "babylonjs/Materials/materialDefines";
  69048. export * from "babylonjs/Materials/thinMaterialHelper";
  69049. export * from "babylonjs/Materials/materialHelper";
  69050. export * from "babylonjs/Materials/multiMaterial";
  69051. export * from "babylonjs/Materials/PBR/index";
  69052. export * from "babylonjs/Materials/pushMaterial";
  69053. export * from "babylonjs/Materials/shaderMaterial";
  69054. export * from "babylonjs/Materials/standardMaterial";
  69055. export * from "babylonjs/Materials/Textures/index";
  69056. export * from "babylonjs/Materials/uniformBuffer";
  69057. export * from "babylonjs/Materials/materialFlags";
  69058. export * from "babylonjs/Materials/Node/index";
  69059. export * from "babylonjs/Materials/effectRenderer";
  69060. export * from "babylonjs/Materials/shadowDepthWrapper";
  69061. }
  69062. declare module "babylonjs/Maths/index" {
  69063. export * from "babylonjs/Maths/math.scalar";
  69064. export * from "babylonjs/Maths/math";
  69065. export * from "babylonjs/Maths/sphericalPolynomial";
  69066. }
  69067. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69068. import { IDisposable } from "babylonjs/scene";
  69069. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69070. /**
  69071. * Configuration for Draco compression
  69072. */
  69073. export interface IDracoCompressionConfiguration {
  69074. /**
  69075. * Configuration for the decoder.
  69076. */
  69077. decoder: {
  69078. /**
  69079. * The url to the WebAssembly module.
  69080. */
  69081. wasmUrl?: string;
  69082. /**
  69083. * The url to the WebAssembly binary.
  69084. */
  69085. wasmBinaryUrl?: string;
  69086. /**
  69087. * The url to the fallback JavaScript module.
  69088. */
  69089. fallbackUrl?: string;
  69090. };
  69091. }
  69092. /**
  69093. * Draco compression (https://google.github.io/draco/)
  69094. *
  69095. * This class wraps the Draco module.
  69096. *
  69097. * **Encoder**
  69098. *
  69099. * The encoder is not currently implemented.
  69100. *
  69101. * **Decoder**
  69102. *
  69103. * 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.
  69104. *
  69105. * To update the configuration, use the following code:
  69106. * ```javascript
  69107. * DracoCompression.Configuration = {
  69108. * decoder: {
  69109. * wasmUrl: "<url to the WebAssembly library>",
  69110. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69111. * fallbackUrl: "<url to the fallback JavaScript library>",
  69112. * }
  69113. * };
  69114. * ```
  69115. *
  69116. * 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.
  69117. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69118. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69119. *
  69120. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69121. * ```javascript
  69122. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69123. * ```
  69124. *
  69125. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69126. */
  69127. export class DracoCompression implements IDisposable {
  69128. private _workerPoolPromise?;
  69129. private _decoderModulePromise?;
  69130. /**
  69131. * The configuration. Defaults to the following urls:
  69132. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69133. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69134. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69135. */
  69136. static Configuration: IDracoCompressionConfiguration;
  69137. /**
  69138. * Returns true if the decoder configuration is available.
  69139. */
  69140. static get DecoderAvailable(): boolean;
  69141. /**
  69142. * Default number of workers to create when creating the draco compression object.
  69143. */
  69144. static DefaultNumWorkers: number;
  69145. private static GetDefaultNumWorkers;
  69146. private static _Default;
  69147. /**
  69148. * Default instance for the draco compression object.
  69149. */
  69150. static get Default(): DracoCompression;
  69151. /**
  69152. * Constructor
  69153. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69154. */
  69155. constructor(numWorkers?: number);
  69156. /**
  69157. * Stop all async operations and release resources.
  69158. */
  69159. dispose(): void;
  69160. /**
  69161. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69162. * @returns a promise that resolves when ready
  69163. */
  69164. whenReadyAsync(): Promise<void>;
  69165. /**
  69166. * Decode Draco compressed mesh data to vertex data.
  69167. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69168. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69169. * @returns A promise that resolves with the decoded vertex data
  69170. */
  69171. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69172. [kind: string]: number;
  69173. }): Promise<VertexData>;
  69174. }
  69175. }
  69176. declare module "babylonjs/Meshes/Compression/index" {
  69177. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69178. }
  69179. declare module "babylonjs/Meshes/csg" {
  69180. import { Nullable } from "babylonjs/types";
  69181. import { Scene } from "babylonjs/scene";
  69182. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69183. import { Mesh } from "babylonjs/Meshes/mesh";
  69184. import { Material } from "babylonjs/Materials/material";
  69185. /**
  69186. * Class for building Constructive Solid Geometry
  69187. */
  69188. export class CSG {
  69189. private polygons;
  69190. /**
  69191. * The world matrix
  69192. */
  69193. matrix: Matrix;
  69194. /**
  69195. * Stores the position
  69196. */
  69197. position: Vector3;
  69198. /**
  69199. * Stores the rotation
  69200. */
  69201. rotation: Vector3;
  69202. /**
  69203. * Stores the rotation quaternion
  69204. */
  69205. rotationQuaternion: Nullable<Quaternion>;
  69206. /**
  69207. * Stores the scaling vector
  69208. */
  69209. scaling: Vector3;
  69210. /**
  69211. * Convert the Mesh to CSG
  69212. * @param mesh The Mesh to convert to CSG
  69213. * @returns A new CSG from the Mesh
  69214. */
  69215. static FromMesh(mesh: Mesh): CSG;
  69216. /**
  69217. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69218. * @param polygons Polygons used to construct a CSG solid
  69219. */
  69220. private static FromPolygons;
  69221. /**
  69222. * Clones, or makes a deep copy, of the CSG
  69223. * @returns A new CSG
  69224. */
  69225. clone(): CSG;
  69226. /**
  69227. * Unions this CSG with another CSG
  69228. * @param csg The CSG to union against this CSG
  69229. * @returns The unioned CSG
  69230. */
  69231. union(csg: CSG): CSG;
  69232. /**
  69233. * Unions this CSG with another CSG in place
  69234. * @param csg The CSG to union against this CSG
  69235. */
  69236. unionInPlace(csg: CSG): void;
  69237. /**
  69238. * Subtracts this CSG with another CSG
  69239. * @param csg The CSG to subtract against this CSG
  69240. * @returns A new CSG
  69241. */
  69242. subtract(csg: CSG): CSG;
  69243. /**
  69244. * Subtracts this CSG with another CSG in place
  69245. * @param csg The CSG to subtact against this CSG
  69246. */
  69247. subtractInPlace(csg: CSG): void;
  69248. /**
  69249. * Intersect this CSG with another CSG
  69250. * @param csg The CSG to intersect against this CSG
  69251. * @returns A new CSG
  69252. */
  69253. intersect(csg: CSG): CSG;
  69254. /**
  69255. * Intersects this CSG with another CSG in place
  69256. * @param csg The CSG to intersect against this CSG
  69257. */
  69258. intersectInPlace(csg: CSG): void;
  69259. /**
  69260. * Return a new CSG solid with solid and empty space switched. This solid is
  69261. * not modified.
  69262. * @returns A new CSG solid with solid and empty space switched
  69263. */
  69264. inverse(): CSG;
  69265. /**
  69266. * Inverses the CSG in place
  69267. */
  69268. inverseInPlace(): void;
  69269. /**
  69270. * This is used to keep meshes transformations so they can be restored
  69271. * when we build back a Babylon Mesh
  69272. * NB : All CSG operations are performed in world coordinates
  69273. * @param csg The CSG to copy the transform attributes from
  69274. * @returns This CSG
  69275. */
  69276. copyTransformAttributes(csg: CSG): CSG;
  69277. /**
  69278. * Build Raw mesh from CSG
  69279. * Coordinates here are in world space
  69280. * @param name The name of the mesh geometry
  69281. * @param scene The Scene
  69282. * @param keepSubMeshes Specifies if the submeshes should be kept
  69283. * @returns A new Mesh
  69284. */
  69285. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69286. /**
  69287. * Build Mesh from CSG taking material and transforms into account
  69288. * @param name The name of the Mesh
  69289. * @param material The material of the Mesh
  69290. * @param scene The Scene
  69291. * @param keepSubMeshes Specifies if submeshes should be kept
  69292. * @returns The new Mesh
  69293. */
  69294. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69295. }
  69296. }
  69297. declare module "babylonjs/Meshes/trailMesh" {
  69298. import { Mesh } from "babylonjs/Meshes/mesh";
  69299. import { Scene } from "babylonjs/scene";
  69300. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69301. /**
  69302. * Class used to create a trail following a mesh
  69303. */
  69304. export class TrailMesh extends Mesh {
  69305. private _generator;
  69306. private _autoStart;
  69307. private _running;
  69308. private _diameter;
  69309. private _length;
  69310. private _sectionPolygonPointsCount;
  69311. private _sectionVectors;
  69312. private _sectionNormalVectors;
  69313. private _beforeRenderObserver;
  69314. /**
  69315. * @constructor
  69316. * @param name The value used by scene.getMeshByName() to do a lookup.
  69317. * @param generator The mesh or transform node to generate a trail.
  69318. * @param scene The scene to add this mesh to.
  69319. * @param diameter Diameter of trailing mesh. Default is 1.
  69320. * @param length Length of trailing mesh. Default is 60.
  69321. * @param autoStart Automatically start trailing mesh. Default true.
  69322. */
  69323. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69324. /**
  69325. * "TrailMesh"
  69326. * @returns "TrailMesh"
  69327. */
  69328. getClassName(): string;
  69329. private _createMesh;
  69330. /**
  69331. * Start trailing mesh.
  69332. */
  69333. start(): void;
  69334. /**
  69335. * Stop trailing mesh.
  69336. */
  69337. stop(): void;
  69338. /**
  69339. * Update trailing mesh geometry.
  69340. */
  69341. update(): void;
  69342. /**
  69343. * Returns a new TrailMesh object.
  69344. * @param name is a string, the name given to the new mesh
  69345. * @param newGenerator use new generator object for cloned trail mesh
  69346. * @returns a new mesh
  69347. */
  69348. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69349. /**
  69350. * Serializes this trail mesh
  69351. * @param serializationObject object to write serialization to
  69352. */
  69353. serialize(serializationObject: any): void;
  69354. /**
  69355. * Parses a serialized trail mesh
  69356. * @param parsedMesh the serialized mesh
  69357. * @param scene the scene to create the trail mesh in
  69358. * @returns the created trail mesh
  69359. */
  69360. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69361. }
  69362. }
  69363. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69364. import { Nullable } from "babylonjs/types";
  69365. import { Scene } from "babylonjs/scene";
  69366. import { Vector4 } from "babylonjs/Maths/math.vector";
  69367. import { Color4 } from "babylonjs/Maths/math.color";
  69368. import { Mesh } from "babylonjs/Meshes/mesh";
  69369. /**
  69370. * Class containing static functions to help procedurally build meshes
  69371. */
  69372. export class TiledBoxBuilder {
  69373. /**
  69374. * Creates a box mesh
  69375. * 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)
  69376. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69380. * @param name defines the name of the mesh
  69381. * @param options defines the options used to create the mesh
  69382. * @param scene defines the hosting scene
  69383. * @returns the box mesh
  69384. */
  69385. static CreateTiledBox(name: string, options: {
  69386. pattern?: number;
  69387. width?: number;
  69388. height?: number;
  69389. depth?: number;
  69390. tileSize?: number;
  69391. tileWidth?: number;
  69392. tileHeight?: number;
  69393. alignHorizontal?: number;
  69394. alignVertical?: number;
  69395. faceUV?: Vector4[];
  69396. faceColors?: Color4[];
  69397. sideOrientation?: number;
  69398. updatable?: boolean;
  69399. }, scene?: Nullable<Scene>): Mesh;
  69400. }
  69401. }
  69402. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69403. import { Vector4 } from "babylonjs/Maths/math.vector";
  69404. import { Mesh } from "babylonjs/Meshes/mesh";
  69405. /**
  69406. * Class containing static functions to help procedurally build meshes
  69407. */
  69408. export class TorusKnotBuilder {
  69409. /**
  69410. * Creates a torus knot mesh
  69411. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69412. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69413. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69414. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69418. * @param name defines the name of the mesh
  69419. * @param options defines the options used to create the mesh
  69420. * @param scene defines the hosting scene
  69421. * @returns the torus knot mesh
  69422. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69423. */
  69424. static CreateTorusKnot(name: string, options: {
  69425. radius?: number;
  69426. tube?: number;
  69427. radialSegments?: number;
  69428. tubularSegments?: number;
  69429. p?: number;
  69430. q?: number;
  69431. updatable?: boolean;
  69432. sideOrientation?: number;
  69433. frontUVs?: Vector4;
  69434. backUVs?: Vector4;
  69435. }, scene: any): Mesh;
  69436. }
  69437. }
  69438. declare module "babylonjs/Meshes/polygonMesh" {
  69439. import { Scene } from "babylonjs/scene";
  69440. import { Vector2 } from "babylonjs/Maths/math.vector";
  69441. import { Mesh } from "babylonjs/Meshes/mesh";
  69442. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69443. import { Path2 } from "babylonjs/Maths/math.path";
  69444. /**
  69445. * Polygon
  69446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69447. */
  69448. export class Polygon {
  69449. /**
  69450. * Creates a rectangle
  69451. * @param xmin bottom X coord
  69452. * @param ymin bottom Y coord
  69453. * @param xmax top X coord
  69454. * @param ymax top Y coord
  69455. * @returns points that make the resulting rectation
  69456. */
  69457. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69458. /**
  69459. * Creates a circle
  69460. * @param radius radius of circle
  69461. * @param cx scale in x
  69462. * @param cy scale in y
  69463. * @param numberOfSides number of sides that make up the circle
  69464. * @returns points that make the resulting circle
  69465. */
  69466. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69467. /**
  69468. * Creates a polygon from input string
  69469. * @param input Input polygon data
  69470. * @returns the parsed points
  69471. */
  69472. static Parse(input: string): Vector2[];
  69473. /**
  69474. * Starts building a polygon from x and y coordinates
  69475. * @param x x coordinate
  69476. * @param y y coordinate
  69477. * @returns the started path2
  69478. */
  69479. static StartingAt(x: number, y: number): Path2;
  69480. }
  69481. /**
  69482. * Builds a polygon
  69483. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69484. */
  69485. export class PolygonMeshBuilder {
  69486. private _points;
  69487. private _outlinepoints;
  69488. private _holes;
  69489. private _name;
  69490. private _scene;
  69491. private _epoints;
  69492. private _eholes;
  69493. private _addToepoint;
  69494. /**
  69495. * Babylon reference to the earcut plugin.
  69496. */
  69497. bjsEarcut: any;
  69498. /**
  69499. * Creates a PolygonMeshBuilder
  69500. * @param name name of the builder
  69501. * @param contours Path of the polygon
  69502. * @param scene scene to add to when creating the mesh
  69503. * @param earcutInjection can be used to inject your own earcut reference
  69504. */
  69505. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69506. /**
  69507. * Adds a whole within the polygon
  69508. * @param hole Array of points defining the hole
  69509. * @returns this
  69510. */
  69511. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69512. /**
  69513. * Creates the polygon
  69514. * @param updatable If the mesh should be updatable
  69515. * @param depth The depth of the mesh created
  69516. * @returns the created mesh
  69517. */
  69518. build(updatable?: boolean, depth?: number): Mesh;
  69519. /**
  69520. * Creates the polygon
  69521. * @param depth The depth of the mesh created
  69522. * @returns the created VertexData
  69523. */
  69524. buildVertexData(depth?: number): VertexData;
  69525. /**
  69526. * Adds a side to the polygon
  69527. * @param positions points that make the polygon
  69528. * @param normals normals of the polygon
  69529. * @param uvs uvs of the polygon
  69530. * @param indices indices of the polygon
  69531. * @param bounds bounds of the polygon
  69532. * @param points points of the polygon
  69533. * @param depth depth of the polygon
  69534. * @param flip flip of the polygon
  69535. */
  69536. private addSide;
  69537. }
  69538. }
  69539. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69540. import { Scene } from "babylonjs/scene";
  69541. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69542. import { Color4 } from "babylonjs/Maths/math.color";
  69543. import { Mesh } from "babylonjs/Meshes/mesh";
  69544. import { Nullable } from "babylonjs/types";
  69545. /**
  69546. * Class containing static functions to help procedurally build meshes
  69547. */
  69548. export class PolygonBuilder {
  69549. /**
  69550. * Creates a polygon mesh
  69551. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69552. * * 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
  69553. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69556. * * Remember you can only change the shape positions, not their number when updating a polygon
  69557. * @param name defines the name of the mesh
  69558. * @param options defines the options used to create the mesh
  69559. * @param scene defines the hosting scene
  69560. * @param earcutInjection can be used to inject your own earcut reference
  69561. * @returns the polygon mesh
  69562. */
  69563. static CreatePolygon(name: string, options: {
  69564. shape: Vector3[];
  69565. holes?: Vector3[][];
  69566. depth?: number;
  69567. faceUV?: Vector4[];
  69568. faceColors?: Color4[];
  69569. updatable?: boolean;
  69570. sideOrientation?: number;
  69571. frontUVs?: Vector4;
  69572. backUVs?: Vector4;
  69573. wrap?: boolean;
  69574. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69575. /**
  69576. * Creates an extruded polygon mesh, with depth in the Y direction.
  69577. * * 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)
  69578. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69579. * @param name defines the name of the mesh
  69580. * @param options defines the options used to create the mesh
  69581. * @param scene defines the hosting scene
  69582. * @param earcutInjection can be used to inject your own earcut reference
  69583. * @returns the polygon mesh
  69584. */
  69585. static ExtrudePolygon(name: string, options: {
  69586. shape: Vector3[];
  69587. holes?: Vector3[][];
  69588. depth?: number;
  69589. faceUV?: Vector4[];
  69590. faceColors?: Color4[];
  69591. updatable?: boolean;
  69592. sideOrientation?: number;
  69593. frontUVs?: Vector4;
  69594. backUVs?: Vector4;
  69595. wrap?: boolean;
  69596. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69597. }
  69598. }
  69599. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69600. import { Scene } from "babylonjs/scene";
  69601. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69602. import { Mesh } from "babylonjs/Meshes/mesh";
  69603. import { Nullable } from "babylonjs/types";
  69604. /**
  69605. * Class containing static functions to help procedurally build meshes
  69606. */
  69607. export class LatheBuilder {
  69608. /**
  69609. * Creates lathe mesh.
  69610. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69611. * * 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
  69612. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69613. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69614. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69615. * * 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
  69616. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69617. * * 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
  69618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69622. * @param name defines the name of the mesh
  69623. * @param options defines the options used to create the mesh
  69624. * @param scene defines the hosting scene
  69625. * @returns the lathe mesh
  69626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69627. */
  69628. static CreateLathe(name: string, options: {
  69629. shape: Vector3[];
  69630. radius?: number;
  69631. tessellation?: number;
  69632. clip?: number;
  69633. arc?: number;
  69634. closed?: boolean;
  69635. updatable?: boolean;
  69636. sideOrientation?: number;
  69637. frontUVs?: Vector4;
  69638. backUVs?: Vector4;
  69639. cap?: number;
  69640. invertUV?: boolean;
  69641. }, scene?: Nullable<Scene>): Mesh;
  69642. }
  69643. }
  69644. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69645. import { Nullable } from "babylonjs/types";
  69646. import { Scene } from "babylonjs/scene";
  69647. import { Vector4 } from "babylonjs/Maths/math.vector";
  69648. import { Mesh } from "babylonjs/Meshes/mesh";
  69649. /**
  69650. * Class containing static functions to help procedurally build meshes
  69651. */
  69652. export class TiledPlaneBuilder {
  69653. /**
  69654. * Creates a tiled plane mesh
  69655. * * The parameter `pattern` will, depending on value, do nothing or
  69656. * * * flip (reflect about central vertical) alternate tiles across and up
  69657. * * * flip every tile on alternate rows
  69658. * * * rotate (180 degs) alternate tiles across and up
  69659. * * * rotate every tile on alternate rows
  69660. * * * flip and rotate alternate tiles across and up
  69661. * * * flip and rotate every tile on alternate rows
  69662. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69663. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69666. * * 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)
  69667. * * 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)
  69668. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69669. * @param name defines the name of the mesh
  69670. * @param options defines the options used to create the mesh
  69671. * @param scene defines the hosting scene
  69672. * @returns the box mesh
  69673. */
  69674. static CreateTiledPlane(name: string, options: {
  69675. pattern?: number;
  69676. tileSize?: number;
  69677. tileWidth?: number;
  69678. tileHeight?: number;
  69679. size?: number;
  69680. width?: number;
  69681. height?: number;
  69682. alignHorizontal?: number;
  69683. alignVertical?: number;
  69684. sideOrientation?: number;
  69685. frontUVs?: Vector4;
  69686. backUVs?: Vector4;
  69687. updatable?: boolean;
  69688. }, scene?: Nullable<Scene>): Mesh;
  69689. }
  69690. }
  69691. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69692. import { Nullable } from "babylonjs/types";
  69693. import { Scene } from "babylonjs/scene";
  69694. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69695. import { Mesh } from "babylonjs/Meshes/mesh";
  69696. /**
  69697. * Class containing static functions to help procedurally build meshes
  69698. */
  69699. export class TubeBuilder {
  69700. /**
  69701. * Creates a tube mesh.
  69702. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69703. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69704. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69705. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69706. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69707. * * 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)
  69708. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69709. * * 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
  69710. * * 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
  69711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69715. * @param name defines the name of the mesh
  69716. * @param options defines the options used to create the mesh
  69717. * @param scene defines the hosting scene
  69718. * @returns the tube mesh
  69719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69720. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69721. */
  69722. static CreateTube(name: string, options: {
  69723. path: Vector3[];
  69724. radius?: number;
  69725. tessellation?: number;
  69726. radiusFunction?: {
  69727. (i: number, distance: number): number;
  69728. };
  69729. cap?: number;
  69730. arc?: number;
  69731. updatable?: boolean;
  69732. sideOrientation?: number;
  69733. frontUVs?: Vector4;
  69734. backUVs?: Vector4;
  69735. instance?: Mesh;
  69736. invertUV?: boolean;
  69737. }, scene?: Nullable<Scene>): Mesh;
  69738. }
  69739. }
  69740. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69741. import { Scene } from "babylonjs/scene";
  69742. import { Vector4 } from "babylonjs/Maths/math.vector";
  69743. import { Mesh } from "babylonjs/Meshes/mesh";
  69744. import { Nullable } from "babylonjs/types";
  69745. /**
  69746. * Class containing static functions to help procedurally build meshes
  69747. */
  69748. export class IcoSphereBuilder {
  69749. /**
  69750. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69751. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69752. * * 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`)
  69753. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69754. * * 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
  69755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69758. * @param name defines the name of the mesh
  69759. * @param options defines the options used to create the mesh
  69760. * @param scene defines the hosting scene
  69761. * @returns the icosahedron mesh
  69762. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69763. */
  69764. static CreateIcoSphere(name: string, options: {
  69765. radius?: number;
  69766. radiusX?: number;
  69767. radiusY?: number;
  69768. radiusZ?: number;
  69769. flat?: boolean;
  69770. subdivisions?: number;
  69771. sideOrientation?: number;
  69772. frontUVs?: Vector4;
  69773. backUVs?: Vector4;
  69774. updatable?: boolean;
  69775. }, scene?: Nullable<Scene>): Mesh;
  69776. }
  69777. }
  69778. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69779. import { Vector3 } from "babylonjs/Maths/math.vector";
  69780. import { Mesh } from "babylonjs/Meshes/mesh";
  69781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69782. /**
  69783. * Class containing static functions to help procedurally build meshes
  69784. */
  69785. export class DecalBuilder {
  69786. /**
  69787. * Creates a decal mesh.
  69788. * 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
  69789. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69790. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69791. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69792. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69793. * @param name defines the name of the mesh
  69794. * @param sourceMesh defines the mesh where the decal must be applied
  69795. * @param options defines the options used to create the mesh
  69796. * @param scene defines the hosting scene
  69797. * @returns the decal mesh
  69798. * @see https://doc.babylonjs.com/how_to/decals
  69799. */
  69800. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69801. position?: Vector3;
  69802. normal?: Vector3;
  69803. size?: Vector3;
  69804. angle?: number;
  69805. }): Mesh;
  69806. }
  69807. }
  69808. declare module "babylonjs/Meshes/meshBuilder" {
  69809. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69810. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69811. import { Nullable } from "babylonjs/types";
  69812. import { Scene } from "babylonjs/scene";
  69813. import { Mesh } from "babylonjs/Meshes/mesh";
  69814. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69815. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69817. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69818. import { Plane } from "babylonjs/Maths/math.plane";
  69819. /**
  69820. * Class containing static functions to help procedurally build meshes
  69821. */
  69822. export class MeshBuilder {
  69823. /**
  69824. * Creates a box mesh
  69825. * * The parameter `size` sets the size (float) of each box side (default 1)
  69826. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69827. * * 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)
  69828. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69832. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69833. * @param name defines the name of the mesh
  69834. * @param options defines the options used to create the mesh
  69835. * @param scene defines the hosting scene
  69836. * @returns the box mesh
  69837. */
  69838. static CreateBox(name: string, options: {
  69839. size?: number;
  69840. width?: number;
  69841. height?: number;
  69842. depth?: number;
  69843. faceUV?: Vector4[];
  69844. faceColors?: Color4[];
  69845. sideOrientation?: number;
  69846. frontUVs?: Vector4;
  69847. backUVs?: Vector4;
  69848. wrap?: boolean;
  69849. topBaseAt?: number;
  69850. bottomBaseAt?: number;
  69851. updatable?: boolean;
  69852. }, scene?: Nullable<Scene>): Mesh;
  69853. /**
  69854. * Creates a tiled box mesh
  69855. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69857. * @param name defines the name of the mesh
  69858. * @param options defines the options used to create the mesh
  69859. * @param scene defines the hosting scene
  69860. * @returns the tiled box mesh
  69861. */
  69862. static CreateTiledBox(name: string, options: {
  69863. pattern?: number;
  69864. size?: number;
  69865. width?: number;
  69866. height?: number;
  69867. depth: number;
  69868. tileSize?: number;
  69869. tileWidth?: number;
  69870. tileHeight?: number;
  69871. faceUV?: Vector4[];
  69872. faceColors?: Color4[];
  69873. alignHorizontal?: number;
  69874. alignVertical?: number;
  69875. sideOrientation?: number;
  69876. updatable?: boolean;
  69877. }, scene?: Nullable<Scene>): Mesh;
  69878. /**
  69879. * Creates a sphere mesh
  69880. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69881. * * 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`)
  69882. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69883. * * 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
  69884. * * 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)
  69885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69888. * @param name defines the name of the mesh
  69889. * @param options defines the options used to create the mesh
  69890. * @param scene defines the hosting scene
  69891. * @returns the sphere mesh
  69892. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69893. */
  69894. static CreateSphere(name: string, options: {
  69895. segments?: number;
  69896. diameter?: number;
  69897. diameterX?: number;
  69898. diameterY?: number;
  69899. diameterZ?: number;
  69900. arc?: number;
  69901. slice?: number;
  69902. sideOrientation?: number;
  69903. frontUVs?: Vector4;
  69904. backUVs?: Vector4;
  69905. updatable?: boolean;
  69906. }, scene?: Nullable<Scene>): Mesh;
  69907. /**
  69908. * Creates a plane polygonal mesh. By default, this is a disc
  69909. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69910. * * 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
  69911. * * 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
  69912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69915. * @param name defines the name of the mesh
  69916. * @param options defines the options used to create the mesh
  69917. * @param scene defines the hosting scene
  69918. * @returns the plane polygonal mesh
  69919. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69920. */
  69921. static CreateDisc(name: string, options: {
  69922. radius?: number;
  69923. tessellation?: number;
  69924. arc?: number;
  69925. updatable?: boolean;
  69926. sideOrientation?: number;
  69927. frontUVs?: Vector4;
  69928. backUVs?: Vector4;
  69929. }, scene?: Nullable<Scene>): Mesh;
  69930. /**
  69931. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69932. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69933. * * 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`)
  69934. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69935. * * 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
  69936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69939. * @param name defines the name of the mesh
  69940. * @param options defines the options used to create the mesh
  69941. * @param scene defines the hosting scene
  69942. * @returns the icosahedron mesh
  69943. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69944. */
  69945. static CreateIcoSphere(name: string, options: {
  69946. radius?: number;
  69947. radiusX?: number;
  69948. radiusY?: number;
  69949. radiusZ?: number;
  69950. flat?: boolean;
  69951. subdivisions?: number;
  69952. sideOrientation?: number;
  69953. frontUVs?: Vector4;
  69954. backUVs?: Vector4;
  69955. updatable?: boolean;
  69956. }, scene?: Nullable<Scene>): Mesh;
  69957. /**
  69958. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69959. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69960. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69961. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69962. * * 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
  69963. * * 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
  69964. * * 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
  69965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69968. * * 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
  69969. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69970. * * 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
  69971. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69973. * @param name defines the name of the mesh
  69974. * @param options defines the options used to create the mesh
  69975. * @param scene defines the hosting scene
  69976. * @returns the ribbon mesh
  69977. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69978. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69979. */
  69980. static CreateRibbon(name: string, options: {
  69981. pathArray: Vector3[][];
  69982. closeArray?: boolean;
  69983. closePath?: boolean;
  69984. offset?: number;
  69985. updatable?: boolean;
  69986. sideOrientation?: number;
  69987. frontUVs?: Vector4;
  69988. backUVs?: Vector4;
  69989. instance?: Mesh;
  69990. invertUV?: boolean;
  69991. uvs?: Vector2[];
  69992. colors?: Color4[];
  69993. }, scene?: Nullable<Scene>): Mesh;
  69994. /**
  69995. * Creates a cylinder or a cone mesh
  69996. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69997. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69998. * * 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.
  69999. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70000. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70001. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70002. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70003. * * 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).
  70004. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70005. * * 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).
  70006. * * 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
  70007. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70008. * * 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
  70009. * * 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.
  70010. * * If `enclose` is false, a ring surface is one element.
  70011. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70012. * * 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
  70013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70016. * @param name defines the name of the mesh
  70017. * @param options defines the options used to create the mesh
  70018. * @param scene defines the hosting scene
  70019. * @returns the cylinder mesh
  70020. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70021. */
  70022. static CreateCylinder(name: string, options: {
  70023. height?: number;
  70024. diameterTop?: number;
  70025. diameterBottom?: number;
  70026. diameter?: number;
  70027. tessellation?: number;
  70028. subdivisions?: number;
  70029. arc?: number;
  70030. faceColors?: Color4[];
  70031. faceUV?: Vector4[];
  70032. updatable?: boolean;
  70033. hasRings?: boolean;
  70034. enclose?: boolean;
  70035. cap?: number;
  70036. sideOrientation?: number;
  70037. frontUVs?: Vector4;
  70038. backUVs?: Vector4;
  70039. }, scene?: Nullable<Scene>): Mesh;
  70040. /**
  70041. * Creates a torus mesh
  70042. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70043. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70044. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70048. * @param name defines the name of the mesh
  70049. * @param options defines the options used to create the mesh
  70050. * @param scene defines the hosting scene
  70051. * @returns the torus mesh
  70052. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70053. */
  70054. static CreateTorus(name: string, options: {
  70055. diameter?: number;
  70056. thickness?: number;
  70057. tessellation?: number;
  70058. updatable?: boolean;
  70059. sideOrientation?: number;
  70060. frontUVs?: Vector4;
  70061. backUVs?: Vector4;
  70062. }, scene?: Nullable<Scene>): Mesh;
  70063. /**
  70064. * Creates a torus knot mesh
  70065. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70066. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70067. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70068. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70072. * @param name defines the name of the mesh
  70073. * @param options defines the options used to create the mesh
  70074. * @param scene defines the hosting scene
  70075. * @returns the torus knot mesh
  70076. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70077. */
  70078. static CreateTorusKnot(name: string, options: {
  70079. radius?: number;
  70080. tube?: number;
  70081. radialSegments?: number;
  70082. tubularSegments?: number;
  70083. p?: number;
  70084. q?: number;
  70085. updatable?: boolean;
  70086. sideOrientation?: number;
  70087. frontUVs?: Vector4;
  70088. backUVs?: Vector4;
  70089. }, scene?: Nullable<Scene>): Mesh;
  70090. /**
  70091. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70092. * * 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
  70093. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70094. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70095. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70096. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70097. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70098. * * 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
  70099. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70102. * @param name defines the name of the new line system
  70103. * @param options defines the options used to create the line system
  70104. * @param scene defines the hosting scene
  70105. * @returns a new line system mesh
  70106. */
  70107. static CreateLineSystem(name: string, options: {
  70108. lines: Vector3[][];
  70109. updatable?: boolean;
  70110. instance?: Nullable<LinesMesh>;
  70111. colors?: Nullable<Color4[][]>;
  70112. useVertexAlpha?: boolean;
  70113. }, scene: Nullable<Scene>): LinesMesh;
  70114. /**
  70115. * Creates a line mesh
  70116. * 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
  70117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70118. * * The parameter `points` is an array successive Vector3
  70119. * * 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
  70120. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70121. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70122. * * When updating an instance, remember that only point positions can change, not the number of points
  70123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70125. * @param name defines the name of the new line system
  70126. * @param options defines the options used to create the line system
  70127. * @param scene defines the hosting scene
  70128. * @returns a new line mesh
  70129. */
  70130. static CreateLines(name: string, options: {
  70131. points: Vector3[];
  70132. updatable?: boolean;
  70133. instance?: Nullable<LinesMesh>;
  70134. colors?: Color4[];
  70135. useVertexAlpha?: boolean;
  70136. }, scene?: Nullable<Scene>): LinesMesh;
  70137. /**
  70138. * Creates a dashed line mesh
  70139. * * 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
  70140. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70141. * * The parameter `points` is an array successive Vector3
  70142. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70143. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70144. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70145. * * 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
  70146. * * When updating an instance, remember that only point positions can change, not the number of points
  70147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70148. * @param name defines the name of the mesh
  70149. * @param options defines the options used to create the mesh
  70150. * @param scene defines the hosting scene
  70151. * @returns the dashed line mesh
  70152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70153. */
  70154. static CreateDashedLines(name: string, options: {
  70155. points: Vector3[];
  70156. dashSize?: number;
  70157. gapSize?: number;
  70158. dashNb?: number;
  70159. updatable?: boolean;
  70160. instance?: LinesMesh;
  70161. }, scene?: Nullable<Scene>): LinesMesh;
  70162. /**
  70163. * 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.
  70164. * * 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.
  70165. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70166. * * 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.
  70167. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70168. * * 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
  70169. * * 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
  70170. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70175. * @param name defines the name of the mesh
  70176. * @param options defines the options used to create the mesh
  70177. * @param scene defines the hosting scene
  70178. * @returns the extruded shape mesh
  70179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70181. */
  70182. static ExtrudeShape(name: string, options: {
  70183. shape: Vector3[];
  70184. path: Vector3[];
  70185. scale?: number;
  70186. rotation?: number;
  70187. cap?: number;
  70188. updatable?: boolean;
  70189. sideOrientation?: number;
  70190. frontUVs?: Vector4;
  70191. backUVs?: Vector4;
  70192. instance?: Mesh;
  70193. invertUV?: boolean;
  70194. }, scene?: Nullable<Scene>): Mesh;
  70195. /**
  70196. * Creates an custom extruded shape mesh.
  70197. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70198. * * 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.
  70199. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70200. * * 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
  70201. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70202. * * 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
  70203. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70204. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70205. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70206. * * 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
  70207. * * 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
  70208. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70211. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70213. * @param name defines the name of the mesh
  70214. * @param options defines the options used to create the mesh
  70215. * @param scene defines the hosting scene
  70216. * @returns the custom extruded shape mesh
  70217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70218. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70219. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70220. */
  70221. static ExtrudeShapeCustom(name: string, options: {
  70222. shape: Vector3[];
  70223. path: Vector3[];
  70224. scaleFunction?: any;
  70225. rotationFunction?: any;
  70226. ribbonCloseArray?: boolean;
  70227. ribbonClosePath?: boolean;
  70228. cap?: number;
  70229. updatable?: boolean;
  70230. sideOrientation?: number;
  70231. frontUVs?: Vector4;
  70232. backUVs?: Vector4;
  70233. instance?: Mesh;
  70234. invertUV?: boolean;
  70235. }, scene?: Nullable<Scene>): Mesh;
  70236. /**
  70237. * Creates lathe mesh.
  70238. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70239. * * 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
  70240. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70241. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70242. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70243. * * 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
  70244. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70245. * * 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
  70246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70248. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70250. * @param name defines the name of the mesh
  70251. * @param options defines the options used to create the mesh
  70252. * @param scene defines the hosting scene
  70253. * @returns the lathe mesh
  70254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70255. */
  70256. static CreateLathe(name: string, options: {
  70257. shape: Vector3[];
  70258. radius?: number;
  70259. tessellation?: number;
  70260. clip?: number;
  70261. arc?: number;
  70262. closed?: boolean;
  70263. updatable?: boolean;
  70264. sideOrientation?: number;
  70265. frontUVs?: Vector4;
  70266. backUVs?: Vector4;
  70267. cap?: number;
  70268. invertUV?: boolean;
  70269. }, scene?: Nullable<Scene>): Mesh;
  70270. /**
  70271. * Creates a tiled plane mesh
  70272. * * You can set a limited pattern arrangement with the tiles
  70273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70276. * @param name defines the name of the mesh
  70277. * @param options defines the options used to create the mesh
  70278. * @param scene defines the hosting scene
  70279. * @returns the plane mesh
  70280. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70281. */
  70282. static CreateTiledPlane(name: string, options: {
  70283. pattern?: number;
  70284. tileSize?: number;
  70285. tileWidth?: number;
  70286. tileHeight?: number;
  70287. size?: number;
  70288. width?: number;
  70289. height?: number;
  70290. alignHorizontal?: number;
  70291. alignVertical?: number;
  70292. sideOrientation?: number;
  70293. frontUVs?: Vector4;
  70294. backUVs?: Vector4;
  70295. updatable?: boolean;
  70296. }, scene?: Nullable<Scene>): Mesh;
  70297. /**
  70298. * Creates a plane mesh
  70299. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70300. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70301. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70305. * @param name defines the name of the mesh
  70306. * @param options defines the options used to create the mesh
  70307. * @param scene defines the hosting scene
  70308. * @returns the plane mesh
  70309. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70310. */
  70311. static CreatePlane(name: string, options: {
  70312. size?: number;
  70313. width?: number;
  70314. height?: number;
  70315. sideOrientation?: number;
  70316. frontUVs?: Vector4;
  70317. backUVs?: Vector4;
  70318. updatable?: boolean;
  70319. sourcePlane?: Plane;
  70320. }, scene?: Nullable<Scene>): Mesh;
  70321. /**
  70322. * Creates a ground mesh
  70323. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70324. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70326. * @param name defines the name of the mesh
  70327. * @param options defines the options used to create the mesh
  70328. * @param scene defines the hosting scene
  70329. * @returns the ground mesh
  70330. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70331. */
  70332. static CreateGround(name: string, options: {
  70333. width?: number;
  70334. height?: number;
  70335. subdivisions?: number;
  70336. subdivisionsX?: number;
  70337. subdivisionsY?: number;
  70338. updatable?: boolean;
  70339. }, scene?: Nullable<Scene>): Mesh;
  70340. /**
  70341. * Creates a tiled ground mesh
  70342. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70343. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70344. * * 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
  70345. * * 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
  70346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70347. * @param name defines the name of the mesh
  70348. * @param options defines the options used to create the mesh
  70349. * @param scene defines the hosting scene
  70350. * @returns the tiled ground mesh
  70351. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70352. */
  70353. static CreateTiledGround(name: string, options: {
  70354. xmin: number;
  70355. zmin: number;
  70356. xmax: number;
  70357. zmax: number;
  70358. subdivisions?: {
  70359. w: number;
  70360. h: number;
  70361. };
  70362. precision?: {
  70363. w: number;
  70364. h: number;
  70365. };
  70366. updatable?: boolean;
  70367. }, scene?: Nullable<Scene>): Mesh;
  70368. /**
  70369. * Creates a ground mesh from a height map
  70370. * * The parameter `url` sets the URL of the height map image resource.
  70371. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70372. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70373. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70374. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70375. * * 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.
  70376. * * 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).
  70377. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70379. * @param name defines the name of the mesh
  70380. * @param url defines the url to the height map
  70381. * @param options defines the options used to create the mesh
  70382. * @param scene defines the hosting scene
  70383. * @returns the ground mesh
  70384. * @see https://doc.babylonjs.com/babylon101/height_map
  70385. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70386. */
  70387. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70388. width?: number;
  70389. height?: number;
  70390. subdivisions?: number;
  70391. minHeight?: number;
  70392. maxHeight?: number;
  70393. colorFilter?: Color3;
  70394. alphaFilter?: number;
  70395. updatable?: boolean;
  70396. onReady?: (mesh: GroundMesh) => void;
  70397. }, scene?: Nullable<Scene>): GroundMesh;
  70398. /**
  70399. * Creates a polygon mesh
  70400. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70401. * * 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
  70402. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70405. * * Remember you can only change the shape positions, not their number when updating a polygon
  70406. * @param name defines the name of the mesh
  70407. * @param options defines the options used to create the mesh
  70408. * @param scene defines the hosting scene
  70409. * @param earcutInjection can be used to inject your own earcut reference
  70410. * @returns the polygon mesh
  70411. */
  70412. static CreatePolygon(name: string, options: {
  70413. shape: Vector3[];
  70414. holes?: Vector3[][];
  70415. depth?: number;
  70416. faceUV?: Vector4[];
  70417. faceColors?: Color4[];
  70418. updatable?: boolean;
  70419. sideOrientation?: number;
  70420. frontUVs?: Vector4;
  70421. backUVs?: Vector4;
  70422. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70423. /**
  70424. * Creates an extruded polygon mesh, with depth in the Y direction.
  70425. * * 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)
  70426. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70427. * @param name defines the name of the mesh
  70428. * @param options defines the options used to create the mesh
  70429. * @param scene defines the hosting scene
  70430. * @param earcutInjection can be used to inject your own earcut reference
  70431. * @returns the polygon mesh
  70432. */
  70433. static ExtrudePolygon(name: string, options: {
  70434. shape: Vector3[];
  70435. holes?: Vector3[][];
  70436. depth?: number;
  70437. faceUV?: Vector4[];
  70438. faceColors?: Color4[];
  70439. updatable?: boolean;
  70440. sideOrientation?: number;
  70441. frontUVs?: Vector4;
  70442. backUVs?: Vector4;
  70443. wrap?: boolean;
  70444. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70445. /**
  70446. * Creates a tube mesh.
  70447. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70448. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70449. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70450. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70451. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70452. * * 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)
  70453. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70454. * * 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
  70455. * * 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
  70456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70460. * @param name defines the name of the mesh
  70461. * @param options defines the options used to create the mesh
  70462. * @param scene defines the hosting scene
  70463. * @returns the tube mesh
  70464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70465. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70466. */
  70467. static CreateTube(name: string, options: {
  70468. path: Vector3[];
  70469. radius?: number;
  70470. tessellation?: number;
  70471. radiusFunction?: {
  70472. (i: number, distance: number): number;
  70473. };
  70474. cap?: number;
  70475. arc?: number;
  70476. updatable?: boolean;
  70477. sideOrientation?: number;
  70478. frontUVs?: Vector4;
  70479. backUVs?: Vector4;
  70480. instance?: Mesh;
  70481. invertUV?: boolean;
  70482. }, scene?: Nullable<Scene>): Mesh;
  70483. /**
  70484. * Creates a polyhedron mesh
  70485. * * 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
  70486. * * The parameter `size` (positive float, default 1) sets the polygon size
  70487. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70488. * * 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`
  70489. * * 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
  70490. * * 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)`)
  70491. * * 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
  70492. * * 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
  70493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70496. * @param name defines the name of the mesh
  70497. * @param options defines the options used to create the mesh
  70498. * @param scene defines the hosting scene
  70499. * @returns the polyhedron mesh
  70500. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70501. */
  70502. static CreatePolyhedron(name: string, options: {
  70503. type?: number;
  70504. size?: number;
  70505. sizeX?: number;
  70506. sizeY?: number;
  70507. sizeZ?: number;
  70508. custom?: any;
  70509. faceUV?: Vector4[];
  70510. faceColors?: Color4[];
  70511. flat?: boolean;
  70512. updatable?: boolean;
  70513. sideOrientation?: number;
  70514. frontUVs?: Vector4;
  70515. backUVs?: Vector4;
  70516. }, scene?: Nullable<Scene>): Mesh;
  70517. /**
  70518. * Creates a decal mesh.
  70519. * 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
  70520. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70521. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70522. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70523. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70524. * @param name defines the name of the mesh
  70525. * @param sourceMesh defines the mesh where the decal must be applied
  70526. * @param options defines the options used to create the mesh
  70527. * @param scene defines the hosting scene
  70528. * @returns the decal mesh
  70529. * @see https://doc.babylonjs.com/how_to/decals
  70530. */
  70531. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70532. position?: Vector3;
  70533. normal?: Vector3;
  70534. size?: Vector3;
  70535. angle?: number;
  70536. }): Mesh;
  70537. /**
  70538. * Creates a Capsule Mesh
  70539. * @param name defines the name of the mesh.
  70540. * @param options the constructors options used to shape the mesh.
  70541. * @param scene defines the scene the mesh is scoped to.
  70542. * @returns the capsule mesh
  70543. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70544. */
  70545. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70546. }
  70547. }
  70548. declare module "babylonjs/Meshes/meshSimplification" {
  70549. import { Mesh } from "babylonjs/Meshes/mesh";
  70550. /**
  70551. * A simplifier interface for future simplification implementations
  70552. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70553. */
  70554. export interface ISimplifier {
  70555. /**
  70556. * Simplification of a given mesh according to the given settings.
  70557. * Since this requires computation, it is assumed that the function runs async.
  70558. * @param settings The settings of the simplification, including quality and distance
  70559. * @param successCallback A callback that will be called after the mesh was simplified.
  70560. * @param errorCallback in case of an error, this callback will be called. optional.
  70561. */
  70562. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70563. }
  70564. /**
  70565. * Expected simplification settings.
  70566. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70567. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70568. */
  70569. export interface ISimplificationSettings {
  70570. /**
  70571. * Gets or sets the expected quality
  70572. */
  70573. quality: number;
  70574. /**
  70575. * Gets or sets the distance when this optimized version should be used
  70576. */
  70577. distance: number;
  70578. /**
  70579. * Gets an already optimized mesh
  70580. */
  70581. optimizeMesh?: boolean;
  70582. }
  70583. /**
  70584. * Class used to specify simplification options
  70585. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70586. */
  70587. export class SimplificationSettings implements ISimplificationSettings {
  70588. /** expected quality */
  70589. quality: number;
  70590. /** distance when this optimized version should be used */
  70591. distance: number;
  70592. /** already optimized mesh */
  70593. optimizeMesh?: boolean | undefined;
  70594. /**
  70595. * Creates a SimplificationSettings
  70596. * @param quality expected quality
  70597. * @param distance distance when this optimized version should be used
  70598. * @param optimizeMesh already optimized mesh
  70599. */
  70600. constructor(
  70601. /** expected quality */
  70602. quality: number,
  70603. /** distance when this optimized version should be used */
  70604. distance: number,
  70605. /** already optimized mesh */
  70606. optimizeMesh?: boolean | undefined);
  70607. }
  70608. /**
  70609. * Interface used to define a simplification task
  70610. */
  70611. export interface ISimplificationTask {
  70612. /**
  70613. * Array of settings
  70614. */
  70615. settings: Array<ISimplificationSettings>;
  70616. /**
  70617. * Simplification type
  70618. */
  70619. simplificationType: SimplificationType;
  70620. /**
  70621. * Mesh to simplify
  70622. */
  70623. mesh: Mesh;
  70624. /**
  70625. * Callback called on success
  70626. */
  70627. successCallback?: () => void;
  70628. /**
  70629. * Defines if parallel processing can be used
  70630. */
  70631. parallelProcessing: boolean;
  70632. }
  70633. /**
  70634. * Queue used to order the simplification tasks
  70635. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70636. */
  70637. export class SimplificationQueue {
  70638. private _simplificationArray;
  70639. /**
  70640. * Gets a boolean indicating that the process is still running
  70641. */
  70642. running: boolean;
  70643. /**
  70644. * Creates a new queue
  70645. */
  70646. constructor();
  70647. /**
  70648. * Adds a new simplification task
  70649. * @param task defines a task to add
  70650. */
  70651. addTask(task: ISimplificationTask): void;
  70652. /**
  70653. * Execute next task
  70654. */
  70655. executeNext(): void;
  70656. /**
  70657. * Execute a simplification task
  70658. * @param task defines the task to run
  70659. */
  70660. runSimplification(task: ISimplificationTask): void;
  70661. private getSimplifier;
  70662. }
  70663. /**
  70664. * The implemented types of simplification
  70665. * At the moment only Quadratic Error Decimation is implemented
  70666. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70667. */
  70668. export enum SimplificationType {
  70669. /** Quadratic error decimation */
  70670. QUADRATIC = 0
  70671. }
  70672. /**
  70673. * An implementation of the Quadratic Error simplification algorithm.
  70674. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70675. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70676. * @author RaananW
  70677. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70678. */
  70679. export class QuadraticErrorSimplification implements ISimplifier {
  70680. private _mesh;
  70681. private triangles;
  70682. private vertices;
  70683. private references;
  70684. private _reconstructedMesh;
  70685. /** Gets or sets the number pf sync interations */
  70686. syncIterations: number;
  70687. /** Gets or sets the aggressiveness of the simplifier */
  70688. aggressiveness: number;
  70689. /** Gets or sets the number of allowed iterations for decimation */
  70690. decimationIterations: number;
  70691. /** Gets or sets the espilon to use for bounding box computation */
  70692. boundingBoxEpsilon: number;
  70693. /**
  70694. * Creates a new QuadraticErrorSimplification
  70695. * @param _mesh defines the target mesh
  70696. */
  70697. constructor(_mesh: Mesh);
  70698. /**
  70699. * Simplification of a given mesh according to the given settings.
  70700. * Since this requires computation, it is assumed that the function runs async.
  70701. * @param settings The settings of the simplification, including quality and distance
  70702. * @param successCallback A callback that will be called after the mesh was simplified.
  70703. */
  70704. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70705. private runDecimation;
  70706. private initWithMesh;
  70707. private init;
  70708. private reconstructMesh;
  70709. private initDecimatedMesh;
  70710. private isFlipped;
  70711. private updateTriangles;
  70712. private identifyBorder;
  70713. private updateMesh;
  70714. private vertexError;
  70715. private calculateError;
  70716. }
  70717. }
  70718. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70719. import { Scene } from "babylonjs/scene";
  70720. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70721. import { ISceneComponent } from "babylonjs/sceneComponent";
  70722. module "babylonjs/scene" {
  70723. interface Scene {
  70724. /** @hidden (Backing field) */
  70725. _simplificationQueue: SimplificationQueue;
  70726. /**
  70727. * Gets or sets the simplification queue attached to the scene
  70728. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70729. */
  70730. simplificationQueue: SimplificationQueue;
  70731. }
  70732. }
  70733. module "babylonjs/Meshes/mesh" {
  70734. interface Mesh {
  70735. /**
  70736. * Simplify the mesh according to the given array of settings.
  70737. * Function will return immediately and will simplify async
  70738. * @param settings a collection of simplification settings
  70739. * @param parallelProcessing should all levels calculate parallel or one after the other
  70740. * @param simplificationType the type of simplification to run
  70741. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70742. * @returns the current mesh
  70743. */
  70744. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70745. }
  70746. }
  70747. /**
  70748. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70749. * created in a scene
  70750. */
  70751. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70752. /**
  70753. * The component name helpfull to identify the component in the list of scene components.
  70754. */
  70755. readonly name: string;
  70756. /**
  70757. * The scene the component belongs to.
  70758. */
  70759. scene: Scene;
  70760. /**
  70761. * Creates a new instance of the component for the given scene
  70762. * @param scene Defines the scene to register the component in
  70763. */
  70764. constructor(scene: Scene);
  70765. /**
  70766. * Registers the component in a given scene
  70767. */
  70768. register(): void;
  70769. /**
  70770. * Rebuilds the elements related to this component in case of
  70771. * context lost for instance.
  70772. */
  70773. rebuild(): void;
  70774. /**
  70775. * Disposes the component and the associated ressources
  70776. */
  70777. dispose(): void;
  70778. private _beforeCameraUpdate;
  70779. }
  70780. }
  70781. declare module "babylonjs/Meshes/Builders/index" {
  70782. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70783. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70784. export * from "babylonjs/Meshes/Builders/discBuilder";
  70785. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70786. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70787. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70788. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70789. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70790. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70791. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70792. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70793. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70794. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70795. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70796. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70797. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70798. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70799. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70800. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70801. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70802. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70803. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70804. }
  70805. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70806. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70807. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70808. import { Matrix } from "babylonjs/Maths/math.vector";
  70809. module "babylonjs/Meshes/mesh" {
  70810. interface Mesh {
  70811. /**
  70812. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70813. */
  70814. thinInstanceEnablePicking: boolean;
  70815. /**
  70816. * Creates a new thin instance
  70817. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70818. * @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
  70819. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70820. */
  70821. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70822. /**
  70823. * Adds the transformation (matrix) of the current mesh as a thin instance
  70824. * @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
  70825. * @returns the thin instance index number
  70826. */
  70827. thinInstanceAddSelf(refresh: boolean): number;
  70828. /**
  70829. * Registers a custom attribute to be used with thin instances
  70830. * @param kind name of the attribute
  70831. * @param stride size in floats of the attribute
  70832. */
  70833. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70834. /**
  70835. * Sets the matrix of a thin instance
  70836. * @param index index of the thin instance
  70837. * @param matrix matrix to set
  70838. * @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
  70839. */
  70840. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70841. /**
  70842. * Sets the value of a custom attribute for a thin instance
  70843. * @param kind name of the attribute
  70844. * @param index index of the thin instance
  70845. * @param value value to set
  70846. * @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
  70847. */
  70848. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70849. /**
  70850. * 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.
  70851. */
  70852. thinInstanceCount: number;
  70853. /**
  70854. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70855. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70856. * @param buffer buffer to set
  70857. * @param stride size in floats of each value of the buffer
  70858. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70859. */
  70860. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70861. /**
  70862. * Gets the list of world matrices
  70863. * @return an array containing all the world matrices from the thin instances
  70864. */
  70865. thinInstanceGetWorldMatrices(): Matrix[];
  70866. /**
  70867. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70868. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70869. */
  70870. thinInstanceBufferUpdated(kind: string): void;
  70871. /**
  70872. * Applies a partial update to a buffer directly on the GPU
  70873. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  70874. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70875. * @param data the data to set in the GPU buffer
  70876. * @param offset the offset in the GPU buffer where to update the data
  70877. */
  70878. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70879. /**
  70880. * Refreshes the bounding info, taking into account all the thin instances defined
  70881. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70882. */
  70883. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70884. /** @hidden */
  70885. _thinInstanceInitializeUserStorage(): void;
  70886. /** @hidden */
  70887. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70888. /** @hidden */
  70889. _userThinInstanceBuffersStorage: {
  70890. data: {
  70891. [key: string]: Float32Array;
  70892. };
  70893. sizes: {
  70894. [key: string]: number;
  70895. };
  70896. vertexBuffers: {
  70897. [key: string]: Nullable<VertexBuffer>;
  70898. };
  70899. strides: {
  70900. [key: string]: number;
  70901. };
  70902. };
  70903. }
  70904. }
  70905. }
  70906. declare module "babylonjs/Meshes/index" {
  70907. export * from "babylonjs/Meshes/abstractMesh";
  70908. export * from "babylonjs/Meshes/buffer";
  70909. export * from "babylonjs/Meshes/Compression/index";
  70910. export * from "babylonjs/Meshes/csg";
  70911. export * from "babylonjs/Meshes/geometry";
  70912. export * from "babylonjs/Meshes/groundMesh";
  70913. export * from "babylonjs/Meshes/trailMesh";
  70914. export * from "babylonjs/Meshes/instancedMesh";
  70915. export * from "babylonjs/Meshes/linesMesh";
  70916. export * from "babylonjs/Meshes/mesh";
  70917. export * from "babylonjs/Meshes/mesh.vertexData";
  70918. export * from "babylonjs/Meshes/meshBuilder";
  70919. export * from "babylonjs/Meshes/meshSimplification";
  70920. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70921. export * from "babylonjs/Meshes/polygonMesh";
  70922. export * from "babylonjs/Meshes/subMesh";
  70923. export * from "babylonjs/Meshes/meshLODLevel";
  70924. export * from "babylonjs/Meshes/transformNode";
  70925. export * from "babylonjs/Meshes/Builders/index";
  70926. export * from "babylonjs/Meshes/dataBuffer";
  70927. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70928. import "babylonjs/Meshes/thinInstanceMesh";
  70929. export * from "babylonjs/Meshes/thinInstanceMesh";
  70930. }
  70931. declare module "babylonjs/Morph/index" {
  70932. export * from "babylonjs/Morph/morphTarget";
  70933. export * from "babylonjs/Morph/morphTargetManager";
  70934. }
  70935. declare module "babylonjs/Navigation/INavigationEngine" {
  70936. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70937. import { Vector3 } from "babylonjs/Maths/math";
  70938. import { Mesh } from "babylonjs/Meshes/mesh";
  70939. import { Scene } from "babylonjs/scene";
  70940. /**
  70941. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70942. */
  70943. export interface INavigationEnginePlugin {
  70944. /**
  70945. * plugin name
  70946. */
  70947. name: string;
  70948. /**
  70949. * Creates a navigation mesh
  70950. * @param meshes array of all the geometry used to compute the navigatio mesh
  70951. * @param parameters bunch of parameters used to filter geometry
  70952. */
  70953. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70954. /**
  70955. * Create a navigation mesh debug mesh
  70956. * @param scene is where the mesh will be added
  70957. * @returns debug display mesh
  70958. */
  70959. createDebugNavMesh(scene: Scene): Mesh;
  70960. /**
  70961. * Get a navigation mesh constrained position, closest to the parameter position
  70962. * @param position world position
  70963. * @returns the closest point to position constrained by the navigation mesh
  70964. */
  70965. getClosestPoint(position: Vector3): Vector3;
  70966. /**
  70967. * Get a navigation mesh constrained position, closest to the parameter position
  70968. * @param position world position
  70969. * @param result output the closest point to position constrained by the navigation mesh
  70970. */
  70971. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70972. /**
  70973. * Get a navigation mesh constrained position, within a particular radius
  70974. * @param position world position
  70975. * @param maxRadius the maximum distance to the constrained world position
  70976. * @returns the closest point to position constrained by the navigation mesh
  70977. */
  70978. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70979. /**
  70980. * Get a navigation mesh constrained position, within a particular radius
  70981. * @param position world position
  70982. * @param maxRadius the maximum distance to the constrained world position
  70983. * @param result output the closest point to position constrained by the navigation mesh
  70984. */
  70985. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70986. /**
  70987. * Compute the final position from a segment made of destination-position
  70988. * @param position world position
  70989. * @param destination world position
  70990. * @returns the resulting point along the navmesh
  70991. */
  70992. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70993. /**
  70994. * Compute the final position from a segment made of destination-position
  70995. * @param position world position
  70996. * @param destination world position
  70997. * @param result output the resulting point along the navmesh
  70998. */
  70999. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71000. /**
  71001. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71002. * @param start world position
  71003. * @param end world position
  71004. * @returns array containing world position composing the path
  71005. */
  71006. computePath(start: Vector3, end: Vector3): Vector3[];
  71007. /**
  71008. * If this plugin is supported
  71009. * @returns true if plugin is supported
  71010. */
  71011. isSupported(): boolean;
  71012. /**
  71013. * Create a new Crowd so you can add agents
  71014. * @param maxAgents the maximum agent count in the crowd
  71015. * @param maxAgentRadius the maximum radius an agent can have
  71016. * @param scene to attach the crowd to
  71017. * @returns the crowd you can add agents to
  71018. */
  71019. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71020. /**
  71021. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71022. * The queries will try to find a solution within those bounds
  71023. * default is (1,1,1)
  71024. * @param extent x,y,z value that define the extent around the queries point of reference
  71025. */
  71026. setDefaultQueryExtent(extent: Vector3): void;
  71027. /**
  71028. * Get the Bounding box extent specified by setDefaultQueryExtent
  71029. * @returns the box extent values
  71030. */
  71031. getDefaultQueryExtent(): Vector3;
  71032. /**
  71033. * build the navmesh from a previously saved state using getNavmeshData
  71034. * @param data the Uint8Array returned by getNavmeshData
  71035. */
  71036. buildFromNavmeshData(data: Uint8Array): void;
  71037. /**
  71038. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71039. * @returns data the Uint8Array that can be saved and reused
  71040. */
  71041. getNavmeshData(): Uint8Array;
  71042. /**
  71043. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71044. * @param result output the box extent values
  71045. */
  71046. getDefaultQueryExtentToRef(result: Vector3): void;
  71047. /**
  71048. * Release all resources
  71049. */
  71050. dispose(): void;
  71051. }
  71052. /**
  71053. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71054. */
  71055. export interface ICrowd {
  71056. /**
  71057. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71058. * You can attach anything to that node. The node position is updated in the scene update tick.
  71059. * @param pos world position that will be constrained by the navigation mesh
  71060. * @param parameters agent parameters
  71061. * @param transform hooked to the agent that will be update by the scene
  71062. * @returns agent index
  71063. */
  71064. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71065. /**
  71066. * Returns the agent position in world space
  71067. * @param index agent index returned by addAgent
  71068. * @returns world space position
  71069. */
  71070. getAgentPosition(index: number): Vector3;
  71071. /**
  71072. * Gets the agent position result in world space
  71073. * @param index agent index returned by addAgent
  71074. * @param result output world space position
  71075. */
  71076. getAgentPositionToRef(index: number, result: Vector3): void;
  71077. /**
  71078. * Gets the agent velocity in world space
  71079. * @param index agent index returned by addAgent
  71080. * @returns world space velocity
  71081. */
  71082. getAgentVelocity(index: number): Vector3;
  71083. /**
  71084. * Gets the agent velocity result in world space
  71085. * @param index agent index returned by addAgent
  71086. * @param result output world space velocity
  71087. */
  71088. getAgentVelocityToRef(index: number, result: Vector3): void;
  71089. /**
  71090. * remove a particular agent previously created
  71091. * @param index agent index returned by addAgent
  71092. */
  71093. removeAgent(index: number): void;
  71094. /**
  71095. * get the list of all agents attached to this crowd
  71096. * @returns list of agent indices
  71097. */
  71098. getAgents(): number[];
  71099. /**
  71100. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71101. * @param deltaTime in seconds
  71102. */
  71103. update(deltaTime: number): void;
  71104. /**
  71105. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71106. * @param index agent index returned by addAgent
  71107. * @param destination targeted world position
  71108. */
  71109. agentGoto(index: number, destination: Vector3): void;
  71110. /**
  71111. * Teleport the agent to a new position
  71112. * @param index agent index returned by addAgent
  71113. * @param destination targeted world position
  71114. */
  71115. agentTeleport(index: number, destination: Vector3): void;
  71116. /**
  71117. * Update agent parameters
  71118. * @param index agent index returned by addAgent
  71119. * @param parameters agent parameters
  71120. */
  71121. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71122. /**
  71123. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71124. * The queries will try to find a solution within those bounds
  71125. * default is (1,1,1)
  71126. * @param extent x,y,z value that define the extent around the queries point of reference
  71127. */
  71128. setDefaultQueryExtent(extent: Vector3): void;
  71129. /**
  71130. * Get the Bounding box extent specified by setDefaultQueryExtent
  71131. * @returns the box extent values
  71132. */
  71133. getDefaultQueryExtent(): Vector3;
  71134. /**
  71135. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71136. * @param result output the box extent values
  71137. */
  71138. getDefaultQueryExtentToRef(result: Vector3): void;
  71139. /**
  71140. * Release all resources
  71141. */
  71142. dispose(): void;
  71143. }
  71144. /**
  71145. * Configures an agent
  71146. */
  71147. export interface IAgentParameters {
  71148. /**
  71149. * Agent radius. [Limit: >= 0]
  71150. */
  71151. radius: number;
  71152. /**
  71153. * Agent height. [Limit: > 0]
  71154. */
  71155. height: number;
  71156. /**
  71157. * Maximum allowed acceleration. [Limit: >= 0]
  71158. */
  71159. maxAcceleration: number;
  71160. /**
  71161. * Maximum allowed speed. [Limit: >= 0]
  71162. */
  71163. maxSpeed: number;
  71164. /**
  71165. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71166. */
  71167. collisionQueryRange: number;
  71168. /**
  71169. * The path visibility optimization range. [Limit: > 0]
  71170. */
  71171. pathOptimizationRange: number;
  71172. /**
  71173. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71174. */
  71175. separationWeight: number;
  71176. }
  71177. /**
  71178. * Configures the navigation mesh creation
  71179. */
  71180. export interface INavMeshParameters {
  71181. /**
  71182. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71183. */
  71184. cs: number;
  71185. /**
  71186. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71187. */
  71188. ch: number;
  71189. /**
  71190. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71191. */
  71192. walkableSlopeAngle: number;
  71193. /**
  71194. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71195. * be considered walkable. [Limit: >= 3] [Units: vx]
  71196. */
  71197. walkableHeight: number;
  71198. /**
  71199. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71200. */
  71201. walkableClimb: number;
  71202. /**
  71203. * The distance to erode/shrink the walkable area of the heightfield away from
  71204. * obstructions. [Limit: >=0] [Units: vx]
  71205. */
  71206. walkableRadius: number;
  71207. /**
  71208. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71209. */
  71210. maxEdgeLen: number;
  71211. /**
  71212. * The maximum distance a simplfied contour's border edges should deviate
  71213. * the original raw contour. [Limit: >=0] [Units: vx]
  71214. */
  71215. maxSimplificationError: number;
  71216. /**
  71217. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71218. */
  71219. minRegionArea: number;
  71220. /**
  71221. * Any regions with a span count smaller than this value will, if possible,
  71222. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71223. */
  71224. mergeRegionArea: number;
  71225. /**
  71226. * The maximum number of vertices allowed for polygons generated during the
  71227. * contour to polygon conversion process. [Limit: >= 3]
  71228. */
  71229. maxVertsPerPoly: number;
  71230. /**
  71231. * Sets the sampling distance to use when generating the detail mesh.
  71232. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71233. */
  71234. detailSampleDist: number;
  71235. /**
  71236. * The maximum distance the detail mesh surface should deviate from heightfield
  71237. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71238. */
  71239. detailSampleMaxError: number;
  71240. }
  71241. }
  71242. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71243. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71244. import { Mesh } from "babylonjs/Meshes/mesh";
  71245. import { Scene } from "babylonjs/scene";
  71246. import { Vector3 } from "babylonjs/Maths/math";
  71247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71248. /**
  71249. * RecastJS navigation plugin
  71250. */
  71251. export class RecastJSPlugin implements INavigationEnginePlugin {
  71252. /**
  71253. * Reference to the Recast library
  71254. */
  71255. bjsRECAST: any;
  71256. /**
  71257. * plugin name
  71258. */
  71259. name: string;
  71260. /**
  71261. * the first navmesh created. We might extend this to support multiple navmeshes
  71262. */
  71263. navMesh: any;
  71264. /**
  71265. * Initializes the recastJS plugin
  71266. * @param recastInjection can be used to inject your own recast reference
  71267. */
  71268. constructor(recastInjection?: any);
  71269. /**
  71270. * Creates a navigation mesh
  71271. * @param meshes array of all the geometry used to compute the navigatio mesh
  71272. * @param parameters bunch of parameters used to filter geometry
  71273. */
  71274. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71275. /**
  71276. * Create a navigation mesh debug mesh
  71277. * @param scene is where the mesh will be added
  71278. * @returns debug display mesh
  71279. */
  71280. createDebugNavMesh(scene: Scene): Mesh;
  71281. /**
  71282. * Get a navigation mesh constrained position, closest to the parameter position
  71283. * @param position world position
  71284. * @returns the closest point to position constrained by the navigation mesh
  71285. */
  71286. getClosestPoint(position: Vector3): Vector3;
  71287. /**
  71288. * Get a navigation mesh constrained position, closest to the parameter position
  71289. * @param position world position
  71290. * @param result output the closest point to position constrained by the navigation mesh
  71291. */
  71292. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71293. /**
  71294. * Get a navigation mesh constrained position, within a particular radius
  71295. * @param position world position
  71296. * @param maxRadius the maximum distance to the constrained world position
  71297. * @returns the closest point to position constrained by the navigation mesh
  71298. */
  71299. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71300. /**
  71301. * Get a navigation mesh constrained position, within a particular radius
  71302. * @param position world position
  71303. * @param maxRadius the maximum distance to the constrained world position
  71304. * @param result output the closest point to position constrained by the navigation mesh
  71305. */
  71306. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71307. /**
  71308. * Compute the final position from a segment made of destination-position
  71309. * @param position world position
  71310. * @param destination world position
  71311. * @returns the resulting point along the navmesh
  71312. */
  71313. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71314. /**
  71315. * Compute the final position from a segment made of destination-position
  71316. * @param position world position
  71317. * @param destination world position
  71318. * @param result output the resulting point along the navmesh
  71319. */
  71320. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71321. /**
  71322. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71323. * @param start world position
  71324. * @param end world position
  71325. * @returns array containing world position composing the path
  71326. */
  71327. computePath(start: Vector3, end: Vector3): Vector3[];
  71328. /**
  71329. * Create a new Crowd so you can add agents
  71330. * @param maxAgents the maximum agent count in the crowd
  71331. * @param maxAgentRadius the maximum radius an agent can have
  71332. * @param scene to attach the crowd to
  71333. * @returns the crowd you can add agents to
  71334. */
  71335. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71336. /**
  71337. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71338. * The queries will try to find a solution within those bounds
  71339. * default is (1,1,1)
  71340. * @param extent x,y,z value that define the extent around the queries point of reference
  71341. */
  71342. setDefaultQueryExtent(extent: Vector3): void;
  71343. /**
  71344. * Get the Bounding box extent specified by setDefaultQueryExtent
  71345. * @returns the box extent values
  71346. */
  71347. getDefaultQueryExtent(): Vector3;
  71348. /**
  71349. * build the navmesh from a previously saved state using getNavmeshData
  71350. * @param data the Uint8Array returned by getNavmeshData
  71351. */
  71352. buildFromNavmeshData(data: Uint8Array): void;
  71353. /**
  71354. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71355. * @returns data the Uint8Array that can be saved and reused
  71356. */
  71357. getNavmeshData(): Uint8Array;
  71358. /**
  71359. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71360. * @param result output the box extent values
  71361. */
  71362. getDefaultQueryExtentToRef(result: Vector3): void;
  71363. /**
  71364. * Disposes
  71365. */
  71366. dispose(): void;
  71367. /**
  71368. * If this plugin is supported
  71369. * @returns true if plugin is supported
  71370. */
  71371. isSupported(): boolean;
  71372. }
  71373. /**
  71374. * Recast detour crowd implementation
  71375. */
  71376. export class RecastJSCrowd implements ICrowd {
  71377. /**
  71378. * Recast/detour plugin
  71379. */
  71380. bjsRECASTPlugin: RecastJSPlugin;
  71381. /**
  71382. * Link to the detour crowd
  71383. */
  71384. recastCrowd: any;
  71385. /**
  71386. * One transform per agent
  71387. */
  71388. transforms: TransformNode[];
  71389. /**
  71390. * All agents created
  71391. */
  71392. agents: number[];
  71393. /**
  71394. * Link to the scene is kept to unregister the crowd from the scene
  71395. */
  71396. private _scene;
  71397. /**
  71398. * Observer for crowd updates
  71399. */
  71400. private _onBeforeAnimationsObserver;
  71401. /**
  71402. * Constructor
  71403. * @param plugin recastJS plugin
  71404. * @param maxAgents the maximum agent count in the crowd
  71405. * @param maxAgentRadius the maximum radius an agent can have
  71406. * @param scene to attach the crowd to
  71407. * @returns the crowd you can add agents to
  71408. */
  71409. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71410. /**
  71411. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71412. * You can attach anything to that node. The node position is updated in the scene update tick.
  71413. * @param pos world position that will be constrained by the navigation mesh
  71414. * @param parameters agent parameters
  71415. * @param transform hooked to the agent that will be update by the scene
  71416. * @returns agent index
  71417. */
  71418. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71419. /**
  71420. * Returns the agent position in world space
  71421. * @param index agent index returned by addAgent
  71422. * @returns world space position
  71423. */
  71424. getAgentPosition(index: number): Vector3;
  71425. /**
  71426. * Returns the agent position result in world space
  71427. * @param index agent index returned by addAgent
  71428. * @param result output world space position
  71429. */
  71430. getAgentPositionToRef(index: number, result: Vector3): void;
  71431. /**
  71432. * Returns the agent velocity in world space
  71433. * @param index agent index returned by addAgent
  71434. * @returns world space velocity
  71435. */
  71436. getAgentVelocity(index: number): Vector3;
  71437. /**
  71438. * Returns the agent velocity result in world space
  71439. * @param index agent index returned by addAgent
  71440. * @param result output world space velocity
  71441. */
  71442. getAgentVelocityToRef(index: number, result: Vector3): void;
  71443. /**
  71444. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71445. * @param index agent index returned by addAgent
  71446. * @param destination targeted world position
  71447. */
  71448. agentGoto(index: number, destination: Vector3): void;
  71449. /**
  71450. * Teleport the agent to a new position
  71451. * @param index agent index returned by addAgent
  71452. * @param destination targeted world position
  71453. */
  71454. agentTeleport(index: number, destination: Vector3): void;
  71455. /**
  71456. * Update agent parameters
  71457. * @param index agent index returned by addAgent
  71458. * @param parameters agent parameters
  71459. */
  71460. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71461. /**
  71462. * remove a particular agent previously created
  71463. * @param index agent index returned by addAgent
  71464. */
  71465. removeAgent(index: number): void;
  71466. /**
  71467. * get the list of all agents attached to this crowd
  71468. * @returns list of agent indices
  71469. */
  71470. getAgents(): number[];
  71471. /**
  71472. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71473. * @param deltaTime in seconds
  71474. */
  71475. update(deltaTime: number): void;
  71476. /**
  71477. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71478. * The queries will try to find a solution within those bounds
  71479. * default is (1,1,1)
  71480. * @param extent x,y,z value that define the extent around the queries point of reference
  71481. */
  71482. setDefaultQueryExtent(extent: Vector3): void;
  71483. /**
  71484. * Get the Bounding box extent specified by setDefaultQueryExtent
  71485. * @returns the box extent values
  71486. */
  71487. getDefaultQueryExtent(): Vector3;
  71488. /**
  71489. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71490. * @param result output the box extent values
  71491. */
  71492. getDefaultQueryExtentToRef(result: Vector3): void;
  71493. /**
  71494. * Release all resources
  71495. */
  71496. dispose(): void;
  71497. }
  71498. }
  71499. declare module "babylonjs/Navigation/Plugins/index" {
  71500. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71501. }
  71502. declare module "babylonjs/Navigation/index" {
  71503. export * from "babylonjs/Navigation/INavigationEngine";
  71504. export * from "babylonjs/Navigation/Plugins/index";
  71505. }
  71506. declare module "babylonjs/Offline/database" {
  71507. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71508. /**
  71509. * Class used to enable access to IndexedDB
  71510. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71511. */
  71512. export class Database implements IOfflineProvider {
  71513. private _callbackManifestChecked;
  71514. private _currentSceneUrl;
  71515. private _db;
  71516. private _enableSceneOffline;
  71517. private _enableTexturesOffline;
  71518. private _manifestVersionFound;
  71519. private _mustUpdateRessources;
  71520. private _hasReachedQuota;
  71521. private _isSupported;
  71522. private _idbFactory;
  71523. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71524. private static IsUASupportingBlobStorage;
  71525. /**
  71526. * Gets a boolean indicating if Database storate is enabled (off by default)
  71527. */
  71528. static IDBStorageEnabled: boolean;
  71529. /**
  71530. * Gets a boolean indicating if scene must be saved in the database
  71531. */
  71532. get enableSceneOffline(): boolean;
  71533. /**
  71534. * Gets a boolean indicating if textures must be saved in the database
  71535. */
  71536. get enableTexturesOffline(): boolean;
  71537. /**
  71538. * Creates a new Database
  71539. * @param urlToScene defines the url to load the scene
  71540. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71541. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71542. */
  71543. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71544. private static _ParseURL;
  71545. private static _ReturnFullUrlLocation;
  71546. private _checkManifestFile;
  71547. /**
  71548. * Open the database and make it available
  71549. * @param successCallback defines the callback to call on success
  71550. * @param errorCallback defines the callback to call on error
  71551. */
  71552. open(successCallback: () => void, errorCallback: () => void): void;
  71553. /**
  71554. * Loads an image from the database
  71555. * @param url defines the url to load from
  71556. * @param image defines the target DOM image
  71557. */
  71558. loadImage(url: string, image: HTMLImageElement): void;
  71559. private _loadImageFromDBAsync;
  71560. private _saveImageIntoDBAsync;
  71561. private _checkVersionFromDB;
  71562. private _loadVersionFromDBAsync;
  71563. private _saveVersionIntoDBAsync;
  71564. /**
  71565. * Loads a file from database
  71566. * @param url defines the URL to load from
  71567. * @param sceneLoaded defines a callback to call on success
  71568. * @param progressCallBack defines a callback to call when progress changed
  71569. * @param errorCallback defines a callback to call on error
  71570. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71571. */
  71572. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71573. private _loadFileAsync;
  71574. private _saveFileAsync;
  71575. /**
  71576. * Validates if xhr data is correct
  71577. * @param xhr defines the request to validate
  71578. * @param dataType defines the expected data type
  71579. * @returns true if data is correct
  71580. */
  71581. private static _ValidateXHRData;
  71582. }
  71583. }
  71584. declare module "babylonjs/Offline/index" {
  71585. export * from "babylonjs/Offline/database";
  71586. export * from "babylonjs/Offline/IOfflineProvider";
  71587. }
  71588. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71589. /** @hidden */
  71590. export var gpuUpdateParticlesPixelShader: {
  71591. name: string;
  71592. shader: string;
  71593. };
  71594. }
  71595. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71596. /** @hidden */
  71597. export var gpuUpdateParticlesVertexShader: {
  71598. name: string;
  71599. shader: string;
  71600. };
  71601. }
  71602. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71603. /** @hidden */
  71604. export var clipPlaneFragmentDeclaration2: {
  71605. name: string;
  71606. shader: string;
  71607. };
  71608. }
  71609. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71610. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71611. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71612. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71613. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71615. /** @hidden */
  71616. export var gpuRenderParticlesPixelShader: {
  71617. name: string;
  71618. shader: string;
  71619. };
  71620. }
  71621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71622. /** @hidden */
  71623. export var clipPlaneVertexDeclaration2: {
  71624. name: string;
  71625. shader: string;
  71626. };
  71627. }
  71628. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71629. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71630. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71631. /** @hidden */
  71632. export var gpuRenderParticlesVertexShader: {
  71633. name: string;
  71634. shader: string;
  71635. };
  71636. }
  71637. declare module "babylonjs/Particles/gpuParticleSystem" {
  71638. import { Nullable } from "babylonjs/types";
  71639. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71640. import { Observable } from "babylonjs/Misc/observable";
  71641. import { Matrix } from "babylonjs/Maths/math.vector";
  71642. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71643. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71644. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71645. import { IDisposable } from "babylonjs/scene";
  71646. import { Effect } from "babylonjs/Materials/effect";
  71647. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71648. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71649. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71650. import { Scene } from "babylonjs/scene";
  71651. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71652. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71653. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71654. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71655. /**
  71656. * This represents a GPU particle system in Babylon
  71657. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71658. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71659. */
  71660. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71661. /**
  71662. * The layer mask we are rendering the particles through.
  71663. */
  71664. layerMask: number;
  71665. private _capacity;
  71666. private _activeCount;
  71667. private _currentActiveCount;
  71668. private _accumulatedCount;
  71669. private _renderEffect;
  71670. private _updateEffect;
  71671. private _buffer0;
  71672. private _buffer1;
  71673. private _spriteBuffer;
  71674. private _updateVAO;
  71675. private _renderVAO;
  71676. private _targetIndex;
  71677. private _sourceBuffer;
  71678. private _targetBuffer;
  71679. private _currentRenderId;
  71680. private _started;
  71681. private _stopped;
  71682. private _timeDelta;
  71683. private _randomTexture;
  71684. private _randomTexture2;
  71685. private _attributesStrideSize;
  71686. private _updateEffectOptions;
  71687. private _randomTextureSize;
  71688. private _actualFrame;
  71689. private _customEffect;
  71690. private readonly _rawTextureWidth;
  71691. /**
  71692. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71693. */
  71694. static get IsSupported(): boolean;
  71695. /**
  71696. * An event triggered when the system is disposed.
  71697. */
  71698. onDisposeObservable: Observable<IParticleSystem>;
  71699. /**
  71700. * An event triggered when the system is stopped
  71701. */
  71702. onStoppedObservable: Observable<IParticleSystem>;
  71703. /**
  71704. * Gets the maximum number of particles active at the same time.
  71705. * @returns The max number of active particles.
  71706. */
  71707. getCapacity(): number;
  71708. /**
  71709. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71710. * to override the particles.
  71711. */
  71712. forceDepthWrite: boolean;
  71713. /**
  71714. * Gets or set the number of active particles
  71715. */
  71716. get activeParticleCount(): number;
  71717. set activeParticleCount(value: number);
  71718. private _preWarmDone;
  71719. /**
  71720. * Specifies if the particles are updated in emitter local space or world space.
  71721. */
  71722. isLocal: boolean;
  71723. /** Gets or sets a matrix to use to compute projection */
  71724. defaultProjectionMatrix: Matrix;
  71725. /**
  71726. * Is this system ready to be used/rendered
  71727. * @return true if the system is ready
  71728. */
  71729. isReady(): boolean;
  71730. /**
  71731. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71732. * @returns True if it has been started, otherwise false.
  71733. */
  71734. isStarted(): boolean;
  71735. /**
  71736. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71737. * @returns True if it has been stopped, otherwise false.
  71738. */
  71739. isStopped(): boolean;
  71740. /**
  71741. * Gets a boolean indicating that the system is stopping
  71742. * @returns true if the system is currently stopping
  71743. */
  71744. isStopping(): boolean;
  71745. /**
  71746. * Gets the number of particles active at the same time.
  71747. * @returns The number of active particles.
  71748. */
  71749. getActiveCount(): number;
  71750. /**
  71751. * Starts the particle system and begins to emit
  71752. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71753. */
  71754. start(delay?: number): void;
  71755. /**
  71756. * Stops the particle system.
  71757. */
  71758. stop(): void;
  71759. /**
  71760. * Remove all active particles
  71761. */
  71762. reset(): void;
  71763. /**
  71764. * Returns the string "GPUParticleSystem"
  71765. * @returns a string containing the class name
  71766. */
  71767. getClassName(): string;
  71768. /**
  71769. * Gets the custom effect used to render the particles
  71770. * @param blendMode Blend mode for which the effect should be retrieved
  71771. * @returns The effect
  71772. */
  71773. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71774. /**
  71775. * Sets the custom effect used to render the particles
  71776. * @param effect The effect to set
  71777. * @param blendMode Blend mode for which the effect should be set
  71778. */
  71779. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71780. /** @hidden */
  71781. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71782. /**
  71783. * Observable that will be called just before the particles are drawn
  71784. */
  71785. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71786. /**
  71787. * Gets the name of the particle vertex shader
  71788. */
  71789. get vertexShaderName(): string;
  71790. private _colorGradientsTexture;
  71791. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71792. /**
  71793. * Adds a new color gradient
  71794. * @param gradient defines the gradient to use (between 0 and 1)
  71795. * @param color1 defines the color to affect to the specified gradient
  71796. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71797. * @returns the current particle system
  71798. */
  71799. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71800. private _refreshColorGradient;
  71801. /** Force the system to rebuild all gradients that need to be resync */
  71802. forceRefreshGradients(): void;
  71803. /**
  71804. * Remove a specific color gradient
  71805. * @param gradient defines the gradient to remove
  71806. * @returns the current particle system
  71807. */
  71808. removeColorGradient(gradient: number): GPUParticleSystem;
  71809. private _angularSpeedGradientsTexture;
  71810. private _sizeGradientsTexture;
  71811. private _velocityGradientsTexture;
  71812. private _limitVelocityGradientsTexture;
  71813. private _dragGradientsTexture;
  71814. private _addFactorGradient;
  71815. /**
  71816. * Adds a new size gradient
  71817. * @param gradient defines the gradient to use (between 0 and 1)
  71818. * @param factor defines the size factor to affect to the specified gradient
  71819. * @returns the current particle system
  71820. */
  71821. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71822. /**
  71823. * Remove a specific size gradient
  71824. * @param gradient defines the gradient to remove
  71825. * @returns the current particle system
  71826. */
  71827. removeSizeGradient(gradient: number): GPUParticleSystem;
  71828. private _refreshFactorGradient;
  71829. /**
  71830. * Adds a new angular speed gradient
  71831. * @param gradient defines the gradient to use (between 0 and 1)
  71832. * @param factor defines the angular speed to affect to the specified gradient
  71833. * @returns the current particle system
  71834. */
  71835. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71836. /**
  71837. * Remove a specific angular speed gradient
  71838. * @param gradient defines the gradient to remove
  71839. * @returns the current particle system
  71840. */
  71841. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71842. /**
  71843. * Adds a new velocity gradient
  71844. * @param gradient defines the gradient to use (between 0 and 1)
  71845. * @param factor defines the velocity to affect to the specified gradient
  71846. * @returns the current particle system
  71847. */
  71848. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71849. /**
  71850. * Remove a specific velocity gradient
  71851. * @param gradient defines the gradient to remove
  71852. * @returns the current particle system
  71853. */
  71854. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71855. /**
  71856. * Adds a new limit velocity gradient
  71857. * @param gradient defines the gradient to use (between 0 and 1)
  71858. * @param factor defines the limit velocity value to affect to the specified gradient
  71859. * @returns the current particle system
  71860. */
  71861. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71862. /**
  71863. * Remove a specific limit velocity gradient
  71864. * @param gradient defines the gradient to remove
  71865. * @returns the current particle system
  71866. */
  71867. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71868. /**
  71869. * Adds a new drag gradient
  71870. * @param gradient defines the gradient to use (between 0 and 1)
  71871. * @param factor defines the drag value to affect to the specified gradient
  71872. * @returns the current particle system
  71873. */
  71874. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71875. /**
  71876. * Remove a specific drag gradient
  71877. * @param gradient defines the gradient to remove
  71878. * @returns the current particle system
  71879. */
  71880. removeDragGradient(gradient: number): GPUParticleSystem;
  71881. /**
  71882. * Not supported by GPUParticleSystem
  71883. * @param gradient defines the gradient to use (between 0 and 1)
  71884. * @param factor defines the emit rate value to affect to the specified gradient
  71885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71886. * @returns the current particle system
  71887. */
  71888. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71889. /**
  71890. * Not supported by GPUParticleSystem
  71891. * @param gradient defines the gradient to remove
  71892. * @returns the current particle system
  71893. */
  71894. removeEmitRateGradient(gradient: number): IParticleSystem;
  71895. /**
  71896. * Not supported by GPUParticleSystem
  71897. * @param gradient defines the gradient to use (between 0 and 1)
  71898. * @param factor defines the start size value to affect to the specified gradient
  71899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71900. * @returns the current particle system
  71901. */
  71902. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71903. /**
  71904. * Not supported by GPUParticleSystem
  71905. * @param gradient defines the gradient to remove
  71906. * @returns the current particle system
  71907. */
  71908. removeStartSizeGradient(gradient: number): IParticleSystem;
  71909. /**
  71910. * Not supported by GPUParticleSystem
  71911. * @param gradient defines the gradient to use (between 0 and 1)
  71912. * @param min defines the color remap minimal range
  71913. * @param max defines the color remap maximal range
  71914. * @returns the current particle system
  71915. */
  71916. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71917. /**
  71918. * Not supported by GPUParticleSystem
  71919. * @param gradient defines the gradient to remove
  71920. * @returns the current particle system
  71921. */
  71922. removeColorRemapGradient(): IParticleSystem;
  71923. /**
  71924. * Not supported by GPUParticleSystem
  71925. * @param gradient defines the gradient to use (between 0 and 1)
  71926. * @param min defines the alpha remap minimal range
  71927. * @param max defines the alpha remap maximal range
  71928. * @returns the current particle system
  71929. */
  71930. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71931. /**
  71932. * Not supported by GPUParticleSystem
  71933. * @param gradient defines the gradient to remove
  71934. * @returns the current particle system
  71935. */
  71936. removeAlphaRemapGradient(): IParticleSystem;
  71937. /**
  71938. * Not supported by GPUParticleSystem
  71939. * @param gradient defines the gradient to use (between 0 and 1)
  71940. * @param color defines the color to affect to the specified gradient
  71941. * @returns the current particle system
  71942. */
  71943. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71944. /**
  71945. * Not supported by GPUParticleSystem
  71946. * @param gradient defines the gradient to remove
  71947. * @returns the current particle system
  71948. */
  71949. removeRampGradient(): IParticleSystem;
  71950. /**
  71951. * Not supported by GPUParticleSystem
  71952. * @returns the list of ramp gradients
  71953. */
  71954. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71955. /**
  71956. * Not supported by GPUParticleSystem
  71957. * Gets or sets a boolean indicating that ramp gradients must be used
  71958. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71959. */
  71960. get useRampGradients(): boolean;
  71961. set useRampGradients(value: boolean);
  71962. /**
  71963. * Not supported by GPUParticleSystem
  71964. * @param gradient defines the gradient to use (between 0 and 1)
  71965. * @param factor defines the life time factor to affect to the specified gradient
  71966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71967. * @returns the current particle system
  71968. */
  71969. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71970. /**
  71971. * Not supported by GPUParticleSystem
  71972. * @param gradient defines the gradient to remove
  71973. * @returns the current particle system
  71974. */
  71975. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71976. /**
  71977. * Instantiates a GPU particle system.
  71978. * 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.
  71979. * @param name The name of the particle system
  71980. * @param options The options used to create the system
  71981. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71982. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71983. * @param customEffect a custom effect used to change the way particles are rendered by default
  71984. */
  71985. constructor(name: string, options: Partial<{
  71986. capacity: number;
  71987. randomTextureSize: number;
  71988. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71989. protected _reset(): void;
  71990. private _createUpdateVAO;
  71991. private _createRenderVAO;
  71992. private _initialize;
  71993. /** @hidden */
  71994. _recreateUpdateEffect(): void;
  71995. private _getEffect;
  71996. /**
  71997. * Fill the defines array according to the current settings of the particle system
  71998. * @param defines Array to be updated
  71999. * @param blendMode blend mode to take into account when updating the array
  72000. */
  72001. fillDefines(defines: Array<string>, blendMode?: number): void;
  72002. /**
  72003. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72004. * @param uniforms Uniforms array to fill
  72005. * @param attributes Attributes array to fill
  72006. * @param samplers Samplers array to fill
  72007. */
  72008. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72009. /** @hidden */
  72010. _recreateRenderEffect(): Effect;
  72011. /**
  72012. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72013. * @param preWarm defines if we are in the pre-warmimg phase
  72014. */
  72015. animate(preWarm?: boolean): void;
  72016. private _createFactorGradientTexture;
  72017. private _createSizeGradientTexture;
  72018. private _createAngularSpeedGradientTexture;
  72019. private _createVelocityGradientTexture;
  72020. private _createLimitVelocityGradientTexture;
  72021. private _createDragGradientTexture;
  72022. private _createColorGradientTexture;
  72023. /**
  72024. * Renders the particle system in its current state
  72025. * @param preWarm defines if the system should only update the particles but not render them
  72026. * @returns the current number of particles
  72027. */
  72028. render(preWarm?: boolean): number;
  72029. /**
  72030. * Rebuilds the particle system
  72031. */
  72032. rebuild(): void;
  72033. private _releaseBuffers;
  72034. private _releaseVAOs;
  72035. /**
  72036. * Disposes the particle system and free the associated resources
  72037. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72038. */
  72039. dispose(disposeTexture?: boolean): void;
  72040. /**
  72041. * Clones the particle system.
  72042. * @param name The name of the cloned object
  72043. * @param newEmitter The new emitter to use
  72044. * @returns the cloned particle system
  72045. */
  72046. clone(name: string, newEmitter: any): GPUParticleSystem;
  72047. /**
  72048. * Serializes the particle system to a JSON object
  72049. * @param serializeTexture defines if the texture must be serialized as well
  72050. * @returns the JSON object
  72051. */
  72052. serialize(serializeTexture?: boolean): any;
  72053. /**
  72054. * Parses a JSON object to create a GPU particle system.
  72055. * @param parsedParticleSystem The JSON object to parse
  72056. * @param sceneOrEngine The scene or the engine to create the particle system in
  72057. * @param rootUrl The root url to use to load external dependencies like texture
  72058. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72059. * @returns the parsed GPU particle system
  72060. */
  72061. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72062. }
  72063. }
  72064. declare module "babylonjs/Particles/particleSystemSet" {
  72065. import { Nullable } from "babylonjs/types";
  72066. import { Color3 } from "babylonjs/Maths/math.color";
  72067. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72069. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72070. import { Scene, IDisposable } from "babylonjs/scene";
  72071. /**
  72072. * Represents a set of particle systems working together to create a specific effect
  72073. */
  72074. export class ParticleSystemSet implements IDisposable {
  72075. /**
  72076. * Gets or sets base Assets URL
  72077. */
  72078. static BaseAssetsUrl: string;
  72079. private _emitterCreationOptions;
  72080. private _emitterNode;
  72081. /**
  72082. * Gets the particle system list
  72083. */
  72084. systems: IParticleSystem[];
  72085. /**
  72086. * Gets the emitter node used with this set
  72087. */
  72088. get emitterNode(): Nullable<TransformNode>;
  72089. /**
  72090. * Creates a new emitter mesh as a sphere
  72091. * @param options defines the options used to create the sphere
  72092. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72093. * @param scene defines the hosting scene
  72094. */
  72095. setEmitterAsSphere(options: {
  72096. diameter: number;
  72097. segments: number;
  72098. color: Color3;
  72099. }, renderingGroupId: number, scene: Scene): void;
  72100. /**
  72101. * Starts all particle systems of the set
  72102. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72103. */
  72104. start(emitter?: AbstractMesh): void;
  72105. /**
  72106. * Release all associated resources
  72107. */
  72108. dispose(): void;
  72109. /**
  72110. * Serialize the set into a JSON compatible object
  72111. * @param serializeTexture defines if the texture must be serialized as well
  72112. * @returns a JSON compatible representation of the set
  72113. */
  72114. serialize(serializeTexture?: boolean): any;
  72115. /**
  72116. * Parse a new ParticleSystemSet from a serialized source
  72117. * @param data defines a JSON compatible representation of the set
  72118. * @param scene defines the hosting scene
  72119. * @param gpu defines if we want GPU particles or CPU particles
  72120. * @returns a new ParticleSystemSet
  72121. */
  72122. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72123. }
  72124. }
  72125. declare module "babylonjs/Particles/particleHelper" {
  72126. import { Nullable } from "babylonjs/types";
  72127. import { Scene } from "babylonjs/scene";
  72128. import { Vector3 } from "babylonjs/Maths/math.vector";
  72129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72130. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72131. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72132. /**
  72133. * This class is made for on one-liner static method to help creating particle system set.
  72134. */
  72135. export class ParticleHelper {
  72136. /**
  72137. * Gets or sets base Assets URL
  72138. */
  72139. static BaseAssetsUrl: string;
  72140. /** Define the Url to load snippets */
  72141. static SnippetUrl: string;
  72142. /**
  72143. * Create a default particle system that you can tweak
  72144. * @param emitter defines the emitter to use
  72145. * @param capacity defines the system capacity (default is 500 particles)
  72146. * @param scene defines the hosting scene
  72147. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72148. * @returns the new Particle system
  72149. */
  72150. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72151. /**
  72152. * This is the main static method (one-liner) of this helper to create different particle systems
  72153. * @param type This string represents the type to the particle system to create
  72154. * @param scene The scene where the particle system should live
  72155. * @param gpu If the system will use gpu
  72156. * @returns the ParticleSystemSet created
  72157. */
  72158. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72159. /**
  72160. * Static function used to export a particle system to a ParticleSystemSet variable.
  72161. * Please note that the emitter shape is not exported
  72162. * @param systems defines the particle systems to export
  72163. * @returns the created particle system set
  72164. */
  72165. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72166. /**
  72167. * Creates a particle system from a snippet saved in a remote file
  72168. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72169. * @param url defines the url to load from
  72170. * @param scene defines the hosting scene
  72171. * @param gpu If the system will use gpu
  72172. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72173. * @returns a promise that will resolve to the new particle system
  72174. */
  72175. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72176. /**
  72177. * Creates a particle system from a snippet saved by the particle system editor
  72178. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72179. * @param scene defines the hosting scene
  72180. * @param gpu If the system will use gpu
  72181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72182. * @returns a promise that will resolve to the new particle system
  72183. */
  72184. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72185. }
  72186. }
  72187. declare module "babylonjs/Particles/particleSystemComponent" {
  72188. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72189. import { Effect } from "babylonjs/Materials/effect";
  72190. import "babylonjs/Shaders/particles.vertex";
  72191. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72192. module "babylonjs/Engines/engine" {
  72193. interface Engine {
  72194. /**
  72195. * Create an effect to use with particle systems.
  72196. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72197. * the particle system for which you want to create a custom effect in the last parameter
  72198. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72199. * @param uniformsNames defines a list of attribute names
  72200. * @param samplers defines an array of string used to represent textures
  72201. * @param defines defines the string containing the defines to use to compile the shaders
  72202. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72203. * @param onCompiled defines a function to call when the effect creation is successful
  72204. * @param onError defines a function to call when the effect creation has failed
  72205. * @param particleSystem the particle system you want to create the effect for
  72206. * @returns the new Effect
  72207. */
  72208. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72209. }
  72210. }
  72211. module "babylonjs/Meshes/mesh" {
  72212. interface Mesh {
  72213. /**
  72214. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72215. * @returns an array of IParticleSystem
  72216. */
  72217. getEmittedParticleSystems(): IParticleSystem[];
  72218. /**
  72219. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72220. * @returns an array of IParticleSystem
  72221. */
  72222. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72223. }
  72224. }
  72225. }
  72226. declare module "babylonjs/Particles/pointsCloudSystem" {
  72227. import { Color4 } from "babylonjs/Maths/math";
  72228. import { Mesh } from "babylonjs/Meshes/mesh";
  72229. import { Scene, IDisposable } from "babylonjs/scene";
  72230. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72231. /** Defines the 4 color options */
  72232. export enum PointColor {
  72233. /** color value */
  72234. Color = 2,
  72235. /** uv value */
  72236. UV = 1,
  72237. /** random value */
  72238. Random = 0,
  72239. /** stated value */
  72240. Stated = 3
  72241. }
  72242. /**
  72243. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72244. * 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.
  72245. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72246. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72247. *
  72248. * Full documentation here : TO BE ENTERED
  72249. */
  72250. export class PointsCloudSystem implements IDisposable {
  72251. /**
  72252. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72253. * Example : var p = SPS.particles[i];
  72254. */
  72255. particles: CloudPoint[];
  72256. /**
  72257. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72258. */
  72259. nbParticles: number;
  72260. /**
  72261. * This a counter for your own usage. It's not set by any SPS functions.
  72262. */
  72263. counter: number;
  72264. /**
  72265. * The PCS name. This name is also given to the underlying mesh.
  72266. */
  72267. name: string;
  72268. /**
  72269. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72270. */
  72271. mesh: Mesh;
  72272. /**
  72273. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72274. * Please read :
  72275. */
  72276. vars: any;
  72277. /**
  72278. * @hidden
  72279. */
  72280. _size: number;
  72281. private _scene;
  72282. private _promises;
  72283. private _positions;
  72284. private _indices;
  72285. private _normals;
  72286. private _colors;
  72287. private _uvs;
  72288. private _indices32;
  72289. private _positions32;
  72290. private _colors32;
  72291. private _uvs32;
  72292. private _updatable;
  72293. private _isVisibilityBoxLocked;
  72294. private _alwaysVisible;
  72295. private _groups;
  72296. private _groupCounter;
  72297. private _computeParticleColor;
  72298. private _computeParticleTexture;
  72299. private _computeParticleRotation;
  72300. private _computeBoundingBox;
  72301. private _isReady;
  72302. /**
  72303. * Creates a PCS (Points Cloud System) object
  72304. * @param name (String) is the PCS name, this will be the underlying mesh name
  72305. * @param pointSize (number) is the size for each point
  72306. * @param scene (Scene) is the scene in which the PCS is added
  72307. * @param options defines the options of the PCS e.g.
  72308. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72309. */
  72310. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72311. updatable?: boolean;
  72312. });
  72313. /**
  72314. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72315. * If no points were added to the PCS, the returned mesh is just a single point.
  72316. * @returns a promise for the created mesh
  72317. */
  72318. buildMeshAsync(): Promise<Mesh>;
  72319. /**
  72320. * @hidden
  72321. */
  72322. private _buildMesh;
  72323. private _addParticle;
  72324. private _randomUnitVector;
  72325. private _getColorIndicesForCoord;
  72326. private _setPointsColorOrUV;
  72327. private _colorFromTexture;
  72328. private _calculateDensity;
  72329. /**
  72330. * Adds points to the PCS in random positions within a unit sphere
  72331. * @param nb (positive integer) the number of particles to be created from this model
  72332. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72333. * @returns the number of groups in the system
  72334. */
  72335. addPoints(nb: number, pointFunction?: any): number;
  72336. /**
  72337. * Adds points to the PCS from the surface of the model shape
  72338. * @param mesh is any Mesh object that will be used as a surface model for the points
  72339. * @param nb (positive integer) the number of particles to be created from this model
  72340. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72341. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72342. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72343. * @returns the number of groups in the system
  72344. */
  72345. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72346. /**
  72347. * Adds points to the PCS inside the model shape
  72348. * @param mesh is any Mesh object that will be used as a surface model for the points
  72349. * @param nb (positive integer) the number of particles to be created from this model
  72350. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72351. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72352. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72353. * @returns the number of groups in the system
  72354. */
  72355. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72356. /**
  72357. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72358. * This method calls `updateParticle()` for each particle of the SPS.
  72359. * For an animated SPS, it is usually called within the render loop.
  72360. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72361. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72362. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72363. * @returns the PCS.
  72364. */
  72365. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72366. /**
  72367. * Disposes the PCS.
  72368. */
  72369. dispose(): void;
  72370. /**
  72371. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72372. * doc :
  72373. * @returns the PCS.
  72374. */
  72375. refreshVisibleSize(): PointsCloudSystem;
  72376. /**
  72377. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72378. * @param size the size (float) of the visibility box
  72379. * note : this doesn't lock the PCS mesh bounding box.
  72380. * doc :
  72381. */
  72382. setVisibilityBox(size: number): void;
  72383. /**
  72384. * Gets whether the PCS is always visible or not
  72385. * doc :
  72386. */
  72387. get isAlwaysVisible(): boolean;
  72388. /**
  72389. * Sets the PCS as always visible or not
  72390. * doc :
  72391. */
  72392. set isAlwaysVisible(val: boolean);
  72393. /**
  72394. * Tells to `setParticles()` to compute the particle rotations or not
  72395. * Default value : false. The PCS is faster when it's set to false
  72396. * Note : particle rotations are only applied to parent particles
  72397. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72398. */
  72399. set computeParticleRotation(val: boolean);
  72400. /**
  72401. * Tells to `setParticles()` to compute the particle colors or not.
  72402. * Default value : true. The PCS is faster when it's set to false.
  72403. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72404. */
  72405. set computeParticleColor(val: boolean);
  72406. set computeParticleTexture(val: boolean);
  72407. /**
  72408. * Gets if `setParticles()` computes the particle colors or not.
  72409. * Default value : false. The PCS is faster when it's set to false.
  72410. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72411. */
  72412. get computeParticleColor(): boolean;
  72413. /**
  72414. * Gets if `setParticles()` computes the particle textures or not.
  72415. * Default value : false. The PCS is faster when it's set to false.
  72416. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72417. */
  72418. get computeParticleTexture(): boolean;
  72419. /**
  72420. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72421. */
  72422. set computeBoundingBox(val: boolean);
  72423. /**
  72424. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72425. */
  72426. get computeBoundingBox(): boolean;
  72427. /**
  72428. * This function does nothing. It may be overwritten to set all the particle first values.
  72429. * The PCS doesn't call this function, you may have to call it by your own.
  72430. * doc :
  72431. */
  72432. initParticles(): void;
  72433. /**
  72434. * This function does nothing. It may be overwritten to recycle a particle
  72435. * The PCS doesn't call this function, you can to call it
  72436. * doc :
  72437. * @param particle The particle to recycle
  72438. * @returns the recycled particle
  72439. */
  72440. recycleParticle(particle: CloudPoint): CloudPoint;
  72441. /**
  72442. * Updates a particle : this function should be overwritten by the user.
  72443. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72444. * doc :
  72445. * @example : just set a particle position or velocity and recycle conditions
  72446. * @param particle The particle to update
  72447. * @returns the updated particle
  72448. */
  72449. updateParticle(particle: CloudPoint): CloudPoint;
  72450. /**
  72451. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72452. * This does nothing and may be overwritten by the user.
  72453. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72454. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72455. * @param update the boolean update value actually passed to setParticles()
  72456. */
  72457. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72458. /**
  72459. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72460. * This will be passed three parameters.
  72461. * This does nothing and may be overwritten by the user.
  72462. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72463. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72464. * @param update the boolean update value actually passed to setParticles()
  72465. */
  72466. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72467. }
  72468. }
  72469. declare module "babylonjs/Particles/cloudPoint" {
  72470. import { Nullable } from "babylonjs/types";
  72471. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72472. import { Mesh } from "babylonjs/Meshes/mesh";
  72473. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72474. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72475. /**
  72476. * Represents one particle of a points cloud system.
  72477. */
  72478. export class CloudPoint {
  72479. /**
  72480. * particle global index
  72481. */
  72482. idx: number;
  72483. /**
  72484. * The color of the particle
  72485. */
  72486. color: Nullable<Color4>;
  72487. /**
  72488. * The world space position of the particle.
  72489. */
  72490. position: Vector3;
  72491. /**
  72492. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72493. */
  72494. rotation: Vector3;
  72495. /**
  72496. * The world space rotation quaternion of the particle.
  72497. */
  72498. rotationQuaternion: Nullable<Quaternion>;
  72499. /**
  72500. * The uv of the particle.
  72501. */
  72502. uv: Nullable<Vector2>;
  72503. /**
  72504. * The current speed of the particle.
  72505. */
  72506. velocity: Vector3;
  72507. /**
  72508. * The pivot point in the particle local space.
  72509. */
  72510. pivot: Vector3;
  72511. /**
  72512. * Must the particle be translated from its pivot point in its local space ?
  72513. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72514. * Default : false
  72515. */
  72516. translateFromPivot: boolean;
  72517. /**
  72518. * Index of this particle in the global "positions" array (Internal use)
  72519. * @hidden
  72520. */
  72521. _pos: number;
  72522. /**
  72523. * @hidden Index of this particle in the global "indices" array (Internal use)
  72524. */
  72525. _ind: number;
  72526. /**
  72527. * Group this particle belongs to
  72528. */
  72529. _group: PointsGroup;
  72530. /**
  72531. * Group id of this particle
  72532. */
  72533. groupId: number;
  72534. /**
  72535. * Index of the particle in its group id (Internal use)
  72536. */
  72537. idxInGroup: number;
  72538. /**
  72539. * @hidden Particle BoundingInfo object (Internal use)
  72540. */
  72541. _boundingInfo: BoundingInfo;
  72542. /**
  72543. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72544. */
  72545. _pcs: PointsCloudSystem;
  72546. /**
  72547. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72548. */
  72549. _stillInvisible: boolean;
  72550. /**
  72551. * @hidden Last computed particle rotation matrix
  72552. */
  72553. _rotationMatrix: number[];
  72554. /**
  72555. * Parent particle Id, if any.
  72556. * Default null.
  72557. */
  72558. parentId: Nullable<number>;
  72559. /**
  72560. * @hidden Internal global position in the PCS.
  72561. */
  72562. _globalPosition: Vector3;
  72563. /**
  72564. * Creates a Point Cloud object.
  72565. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72566. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72567. * @param group (PointsGroup) is the group the particle belongs to
  72568. * @param groupId (integer) is the group identifier in the PCS.
  72569. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72570. * @param pcs defines the PCS it is associated to
  72571. */
  72572. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72573. /**
  72574. * get point size
  72575. */
  72576. get size(): Vector3;
  72577. /**
  72578. * Set point size
  72579. */
  72580. set size(scale: Vector3);
  72581. /**
  72582. * Legacy support, changed quaternion to rotationQuaternion
  72583. */
  72584. get quaternion(): Nullable<Quaternion>;
  72585. /**
  72586. * Legacy support, changed quaternion to rotationQuaternion
  72587. */
  72588. set quaternion(q: Nullable<Quaternion>);
  72589. /**
  72590. * Returns a boolean. True if the particle intersects a mesh, else false
  72591. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72592. * @param target is the object (point or mesh) what the intersection is computed against
  72593. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72594. * @returns true if it intersects
  72595. */
  72596. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72597. /**
  72598. * get the rotation matrix of the particle
  72599. * @hidden
  72600. */
  72601. getRotationMatrix(m: Matrix): void;
  72602. }
  72603. /**
  72604. * Represents a group of points in a points cloud system
  72605. * * PCS internal tool, don't use it manually.
  72606. */
  72607. export class PointsGroup {
  72608. /**
  72609. * The group id
  72610. * @hidden
  72611. */
  72612. groupID: number;
  72613. /**
  72614. * image data for group (internal use)
  72615. * @hidden
  72616. */
  72617. _groupImageData: Nullable<ArrayBufferView>;
  72618. /**
  72619. * Image Width (internal use)
  72620. * @hidden
  72621. */
  72622. _groupImgWidth: number;
  72623. /**
  72624. * Image Height (internal use)
  72625. * @hidden
  72626. */
  72627. _groupImgHeight: number;
  72628. /**
  72629. * Custom position function (internal use)
  72630. * @hidden
  72631. */
  72632. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72633. /**
  72634. * density per facet for surface points
  72635. * @hidden
  72636. */
  72637. _groupDensity: number[];
  72638. /**
  72639. * Only when points are colored by texture carries pointer to texture list array
  72640. * @hidden
  72641. */
  72642. _textureNb: number;
  72643. /**
  72644. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72645. * PCS internal tool, don't use it manually.
  72646. * @hidden
  72647. */
  72648. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72649. }
  72650. }
  72651. declare module "babylonjs/Particles/index" {
  72652. export * from "babylonjs/Particles/baseParticleSystem";
  72653. export * from "babylonjs/Particles/EmitterTypes/index";
  72654. export * from "babylonjs/Particles/gpuParticleSystem";
  72655. export * from "babylonjs/Particles/IParticleSystem";
  72656. export * from "babylonjs/Particles/particle";
  72657. export * from "babylonjs/Particles/particleHelper";
  72658. export * from "babylonjs/Particles/particleSystem";
  72659. import "babylonjs/Particles/particleSystemComponent";
  72660. export * from "babylonjs/Particles/particleSystemComponent";
  72661. export * from "babylonjs/Particles/particleSystemSet";
  72662. export * from "babylonjs/Particles/solidParticle";
  72663. export * from "babylonjs/Particles/solidParticleSystem";
  72664. export * from "babylonjs/Particles/cloudPoint";
  72665. export * from "babylonjs/Particles/pointsCloudSystem";
  72666. export * from "babylonjs/Particles/subEmitter";
  72667. }
  72668. declare module "babylonjs/Physics/physicsEngineComponent" {
  72669. import { Nullable } from "babylonjs/types";
  72670. import { Observable, Observer } from "babylonjs/Misc/observable";
  72671. import { Vector3 } from "babylonjs/Maths/math.vector";
  72672. import { Mesh } from "babylonjs/Meshes/mesh";
  72673. import { ISceneComponent } from "babylonjs/sceneComponent";
  72674. import { Scene } from "babylonjs/scene";
  72675. import { Node } from "babylonjs/node";
  72676. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72677. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72678. module "babylonjs/scene" {
  72679. interface Scene {
  72680. /** @hidden (Backing field) */
  72681. _physicsEngine: Nullable<IPhysicsEngine>;
  72682. /** @hidden */
  72683. _physicsTimeAccumulator: number;
  72684. /**
  72685. * Gets the current physics engine
  72686. * @returns a IPhysicsEngine or null if none attached
  72687. */
  72688. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72689. /**
  72690. * Enables physics to the current scene
  72691. * @param gravity defines the scene's gravity for the physics engine
  72692. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72693. * @return a boolean indicating if the physics engine was initialized
  72694. */
  72695. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72696. /**
  72697. * Disables and disposes the physics engine associated with the scene
  72698. */
  72699. disablePhysicsEngine(): void;
  72700. /**
  72701. * Gets a boolean indicating if there is an active physics engine
  72702. * @returns a boolean indicating if there is an active physics engine
  72703. */
  72704. isPhysicsEnabled(): boolean;
  72705. /**
  72706. * Deletes a physics compound impostor
  72707. * @param compound defines the compound to delete
  72708. */
  72709. deleteCompoundImpostor(compound: any): void;
  72710. /**
  72711. * An event triggered when physic simulation is about to be run
  72712. */
  72713. onBeforePhysicsObservable: Observable<Scene>;
  72714. /**
  72715. * An event triggered when physic simulation has been done
  72716. */
  72717. onAfterPhysicsObservable: Observable<Scene>;
  72718. }
  72719. }
  72720. module "babylonjs/Meshes/abstractMesh" {
  72721. interface AbstractMesh {
  72722. /** @hidden */
  72723. _physicsImpostor: Nullable<PhysicsImpostor>;
  72724. /**
  72725. * Gets or sets impostor used for physic simulation
  72726. * @see https://doc.babylonjs.com/features/physics_engine
  72727. */
  72728. physicsImpostor: Nullable<PhysicsImpostor>;
  72729. /**
  72730. * Gets the current physics impostor
  72731. * @see https://doc.babylonjs.com/features/physics_engine
  72732. * @returns a physics impostor or null
  72733. */
  72734. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72735. /** Apply a physic impulse to the mesh
  72736. * @param force defines the force to apply
  72737. * @param contactPoint defines where to apply the force
  72738. * @returns the current mesh
  72739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72740. */
  72741. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72742. /**
  72743. * Creates a physic joint between two meshes
  72744. * @param otherMesh defines the other mesh to use
  72745. * @param pivot1 defines the pivot to use on this mesh
  72746. * @param pivot2 defines the pivot to use on the other mesh
  72747. * @param options defines additional options (can be plugin dependent)
  72748. * @returns the current mesh
  72749. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72750. */
  72751. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72752. /** @hidden */
  72753. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72754. }
  72755. }
  72756. /**
  72757. * Defines the physics engine scene component responsible to manage a physics engine
  72758. */
  72759. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72760. /**
  72761. * The component name helpful to identify the component in the list of scene components.
  72762. */
  72763. readonly name: string;
  72764. /**
  72765. * The scene the component belongs to.
  72766. */
  72767. scene: Scene;
  72768. /**
  72769. * Creates a new instance of the component for the given scene
  72770. * @param scene Defines the scene to register the component in
  72771. */
  72772. constructor(scene: Scene);
  72773. /**
  72774. * Registers the component in a given scene
  72775. */
  72776. register(): void;
  72777. /**
  72778. * Rebuilds the elements related to this component in case of
  72779. * context lost for instance.
  72780. */
  72781. rebuild(): void;
  72782. /**
  72783. * Disposes the component and the associated ressources
  72784. */
  72785. dispose(): void;
  72786. }
  72787. }
  72788. declare module "babylonjs/Physics/physicsHelper" {
  72789. import { Nullable } from "babylonjs/types";
  72790. import { Vector3 } from "babylonjs/Maths/math.vector";
  72791. import { Mesh } from "babylonjs/Meshes/mesh";
  72792. import { Scene } from "babylonjs/scene";
  72793. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72794. /**
  72795. * A helper for physics simulations
  72796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72797. */
  72798. export class PhysicsHelper {
  72799. private _scene;
  72800. private _physicsEngine;
  72801. /**
  72802. * Initializes the Physics helper
  72803. * @param scene Babylon.js scene
  72804. */
  72805. constructor(scene: Scene);
  72806. /**
  72807. * Applies a radial explosion impulse
  72808. * @param origin the origin of the explosion
  72809. * @param radiusOrEventOptions the radius or the options of radial explosion
  72810. * @param strength the explosion strength
  72811. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72812. * @returns A physics radial explosion event, or null
  72813. */
  72814. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72815. /**
  72816. * Applies a radial explosion force
  72817. * @param origin the origin of the explosion
  72818. * @param radiusOrEventOptions the radius or the options of radial explosion
  72819. * @param strength the explosion strength
  72820. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72821. * @returns A physics radial explosion event, or null
  72822. */
  72823. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72824. /**
  72825. * Creates a gravitational field
  72826. * @param origin the origin of the explosion
  72827. * @param radiusOrEventOptions the radius or the options of radial explosion
  72828. * @param strength the explosion strength
  72829. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72830. * @returns A physics gravitational field event, or null
  72831. */
  72832. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72833. /**
  72834. * Creates a physics updraft event
  72835. * @param origin the origin of the updraft
  72836. * @param radiusOrEventOptions the radius or the options of the updraft
  72837. * @param strength the strength of the updraft
  72838. * @param height the height of the updraft
  72839. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72840. * @returns A physics updraft event, or null
  72841. */
  72842. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72843. /**
  72844. * Creates a physics vortex event
  72845. * @param origin the of the vortex
  72846. * @param radiusOrEventOptions the radius or the options of the vortex
  72847. * @param strength the strength of the vortex
  72848. * @param height the height of the vortex
  72849. * @returns a Physics vortex event, or null
  72850. * A physics vortex event or null
  72851. */
  72852. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72853. }
  72854. /**
  72855. * Represents a physics radial explosion event
  72856. */
  72857. class PhysicsRadialExplosionEvent {
  72858. private _scene;
  72859. private _options;
  72860. private _sphere;
  72861. private _dataFetched;
  72862. /**
  72863. * Initializes a radial explosioin event
  72864. * @param _scene BabylonJS scene
  72865. * @param _options The options for the vortex event
  72866. */
  72867. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72868. /**
  72869. * Returns the data related to the radial explosion event (sphere).
  72870. * @returns The radial explosion event data
  72871. */
  72872. getData(): PhysicsRadialExplosionEventData;
  72873. /**
  72874. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72875. * @param impostor A physics imposter
  72876. * @param origin the origin of the explosion
  72877. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72878. */
  72879. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72880. /**
  72881. * Triggers affecterd impostors callbacks
  72882. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72883. */
  72884. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72885. /**
  72886. * Disposes the sphere.
  72887. * @param force Specifies if the sphere should be disposed by force
  72888. */
  72889. dispose(force?: boolean): void;
  72890. /*** Helpers ***/
  72891. private _prepareSphere;
  72892. private _intersectsWithSphere;
  72893. }
  72894. /**
  72895. * Represents a gravitational field event
  72896. */
  72897. class PhysicsGravitationalFieldEvent {
  72898. private _physicsHelper;
  72899. private _scene;
  72900. private _origin;
  72901. private _options;
  72902. private _tickCallback;
  72903. private _sphere;
  72904. private _dataFetched;
  72905. /**
  72906. * Initializes the physics gravitational field event
  72907. * @param _physicsHelper A physics helper
  72908. * @param _scene BabylonJS scene
  72909. * @param _origin The origin position of the gravitational field event
  72910. * @param _options The options for the vortex event
  72911. */
  72912. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72913. /**
  72914. * Returns the data related to the gravitational field event (sphere).
  72915. * @returns A gravitational field event
  72916. */
  72917. getData(): PhysicsGravitationalFieldEventData;
  72918. /**
  72919. * Enables the gravitational field.
  72920. */
  72921. enable(): void;
  72922. /**
  72923. * Disables the gravitational field.
  72924. */
  72925. disable(): void;
  72926. /**
  72927. * Disposes the sphere.
  72928. * @param force The force to dispose from the gravitational field event
  72929. */
  72930. dispose(force?: boolean): void;
  72931. private _tick;
  72932. }
  72933. /**
  72934. * Represents a physics updraft event
  72935. */
  72936. class PhysicsUpdraftEvent {
  72937. private _scene;
  72938. private _origin;
  72939. private _options;
  72940. private _physicsEngine;
  72941. private _originTop;
  72942. private _originDirection;
  72943. private _tickCallback;
  72944. private _cylinder;
  72945. private _cylinderPosition;
  72946. private _dataFetched;
  72947. /**
  72948. * Initializes the physics updraft event
  72949. * @param _scene BabylonJS scene
  72950. * @param _origin The origin position of the updraft
  72951. * @param _options The options for the updraft event
  72952. */
  72953. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72954. /**
  72955. * Returns the data related to the updraft event (cylinder).
  72956. * @returns A physics updraft event
  72957. */
  72958. getData(): PhysicsUpdraftEventData;
  72959. /**
  72960. * Enables the updraft.
  72961. */
  72962. enable(): void;
  72963. /**
  72964. * Disables the updraft.
  72965. */
  72966. disable(): void;
  72967. /**
  72968. * Disposes the cylinder.
  72969. * @param force Specifies if the updraft should be disposed by force
  72970. */
  72971. dispose(force?: boolean): void;
  72972. private getImpostorHitData;
  72973. private _tick;
  72974. /*** Helpers ***/
  72975. private _prepareCylinder;
  72976. private _intersectsWithCylinder;
  72977. }
  72978. /**
  72979. * Represents a physics vortex event
  72980. */
  72981. class PhysicsVortexEvent {
  72982. private _scene;
  72983. private _origin;
  72984. private _options;
  72985. private _physicsEngine;
  72986. private _originTop;
  72987. private _tickCallback;
  72988. private _cylinder;
  72989. private _cylinderPosition;
  72990. private _dataFetched;
  72991. /**
  72992. * Initializes the physics vortex event
  72993. * @param _scene The BabylonJS scene
  72994. * @param _origin The origin position of the vortex
  72995. * @param _options The options for the vortex event
  72996. */
  72997. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72998. /**
  72999. * Returns the data related to the vortex event (cylinder).
  73000. * @returns The physics vortex event data
  73001. */
  73002. getData(): PhysicsVortexEventData;
  73003. /**
  73004. * Enables the vortex.
  73005. */
  73006. enable(): void;
  73007. /**
  73008. * Disables the cortex.
  73009. */
  73010. disable(): void;
  73011. /**
  73012. * Disposes the sphere.
  73013. * @param force
  73014. */
  73015. dispose(force?: boolean): void;
  73016. private getImpostorHitData;
  73017. private _tick;
  73018. /*** Helpers ***/
  73019. private _prepareCylinder;
  73020. private _intersectsWithCylinder;
  73021. }
  73022. /**
  73023. * Options fot the radial explosion event
  73024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73025. */
  73026. export class PhysicsRadialExplosionEventOptions {
  73027. /**
  73028. * The radius of the sphere for the radial explosion.
  73029. */
  73030. radius: number;
  73031. /**
  73032. * The strenth of the explosion.
  73033. */
  73034. strength: number;
  73035. /**
  73036. * The strenght of the force in correspondence to the distance of the affected object
  73037. */
  73038. falloff: PhysicsRadialImpulseFalloff;
  73039. /**
  73040. * Sphere options for the radial explosion.
  73041. */
  73042. sphere: {
  73043. segments: number;
  73044. diameter: number;
  73045. };
  73046. /**
  73047. * Sphere options for the radial explosion.
  73048. */
  73049. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73050. }
  73051. /**
  73052. * Options fot the updraft event
  73053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73054. */
  73055. export class PhysicsUpdraftEventOptions {
  73056. /**
  73057. * The radius of the cylinder for the vortex
  73058. */
  73059. radius: number;
  73060. /**
  73061. * The strenth of the updraft.
  73062. */
  73063. strength: number;
  73064. /**
  73065. * The height of the cylinder for the updraft.
  73066. */
  73067. height: number;
  73068. /**
  73069. * The mode for the the updraft.
  73070. */
  73071. updraftMode: PhysicsUpdraftMode;
  73072. }
  73073. /**
  73074. * Options fot the vortex event
  73075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73076. */
  73077. export class PhysicsVortexEventOptions {
  73078. /**
  73079. * The radius of the cylinder for the vortex
  73080. */
  73081. radius: number;
  73082. /**
  73083. * The strenth of the vortex.
  73084. */
  73085. strength: number;
  73086. /**
  73087. * The height of the cylinder for the vortex.
  73088. */
  73089. height: number;
  73090. /**
  73091. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73092. */
  73093. centripetalForceThreshold: number;
  73094. /**
  73095. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73096. */
  73097. centripetalForceMultiplier: number;
  73098. /**
  73099. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73100. */
  73101. centrifugalForceMultiplier: number;
  73102. /**
  73103. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73104. */
  73105. updraftForceMultiplier: number;
  73106. }
  73107. /**
  73108. * The strenght of the force in correspondence to the distance of the affected object
  73109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73110. */
  73111. export enum PhysicsRadialImpulseFalloff {
  73112. /** Defines that impulse is constant in strength across it's whole radius */
  73113. Constant = 0,
  73114. /** Defines that impulse gets weaker if it's further from the origin */
  73115. Linear = 1
  73116. }
  73117. /**
  73118. * The strength of the force in correspondence to the distance of the affected object
  73119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73120. */
  73121. export enum PhysicsUpdraftMode {
  73122. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73123. Center = 0,
  73124. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73125. Perpendicular = 1
  73126. }
  73127. /**
  73128. * Interface for a physics hit data
  73129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73130. */
  73131. export interface PhysicsHitData {
  73132. /**
  73133. * The force applied at the contact point
  73134. */
  73135. force: Vector3;
  73136. /**
  73137. * The contact point
  73138. */
  73139. contactPoint: Vector3;
  73140. /**
  73141. * The distance from the origin to the contact point
  73142. */
  73143. distanceFromOrigin: number;
  73144. }
  73145. /**
  73146. * Interface for radial explosion event data
  73147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73148. */
  73149. export interface PhysicsRadialExplosionEventData {
  73150. /**
  73151. * A sphere used for the radial explosion event
  73152. */
  73153. sphere: Mesh;
  73154. }
  73155. /**
  73156. * Interface for gravitational field event data
  73157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73158. */
  73159. export interface PhysicsGravitationalFieldEventData {
  73160. /**
  73161. * A sphere mesh used for the gravitational field event
  73162. */
  73163. sphere: Mesh;
  73164. }
  73165. /**
  73166. * Interface for updraft event data
  73167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73168. */
  73169. export interface PhysicsUpdraftEventData {
  73170. /**
  73171. * A cylinder used for the updraft event
  73172. */
  73173. cylinder: Mesh;
  73174. }
  73175. /**
  73176. * Interface for vortex event data
  73177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73178. */
  73179. export interface PhysicsVortexEventData {
  73180. /**
  73181. * A cylinder used for the vortex event
  73182. */
  73183. cylinder: Mesh;
  73184. }
  73185. /**
  73186. * Interface for an affected physics impostor
  73187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73188. */
  73189. export interface PhysicsAffectedImpostorWithData {
  73190. /**
  73191. * The impostor affected by the effect
  73192. */
  73193. impostor: PhysicsImpostor;
  73194. /**
  73195. * The data about the hit/horce from the explosion
  73196. */
  73197. hitData: PhysicsHitData;
  73198. }
  73199. }
  73200. declare module "babylonjs/Physics/Plugins/index" {
  73201. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73202. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73203. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73204. }
  73205. declare module "babylonjs/Physics/index" {
  73206. export * from "babylonjs/Physics/IPhysicsEngine";
  73207. export * from "babylonjs/Physics/physicsEngine";
  73208. export * from "babylonjs/Physics/physicsEngineComponent";
  73209. export * from "babylonjs/Physics/physicsHelper";
  73210. export * from "babylonjs/Physics/physicsImpostor";
  73211. export * from "babylonjs/Physics/physicsJoint";
  73212. export * from "babylonjs/Physics/Plugins/index";
  73213. }
  73214. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73215. /** @hidden */
  73216. export var blackAndWhitePixelShader: {
  73217. name: string;
  73218. shader: string;
  73219. };
  73220. }
  73221. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73223. import { Camera } from "babylonjs/Cameras/camera";
  73224. import { Engine } from "babylonjs/Engines/engine";
  73225. import "babylonjs/Shaders/blackAndWhite.fragment";
  73226. import { Nullable } from "babylonjs/types";
  73227. import { Scene } from "babylonjs/scene";
  73228. /**
  73229. * Post process used to render in black and white
  73230. */
  73231. export class BlackAndWhitePostProcess extends PostProcess {
  73232. /**
  73233. * Linear about to convert he result to black and white (default: 1)
  73234. */
  73235. degree: number;
  73236. /**
  73237. * Gets a string identifying the name of the class
  73238. * @returns "BlackAndWhitePostProcess" string
  73239. */
  73240. getClassName(): string;
  73241. /**
  73242. * Creates a black and white post process
  73243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73244. * @param name The name of the effect.
  73245. * @param options The required width/height ratio to downsize to before computing the render pass.
  73246. * @param camera The camera to apply the render pass to.
  73247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73248. * @param engine The engine which the post process will be applied. (default: current engine)
  73249. * @param reusable If the post process can be reused on the same frame. (default: false)
  73250. */
  73251. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73252. /** @hidden */
  73253. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73254. }
  73255. }
  73256. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73257. import { Nullable } from "babylonjs/types";
  73258. import { Camera } from "babylonjs/Cameras/camera";
  73259. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73260. import { Engine } from "babylonjs/Engines/engine";
  73261. /**
  73262. * This represents a set of one or more post processes in Babylon.
  73263. * A post process can be used to apply a shader to a texture after it is rendered.
  73264. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73265. */
  73266. export class PostProcessRenderEffect {
  73267. private _postProcesses;
  73268. private _getPostProcesses;
  73269. private _singleInstance;
  73270. private _cameras;
  73271. private _indicesForCamera;
  73272. /**
  73273. * Name of the effect
  73274. * @hidden
  73275. */
  73276. _name: string;
  73277. /**
  73278. * Instantiates a post process render effect.
  73279. * A post process can be used to apply a shader to a texture after it is rendered.
  73280. * @param engine The engine the effect is tied to
  73281. * @param name The name of the effect
  73282. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73283. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73284. */
  73285. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73286. /**
  73287. * Checks if all the post processes in the effect are supported.
  73288. */
  73289. get isSupported(): boolean;
  73290. /**
  73291. * Updates the current state of the effect
  73292. * @hidden
  73293. */
  73294. _update(): void;
  73295. /**
  73296. * Attaches the effect on cameras
  73297. * @param cameras The camera to attach to.
  73298. * @hidden
  73299. */
  73300. _attachCameras(cameras: Camera): void;
  73301. /**
  73302. * Attaches the effect on cameras
  73303. * @param cameras The camera to attach to.
  73304. * @hidden
  73305. */
  73306. _attachCameras(cameras: Camera[]): void;
  73307. /**
  73308. * Detaches the effect on cameras
  73309. * @param cameras The camera to detatch from.
  73310. * @hidden
  73311. */
  73312. _detachCameras(cameras: Camera): void;
  73313. /**
  73314. * Detatches the effect on cameras
  73315. * @param cameras The camera to detatch from.
  73316. * @hidden
  73317. */
  73318. _detachCameras(cameras: Camera[]): void;
  73319. /**
  73320. * Enables the effect on given cameras
  73321. * @param cameras The camera to enable.
  73322. * @hidden
  73323. */
  73324. _enable(cameras: Camera): void;
  73325. /**
  73326. * Enables the effect on given cameras
  73327. * @param cameras The camera to enable.
  73328. * @hidden
  73329. */
  73330. _enable(cameras: Nullable<Camera[]>): void;
  73331. /**
  73332. * Disables the effect on the given cameras
  73333. * @param cameras The camera to disable.
  73334. * @hidden
  73335. */
  73336. _disable(cameras: Camera): void;
  73337. /**
  73338. * Disables the effect on the given cameras
  73339. * @param cameras The camera to disable.
  73340. * @hidden
  73341. */
  73342. _disable(cameras: Nullable<Camera[]>): void;
  73343. /**
  73344. * Gets a list of the post processes contained in the effect.
  73345. * @param camera The camera to get the post processes on.
  73346. * @returns The list of the post processes in the effect.
  73347. */
  73348. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73349. }
  73350. }
  73351. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73353. /** @hidden */
  73354. export var extractHighlightsPixelShader: {
  73355. name: string;
  73356. shader: string;
  73357. };
  73358. }
  73359. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73360. import { Nullable } from "babylonjs/types";
  73361. import { Camera } from "babylonjs/Cameras/camera";
  73362. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73363. import { Engine } from "babylonjs/Engines/engine";
  73364. import "babylonjs/Shaders/extractHighlights.fragment";
  73365. /**
  73366. * 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.
  73367. */
  73368. export class ExtractHighlightsPostProcess extends PostProcess {
  73369. /**
  73370. * The luminance threshold, pixels below this value will be set to black.
  73371. */
  73372. threshold: number;
  73373. /** @hidden */
  73374. _exposure: number;
  73375. /**
  73376. * Post process which has the input texture to be used when performing highlight extraction
  73377. * @hidden
  73378. */
  73379. _inputPostProcess: Nullable<PostProcess>;
  73380. /**
  73381. * Gets a string identifying the name of the class
  73382. * @returns "ExtractHighlightsPostProcess" string
  73383. */
  73384. getClassName(): string;
  73385. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73386. }
  73387. }
  73388. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73389. /** @hidden */
  73390. export var bloomMergePixelShader: {
  73391. name: string;
  73392. shader: string;
  73393. };
  73394. }
  73395. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73396. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73397. import { Nullable } from "babylonjs/types";
  73398. import { Engine } from "babylonjs/Engines/engine";
  73399. import { Camera } from "babylonjs/Cameras/camera";
  73400. import "babylonjs/Shaders/bloomMerge.fragment";
  73401. /**
  73402. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73403. */
  73404. export class BloomMergePostProcess extends PostProcess {
  73405. /** Weight of the bloom to be added to the original input. */
  73406. weight: number;
  73407. /**
  73408. * Gets a string identifying the name of the class
  73409. * @returns "BloomMergePostProcess" string
  73410. */
  73411. getClassName(): string;
  73412. /**
  73413. * Creates a new instance of @see BloomMergePostProcess
  73414. * @param name The name of the effect.
  73415. * @param originalFromInput Post process which's input will be used for the merge.
  73416. * @param blurred Blurred highlights post process which's output will be used.
  73417. * @param weight Weight of the bloom to be added to the original input.
  73418. * @param options The required width/height ratio to downsize to before computing the render pass.
  73419. * @param camera The camera to apply the render pass to.
  73420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73421. * @param engine The engine which the post process will be applied. (default: current engine)
  73422. * @param reusable If the post process can be reused on the same frame. (default: false)
  73423. * @param textureType Type of textures used when performing the post process. (default: 0)
  73424. * @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)
  73425. */
  73426. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73427. /** Weight of the bloom to be added to the original input. */
  73428. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73429. }
  73430. }
  73431. declare module "babylonjs/PostProcesses/bloomEffect" {
  73432. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73434. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73435. import { Camera } from "babylonjs/Cameras/camera";
  73436. import { Scene } from "babylonjs/scene";
  73437. /**
  73438. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73439. */
  73440. export class BloomEffect extends PostProcessRenderEffect {
  73441. private bloomScale;
  73442. /**
  73443. * @hidden Internal
  73444. */
  73445. _effects: Array<PostProcess>;
  73446. /**
  73447. * @hidden Internal
  73448. */
  73449. _downscale: ExtractHighlightsPostProcess;
  73450. private _blurX;
  73451. private _blurY;
  73452. private _merge;
  73453. /**
  73454. * The luminance threshold to find bright areas of the image to bloom.
  73455. */
  73456. get threshold(): number;
  73457. set threshold(value: number);
  73458. /**
  73459. * The strength of the bloom.
  73460. */
  73461. get weight(): number;
  73462. set weight(value: number);
  73463. /**
  73464. * Specifies the size of the bloom blur kernel, relative to the final output size
  73465. */
  73466. get kernel(): number;
  73467. set kernel(value: number);
  73468. /**
  73469. * Creates a new instance of @see BloomEffect
  73470. * @param scene The scene the effect belongs to.
  73471. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73472. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73473. * @param bloomWeight The the strength of bloom.
  73474. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73475. * @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)
  73476. */
  73477. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73478. /**
  73479. * Disposes each of the internal effects for a given camera.
  73480. * @param camera The camera to dispose the effect on.
  73481. */
  73482. disposeEffects(camera: Camera): void;
  73483. /**
  73484. * @hidden Internal
  73485. */
  73486. _updateEffects(): void;
  73487. /**
  73488. * Internal
  73489. * @returns if all the contained post processes are ready.
  73490. * @hidden
  73491. */
  73492. _isReady(): boolean;
  73493. }
  73494. }
  73495. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73496. /** @hidden */
  73497. export var chromaticAberrationPixelShader: {
  73498. name: string;
  73499. shader: string;
  73500. };
  73501. }
  73502. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73503. import { Vector2 } from "babylonjs/Maths/math.vector";
  73504. import { Nullable } from "babylonjs/types";
  73505. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73506. import { Camera } from "babylonjs/Cameras/camera";
  73507. import { Engine } from "babylonjs/Engines/engine";
  73508. import "babylonjs/Shaders/chromaticAberration.fragment";
  73509. import { Scene } from "babylonjs/scene";
  73510. /**
  73511. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73512. */
  73513. export class ChromaticAberrationPostProcess extends PostProcess {
  73514. /**
  73515. * The amount of seperation of rgb channels (default: 30)
  73516. */
  73517. aberrationAmount: number;
  73518. /**
  73519. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73520. */
  73521. radialIntensity: number;
  73522. /**
  73523. * 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))
  73524. */
  73525. direction: Vector2;
  73526. /**
  73527. * 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))
  73528. */
  73529. centerPosition: Vector2;
  73530. /** The width of the screen to apply the effect on */
  73531. screenWidth: number;
  73532. /** The height of the screen to apply the effect on */
  73533. screenHeight: number;
  73534. /**
  73535. * Gets a string identifying the name of the class
  73536. * @returns "ChromaticAberrationPostProcess" string
  73537. */
  73538. getClassName(): string;
  73539. /**
  73540. * Creates a new instance ChromaticAberrationPostProcess
  73541. * @param name The name of the effect.
  73542. * @param screenWidth The width of the screen to apply the effect on.
  73543. * @param screenHeight The height of the screen to apply the effect on.
  73544. * @param options The required width/height ratio to downsize to before computing the render pass.
  73545. * @param camera The camera to apply the render pass to.
  73546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73547. * @param engine The engine which the post process will be applied. (default: current engine)
  73548. * @param reusable If the post process can be reused on the same frame. (default: false)
  73549. * @param textureType Type of textures used when performing the post process. (default: 0)
  73550. * @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)
  73551. */
  73552. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73553. /** @hidden */
  73554. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73555. }
  73556. }
  73557. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73558. /** @hidden */
  73559. export var circleOfConfusionPixelShader: {
  73560. name: string;
  73561. shader: string;
  73562. };
  73563. }
  73564. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73565. import { Nullable } from "babylonjs/types";
  73566. import { Engine } from "babylonjs/Engines/engine";
  73567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73569. import { Camera } from "babylonjs/Cameras/camera";
  73570. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73571. /**
  73572. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73573. */
  73574. export class CircleOfConfusionPostProcess extends PostProcess {
  73575. /**
  73576. * 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.
  73577. */
  73578. lensSize: number;
  73579. /**
  73580. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73581. */
  73582. fStop: number;
  73583. /**
  73584. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73585. */
  73586. focusDistance: number;
  73587. /**
  73588. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73589. */
  73590. focalLength: number;
  73591. /**
  73592. * Gets a string identifying the name of the class
  73593. * @returns "CircleOfConfusionPostProcess" string
  73594. */
  73595. getClassName(): string;
  73596. private _depthTexture;
  73597. /**
  73598. * Creates a new instance CircleOfConfusionPostProcess
  73599. * @param name The name of the effect.
  73600. * @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.
  73601. * @param options The required width/height ratio to downsize to before computing the render pass.
  73602. * @param camera The camera to apply the render pass to.
  73603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73604. * @param engine The engine which the post process will be applied. (default: current engine)
  73605. * @param reusable If the post process can be reused on the same frame. (default: false)
  73606. * @param textureType Type of textures used when performing the post process. (default: 0)
  73607. * @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)
  73608. */
  73609. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73610. /**
  73611. * 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.
  73612. */
  73613. set depthTexture(value: RenderTargetTexture);
  73614. }
  73615. }
  73616. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73617. /** @hidden */
  73618. export var colorCorrectionPixelShader: {
  73619. name: string;
  73620. shader: string;
  73621. };
  73622. }
  73623. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73625. import { Engine } from "babylonjs/Engines/engine";
  73626. import { Camera } from "babylonjs/Cameras/camera";
  73627. import "babylonjs/Shaders/colorCorrection.fragment";
  73628. import { Nullable } from "babylonjs/types";
  73629. import { Scene } from "babylonjs/scene";
  73630. /**
  73631. *
  73632. * This post-process allows the modification of rendered colors by using
  73633. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73634. *
  73635. * The object needs to be provided an url to a texture containing the color
  73636. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73637. * Use an image editing software to tweak the LUT to match your needs.
  73638. *
  73639. * For an example of a color LUT, see here:
  73640. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73641. * For explanations on color grading, see here:
  73642. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73643. *
  73644. */
  73645. export class ColorCorrectionPostProcess extends PostProcess {
  73646. private _colorTableTexture;
  73647. /**
  73648. * Gets the color table url used to create the LUT texture
  73649. */
  73650. colorTableUrl: string;
  73651. /**
  73652. * Gets a string identifying the name of the class
  73653. * @returns "ColorCorrectionPostProcess" string
  73654. */
  73655. getClassName(): string;
  73656. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73657. /** @hidden */
  73658. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73659. }
  73660. }
  73661. declare module "babylonjs/Shaders/convolution.fragment" {
  73662. /** @hidden */
  73663. export var convolutionPixelShader: {
  73664. name: string;
  73665. shader: string;
  73666. };
  73667. }
  73668. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73669. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73670. import { Nullable } from "babylonjs/types";
  73671. import { Camera } from "babylonjs/Cameras/camera";
  73672. import { Engine } from "babylonjs/Engines/engine";
  73673. import "babylonjs/Shaders/convolution.fragment";
  73674. import { Scene } from "babylonjs/scene";
  73675. /**
  73676. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73677. * input texture to perform effects such as edge detection or sharpening
  73678. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73679. */
  73680. export class ConvolutionPostProcess extends PostProcess {
  73681. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73682. kernel: number[];
  73683. /**
  73684. * Gets a string identifying the name of the class
  73685. * @returns "ConvolutionPostProcess" string
  73686. */
  73687. getClassName(): string;
  73688. /**
  73689. * Creates a new instance ConvolutionPostProcess
  73690. * @param name The name of the effect.
  73691. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73692. * @param options The required width/height ratio to downsize to before computing the render pass.
  73693. * @param camera The camera to apply the render pass to.
  73694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73695. * @param engine The engine which the post process will be applied. (default: current engine)
  73696. * @param reusable If the post process can be reused on the same frame. (default: false)
  73697. * @param textureType Type of textures used when performing the post process. (default: 0)
  73698. */
  73699. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73700. /** @hidden */
  73701. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73702. /**
  73703. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73704. */
  73705. static EdgeDetect0Kernel: number[];
  73706. /**
  73707. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73708. */
  73709. static EdgeDetect1Kernel: number[];
  73710. /**
  73711. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73712. */
  73713. static EdgeDetect2Kernel: number[];
  73714. /**
  73715. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73716. */
  73717. static SharpenKernel: number[];
  73718. /**
  73719. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73720. */
  73721. static EmbossKernel: number[];
  73722. /**
  73723. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73724. */
  73725. static GaussianKernel: number[];
  73726. }
  73727. }
  73728. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73729. import { Nullable } from "babylonjs/types";
  73730. import { Vector2 } from "babylonjs/Maths/math.vector";
  73731. import { Camera } from "babylonjs/Cameras/camera";
  73732. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73733. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73734. import { Engine } from "babylonjs/Engines/engine";
  73735. import { Scene } from "babylonjs/scene";
  73736. /**
  73737. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73738. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73739. * based on samples that have a large difference in distance than the center pixel.
  73740. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73741. */
  73742. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73743. /**
  73744. * The direction the blur should be applied
  73745. */
  73746. direction: Vector2;
  73747. /**
  73748. * Gets a string identifying the name of the class
  73749. * @returns "DepthOfFieldBlurPostProcess" string
  73750. */
  73751. getClassName(): string;
  73752. /**
  73753. * Creates a new instance CircleOfConfusionPostProcess
  73754. * @param name The name of the effect.
  73755. * @param scene The scene the effect belongs to.
  73756. * @param direction The direction the blur should be applied.
  73757. * @param kernel The size of the kernel used to blur.
  73758. * @param options The required width/height ratio to downsize to before computing the render pass.
  73759. * @param camera The camera to apply the render pass to.
  73760. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73761. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73763. * @param engine The engine which the post process will be applied. (default: current engine)
  73764. * @param reusable If the post process can be reused on the same frame. (default: false)
  73765. * @param textureType Type of textures used when performing the post process. (default: 0)
  73766. * @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)
  73767. */
  73768. 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);
  73769. }
  73770. }
  73771. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73772. /** @hidden */
  73773. export var depthOfFieldMergePixelShader: {
  73774. name: string;
  73775. shader: string;
  73776. };
  73777. }
  73778. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73779. import { Nullable } from "babylonjs/types";
  73780. import { Camera } from "babylonjs/Cameras/camera";
  73781. import { Effect } from "babylonjs/Materials/effect";
  73782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73783. import { Engine } from "babylonjs/Engines/engine";
  73784. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73785. /**
  73786. * Options to be set when merging outputs from the default pipeline.
  73787. */
  73788. export class DepthOfFieldMergePostProcessOptions {
  73789. /**
  73790. * The original image to merge on top of
  73791. */
  73792. originalFromInput: PostProcess;
  73793. /**
  73794. * Parameters to perform the merge of the depth of field effect
  73795. */
  73796. depthOfField?: {
  73797. circleOfConfusion: PostProcess;
  73798. blurSteps: Array<PostProcess>;
  73799. };
  73800. /**
  73801. * Parameters to perform the merge of bloom effect
  73802. */
  73803. bloom?: {
  73804. blurred: PostProcess;
  73805. weight: number;
  73806. };
  73807. }
  73808. /**
  73809. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73810. */
  73811. export class DepthOfFieldMergePostProcess extends PostProcess {
  73812. private blurSteps;
  73813. /**
  73814. * Gets a string identifying the name of the class
  73815. * @returns "DepthOfFieldMergePostProcess" string
  73816. */
  73817. getClassName(): string;
  73818. /**
  73819. * Creates a new instance of DepthOfFieldMergePostProcess
  73820. * @param name The name of the effect.
  73821. * @param originalFromInput Post process which's input will be used for the merge.
  73822. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73823. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73824. * @param options The required width/height ratio to downsize to before computing the render pass.
  73825. * @param camera The camera to apply the render pass to.
  73826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73827. * @param engine The engine which the post process will be applied. (default: current engine)
  73828. * @param reusable If the post process can be reused on the same frame. (default: false)
  73829. * @param textureType Type of textures used when performing the post process. (default: 0)
  73830. * @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)
  73831. */
  73832. 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);
  73833. /**
  73834. * Updates the effect with the current post process compile time values and recompiles the shader.
  73835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73838. * @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
  73839. * @param onCompiled Called when the shader has been compiled.
  73840. * @param onError Called if there is an error when compiling a shader.
  73841. */
  73842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73843. }
  73844. }
  73845. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73846. import { Nullable } from "babylonjs/types";
  73847. import { Camera } from "babylonjs/Cameras/camera";
  73848. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73849. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73850. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73851. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73852. import { Scene } from "babylonjs/scene";
  73853. /**
  73854. * Specifies the level of max blur that should be applied when using the depth of field effect
  73855. */
  73856. export enum DepthOfFieldEffectBlurLevel {
  73857. /**
  73858. * Subtle blur
  73859. */
  73860. Low = 0,
  73861. /**
  73862. * Medium blur
  73863. */
  73864. Medium = 1,
  73865. /**
  73866. * Large blur
  73867. */
  73868. High = 2
  73869. }
  73870. /**
  73871. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73872. */
  73873. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73874. private _circleOfConfusion;
  73875. /**
  73876. * @hidden Internal, blurs from high to low
  73877. */
  73878. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73879. private _depthOfFieldBlurY;
  73880. private _dofMerge;
  73881. /**
  73882. * @hidden Internal post processes in depth of field effect
  73883. */
  73884. _effects: Array<PostProcess>;
  73885. /**
  73886. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73887. */
  73888. set focalLength(value: number);
  73889. get focalLength(): number;
  73890. /**
  73891. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73892. */
  73893. set fStop(value: number);
  73894. get fStop(): number;
  73895. /**
  73896. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73897. */
  73898. set focusDistance(value: number);
  73899. get focusDistance(): number;
  73900. /**
  73901. * 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.
  73902. */
  73903. set lensSize(value: number);
  73904. get lensSize(): number;
  73905. /**
  73906. * Creates a new instance DepthOfFieldEffect
  73907. * @param scene The scene the effect belongs to.
  73908. * @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.
  73909. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73910. * @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)
  73911. */
  73912. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73913. /**
  73914. * Get the current class name of the current effet
  73915. * @returns "DepthOfFieldEffect"
  73916. */
  73917. getClassName(): string;
  73918. /**
  73919. * 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.
  73920. */
  73921. set depthTexture(value: RenderTargetTexture);
  73922. /**
  73923. * Disposes each of the internal effects for a given camera.
  73924. * @param camera The camera to dispose the effect on.
  73925. */
  73926. disposeEffects(camera: Camera): void;
  73927. /**
  73928. * @hidden Internal
  73929. */
  73930. _updateEffects(): void;
  73931. /**
  73932. * Internal
  73933. * @returns if all the contained post processes are ready.
  73934. * @hidden
  73935. */
  73936. _isReady(): boolean;
  73937. }
  73938. }
  73939. declare module "babylonjs/Shaders/displayPass.fragment" {
  73940. /** @hidden */
  73941. export var displayPassPixelShader: {
  73942. name: string;
  73943. shader: string;
  73944. };
  73945. }
  73946. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73947. import { Nullable } from "babylonjs/types";
  73948. import { Camera } from "babylonjs/Cameras/camera";
  73949. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73950. import { Engine } from "babylonjs/Engines/engine";
  73951. import "babylonjs/Shaders/displayPass.fragment";
  73952. import { Scene } from "babylonjs/scene";
  73953. /**
  73954. * DisplayPassPostProcess which produces an output the same as it's input
  73955. */
  73956. export class DisplayPassPostProcess extends PostProcess {
  73957. /**
  73958. * Gets a string identifying the name of the class
  73959. * @returns "DisplayPassPostProcess" string
  73960. */
  73961. getClassName(): string;
  73962. /**
  73963. * Creates the DisplayPassPostProcess
  73964. * @param name The name of the effect.
  73965. * @param options The required width/height ratio to downsize to before computing the render pass.
  73966. * @param camera The camera to apply the render pass to.
  73967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73968. * @param engine The engine which the post process will be applied. (default: current engine)
  73969. * @param reusable If the post process can be reused on the same frame. (default: false)
  73970. */
  73971. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73972. /** @hidden */
  73973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73974. }
  73975. }
  73976. declare module "babylonjs/Shaders/filter.fragment" {
  73977. /** @hidden */
  73978. export var filterPixelShader: {
  73979. name: string;
  73980. shader: string;
  73981. };
  73982. }
  73983. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73984. import { Nullable } from "babylonjs/types";
  73985. import { Matrix } from "babylonjs/Maths/math.vector";
  73986. import { Camera } from "babylonjs/Cameras/camera";
  73987. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73988. import { Engine } from "babylonjs/Engines/engine";
  73989. import "babylonjs/Shaders/filter.fragment";
  73990. import { Scene } from "babylonjs/scene";
  73991. /**
  73992. * Applies a kernel filter to the image
  73993. */
  73994. export class FilterPostProcess extends PostProcess {
  73995. /** The matrix to be applied to the image */
  73996. kernelMatrix: Matrix;
  73997. /**
  73998. * Gets a string identifying the name of the class
  73999. * @returns "FilterPostProcess" string
  74000. */
  74001. getClassName(): string;
  74002. /**
  74003. *
  74004. * @param name The name of the effect.
  74005. * @param kernelMatrix The matrix to be applied to the image
  74006. * @param options The required width/height ratio to downsize to before computing the render pass.
  74007. * @param camera The camera to apply the render pass to.
  74008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74009. * @param engine The engine which the post process will be applied. (default: current engine)
  74010. * @param reusable If the post process can be reused on the same frame. (default: false)
  74011. */
  74012. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74013. /** @hidden */
  74014. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74015. }
  74016. }
  74017. declare module "babylonjs/Shaders/fxaa.fragment" {
  74018. /** @hidden */
  74019. export var fxaaPixelShader: {
  74020. name: string;
  74021. shader: string;
  74022. };
  74023. }
  74024. declare module "babylonjs/Shaders/fxaa.vertex" {
  74025. /** @hidden */
  74026. export var fxaaVertexShader: {
  74027. name: string;
  74028. shader: string;
  74029. };
  74030. }
  74031. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74032. import { Nullable } from "babylonjs/types";
  74033. import { Camera } from "babylonjs/Cameras/camera";
  74034. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74035. import { Engine } from "babylonjs/Engines/engine";
  74036. import "babylonjs/Shaders/fxaa.fragment";
  74037. import "babylonjs/Shaders/fxaa.vertex";
  74038. import { Scene } from "babylonjs/scene";
  74039. /**
  74040. * Fxaa post process
  74041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74042. */
  74043. export class FxaaPostProcess extends PostProcess {
  74044. /**
  74045. * Gets a string identifying the name of the class
  74046. * @returns "FxaaPostProcess" string
  74047. */
  74048. getClassName(): string;
  74049. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74050. private _getDefines;
  74051. /** @hidden */
  74052. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74053. }
  74054. }
  74055. declare module "babylonjs/Shaders/grain.fragment" {
  74056. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74057. /** @hidden */
  74058. export var grainPixelShader: {
  74059. name: string;
  74060. shader: string;
  74061. };
  74062. }
  74063. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74064. import { Nullable } from "babylonjs/types";
  74065. import { Camera } from "babylonjs/Cameras/camera";
  74066. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74067. import { Engine } from "babylonjs/Engines/engine";
  74068. import "babylonjs/Shaders/grain.fragment";
  74069. import { Scene } from "babylonjs/scene";
  74070. /**
  74071. * The GrainPostProcess adds noise to the image at mid luminance levels
  74072. */
  74073. export class GrainPostProcess extends PostProcess {
  74074. /**
  74075. * The intensity of the grain added (default: 30)
  74076. */
  74077. intensity: number;
  74078. /**
  74079. * If the grain should be randomized on every frame
  74080. */
  74081. animated: boolean;
  74082. /**
  74083. * Gets a string identifying the name of the class
  74084. * @returns "GrainPostProcess" string
  74085. */
  74086. getClassName(): string;
  74087. /**
  74088. * Creates a new instance of @see GrainPostProcess
  74089. * @param name The name of the effect.
  74090. * @param options The required width/height ratio to downsize to before computing the render pass.
  74091. * @param camera The camera to apply the render pass to.
  74092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74093. * @param engine The engine which the post process will be applied. (default: current engine)
  74094. * @param reusable If the post process can be reused on the same frame. (default: false)
  74095. * @param textureType Type of textures used when performing the post process. (default: 0)
  74096. * @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)
  74097. */
  74098. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74099. /** @hidden */
  74100. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74101. }
  74102. }
  74103. declare module "babylonjs/Shaders/highlights.fragment" {
  74104. /** @hidden */
  74105. export var highlightsPixelShader: {
  74106. name: string;
  74107. shader: string;
  74108. };
  74109. }
  74110. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74111. import { Nullable } from "babylonjs/types";
  74112. import { Camera } from "babylonjs/Cameras/camera";
  74113. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74114. import { Engine } from "babylonjs/Engines/engine";
  74115. import "babylonjs/Shaders/highlights.fragment";
  74116. /**
  74117. * Extracts highlights from the image
  74118. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74119. */
  74120. export class HighlightsPostProcess extends PostProcess {
  74121. /**
  74122. * Gets a string identifying the name of the class
  74123. * @returns "HighlightsPostProcess" string
  74124. */
  74125. getClassName(): string;
  74126. /**
  74127. * Extracts highlights from the image
  74128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74129. * @param name The name of the effect.
  74130. * @param options The required width/height ratio to downsize to before computing the render pass.
  74131. * @param camera The camera to apply the render pass to.
  74132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74133. * @param engine The engine which the post process will be applied. (default: current engine)
  74134. * @param reusable If the post process can be reused on the same frame. (default: false)
  74135. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74136. */
  74137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74138. }
  74139. }
  74140. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74141. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74142. /**
  74143. * Contains all parameters needed for the prepass to perform
  74144. * motion blur
  74145. */
  74146. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74147. /**
  74148. * Is motion blur enabled
  74149. */
  74150. enabled: boolean;
  74151. /**
  74152. * Name of the configuration
  74153. */
  74154. name: string;
  74155. /**
  74156. * Textures that should be present in the MRT for this effect to work
  74157. */
  74158. readonly texturesRequired: number[];
  74159. }
  74160. }
  74161. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74162. import { Nullable } from "babylonjs/types";
  74163. import { Scene } from "babylonjs/scene";
  74164. import { ISceneComponent } from "babylonjs/sceneComponent";
  74165. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74166. module "babylonjs/scene" {
  74167. interface Scene {
  74168. /** @hidden (Backing field) */
  74169. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74170. /**
  74171. * Gets or Sets the current geometry buffer associated to the scene.
  74172. */
  74173. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74174. /**
  74175. * Enables a GeometryBufferRender and associates it with the scene
  74176. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74177. * @returns the GeometryBufferRenderer
  74178. */
  74179. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74180. /**
  74181. * Disables the GeometryBufferRender associated with the scene
  74182. */
  74183. disableGeometryBufferRenderer(): void;
  74184. }
  74185. }
  74186. /**
  74187. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74188. * in several rendering techniques.
  74189. */
  74190. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74191. /**
  74192. * The component name helpful to identify the component in the list of scene components.
  74193. */
  74194. readonly name: string;
  74195. /**
  74196. * The scene the component belongs to.
  74197. */
  74198. scene: Scene;
  74199. /**
  74200. * Creates a new instance of the component for the given scene
  74201. * @param scene Defines the scene to register the component in
  74202. */
  74203. constructor(scene: Scene);
  74204. /**
  74205. * Registers the component in a given scene
  74206. */
  74207. register(): void;
  74208. /**
  74209. * Rebuilds the elements related to this component in case of
  74210. * context lost for instance.
  74211. */
  74212. rebuild(): void;
  74213. /**
  74214. * Disposes the component and the associated ressources
  74215. */
  74216. dispose(): void;
  74217. private _gatherRenderTargets;
  74218. }
  74219. }
  74220. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74221. /** @hidden */
  74222. export var motionBlurPixelShader: {
  74223. name: string;
  74224. shader: string;
  74225. };
  74226. }
  74227. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74228. import { Nullable } from "babylonjs/types";
  74229. import { Camera } from "babylonjs/Cameras/camera";
  74230. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74232. import "babylonjs/Animations/animatable";
  74233. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74234. import "babylonjs/Shaders/motionBlur.fragment";
  74235. import { Engine } from "babylonjs/Engines/engine";
  74236. import { Scene } from "babylonjs/scene";
  74237. /**
  74238. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74239. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74240. * As an example, all you have to do is to create the post-process:
  74241. * var mb = new BABYLON.MotionBlurPostProcess(
  74242. * 'mb', // The name of the effect.
  74243. * scene, // The scene containing the objects to blur according to their velocity.
  74244. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74245. * camera // The camera to apply the render pass to.
  74246. * );
  74247. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74248. */
  74249. export class MotionBlurPostProcess extends PostProcess {
  74250. /**
  74251. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74252. */
  74253. motionStrength: number;
  74254. /**
  74255. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74256. */
  74257. get motionBlurSamples(): number;
  74258. /**
  74259. * Sets the number of iterations to be used for motion blur quality
  74260. */
  74261. set motionBlurSamples(samples: number);
  74262. private _motionBlurSamples;
  74263. private _forceGeometryBuffer;
  74264. private _geometryBufferRenderer;
  74265. private _prePassRenderer;
  74266. /**
  74267. * Gets a string identifying the name of the class
  74268. * @returns "MotionBlurPostProcess" string
  74269. */
  74270. getClassName(): string;
  74271. /**
  74272. * Creates a new instance MotionBlurPostProcess
  74273. * @param name The name of the effect.
  74274. * @param scene The scene containing the objects to blur according to their velocity.
  74275. * @param options The required width/height ratio to downsize to before computing the render pass.
  74276. * @param camera The camera to apply the render pass to.
  74277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74278. * @param engine The engine which the post process will be applied. (default: current engine)
  74279. * @param reusable If the post process can be reused on the same frame. (default: false)
  74280. * @param textureType Type of textures used when performing the post process. (default: 0)
  74281. * @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)
  74282. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74283. */
  74284. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74285. /**
  74286. * Excludes the given skinned mesh from computing bones velocities.
  74287. * 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.
  74288. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74289. */
  74290. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74291. /**
  74292. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74293. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74294. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74295. */
  74296. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74297. /**
  74298. * Disposes the post process.
  74299. * @param camera The camera to dispose the post process on.
  74300. */
  74301. dispose(camera?: Camera): void;
  74302. /** @hidden */
  74303. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74304. }
  74305. }
  74306. declare module "babylonjs/Shaders/refraction.fragment" {
  74307. /** @hidden */
  74308. export var refractionPixelShader: {
  74309. name: string;
  74310. shader: string;
  74311. };
  74312. }
  74313. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74314. import { Color3 } from "babylonjs/Maths/math.color";
  74315. import { Camera } from "babylonjs/Cameras/camera";
  74316. import { Texture } from "babylonjs/Materials/Textures/texture";
  74317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74318. import { Engine } from "babylonjs/Engines/engine";
  74319. import "babylonjs/Shaders/refraction.fragment";
  74320. import { Scene } from "babylonjs/scene";
  74321. /**
  74322. * Post process which applies a refractin texture
  74323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74324. */
  74325. export class RefractionPostProcess extends PostProcess {
  74326. private _refTexture;
  74327. private _ownRefractionTexture;
  74328. /** the base color of the refraction (used to taint the rendering) */
  74329. color: Color3;
  74330. /** simulated refraction depth */
  74331. depth: number;
  74332. /** the coefficient of the base color (0 to remove base color tainting) */
  74333. colorLevel: number;
  74334. /** Gets the url used to load the refraction texture */
  74335. refractionTextureUrl: string;
  74336. /**
  74337. * Gets or sets the refraction texture
  74338. * Please note that you are responsible for disposing the texture if you set it manually
  74339. */
  74340. get refractionTexture(): Texture;
  74341. set refractionTexture(value: Texture);
  74342. /**
  74343. * Gets a string identifying the name of the class
  74344. * @returns "RefractionPostProcess" string
  74345. */
  74346. getClassName(): string;
  74347. /**
  74348. * Initializes the RefractionPostProcess
  74349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74350. * @param name The name of the effect.
  74351. * @param refractionTextureUrl Url of the refraction texture to use
  74352. * @param color the base color of the refraction (used to taint the rendering)
  74353. * @param depth simulated refraction depth
  74354. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74355. * @param camera The camera to apply the render pass to.
  74356. * @param options The required width/height ratio to downsize to before computing the render pass.
  74357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74358. * @param engine The engine which the post process will be applied. (default: current engine)
  74359. * @param reusable If the post process can be reused on the same frame. (default: false)
  74360. */
  74361. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74362. /**
  74363. * Disposes of the post process
  74364. * @param camera Camera to dispose post process on
  74365. */
  74366. dispose(camera: Camera): void;
  74367. /** @hidden */
  74368. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74369. }
  74370. }
  74371. declare module "babylonjs/Shaders/sharpen.fragment" {
  74372. /** @hidden */
  74373. export var sharpenPixelShader: {
  74374. name: string;
  74375. shader: string;
  74376. };
  74377. }
  74378. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74379. import { Nullable } from "babylonjs/types";
  74380. import { Camera } from "babylonjs/Cameras/camera";
  74381. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74382. import "babylonjs/Shaders/sharpen.fragment";
  74383. import { Engine } from "babylonjs/Engines/engine";
  74384. import { Scene } from "babylonjs/scene";
  74385. /**
  74386. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74387. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74388. */
  74389. export class SharpenPostProcess extends PostProcess {
  74390. /**
  74391. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74392. */
  74393. colorAmount: number;
  74394. /**
  74395. * How much sharpness should be applied (default: 0.3)
  74396. */
  74397. edgeAmount: number;
  74398. /**
  74399. * Gets a string identifying the name of the class
  74400. * @returns "SharpenPostProcess" string
  74401. */
  74402. getClassName(): string;
  74403. /**
  74404. * Creates a new instance ConvolutionPostProcess
  74405. * @param name The name of the effect.
  74406. * @param options The required width/height ratio to downsize to before computing the render pass.
  74407. * @param camera The camera to apply the render pass to.
  74408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74409. * @param engine The engine which the post process will be applied. (default: current engine)
  74410. * @param reusable If the post process can be reused on the same frame. (default: false)
  74411. * @param textureType Type of textures used when performing the post process. (default: 0)
  74412. * @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)
  74413. */
  74414. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74415. /** @hidden */
  74416. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74417. }
  74418. }
  74419. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74420. import { Nullable } from "babylonjs/types";
  74421. import { Camera } from "babylonjs/Cameras/camera";
  74422. import { Engine } from "babylonjs/Engines/engine";
  74423. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74424. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74425. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74426. /**
  74427. * PostProcessRenderPipeline
  74428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74429. */
  74430. export class PostProcessRenderPipeline {
  74431. private engine;
  74432. private _renderEffects;
  74433. private _renderEffectsForIsolatedPass;
  74434. /**
  74435. * List of inspectable custom properties (used by the Inspector)
  74436. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74437. */
  74438. inspectableCustomProperties: IInspectable[];
  74439. /**
  74440. * @hidden
  74441. */
  74442. protected _cameras: Camera[];
  74443. /** @hidden */
  74444. _name: string;
  74445. /**
  74446. * Gets pipeline name
  74447. */
  74448. get name(): string;
  74449. /** Gets the list of attached cameras */
  74450. get cameras(): Camera[];
  74451. /**
  74452. * Initializes a PostProcessRenderPipeline
  74453. * @param engine engine to add the pipeline to
  74454. * @param name name of the pipeline
  74455. */
  74456. constructor(engine: Engine, name: string);
  74457. /**
  74458. * Gets the class name
  74459. * @returns "PostProcessRenderPipeline"
  74460. */
  74461. getClassName(): string;
  74462. /**
  74463. * If all the render effects in the pipeline are supported
  74464. */
  74465. get isSupported(): boolean;
  74466. /**
  74467. * Adds an effect to the pipeline
  74468. * @param renderEffect the effect to add
  74469. */
  74470. addEffect(renderEffect: PostProcessRenderEffect): void;
  74471. /** @hidden */
  74472. _rebuild(): void;
  74473. /** @hidden */
  74474. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74475. /** @hidden */
  74476. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74477. /** @hidden */
  74478. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74479. /** @hidden */
  74480. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74481. /** @hidden */
  74482. _attachCameras(cameras: Camera, unique: boolean): void;
  74483. /** @hidden */
  74484. _attachCameras(cameras: Camera[], unique: boolean): void;
  74485. /** @hidden */
  74486. _detachCameras(cameras: Camera): void;
  74487. /** @hidden */
  74488. _detachCameras(cameras: Nullable<Camera[]>): void;
  74489. /** @hidden */
  74490. _update(): void;
  74491. /** @hidden */
  74492. _reset(): void;
  74493. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74494. /**
  74495. * Sets the required values to the prepass renderer.
  74496. * @param prePassRenderer defines the prepass renderer to setup.
  74497. * @returns true if the pre pass is needed.
  74498. */
  74499. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74500. /**
  74501. * Disposes of the pipeline
  74502. */
  74503. dispose(): void;
  74504. }
  74505. }
  74506. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74507. import { Camera } from "babylonjs/Cameras/camera";
  74508. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74509. /**
  74510. * PostProcessRenderPipelineManager class
  74511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74512. */
  74513. export class PostProcessRenderPipelineManager {
  74514. private _renderPipelines;
  74515. /**
  74516. * Initializes a PostProcessRenderPipelineManager
  74517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74518. */
  74519. constructor();
  74520. /**
  74521. * Gets the list of supported render pipelines
  74522. */
  74523. get supportedPipelines(): PostProcessRenderPipeline[];
  74524. /**
  74525. * Adds a pipeline to the manager
  74526. * @param renderPipeline The pipeline to add
  74527. */
  74528. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74529. /**
  74530. * Attaches a camera to the pipeline
  74531. * @param renderPipelineName The name of the pipeline to attach to
  74532. * @param cameras the camera to attach
  74533. * @param unique if the camera can be attached multiple times to the pipeline
  74534. */
  74535. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74536. /**
  74537. * Detaches a camera from the pipeline
  74538. * @param renderPipelineName The name of the pipeline to detach from
  74539. * @param cameras the camera to detach
  74540. */
  74541. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74542. /**
  74543. * Enables an effect by name on a pipeline
  74544. * @param renderPipelineName the name of the pipeline to enable the effect in
  74545. * @param renderEffectName the name of the effect to enable
  74546. * @param cameras the cameras that the effect should be enabled on
  74547. */
  74548. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74549. /**
  74550. * Disables an effect by name on a pipeline
  74551. * @param renderPipelineName the name of the pipeline to disable the effect in
  74552. * @param renderEffectName the name of the effect to disable
  74553. * @param cameras the cameras that the effect should be disabled on
  74554. */
  74555. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74556. /**
  74557. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74558. */
  74559. update(): void;
  74560. /** @hidden */
  74561. _rebuild(): void;
  74562. /**
  74563. * Disposes of the manager and pipelines
  74564. */
  74565. dispose(): void;
  74566. }
  74567. }
  74568. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74569. import { ISceneComponent } from "babylonjs/sceneComponent";
  74570. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74571. import { Scene } from "babylonjs/scene";
  74572. module "babylonjs/scene" {
  74573. interface Scene {
  74574. /** @hidden (Backing field) */
  74575. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74576. /**
  74577. * Gets the postprocess render pipeline manager
  74578. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74579. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74580. */
  74581. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74582. }
  74583. }
  74584. /**
  74585. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74586. */
  74587. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74588. /**
  74589. * The component name helpfull to identify the component in the list of scene components.
  74590. */
  74591. readonly name: string;
  74592. /**
  74593. * The scene the component belongs to.
  74594. */
  74595. scene: Scene;
  74596. /**
  74597. * Creates a new instance of the component for the given scene
  74598. * @param scene Defines the scene to register the component in
  74599. */
  74600. constructor(scene: Scene);
  74601. /**
  74602. * Registers the component in a given scene
  74603. */
  74604. register(): void;
  74605. /**
  74606. * Rebuilds the elements related to this component in case of
  74607. * context lost for instance.
  74608. */
  74609. rebuild(): void;
  74610. /**
  74611. * Disposes the component and the associated ressources
  74612. */
  74613. dispose(): void;
  74614. private _gatherRenderTargets;
  74615. }
  74616. }
  74617. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74618. import { Nullable } from "babylonjs/types";
  74619. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74620. import { Camera } from "babylonjs/Cameras/camera";
  74621. import { IDisposable } from "babylonjs/scene";
  74622. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74623. import { Scene } from "babylonjs/scene";
  74624. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74625. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74626. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74627. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74628. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74629. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74630. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74631. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74632. import { Animation } from "babylonjs/Animations/animation";
  74633. /**
  74634. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74635. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74636. */
  74637. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74638. private _scene;
  74639. private _camerasToBeAttached;
  74640. /**
  74641. * ID of the sharpen post process,
  74642. */
  74643. private readonly SharpenPostProcessId;
  74644. /**
  74645. * @ignore
  74646. * ID of the image processing post process;
  74647. */
  74648. readonly ImageProcessingPostProcessId: string;
  74649. /**
  74650. * @ignore
  74651. * ID of the Fast Approximate Anti-Aliasing post process;
  74652. */
  74653. readonly FxaaPostProcessId: string;
  74654. /**
  74655. * ID of the chromatic aberration post process,
  74656. */
  74657. private readonly ChromaticAberrationPostProcessId;
  74658. /**
  74659. * ID of the grain post process
  74660. */
  74661. private readonly GrainPostProcessId;
  74662. /**
  74663. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74664. */
  74665. sharpen: SharpenPostProcess;
  74666. private _sharpenEffect;
  74667. private bloom;
  74668. /**
  74669. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74670. */
  74671. depthOfField: DepthOfFieldEffect;
  74672. /**
  74673. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74674. */
  74675. fxaa: FxaaPostProcess;
  74676. /**
  74677. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74678. */
  74679. imageProcessing: ImageProcessingPostProcess;
  74680. /**
  74681. * Chromatic aberration post process which will shift rgb colors in the image
  74682. */
  74683. chromaticAberration: ChromaticAberrationPostProcess;
  74684. private _chromaticAberrationEffect;
  74685. /**
  74686. * Grain post process which add noise to the image
  74687. */
  74688. grain: GrainPostProcess;
  74689. private _grainEffect;
  74690. /**
  74691. * Glow post process which adds a glow to emissive areas of the image
  74692. */
  74693. private _glowLayer;
  74694. /**
  74695. * Animations which can be used to tweak settings over a period of time
  74696. */
  74697. animations: Animation[];
  74698. private _imageProcessingConfigurationObserver;
  74699. private _sharpenEnabled;
  74700. private _bloomEnabled;
  74701. private _depthOfFieldEnabled;
  74702. private _depthOfFieldBlurLevel;
  74703. private _fxaaEnabled;
  74704. private _imageProcessingEnabled;
  74705. private _defaultPipelineTextureType;
  74706. private _bloomScale;
  74707. private _chromaticAberrationEnabled;
  74708. private _grainEnabled;
  74709. private _buildAllowed;
  74710. /**
  74711. * Gets active scene
  74712. */
  74713. get scene(): Scene;
  74714. /**
  74715. * Enable or disable the sharpen process from the pipeline
  74716. */
  74717. set sharpenEnabled(enabled: boolean);
  74718. get sharpenEnabled(): boolean;
  74719. private _resizeObserver;
  74720. private _hardwareScaleLevel;
  74721. private _bloomKernel;
  74722. /**
  74723. * Specifies the size of the bloom blur kernel, relative to the final output size
  74724. */
  74725. get bloomKernel(): number;
  74726. set bloomKernel(value: number);
  74727. /**
  74728. * Specifies the weight of the bloom in the final rendering
  74729. */
  74730. private _bloomWeight;
  74731. /**
  74732. * Specifies the luma threshold for the area that will be blurred by the bloom
  74733. */
  74734. private _bloomThreshold;
  74735. private _hdr;
  74736. /**
  74737. * The strength of the bloom.
  74738. */
  74739. set bloomWeight(value: number);
  74740. get bloomWeight(): number;
  74741. /**
  74742. * The strength of the bloom.
  74743. */
  74744. set bloomThreshold(value: number);
  74745. get bloomThreshold(): number;
  74746. /**
  74747. * The scale of the bloom, lower value will provide better performance.
  74748. */
  74749. set bloomScale(value: number);
  74750. get bloomScale(): number;
  74751. /**
  74752. * Enable or disable the bloom from the pipeline
  74753. */
  74754. set bloomEnabled(enabled: boolean);
  74755. get bloomEnabled(): boolean;
  74756. private _rebuildBloom;
  74757. /**
  74758. * If the depth of field is enabled.
  74759. */
  74760. get depthOfFieldEnabled(): boolean;
  74761. set depthOfFieldEnabled(enabled: boolean);
  74762. /**
  74763. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74764. */
  74765. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74766. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74767. /**
  74768. * If the anti aliasing is enabled.
  74769. */
  74770. set fxaaEnabled(enabled: boolean);
  74771. get fxaaEnabled(): boolean;
  74772. private _samples;
  74773. /**
  74774. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74775. */
  74776. set samples(sampleCount: number);
  74777. get samples(): number;
  74778. /**
  74779. * If image processing is enabled.
  74780. */
  74781. set imageProcessingEnabled(enabled: boolean);
  74782. get imageProcessingEnabled(): boolean;
  74783. /**
  74784. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74785. */
  74786. set glowLayerEnabled(enabled: boolean);
  74787. get glowLayerEnabled(): boolean;
  74788. /**
  74789. * Gets the glow layer (or null if not defined)
  74790. */
  74791. get glowLayer(): Nullable<GlowLayer>;
  74792. /**
  74793. * Enable or disable the chromaticAberration process from the pipeline
  74794. */
  74795. set chromaticAberrationEnabled(enabled: boolean);
  74796. get chromaticAberrationEnabled(): boolean;
  74797. /**
  74798. * Enable or disable the grain process from the pipeline
  74799. */
  74800. set grainEnabled(enabled: boolean);
  74801. get grainEnabled(): boolean;
  74802. /**
  74803. * @constructor
  74804. * @param name - The rendering pipeline name (default: "")
  74805. * @param hdr - If high dynamic range textures should be used (default: true)
  74806. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74807. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74808. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74809. */
  74810. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74811. /**
  74812. * Get the class name
  74813. * @returns "DefaultRenderingPipeline"
  74814. */
  74815. getClassName(): string;
  74816. /**
  74817. * Force the compilation of the entire pipeline.
  74818. */
  74819. prepare(): void;
  74820. private _hasCleared;
  74821. private _prevPostProcess;
  74822. private _prevPrevPostProcess;
  74823. private _setAutoClearAndTextureSharing;
  74824. private _depthOfFieldSceneObserver;
  74825. private _buildPipeline;
  74826. private _disposePostProcesses;
  74827. /**
  74828. * Adds a camera to the pipeline
  74829. * @param camera the camera to be added
  74830. */
  74831. addCamera(camera: Camera): void;
  74832. /**
  74833. * Removes a camera from the pipeline
  74834. * @param camera the camera to remove
  74835. */
  74836. removeCamera(camera: Camera): void;
  74837. /**
  74838. * Dispose of the pipeline and stop all post processes
  74839. */
  74840. dispose(): void;
  74841. /**
  74842. * Serialize the rendering pipeline (Used when exporting)
  74843. * @returns the serialized object
  74844. */
  74845. serialize(): any;
  74846. /**
  74847. * Parse the serialized pipeline
  74848. * @param source Source pipeline.
  74849. * @param scene The scene to load the pipeline to.
  74850. * @param rootUrl The URL of the serialized pipeline.
  74851. * @returns An instantiated pipeline from the serialized object.
  74852. */
  74853. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74854. }
  74855. }
  74856. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74857. /** @hidden */
  74858. export var lensHighlightsPixelShader: {
  74859. name: string;
  74860. shader: string;
  74861. };
  74862. }
  74863. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74864. /** @hidden */
  74865. export var depthOfFieldPixelShader: {
  74866. name: string;
  74867. shader: string;
  74868. };
  74869. }
  74870. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74871. import { Camera } from "babylonjs/Cameras/camera";
  74872. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74873. import { Scene } from "babylonjs/scene";
  74874. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74875. import "babylonjs/Shaders/chromaticAberration.fragment";
  74876. import "babylonjs/Shaders/lensHighlights.fragment";
  74877. import "babylonjs/Shaders/depthOfField.fragment";
  74878. /**
  74879. * BABYLON.JS Chromatic Aberration GLSL Shader
  74880. * Author: Olivier Guyot
  74881. * Separates very slightly R, G and B colors on the edges of the screen
  74882. * Inspired by Francois Tarlier & Martins Upitis
  74883. */
  74884. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74885. /**
  74886. * @ignore
  74887. * The chromatic aberration PostProcess id in the pipeline
  74888. */
  74889. LensChromaticAberrationEffect: string;
  74890. /**
  74891. * @ignore
  74892. * The highlights enhancing PostProcess id in the pipeline
  74893. */
  74894. HighlightsEnhancingEffect: string;
  74895. /**
  74896. * @ignore
  74897. * The depth-of-field PostProcess id in the pipeline
  74898. */
  74899. LensDepthOfFieldEffect: string;
  74900. private _scene;
  74901. private _depthTexture;
  74902. private _grainTexture;
  74903. private _chromaticAberrationPostProcess;
  74904. private _highlightsPostProcess;
  74905. private _depthOfFieldPostProcess;
  74906. private _edgeBlur;
  74907. private _grainAmount;
  74908. private _chromaticAberration;
  74909. private _distortion;
  74910. private _highlightsGain;
  74911. private _highlightsThreshold;
  74912. private _dofDistance;
  74913. private _dofAperture;
  74914. private _dofDarken;
  74915. private _dofPentagon;
  74916. private _blurNoise;
  74917. /**
  74918. * @constructor
  74919. *
  74920. * Effect parameters are as follow:
  74921. * {
  74922. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74923. * edge_blur: number; // from 0 to x (1 for realism)
  74924. * distortion: number; // from 0 to x (1 for realism)
  74925. * grain_amount: number; // from 0 to 1
  74926. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74927. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74928. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74929. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74930. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74931. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74932. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74933. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74934. * }
  74935. * Note: if an effect parameter is unset, effect is disabled
  74936. *
  74937. * @param name The rendering pipeline name
  74938. * @param parameters - An object containing all parameters (see above)
  74939. * @param scene The scene linked to this pipeline
  74940. * @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)
  74941. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74942. */
  74943. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74944. /**
  74945. * Get the class name
  74946. * @returns "LensRenderingPipeline"
  74947. */
  74948. getClassName(): string;
  74949. /**
  74950. * Gets associated scene
  74951. */
  74952. get scene(): Scene;
  74953. /**
  74954. * Gets or sets the edge blur
  74955. */
  74956. get edgeBlur(): number;
  74957. set edgeBlur(value: number);
  74958. /**
  74959. * Gets or sets the grain amount
  74960. */
  74961. get grainAmount(): number;
  74962. set grainAmount(value: number);
  74963. /**
  74964. * Gets or sets the chromatic aberration amount
  74965. */
  74966. get chromaticAberration(): number;
  74967. set chromaticAberration(value: number);
  74968. /**
  74969. * Gets or sets the depth of field aperture
  74970. */
  74971. get dofAperture(): number;
  74972. set dofAperture(value: number);
  74973. /**
  74974. * Gets or sets the edge distortion
  74975. */
  74976. get edgeDistortion(): number;
  74977. set edgeDistortion(value: number);
  74978. /**
  74979. * Gets or sets the depth of field distortion
  74980. */
  74981. get dofDistortion(): number;
  74982. set dofDistortion(value: number);
  74983. /**
  74984. * Gets or sets the darken out of focus amount
  74985. */
  74986. get darkenOutOfFocus(): number;
  74987. set darkenOutOfFocus(value: number);
  74988. /**
  74989. * Gets or sets a boolean indicating if blur noise is enabled
  74990. */
  74991. get blurNoise(): boolean;
  74992. set blurNoise(value: boolean);
  74993. /**
  74994. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74995. */
  74996. get pentagonBokeh(): boolean;
  74997. set pentagonBokeh(value: boolean);
  74998. /**
  74999. * Gets or sets the highlight grain amount
  75000. */
  75001. get highlightsGain(): number;
  75002. set highlightsGain(value: number);
  75003. /**
  75004. * Gets or sets the highlight threshold
  75005. */
  75006. get highlightsThreshold(): number;
  75007. set highlightsThreshold(value: number);
  75008. /**
  75009. * Sets the amount of blur at the edges
  75010. * @param amount blur amount
  75011. */
  75012. setEdgeBlur(amount: number): void;
  75013. /**
  75014. * Sets edge blur to 0
  75015. */
  75016. disableEdgeBlur(): void;
  75017. /**
  75018. * Sets the amout of grain
  75019. * @param amount Amount of grain
  75020. */
  75021. setGrainAmount(amount: number): void;
  75022. /**
  75023. * Set grain amount to 0
  75024. */
  75025. disableGrain(): void;
  75026. /**
  75027. * Sets the chromatic aberration amount
  75028. * @param amount amount of chromatic aberration
  75029. */
  75030. setChromaticAberration(amount: number): void;
  75031. /**
  75032. * Sets chromatic aberration amount to 0
  75033. */
  75034. disableChromaticAberration(): void;
  75035. /**
  75036. * Sets the EdgeDistortion amount
  75037. * @param amount amount of EdgeDistortion
  75038. */
  75039. setEdgeDistortion(amount: number): void;
  75040. /**
  75041. * Sets edge distortion to 0
  75042. */
  75043. disableEdgeDistortion(): void;
  75044. /**
  75045. * Sets the FocusDistance amount
  75046. * @param amount amount of FocusDistance
  75047. */
  75048. setFocusDistance(amount: number): void;
  75049. /**
  75050. * Disables depth of field
  75051. */
  75052. disableDepthOfField(): void;
  75053. /**
  75054. * Sets the Aperture amount
  75055. * @param amount amount of Aperture
  75056. */
  75057. setAperture(amount: number): void;
  75058. /**
  75059. * Sets the DarkenOutOfFocus amount
  75060. * @param amount amount of DarkenOutOfFocus
  75061. */
  75062. setDarkenOutOfFocus(amount: number): void;
  75063. private _pentagonBokehIsEnabled;
  75064. /**
  75065. * Creates a pentagon bokeh effect
  75066. */
  75067. enablePentagonBokeh(): void;
  75068. /**
  75069. * Disables the pentagon bokeh effect
  75070. */
  75071. disablePentagonBokeh(): void;
  75072. /**
  75073. * Enables noise blur
  75074. */
  75075. enableNoiseBlur(): void;
  75076. /**
  75077. * Disables noise blur
  75078. */
  75079. disableNoiseBlur(): void;
  75080. /**
  75081. * Sets the HighlightsGain amount
  75082. * @param amount amount of HighlightsGain
  75083. */
  75084. setHighlightsGain(amount: number): void;
  75085. /**
  75086. * Sets the HighlightsThreshold amount
  75087. * @param amount amount of HighlightsThreshold
  75088. */
  75089. setHighlightsThreshold(amount: number): void;
  75090. /**
  75091. * Disables highlights
  75092. */
  75093. disableHighlights(): void;
  75094. /**
  75095. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75096. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75097. */
  75098. dispose(disableDepthRender?: boolean): void;
  75099. private _createChromaticAberrationPostProcess;
  75100. private _createHighlightsPostProcess;
  75101. private _createDepthOfFieldPostProcess;
  75102. private _createGrainTexture;
  75103. }
  75104. }
  75105. declare module "babylonjs/Rendering/ssao2Configuration" {
  75106. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75107. /**
  75108. * Contains all parameters needed for the prepass to perform
  75109. * screen space subsurface scattering
  75110. */
  75111. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75112. /**
  75113. * Is subsurface enabled
  75114. */
  75115. enabled: boolean;
  75116. /**
  75117. * Name of the configuration
  75118. */
  75119. name: string;
  75120. /**
  75121. * Textures that should be present in the MRT for this effect to work
  75122. */
  75123. readonly texturesRequired: number[];
  75124. }
  75125. }
  75126. declare module "babylonjs/Shaders/ssao2.fragment" {
  75127. /** @hidden */
  75128. export var ssao2PixelShader: {
  75129. name: string;
  75130. shader: string;
  75131. };
  75132. }
  75133. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75134. /** @hidden */
  75135. export var ssaoCombinePixelShader: {
  75136. name: string;
  75137. shader: string;
  75138. };
  75139. }
  75140. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75141. import { Camera } from "babylonjs/Cameras/camera";
  75142. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75143. import { Scene } from "babylonjs/scene";
  75144. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75145. import "babylonjs/Shaders/ssao2.fragment";
  75146. import "babylonjs/Shaders/ssaoCombine.fragment";
  75147. /**
  75148. * Render pipeline to produce ssao effect
  75149. */
  75150. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75151. /**
  75152. * @ignore
  75153. * The PassPostProcess id in the pipeline that contains the original scene color
  75154. */
  75155. SSAOOriginalSceneColorEffect: string;
  75156. /**
  75157. * @ignore
  75158. * The SSAO PostProcess id in the pipeline
  75159. */
  75160. SSAORenderEffect: string;
  75161. /**
  75162. * @ignore
  75163. * The horizontal blur PostProcess id in the pipeline
  75164. */
  75165. SSAOBlurHRenderEffect: string;
  75166. /**
  75167. * @ignore
  75168. * The vertical blur PostProcess id in the pipeline
  75169. */
  75170. SSAOBlurVRenderEffect: string;
  75171. /**
  75172. * @ignore
  75173. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75174. */
  75175. SSAOCombineRenderEffect: string;
  75176. /**
  75177. * The output strength of the SSAO post-process. Default value is 1.0.
  75178. */
  75179. totalStrength: number;
  75180. /**
  75181. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75182. */
  75183. maxZ: number;
  75184. /**
  75185. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75186. */
  75187. minZAspect: number;
  75188. private _samples;
  75189. /**
  75190. * Number of samples used for the SSAO calculations. Default value is 8
  75191. */
  75192. set samples(n: number);
  75193. get samples(): number;
  75194. private _textureSamples;
  75195. /**
  75196. * Number of samples to use for antialiasing
  75197. */
  75198. set textureSamples(n: number);
  75199. get textureSamples(): number;
  75200. /**
  75201. * Force rendering the geometry through geometry buffer
  75202. */
  75203. private _forceGeometryBuffer;
  75204. /**
  75205. * Ratio object used for SSAO ratio and blur ratio
  75206. */
  75207. private _ratio;
  75208. /**
  75209. * Dynamically generated sphere sampler.
  75210. */
  75211. private _sampleSphere;
  75212. /**
  75213. * Blur filter offsets
  75214. */
  75215. private _samplerOffsets;
  75216. private _expensiveBlur;
  75217. /**
  75218. * If bilateral blur should be used
  75219. */
  75220. set expensiveBlur(b: boolean);
  75221. get expensiveBlur(): boolean;
  75222. /**
  75223. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75224. */
  75225. radius: number;
  75226. /**
  75227. * The base color of the SSAO post-process
  75228. * The final result is "base + ssao" between [0, 1]
  75229. */
  75230. base: number;
  75231. /**
  75232. * Support test.
  75233. */
  75234. static get IsSupported(): boolean;
  75235. private _scene;
  75236. private _randomTexture;
  75237. private _originalColorPostProcess;
  75238. private _ssaoPostProcess;
  75239. private _blurHPostProcess;
  75240. private _blurVPostProcess;
  75241. private _ssaoCombinePostProcess;
  75242. private _prePassRenderer;
  75243. /**
  75244. * Gets active scene
  75245. */
  75246. get scene(): Scene;
  75247. /**
  75248. * @constructor
  75249. * @param name The rendering pipeline name
  75250. * @param scene The scene linked to this pipeline
  75251. * @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 }
  75252. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75253. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75254. */
  75255. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75256. /**
  75257. * Get the class name
  75258. * @returns "SSAO2RenderingPipeline"
  75259. */
  75260. getClassName(): string;
  75261. /**
  75262. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75263. */
  75264. dispose(disableGeometryBufferRenderer?: boolean): void;
  75265. private _createBlurPostProcess;
  75266. /** @hidden */
  75267. _rebuild(): void;
  75268. private _bits;
  75269. private _radicalInverse_VdC;
  75270. private _hammersley;
  75271. private _hemisphereSample_uniform;
  75272. private _generateHemisphere;
  75273. private _getDefinesForSSAO;
  75274. private _createSSAOPostProcess;
  75275. private _createSSAOCombinePostProcess;
  75276. private _createRandomTexture;
  75277. /**
  75278. * Serialize the rendering pipeline (Used when exporting)
  75279. * @returns the serialized object
  75280. */
  75281. serialize(): any;
  75282. /**
  75283. * Parse the serialized pipeline
  75284. * @param source Source pipeline.
  75285. * @param scene The scene to load the pipeline to.
  75286. * @param rootUrl The URL of the serialized pipeline.
  75287. * @returns An instantiated pipeline from the serialized object.
  75288. */
  75289. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75290. }
  75291. }
  75292. declare module "babylonjs/Shaders/ssao.fragment" {
  75293. /** @hidden */
  75294. export var ssaoPixelShader: {
  75295. name: string;
  75296. shader: string;
  75297. };
  75298. }
  75299. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75300. import { Camera } from "babylonjs/Cameras/camera";
  75301. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75302. import { Scene } from "babylonjs/scene";
  75303. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75304. import "babylonjs/Shaders/ssao.fragment";
  75305. import "babylonjs/Shaders/ssaoCombine.fragment";
  75306. /**
  75307. * Render pipeline to produce ssao effect
  75308. */
  75309. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75310. /**
  75311. * @ignore
  75312. * The PassPostProcess id in the pipeline that contains the original scene color
  75313. */
  75314. SSAOOriginalSceneColorEffect: string;
  75315. /**
  75316. * @ignore
  75317. * The SSAO PostProcess id in the pipeline
  75318. */
  75319. SSAORenderEffect: string;
  75320. /**
  75321. * @ignore
  75322. * The horizontal blur PostProcess id in the pipeline
  75323. */
  75324. SSAOBlurHRenderEffect: string;
  75325. /**
  75326. * @ignore
  75327. * The vertical blur PostProcess id in the pipeline
  75328. */
  75329. SSAOBlurVRenderEffect: string;
  75330. /**
  75331. * @ignore
  75332. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75333. */
  75334. SSAOCombineRenderEffect: string;
  75335. /**
  75336. * The output strength of the SSAO post-process. Default value is 1.0.
  75337. */
  75338. totalStrength: number;
  75339. /**
  75340. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75341. */
  75342. radius: number;
  75343. /**
  75344. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75345. * Must not be equal to fallOff and superior to fallOff.
  75346. * Default value is 0.0075
  75347. */
  75348. area: number;
  75349. /**
  75350. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75351. * Must not be equal to area and inferior to area.
  75352. * Default value is 0.000001
  75353. */
  75354. fallOff: number;
  75355. /**
  75356. * The base color of the SSAO post-process
  75357. * The final result is "base + ssao" between [0, 1]
  75358. */
  75359. base: number;
  75360. private _scene;
  75361. private _depthTexture;
  75362. private _randomTexture;
  75363. private _originalColorPostProcess;
  75364. private _ssaoPostProcess;
  75365. private _blurHPostProcess;
  75366. private _blurVPostProcess;
  75367. private _ssaoCombinePostProcess;
  75368. private _firstUpdate;
  75369. /**
  75370. * Gets active scene
  75371. */
  75372. get scene(): Scene;
  75373. /**
  75374. * @constructor
  75375. * @param name - The rendering pipeline name
  75376. * @param scene - The scene linked to this pipeline
  75377. * @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 }
  75378. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75379. */
  75380. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75381. /**
  75382. * Get the class name
  75383. * @returns "SSAORenderingPipeline"
  75384. */
  75385. getClassName(): string;
  75386. /**
  75387. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75388. */
  75389. dispose(disableDepthRender?: boolean): void;
  75390. private _createBlurPostProcess;
  75391. /** @hidden */
  75392. _rebuild(): void;
  75393. private _createSSAOPostProcess;
  75394. private _createSSAOCombinePostProcess;
  75395. private _createRandomTexture;
  75396. }
  75397. }
  75398. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75399. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75400. /**
  75401. * Contains all parameters needed for the prepass to perform
  75402. * screen space reflections
  75403. */
  75404. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75405. /**
  75406. * Is ssr enabled
  75407. */
  75408. enabled: boolean;
  75409. /**
  75410. * Name of the configuration
  75411. */
  75412. name: string;
  75413. /**
  75414. * Textures that should be present in the MRT for this effect to work
  75415. */
  75416. readonly texturesRequired: number[];
  75417. }
  75418. }
  75419. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75420. /** @hidden */
  75421. export var screenSpaceReflectionPixelShader: {
  75422. name: string;
  75423. shader: string;
  75424. };
  75425. }
  75426. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75427. import { Nullable } from "babylonjs/types";
  75428. import { Camera } from "babylonjs/Cameras/camera";
  75429. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75430. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75431. import { Engine } from "babylonjs/Engines/engine";
  75432. import { Scene } from "babylonjs/scene";
  75433. /**
  75434. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75435. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75436. */
  75437. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75438. /**
  75439. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75440. */
  75441. threshold: number;
  75442. /**
  75443. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75444. */
  75445. strength: number;
  75446. /**
  75447. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75448. */
  75449. reflectionSpecularFalloffExponent: number;
  75450. /**
  75451. * 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]
  75452. */
  75453. step: number;
  75454. /**
  75455. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75456. */
  75457. roughnessFactor: number;
  75458. private _forceGeometryBuffer;
  75459. private _geometryBufferRenderer;
  75460. private _prePassRenderer;
  75461. private _enableSmoothReflections;
  75462. private _reflectionSamples;
  75463. private _smoothSteps;
  75464. /**
  75465. * Gets a string identifying the name of the class
  75466. * @returns "ScreenSpaceReflectionPostProcess" string
  75467. */
  75468. getClassName(): string;
  75469. /**
  75470. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75471. * @param name The name of the effect.
  75472. * @param scene The scene containing the objects to calculate reflections.
  75473. * @param options The required width/height ratio to downsize to before computing the render pass.
  75474. * @param camera The camera to apply the render pass to.
  75475. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75476. * @param engine The engine which the post process will be applied. (default: current engine)
  75477. * @param reusable If the post process can be reused on the same frame. (default: false)
  75478. * @param textureType Type of textures used when performing the post process. (default: 0)
  75479. * @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)
  75480. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75481. */
  75482. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75483. /**
  75484. * Gets wether or not smoothing reflections is enabled.
  75485. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75486. */
  75487. get enableSmoothReflections(): boolean;
  75488. /**
  75489. * Sets wether or not smoothing reflections is enabled.
  75490. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75491. */
  75492. set enableSmoothReflections(enabled: boolean);
  75493. /**
  75494. * Gets the number of samples taken while computing reflections. More samples count is high,
  75495. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75496. */
  75497. get reflectionSamples(): number;
  75498. /**
  75499. * Sets the number of samples taken while computing reflections. More samples count is high,
  75500. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75501. */
  75502. set reflectionSamples(samples: number);
  75503. /**
  75504. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75505. * more the post-process will require GPU power and can generate a drop in FPS.
  75506. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75507. */
  75508. get smoothSteps(): number;
  75509. set smoothSteps(steps: number);
  75510. private _updateEffectDefines;
  75511. /** @hidden */
  75512. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75513. }
  75514. }
  75515. declare module "babylonjs/Shaders/standard.fragment" {
  75516. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75517. /** @hidden */
  75518. export var standardPixelShader: {
  75519. name: string;
  75520. shader: string;
  75521. };
  75522. }
  75523. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75524. import { Nullable } from "babylonjs/types";
  75525. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75526. import { Camera } from "babylonjs/Cameras/camera";
  75527. import { Texture } from "babylonjs/Materials/Textures/texture";
  75528. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75529. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75530. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75531. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75532. import { IDisposable } from "babylonjs/scene";
  75533. import { SpotLight } from "babylonjs/Lights/spotLight";
  75534. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75535. import { Scene } from "babylonjs/scene";
  75536. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75537. import { Animation } from "babylonjs/Animations/animation";
  75538. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75539. import "babylonjs/Shaders/standard.fragment";
  75540. /**
  75541. * Standard rendering pipeline
  75542. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75543. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75544. */
  75545. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75546. /**
  75547. * Public members
  75548. */
  75549. /**
  75550. * Post-process which contains the original scene color before the pipeline applies all the effects
  75551. */
  75552. originalPostProcess: Nullable<PostProcess>;
  75553. /**
  75554. * Post-process used to down scale an image x4
  75555. */
  75556. downSampleX4PostProcess: Nullable<PostProcess>;
  75557. /**
  75558. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75559. */
  75560. brightPassPostProcess: Nullable<PostProcess>;
  75561. /**
  75562. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75563. */
  75564. blurHPostProcesses: PostProcess[];
  75565. /**
  75566. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75567. */
  75568. blurVPostProcesses: PostProcess[];
  75569. /**
  75570. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75571. */
  75572. textureAdderPostProcess: Nullable<PostProcess>;
  75573. /**
  75574. * Post-process used to create volumetric lighting effect
  75575. */
  75576. volumetricLightPostProcess: Nullable<PostProcess>;
  75577. /**
  75578. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75579. */
  75580. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75581. /**
  75582. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75583. */
  75584. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75585. /**
  75586. * Post-process used to merge the volumetric light effect and the real scene color
  75587. */
  75588. volumetricLightMergePostProces: Nullable<PostProcess>;
  75589. /**
  75590. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75591. */
  75592. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75593. /**
  75594. * Base post-process used to calculate the average luminance of the final image for HDR
  75595. */
  75596. luminancePostProcess: Nullable<PostProcess>;
  75597. /**
  75598. * Post-processes used to create down sample post-processes in order to get
  75599. * the average luminance of the final image for HDR
  75600. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75601. */
  75602. luminanceDownSamplePostProcesses: PostProcess[];
  75603. /**
  75604. * Post-process used to create a HDR effect (light adaptation)
  75605. */
  75606. hdrPostProcess: Nullable<PostProcess>;
  75607. /**
  75608. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75609. */
  75610. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75611. /**
  75612. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75613. */
  75614. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75615. /**
  75616. * Post-process used to merge the final HDR post-process and the real scene color
  75617. */
  75618. hdrFinalPostProcess: Nullable<PostProcess>;
  75619. /**
  75620. * Post-process used to create a lens flare effect
  75621. */
  75622. lensFlarePostProcess: Nullable<PostProcess>;
  75623. /**
  75624. * Post-process that merges the result of the lens flare post-process and the real scene color
  75625. */
  75626. lensFlareComposePostProcess: Nullable<PostProcess>;
  75627. /**
  75628. * Post-process used to create a motion blur effect
  75629. */
  75630. motionBlurPostProcess: Nullable<PostProcess>;
  75631. /**
  75632. * Post-process used to create a depth of field effect
  75633. */
  75634. depthOfFieldPostProcess: Nullable<PostProcess>;
  75635. /**
  75636. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75637. */
  75638. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75639. /**
  75640. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75641. */
  75642. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75643. /**
  75644. * Represents the brightness threshold in order to configure the illuminated surfaces
  75645. */
  75646. brightThreshold: number;
  75647. /**
  75648. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75649. */
  75650. blurWidth: number;
  75651. /**
  75652. * Sets if the blur for highlighted surfaces must be only horizontal
  75653. */
  75654. horizontalBlur: boolean;
  75655. /**
  75656. * Gets the overall exposure used by the pipeline
  75657. */
  75658. get exposure(): number;
  75659. /**
  75660. * Sets the overall exposure used by the pipeline
  75661. */
  75662. set exposure(value: number);
  75663. /**
  75664. * Texture used typically to simulate "dirty" on camera lens
  75665. */
  75666. lensTexture: Nullable<Texture>;
  75667. /**
  75668. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75669. */
  75670. volumetricLightCoefficient: number;
  75671. /**
  75672. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75673. */
  75674. volumetricLightPower: number;
  75675. /**
  75676. * Used the set the blur intensity to smooth the volumetric lights
  75677. */
  75678. volumetricLightBlurScale: number;
  75679. /**
  75680. * Light (spot or directional) used to generate the volumetric lights rays
  75681. * The source light must have a shadow generate so the pipeline can get its
  75682. * depth map
  75683. */
  75684. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75685. /**
  75686. * For eye adaptation, represents the minimum luminance the eye can see
  75687. */
  75688. hdrMinimumLuminance: number;
  75689. /**
  75690. * For eye adaptation, represents the decrease luminance speed
  75691. */
  75692. hdrDecreaseRate: number;
  75693. /**
  75694. * For eye adaptation, represents the increase luminance speed
  75695. */
  75696. hdrIncreaseRate: number;
  75697. /**
  75698. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75699. */
  75700. get hdrAutoExposure(): boolean;
  75701. /**
  75702. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75703. */
  75704. set hdrAutoExposure(value: boolean);
  75705. /**
  75706. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75707. */
  75708. lensColorTexture: Nullable<Texture>;
  75709. /**
  75710. * The overall strengh for the lens flare effect
  75711. */
  75712. lensFlareStrength: number;
  75713. /**
  75714. * Dispersion coefficient for lens flare ghosts
  75715. */
  75716. lensFlareGhostDispersal: number;
  75717. /**
  75718. * Main lens flare halo width
  75719. */
  75720. lensFlareHaloWidth: number;
  75721. /**
  75722. * Based on the lens distortion effect, defines how much the lens flare result
  75723. * is distorted
  75724. */
  75725. lensFlareDistortionStrength: number;
  75726. /**
  75727. * Configures the blur intensity used for for lens flare (halo)
  75728. */
  75729. lensFlareBlurWidth: number;
  75730. /**
  75731. * Lens star texture must be used to simulate rays on the flares and is available
  75732. * in the documentation
  75733. */
  75734. lensStarTexture: Nullable<Texture>;
  75735. /**
  75736. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75737. * flare effect by taking account of the dirt texture
  75738. */
  75739. lensFlareDirtTexture: Nullable<Texture>;
  75740. /**
  75741. * Represents the focal length for the depth of field effect
  75742. */
  75743. depthOfFieldDistance: number;
  75744. /**
  75745. * Represents the blur intensity for the blurred part of the depth of field effect
  75746. */
  75747. depthOfFieldBlurWidth: number;
  75748. /**
  75749. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75750. */
  75751. get motionStrength(): number;
  75752. /**
  75753. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75754. */
  75755. set motionStrength(strength: number);
  75756. /**
  75757. * Gets wether or not the motion blur post-process is object based or screen based.
  75758. */
  75759. get objectBasedMotionBlur(): boolean;
  75760. /**
  75761. * Sets wether or not the motion blur post-process should be object based or screen based
  75762. */
  75763. set objectBasedMotionBlur(value: boolean);
  75764. /**
  75765. * List of animations for the pipeline (IAnimatable implementation)
  75766. */
  75767. animations: Animation[];
  75768. /**
  75769. * Private members
  75770. */
  75771. private _scene;
  75772. private _currentDepthOfFieldSource;
  75773. private _basePostProcess;
  75774. private _fixedExposure;
  75775. private _currentExposure;
  75776. private _hdrAutoExposure;
  75777. private _hdrCurrentLuminance;
  75778. private _motionStrength;
  75779. private _isObjectBasedMotionBlur;
  75780. private _floatTextureType;
  75781. private _camerasToBeAttached;
  75782. private _ratio;
  75783. private _bloomEnabled;
  75784. private _depthOfFieldEnabled;
  75785. private _vlsEnabled;
  75786. private _lensFlareEnabled;
  75787. private _hdrEnabled;
  75788. private _motionBlurEnabled;
  75789. private _fxaaEnabled;
  75790. private _screenSpaceReflectionsEnabled;
  75791. private _motionBlurSamples;
  75792. private _volumetricLightStepsCount;
  75793. private _samples;
  75794. /**
  75795. * @ignore
  75796. * Specifies if the bloom pipeline is enabled
  75797. */
  75798. get BloomEnabled(): boolean;
  75799. set BloomEnabled(enabled: boolean);
  75800. /**
  75801. * @ignore
  75802. * Specifies if the depth of field pipeline is enabed
  75803. */
  75804. get DepthOfFieldEnabled(): boolean;
  75805. set DepthOfFieldEnabled(enabled: boolean);
  75806. /**
  75807. * @ignore
  75808. * Specifies if the lens flare pipeline is enabed
  75809. */
  75810. get LensFlareEnabled(): boolean;
  75811. set LensFlareEnabled(enabled: boolean);
  75812. /**
  75813. * @ignore
  75814. * Specifies if the HDR pipeline is enabled
  75815. */
  75816. get HDREnabled(): boolean;
  75817. set HDREnabled(enabled: boolean);
  75818. /**
  75819. * @ignore
  75820. * Specifies if the volumetric lights scattering effect is enabled
  75821. */
  75822. get VLSEnabled(): boolean;
  75823. set VLSEnabled(enabled: boolean);
  75824. /**
  75825. * @ignore
  75826. * Specifies if the motion blur effect is enabled
  75827. */
  75828. get MotionBlurEnabled(): boolean;
  75829. set MotionBlurEnabled(enabled: boolean);
  75830. /**
  75831. * Specifies if anti-aliasing is enabled
  75832. */
  75833. get fxaaEnabled(): boolean;
  75834. set fxaaEnabled(enabled: boolean);
  75835. /**
  75836. * Specifies if screen space reflections are enabled.
  75837. */
  75838. get screenSpaceReflectionsEnabled(): boolean;
  75839. set screenSpaceReflectionsEnabled(enabled: boolean);
  75840. /**
  75841. * Specifies the number of steps used to calculate the volumetric lights
  75842. * Typically in interval [50, 200]
  75843. */
  75844. get volumetricLightStepsCount(): number;
  75845. set volumetricLightStepsCount(count: number);
  75846. /**
  75847. * Specifies the number of samples used for the motion blur effect
  75848. * Typically in interval [16, 64]
  75849. */
  75850. get motionBlurSamples(): number;
  75851. set motionBlurSamples(samples: number);
  75852. /**
  75853. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75854. */
  75855. get samples(): number;
  75856. set samples(sampleCount: number);
  75857. /**
  75858. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75859. * @constructor
  75860. * @param name The rendering pipeline name
  75861. * @param scene The scene linked to this pipeline
  75862. * @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)
  75863. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75864. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75865. */
  75866. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75867. private _buildPipeline;
  75868. private _createDownSampleX4PostProcess;
  75869. private _createBrightPassPostProcess;
  75870. private _createBlurPostProcesses;
  75871. private _createTextureAdderPostProcess;
  75872. private _createVolumetricLightPostProcess;
  75873. private _createLuminancePostProcesses;
  75874. private _createHdrPostProcess;
  75875. private _createLensFlarePostProcess;
  75876. private _createDepthOfFieldPostProcess;
  75877. private _createMotionBlurPostProcess;
  75878. private _getDepthTexture;
  75879. private _disposePostProcesses;
  75880. /**
  75881. * Dispose of the pipeline and stop all post processes
  75882. */
  75883. dispose(): void;
  75884. /**
  75885. * Serialize the rendering pipeline (Used when exporting)
  75886. * @returns the serialized object
  75887. */
  75888. serialize(): any;
  75889. /**
  75890. * Parse the serialized pipeline
  75891. * @param source Source pipeline.
  75892. * @param scene The scene to load the pipeline to.
  75893. * @param rootUrl The URL of the serialized pipeline.
  75894. * @returns An instantiated pipeline from the serialized object.
  75895. */
  75896. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75897. /**
  75898. * Luminance steps
  75899. */
  75900. static LuminanceSteps: number;
  75901. }
  75902. }
  75903. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75904. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75905. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75906. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75907. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75908. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75909. }
  75910. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75911. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75912. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75913. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75914. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75915. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75916. }
  75917. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75918. /** @hidden */
  75919. export var stereoscopicInterlacePixelShader: {
  75920. name: string;
  75921. shader: string;
  75922. };
  75923. }
  75924. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75925. import { Camera } from "babylonjs/Cameras/camera";
  75926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75927. import { Engine } from "babylonjs/Engines/engine";
  75928. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75929. /**
  75930. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75931. */
  75932. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75933. private _stepSize;
  75934. private _passedProcess;
  75935. /**
  75936. * Gets a string identifying the name of the class
  75937. * @returns "StereoscopicInterlacePostProcessI" string
  75938. */
  75939. getClassName(): string;
  75940. /**
  75941. * Initializes a StereoscopicInterlacePostProcessI
  75942. * @param name The name of the effect.
  75943. * @param rigCameras The rig cameras to be appled to the post process
  75944. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75945. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75947. * @param engine The engine which the post process will be applied. (default: current engine)
  75948. * @param reusable If the post process can be reused on the same frame. (default: false)
  75949. */
  75950. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75951. }
  75952. /**
  75953. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75954. */
  75955. export class StereoscopicInterlacePostProcess extends PostProcess {
  75956. private _stepSize;
  75957. private _passedProcess;
  75958. /**
  75959. * Gets a string identifying the name of the class
  75960. * @returns "StereoscopicInterlacePostProcess" string
  75961. */
  75962. getClassName(): string;
  75963. /**
  75964. * Initializes a StereoscopicInterlacePostProcess
  75965. * @param name The name of the effect.
  75966. * @param rigCameras The rig cameras to be appled to the post process
  75967. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75969. * @param engine The engine which the post process will be applied. (default: current engine)
  75970. * @param reusable If the post process can be reused on the same frame. (default: false)
  75971. */
  75972. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75973. }
  75974. }
  75975. declare module "babylonjs/Shaders/tonemap.fragment" {
  75976. /** @hidden */
  75977. export var tonemapPixelShader: {
  75978. name: string;
  75979. shader: string;
  75980. };
  75981. }
  75982. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75983. import { Camera } from "babylonjs/Cameras/camera";
  75984. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75985. import "babylonjs/Shaders/tonemap.fragment";
  75986. import { Engine } from "babylonjs/Engines/engine";
  75987. /** Defines operator used for tonemapping */
  75988. export enum TonemappingOperator {
  75989. /** Hable */
  75990. Hable = 0,
  75991. /** Reinhard */
  75992. Reinhard = 1,
  75993. /** HejiDawson */
  75994. HejiDawson = 2,
  75995. /** Photographic */
  75996. Photographic = 3
  75997. }
  75998. /**
  75999. * Defines a post process to apply tone mapping
  76000. */
  76001. export class TonemapPostProcess extends PostProcess {
  76002. private _operator;
  76003. /** Defines the required exposure adjustement */
  76004. exposureAdjustment: number;
  76005. /**
  76006. * Gets a string identifying the name of the class
  76007. * @returns "TonemapPostProcess" string
  76008. */
  76009. getClassName(): string;
  76010. /**
  76011. * Creates a new TonemapPostProcess
  76012. * @param name defines the name of the postprocess
  76013. * @param _operator defines the operator to use
  76014. * @param exposureAdjustment defines the required exposure adjustement
  76015. * @param camera defines the camera to use (can be null)
  76016. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76017. * @param engine defines the hosting engine (can be ignore if camera is set)
  76018. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76019. */
  76020. constructor(name: string, _operator: TonemappingOperator,
  76021. /** Defines the required exposure adjustement */
  76022. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76023. }
  76024. }
  76025. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76026. /** @hidden */
  76027. export var volumetricLightScatteringPixelShader: {
  76028. name: string;
  76029. shader: string;
  76030. };
  76031. }
  76032. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76033. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76034. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76036. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76038. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76039. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76040. /** @hidden */
  76041. export var volumetricLightScatteringPassVertexShader: {
  76042. name: string;
  76043. shader: string;
  76044. };
  76045. }
  76046. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76047. /** @hidden */
  76048. export var volumetricLightScatteringPassPixelShader: {
  76049. name: string;
  76050. shader: string;
  76051. };
  76052. }
  76053. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76054. import { Vector3 } from "babylonjs/Maths/math.vector";
  76055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76056. import { Mesh } from "babylonjs/Meshes/mesh";
  76057. import { Camera } from "babylonjs/Cameras/camera";
  76058. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76060. import { Scene } from "babylonjs/scene";
  76061. import "babylonjs/Meshes/Builders/planeBuilder";
  76062. import "babylonjs/Shaders/depth.vertex";
  76063. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76064. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76065. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76066. import { Engine } from "babylonjs/Engines/engine";
  76067. /**
  76068. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76069. */
  76070. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76071. private _volumetricLightScatteringPass;
  76072. private _volumetricLightScatteringRTT;
  76073. private _viewPort;
  76074. private _screenCoordinates;
  76075. private _cachedDefines;
  76076. /**
  76077. * If not undefined, the mesh position is computed from the attached node position
  76078. */
  76079. attachedNode: {
  76080. position: Vector3;
  76081. };
  76082. /**
  76083. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76084. */
  76085. customMeshPosition: Vector3;
  76086. /**
  76087. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76088. */
  76089. useCustomMeshPosition: boolean;
  76090. /**
  76091. * If the post-process should inverse the light scattering direction
  76092. */
  76093. invert: boolean;
  76094. /**
  76095. * The internal mesh used by the post-process
  76096. */
  76097. mesh: Mesh;
  76098. /**
  76099. * @hidden
  76100. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76101. */
  76102. get useDiffuseColor(): boolean;
  76103. set useDiffuseColor(useDiffuseColor: boolean);
  76104. /**
  76105. * Array containing the excluded meshes not rendered in the internal pass
  76106. */
  76107. excludedMeshes: AbstractMesh[];
  76108. /**
  76109. * Controls the overall intensity of the post-process
  76110. */
  76111. exposure: number;
  76112. /**
  76113. * Dissipates each sample's contribution in range [0, 1]
  76114. */
  76115. decay: number;
  76116. /**
  76117. * Controls the overall intensity of each sample
  76118. */
  76119. weight: number;
  76120. /**
  76121. * Controls the density of each sample
  76122. */
  76123. density: number;
  76124. /**
  76125. * @constructor
  76126. * @param name The post-process name
  76127. * @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)
  76128. * @param camera The camera that the post-process will be attached to
  76129. * @param mesh The mesh used to create the light scattering
  76130. * @param samples The post-process quality, default 100
  76131. * @param samplingModeThe post-process filtering mode
  76132. * @param engine The babylon engine
  76133. * @param reusable If the post-process is reusable
  76134. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76135. */
  76136. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76137. /**
  76138. * Returns the string "VolumetricLightScatteringPostProcess"
  76139. * @returns "VolumetricLightScatteringPostProcess"
  76140. */
  76141. getClassName(): string;
  76142. private _isReady;
  76143. /**
  76144. * Sets the new light position for light scattering effect
  76145. * @param position The new custom light position
  76146. */
  76147. setCustomMeshPosition(position: Vector3): void;
  76148. /**
  76149. * Returns the light position for light scattering effect
  76150. * @return Vector3 The custom light position
  76151. */
  76152. getCustomMeshPosition(): Vector3;
  76153. /**
  76154. * Disposes the internal assets and detaches the post-process from the camera
  76155. */
  76156. dispose(camera: Camera): void;
  76157. /**
  76158. * Returns the render target texture used by the post-process
  76159. * @return the render target texture used by the post-process
  76160. */
  76161. getPass(): RenderTargetTexture;
  76162. private _meshExcluded;
  76163. private _createPass;
  76164. private _updateMeshScreenCoordinates;
  76165. /**
  76166. * Creates a default mesh for the Volumeric Light Scattering post-process
  76167. * @param name The mesh name
  76168. * @param scene The scene where to create the mesh
  76169. * @return the default mesh
  76170. */
  76171. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76172. }
  76173. }
  76174. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76175. /** @hidden */
  76176. export var screenSpaceCurvaturePixelShader: {
  76177. name: string;
  76178. shader: string;
  76179. };
  76180. }
  76181. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76182. import { Nullable } from "babylonjs/types";
  76183. import { Camera } from "babylonjs/Cameras/camera";
  76184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76185. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76186. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76187. import { Engine } from "babylonjs/Engines/engine";
  76188. import { Scene } from "babylonjs/scene";
  76189. /**
  76190. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76191. */
  76192. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76193. /**
  76194. * Defines how much ridge the curvature effect displays.
  76195. */
  76196. ridge: number;
  76197. /**
  76198. * Defines how much valley the curvature effect displays.
  76199. */
  76200. valley: number;
  76201. private _geometryBufferRenderer;
  76202. /**
  76203. * Gets a string identifying the name of the class
  76204. * @returns "ScreenSpaceCurvaturePostProcess" string
  76205. */
  76206. getClassName(): string;
  76207. /**
  76208. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76209. * @param name The name of the effect.
  76210. * @param scene The scene containing the objects to blur according to their velocity.
  76211. * @param options The required width/height ratio to downsize to before computing the render pass.
  76212. * @param camera The camera to apply the render pass to.
  76213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76214. * @param engine The engine which the post process will be applied. (default: current engine)
  76215. * @param reusable If the post process can be reused on the same frame. (default: false)
  76216. * @param textureType Type of textures used when performing the post process. (default: 0)
  76217. * @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)
  76218. */
  76219. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76220. /**
  76221. * Support test.
  76222. */
  76223. static get IsSupported(): boolean;
  76224. /** @hidden */
  76225. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76226. }
  76227. }
  76228. declare module "babylonjs/PostProcesses/index" {
  76229. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76230. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76231. export * from "babylonjs/PostProcesses/bloomEffect";
  76232. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76233. export * from "babylonjs/PostProcesses/blurPostProcess";
  76234. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76235. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76236. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76237. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76238. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76239. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76240. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76241. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76242. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76243. export * from "babylonjs/PostProcesses/filterPostProcess";
  76244. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76245. export * from "babylonjs/PostProcesses/grainPostProcess";
  76246. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76247. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76248. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76249. export * from "babylonjs/PostProcesses/passPostProcess";
  76250. export * from "babylonjs/PostProcesses/postProcess";
  76251. export * from "babylonjs/PostProcesses/postProcessManager";
  76252. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76253. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76254. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76255. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76256. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76257. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76258. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76259. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76260. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76261. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76262. }
  76263. declare module "babylonjs/Probes/index" {
  76264. export * from "babylonjs/Probes/reflectionProbe";
  76265. }
  76266. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76267. import { Scene } from "babylonjs/scene";
  76268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76269. import { SmartArray } from "babylonjs/Misc/smartArray";
  76270. import { ISceneComponent } from "babylonjs/sceneComponent";
  76271. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76272. import "babylonjs/Meshes/Builders/boxBuilder";
  76273. import "babylonjs/Shaders/color.fragment";
  76274. import "babylonjs/Shaders/color.vertex";
  76275. import { Color3 } from "babylonjs/Maths/math.color";
  76276. import { Observable } from "babylonjs/Misc/observable";
  76277. module "babylonjs/scene" {
  76278. interface Scene {
  76279. /** @hidden (Backing field) */
  76280. _boundingBoxRenderer: BoundingBoxRenderer;
  76281. /** @hidden (Backing field) */
  76282. _forceShowBoundingBoxes: boolean;
  76283. /**
  76284. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76285. */
  76286. forceShowBoundingBoxes: boolean;
  76287. /**
  76288. * Gets the bounding box renderer associated with the scene
  76289. * @returns a BoundingBoxRenderer
  76290. */
  76291. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76292. }
  76293. }
  76294. module "babylonjs/Meshes/abstractMesh" {
  76295. interface AbstractMesh {
  76296. /** @hidden (Backing field) */
  76297. _showBoundingBox: boolean;
  76298. /**
  76299. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76300. */
  76301. showBoundingBox: boolean;
  76302. }
  76303. }
  76304. /**
  76305. * Component responsible of rendering the bounding box of the meshes in a scene.
  76306. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76307. */
  76308. export class BoundingBoxRenderer implements ISceneComponent {
  76309. /**
  76310. * The component name helpfull to identify the component in the list of scene components.
  76311. */
  76312. readonly name: string;
  76313. /**
  76314. * The scene the component belongs to.
  76315. */
  76316. scene: Scene;
  76317. /**
  76318. * Color of the bounding box lines placed in front of an object
  76319. */
  76320. frontColor: Color3;
  76321. /**
  76322. * Color of the bounding box lines placed behind an object
  76323. */
  76324. backColor: Color3;
  76325. /**
  76326. * Defines if the renderer should show the back lines or not
  76327. */
  76328. showBackLines: boolean;
  76329. /**
  76330. * Observable raised before rendering a bounding box
  76331. */
  76332. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76333. /**
  76334. * Observable raised after rendering a bounding box
  76335. */
  76336. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76337. /**
  76338. * @hidden
  76339. */
  76340. renderList: SmartArray<BoundingBox>;
  76341. private _colorShader;
  76342. private _vertexBuffers;
  76343. private _indexBuffer;
  76344. private _fillIndexBuffer;
  76345. private _fillIndexData;
  76346. /**
  76347. * Instantiates a new bounding box renderer in a scene.
  76348. * @param scene the scene the renderer renders in
  76349. */
  76350. constructor(scene: Scene);
  76351. /**
  76352. * Registers the component in a given scene
  76353. */
  76354. register(): void;
  76355. private _evaluateSubMesh;
  76356. private _activeMesh;
  76357. private _prepareRessources;
  76358. private _createIndexBuffer;
  76359. /**
  76360. * Rebuilds the elements related to this component in case of
  76361. * context lost for instance.
  76362. */
  76363. rebuild(): void;
  76364. /**
  76365. * @hidden
  76366. */
  76367. reset(): void;
  76368. /**
  76369. * Render the bounding boxes of a specific rendering group
  76370. * @param renderingGroupId defines the rendering group to render
  76371. */
  76372. render(renderingGroupId: number): void;
  76373. /**
  76374. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76375. * @param mesh Define the mesh to render the occlusion bounding box for
  76376. */
  76377. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76378. /**
  76379. * Dispose and release the resources attached to this renderer.
  76380. */
  76381. dispose(): void;
  76382. }
  76383. }
  76384. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76385. import { Nullable } from "babylonjs/types";
  76386. import { Scene } from "babylonjs/scene";
  76387. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76388. import { Camera } from "babylonjs/Cameras/camera";
  76389. import { ISceneComponent } from "babylonjs/sceneComponent";
  76390. module "babylonjs/scene" {
  76391. interface Scene {
  76392. /** @hidden (Backing field) */
  76393. _depthRenderer: {
  76394. [id: string]: DepthRenderer;
  76395. };
  76396. /**
  76397. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76398. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76399. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76400. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76401. * @returns the created depth renderer
  76402. */
  76403. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76404. /**
  76405. * Disables a depth renderer for a given camera
  76406. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76407. */
  76408. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76409. }
  76410. }
  76411. /**
  76412. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76413. * in several rendering techniques.
  76414. */
  76415. export class DepthRendererSceneComponent implements ISceneComponent {
  76416. /**
  76417. * The component name helpfull to identify the component in the list of scene components.
  76418. */
  76419. readonly name: string;
  76420. /**
  76421. * The scene the component belongs to.
  76422. */
  76423. scene: Scene;
  76424. /**
  76425. * Creates a new instance of the component for the given scene
  76426. * @param scene Defines the scene to register the component in
  76427. */
  76428. constructor(scene: Scene);
  76429. /**
  76430. * Registers the component in a given scene
  76431. */
  76432. register(): void;
  76433. /**
  76434. * Rebuilds the elements related to this component in case of
  76435. * context lost for instance.
  76436. */
  76437. rebuild(): void;
  76438. /**
  76439. * Disposes the component and the associated ressources
  76440. */
  76441. dispose(): void;
  76442. private _gatherRenderTargets;
  76443. private _gatherActiveCameraRenderTargets;
  76444. }
  76445. }
  76446. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76447. import { Nullable } from "babylonjs/types";
  76448. import { Scene } from "babylonjs/scene";
  76449. import { ISceneComponent } from "babylonjs/sceneComponent";
  76450. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76451. module "babylonjs/abstractScene" {
  76452. interface AbstractScene {
  76453. /** @hidden (Backing field) */
  76454. _prePassRenderer: Nullable<PrePassRenderer>;
  76455. /**
  76456. * Gets or Sets the current prepass renderer associated to the scene.
  76457. */
  76458. prePassRenderer: Nullable<PrePassRenderer>;
  76459. /**
  76460. * Enables the prepass and associates it with the scene
  76461. * @returns the PrePassRenderer
  76462. */
  76463. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76464. /**
  76465. * Disables the prepass associated with the scene
  76466. */
  76467. disablePrePassRenderer(): void;
  76468. }
  76469. }
  76470. /**
  76471. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76472. * in several rendering techniques.
  76473. */
  76474. export class PrePassRendererSceneComponent implements ISceneComponent {
  76475. /**
  76476. * The component name helpful to identify the component in the list of scene components.
  76477. */
  76478. readonly name: string;
  76479. /**
  76480. * The scene the component belongs to.
  76481. */
  76482. scene: Scene;
  76483. /**
  76484. * Creates a new instance of the component for the given scene
  76485. * @param scene Defines the scene to register the component in
  76486. */
  76487. constructor(scene: Scene);
  76488. /**
  76489. * Registers the component in a given scene
  76490. */
  76491. register(): void;
  76492. private _beforeCameraDraw;
  76493. private _afterCameraDraw;
  76494. private _beforeClearStage;
  76495. /**
  76496. * Rebuilds the elements related to this component in case of
  76497. * context lost for instance.
  76498. */
  76499. rebuild(): void;
  76500. /**
  76501. * Disposes the component and the associated ressources
  76502. */
  76503. dispose(): void;
  76504. }
  76505. }
  76506. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76507. /** @hidden */
  76508. export var fibonacci: {
  76509. name: string;
  76510. shader: string;
  76511. };
  76512. }
  76513. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76514. /** @hidden */
  76515. export var diffusionProfile: {
  76516. name: string;
  76517. shader: string;
  76518. };
  76519. }
  76520. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76521. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76523. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76524. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76525. /** @hidden */
  76526. export var subSurfaceScatteringPixelShader: {
  76527. name: string;
  76528. shader: string;
  76529. };
  76530. }
  76531. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76532. import { Nullable } from "babylonjs/types";
  76533. import { Camera } from "babylonjs/Cameras/camera";
  76534. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76535. import { Engine } from "babylonjs/Engines/engine";
  76536. import { Scene } from "babylonjs/scene";
  76537. import "babylonjs/Shaders/imageProcessing.fragment";
  76538. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76539. import "babylonjs/Shaders/postprocess.vertex";
  76540. /**
  76541. * Sub surface scattering post process
  76542. */
  76543. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76544. /**
  76545. * Gets a string identifying the name of the class
  76546. * @returns "SubSurfaceScatteringPostProcess" string
  76547. */
  76548. getClassName(): string;
  76549. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76550. }
  76551. }
  76552. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76553. import { Scene } from "babylonjs/scene";
  76554. import { Color3 } from "babylonjs/Maths/math.color";
  76555. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76556. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76557. /**
  76558. * Contains all parameters needed for the prepass to perform
  76559. * screen space subsurface scattering
  76560. */
  76561. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76562. /** @hidden */
  76563. static _SceneComponentInitialization: (scene: Scene) => void;
  76564. private _ssDiffusionS;
  76565. private _ssFilterRadii;
  76566. private _ssDiffusionD;
  76567. /**
  76568. * Post process to attach for screen space subsurface scattering
  76569. */
  76570. postProcess: SubSurfaceScatteringPostProcess;
  76571. /**
  76572. * Diffusion profile color for subsurface scattering
  76573. */
  76574. get ssDiffusionS(): number[];
  76575. /**
  76576. * Diffusion profile max color channel value for subsurface scattering
  76577. */
  76578. get ssDiffusionD(): number[];
  76579. /**
  76580. * Diffusion profile filter radius for subsurface scattering
  76581. */
  76582. get ssFilterRadii(): number[];
  76583. /**
  76584. * Is subsurface enabled
  76585. */
  76586. enabled: boolean;
  76587. /**
  76588. * Name of the configuration
  76589. */
  76590. name: string;
  76591. /**
  76592. * Diffusion profile colors for subsurface scattering
  76593. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76594. * See ...
  76595. * Note that you can only store up to 5 of them
  76596. */
  76597. ssDiffusionProfileColors: Color3[];
  76598. /**
  76599. * Defines the ratio real world => scene units.
  76600. * Used for subsurface scattering
  76601. */
  76602. metersPerUnit: number;
  76603. /**
  76604. * Textures that should be present in the MRT for this effect to work
  76605. */
  76606. readonly texturesRequired: number[];
  76607. private _scene;
  76608. /**
  76609. * Builds a subsurface configuration object
  76610. * @param scene The scene
  76611. */
  76612. constructor(scene: Scene);
  76613. /**
  76614. * Adds a new diffusion profile.
  76615. * Useful for more realistic subsurface scattering on diverse materials.
  76616. * @param color The color of the diffusion profile. Should be the average color of the material.
  76617. * @return The index of the diffusion profile for the material subsurface configuration
  76618. */
  76619. addDiffusionProfile(color: Color3): number;
  76620. /**
  76621. * Creates the sss post process
  76622. * @return The created post process
  76623. */
  76624. createPostProcess(): SubSurfaceScatteringPostProcess;
  76625. /**
  76626. * Deletes all diffusion profiles.
  76627. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76628. */
  76629. clearAllDiffusionProfiles(): void;
  76630. /**
  76631. * Disposes this object
  76632. */
  76633. dispose(): void;
  76634. /**
  76635. * @hidden
  76636. * https://zero-radiance.github.io/post/sampling-diffusion/
  76637. *
  76638. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76639. * ------------------------------------------------------------------------------------
  76640. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76641. * PDF[r, phi, s] = r * R[r, phi, s]
  76642. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76643. * ------------------------------------------------------------------------------------
  76644. * We importance sample the color channel with the widest scattering distance.
  76645. */
  76646. getDiffusionProfileParameters(color: Color3): number;
  76647. /**
  76648. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76649. * 'u' is the random number (the value of the CDF): [0, 1).
  76650. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76651. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76652. */
  76653. private _sampleBurleyDiffusionProfile;
  76654. }
  76655. }
  76656. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76657. import { Nullable } from "babylonjs/types";
  76658. import { Scene } from "babylonjs/scene";
  76659. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76660. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76661. import { AbstractScene } from "babylonjs/abstractScene";
  76662. module "babylonjs/abstractScene" {
  76663. interface AbstractScene {
  76664. /** @hidden (Backing field) */
  76665. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76666. /**
  76667. * Gets or Sets the current prepass renderer associated to the scene.
  76668. */
  76669. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76670. /**
  76671. * Enables the subsurface effect for prepass
  76672. * @returns the SubSurfaceConfiguration
  76673. */
  76674. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76675. /**
  76676. * Disables the subsurface effect for prepass
  76677. */
  76678. disableSubSurfaceForPrePass(): void;
  76679. }
  76680. }
  76681. /**
  76682. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76683. * in several rendering techniques.
  76684. */
  76685. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76686. /**
  76687. * The component name helpful to identify the component in the list of scene components.
  76688. */
  76689. readonly name: string;
  76690. /**
  76691. * The scene the component belongs to.
  76692. */
  76693. scene: Scene;
  76694. /**
  76695. * Creates a new instance of the component for the given scene
  76696. * @param scene Defines the scene to register the component in
  76697. */
  76698. constructor(scene: Scene);
  76699. /**
  76700. * Registers the component in a given scene
  76701. */
  76702. register(): void;
  76703. /**
  76704. * Serializes the component data to the specified json object
  76705. * @param serializationObject The object to serialize to
  76706. */
  76707. serialize(serializationObject: any): void;
  76708. /**
  76709. * Adds all the elements from the container to the scene
  76710. * @param container the container holding the elements
  76711. */
  76712. addFromContainer(container: AbstractScene): void;
  76713. /**
  76714. * Removes all the elements in the container from the scene
  76715. * @param container contains the elements to remove
  76716. * @param dispose if the removed element should be disposed (default: false)
  76717. */
  76718. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76719. /**
  76720. * Rebuilds the elements related to this component in case of
  76721. * context lost for instance.
  76722. */
  76723. rebuild(): void;
  76724. /**
  76725. * Disposes the component and the associated ressources
  76726. */
  76727. dispose(): void;
  76728. }
  76729. }
  76730. declare module "babylonjs/Shaders/outline.fragment" {
  76731. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76732. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76733. /** @hidden */
  76734. export var outlinePixelShader: {
  76735. name: string;
  76736. shader: string;
  76737. };
  76738. }
  76739. declare module "babylonjs/Shaders/outline.vertex" {
  76740. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76743. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76744. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76745. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76746. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76747. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76748. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76749. /** @hidden */
  76750. export var outlineVertexShader: {
  76751. name: string;
  76752. shader: string;
  76753. };
  76754. }
  76755. declare module "babylonjs/Rendering/outlineRenderer" {
  76756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76757. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76758. import { Scene } from "babylonjs/scene";
  76759. import { ISceneComponent } from "babylonjs/sceneComponent";
  76760. import "babylonjs/Shaders/outline.fragment";
  76761. import "babylonjs/Shaders/outline.vertex";
  76762. module "babylonjs/scene" {
  76763. interface Scene {
  76764. /** @hidden */
  76765. _outlineRenderer: OutlineRenderer;
  76766. /**
  76767. * Gets the outline renderer associated with the scene
  76768. * @returns a OutlineRenderer
  76769. */
  76770. getOutlineRenderer(): OutlineRenderer;
  76771. }
  76772. }
  76773. module "babylonjs/Meshes/abstractMesh" {
  76774. interface AbstractMesh {
  76775. /** @hidden (Backing field) */
  76776. _renderOutline: boolean;
  76777. /**
  76778. * Gets or sets a boolean indicating if the outline must be rendered as well
  76779. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76780. */
  76781. renderOutline: boolean;
  76782. /** @hidden (Backing field) */
  76783. _renderOverlay: boolean;
  76784. /**
  76785. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76786. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76787. */
  76788. renderOverlay: boolean;
  76789. }
  76790. }
  76791. /**
  76792. * This class is responsible to draw bothe outline/overlay of meshes.
  76793. * It should not be used directly but through the available method on mesh.
  76794. */
  76795. export class OutlineRenderer implements ISceneComponent {
  76796. /**
  76797. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76798. */
  76799. private static _StencilReference;
  76800. /**
  76801. * The name of the component. Each component must have a unique name.
  76802. */
  76803. name: string;
  76804. /**
  76805. * The scene the component belongs to.
  76806. */
  76807. scene: Scene;
  76808. /**
  76809. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76810. */
  76811. zOffset: number;
  76812. private _engine;
  76813. private _effect;
  76814. private _cachedDefines;
  76815. private _savedDepthWrite;
  76816. /**
  76817. * Instantiates a new outline renderer. (There could be only one per scene).
  76818. * @param scene Defines the scene it belongs to
  76819. */
  76820. constructor(scene: Scene);
  76821. /**
  76822. * Register the component to one instance of a scene.
  76823. */
  76824. register(): void;
  76825. /**
  76826. * Rebuilds the elements related to this component in case of
  76827. * context lost for instance.
  76828. */
  76829. rebuild(): void;
  76830. /**
  76831. * Disposes the component and the associated ressources.
  76832. */
  76833. dispose(): void;
  76834. /**
  76835. * Renders the outline in the canvas.
  76836. * @param subMesh Defines the sumesh to render
  76837. * @param batch Defines the batch of meshes in case of instances
  76838. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76839. */
  76840. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76841. /**
  76842. * Returns whether or not the outline renderer is ready for a given submesh.
  76843. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76844. * @param subMesh Defines the submesh to check readyness for
  76845. * @param useInstances Defines wheter wee are trying to render instances or not
  76846. * @returns true if ready otherwise false
  76847. */
  76848. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76849. private _beforeRenderingMesh;
  76850. private _afterRenderingMesh;
  76851. }
  76852. }
  76853. declare module "babylonjs/Rendering/index" {
  76854. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76855. export * from "babylonjs/Rendering/depthRenderer";
  76856. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76857. export * from "babylonjs/Rendering/edgesRenderer";
  76858. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76859. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76860. export * from "babylonjs/Rendering/prePassRenderer";
  76861. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76862. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76863. export * from "babylonjs/Rendering/outlineRenderer";
  76864. export * from "babylonjs/Rendering/renderingGroup";
  76865. export * from "babylonjs/Rendering/renderingManager";
  76866. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76867. }
  76868. declare module "babylonjs/Sprites/ISprites" {
  76869. /**
  76870. * Defines the basic options interface of a Sprite Frame Source Size.
  76871. */
  76872. export interface ISpriteJSONSpriteSourceSize {
  76873. /**
  76874. * number of the original width of the Frame
  76875. */
  76876. w: number;
  76877. /**
  76878. * number of the original height of the Frame
  76879. */
  76880. h: number;
  76881. }
  76882. /**
  76883. * Defines the basic options interface of a Sprite Frame Data.
  76884. */
  76885. export interface ISpriteJSONSpriteFrameData {
  76886. /**
  76887. * number of the x offset of the Frame
  76888. */
  76889. x: number;
  76890. /**
  76891. * number of the y offset of the Frame
  76892. */
  76893. y: number;
  76894. /**
  76895. * number of the width of the Frame
  76896. */
  76897. w: number;
  76898. /**
  76899. * number of the height of the Frame
  76900. */
  76901. h: number;
  76902. }
  76903. /**
  76904. * Defines the basic options interface of a JSON Sprite.
  76905. */
  76906. export interface ISpriteJSONSprite {
  76907. /**
  76908. * string name of the Frame
  76909. */
  76910. filename: string;
  76911. /**
  76912. * ISpriteJSONSpriteFrame basic object of the frame data
  76913. */
  76914. frame: ISpriteJSONSpriteFrameData;
  76915. /**
  76916. * boolean to flag is the frame was rotated.
  76917. */
  76918. rotated: boolean;
  76919. /**
  76920. * boolean to flag is the frame was trimmed.
  76921. */
  76922. trimmed: boolean;
  76923. /**
  76924. * ISpriteJSONSpriteFrame basic object of the source data
  76925. */
  76926. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76927. /**
  76928. * ISpriteJSONSpriteFrame basic object of the source data
  76929. */
  76930. sourceSize: ISpriteJSONSpriteSourceSize;
  76931. }
  76932. /**
  76933. * Defines the basic options interface of a JSON atlas.
  76934. */
  76935. export interface ISpriteJSONAtlas {
  76936. /**
  76937. * Array of objects that contain the frame data.
  76938. */
  76939. frames: Array<ISpriteJSONSprite>;
  76940. /**
  76941. * object basic object containing the sprite meta data.
  76942. */
  76943. meta?: object;
  76944. }
  76945. }
  76946. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76947. /** @hidden */
  76948. export var spriteMapPixelShader: {
  76949. name: string;
  76950. shader: string;
  76951. };
  76952. }
  76953. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76954. /** @hidden */
  76955. export var spriteMapVertexShader: {
  76956. name: string;
  76957. shader: string;
  76958. };
  76959. }
  76960. declare module "babylonjs/Sprites/spriteMap" {
  76961. import { IDisposable, Scene } from "babylonjs/scene";
  76962. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76963. import { Texture } from "babylonjs/Materials/Textures/texture";
  76964. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76965. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76966. import "babylonjs/Meshes/Builders/planeBuilder";
  76967. import "babylonjs/Shaders/spriteMap.fragment";
  76968. import "babylonjs/Shaders/spriteMap.vertex";
  76969. /**
  76970. * Defines the basic options interface of a SpriteMap
  76971. */
  76972. export interface ISpriteMapOptions {
  76973. /**
  76974. * Vector2 of the number of cells in the grid.
  76975. */
  76976. stageSize?: Vector2;
  76977. /**
  76978. * Vector2 of the size of the output plane in World Units.
  76979. */
  76980. outputSize?: Vector2;
  76981. /**
  76982. * Vector3 of the position of the output plane in World Units.
  76983. */
  76984. outputPosition?: Vector3;
  76985. /**
  76986. * Vector3 of the rotation of the output plane.
  76987. */
  76988. outputRotation?: Vector3;
  76989. /**
  76990. * number of layers that the system will reserve in resources.
  76991. */
  76992. layerCount?: number;
  76993. /**
  76994. * number of max animation frames a single cell will reserve in resources.
  76995. */
  76996. maxAnimationFrames?: number;
  76997. /**
  76998. * number cell index of the base tile when the system compiles.
  76999. */
  77000. baseTile?: number;
  77001. /**
  77002. * boolean flip the sprite after its been repositioned by the framing data.
  77003. */
  77004. flipU?: boolean;
  77005. /**
  77006. * Vector3 scalar of the global RGB values of the SpriteMap.
  77007. */
  77008. colorMultiply?: Vector3;
  77009. }
  77010. /**
  77011. * Defines the IDisposable interface in order to be cleanable from resources.
  77012. */
  77013. export interface ISpriteMap extends IDisposable {
  77014. /**
  77015. * String name of the SpriteMap.
  77016. */
  77017. name: string;
  77018. /**
  77019. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77020. */
  77021. atlasJSON: ISpriteJSONAtlas;
  77022. /**
  77023. * Texture of the SpriteMap.
  77024. */
  77025. spriteSheet: Texture;
  77026. /**
  77027. * The parameters to initialize the SpriteMap with.
  77028. */
  77029. options: ISpriteMapOptions;
  77030. }
  77031. /**
  77032. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77033. */
  77034. export class SpriteMap implements ISpriteMap {
  77035. /** The Name of the spriteMap */
  77036. name: string;
  77037. /** The JSON file with the frame and meta data */
  77038. atlasJSON: ISpriteJSONAtlas;
  77039. /** The systems Sprite Sheet Texture */
  77040. spriteSheet: Texture;
  77041. /** Arguments passed with the Constructor */
  77042. options: ISpriteMapOptions;
  77043. /** Public Sprite Storage array, parsed from atlasJSON */
  77044. sprites: Array<ISpriteJSONSprite>;
  77045. /** Returns the Number of Sprites in the System */
  77046. get spriteCount(): number;
  77047. /** Returns the Position of Output Plane*/
  77048. get position(): Vector3;
  77049. /** Returns the Position of Output Plane*/
  77050. set position(v: Vector3);
  77051. /** Returns the Rotation of Output Plane*/
  77052. get rotation(): Vector3;
  77053. /** Returns the Rotation of Output Plane*/
  77054. set rotation(v: Vector3);
  77055. /** Sets the AnimationMap*/
  77056. get animationMap(): RawTexture;
  77057. /** Sets the AnimationMap*/
  77058. set animationMap(v: RawTexture);
  77059. /** Scene that the SpriteMap was created in */
  77060. private _scene;
  77061. /** Texture Buffer of Float32 that holds tile frame data*/
  77062. private _frameMap;
  77063. /** Texture Buffers of Float32 that holds tileMap data*/
  77064. private _tileMaps;
  77065. /** Texture Buffer of Float32 that holds Animation Data*/
  77066. private _animationMap;
  77067. /** Custom ShaderMaterial Central to the System*/
  77068. private _material;
  77069. /** Custom ShaderMaterial Central to the System*/
  77070. private _output;
  77071. /** Systems Time Ticker*/
  77072. private _time;
  77073. /**
  77074. * Creates a new SpriteMap
  77075. * @param name defines the SpriteMaps Name
  77076. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77077. * @param spriteSheet is the Texture that the Sprites are on.
  77078. * @param options a basic deployment configuration
  77079. * @param scene The Scene that the map is deployed on
  77080. */
  77081. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77082. /**
  77083. * Returns tileID location
  77084. * @returns Vector2 the cell position ID
  77085. */
  77086. getTileID(): Vector2;
  77087. /**
  77088. * Gets the UV location of the mouse over the SpriteMap.
  77089. * @returns Vector2 the UV position of the mouse interaction
  77090. */
  77091. getMousePosition(): Vector2;
  77092. /**
  77093. * Creates the "frame" texture Buffer
  77094. * -------------------------------------
  77095. * Structure of frames
  77096. * "filename": "Falling-Water-2.png",
  77097. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77098. * "rotated": true,
  77099. * "trimmed": true,
  77100. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77101. * "sourceSize": {"w":32,"h":32}
  77102. * @returns RawTexture of the frameMap
  77103. */
  77104. private _createFrameBuffer;
  77105. /**
  77106. * Creates the tileMap texture Buffer
  77107. * @param buffer normally and array of numbers, or a false to generate from scratch
  77108. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77109. * @returns RawTexture of the tileMap
  77110. */
  77111. private _createTileBuffer;
  77112. /**
  77113. * Modifies the data of the tileMaps
  77114. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77115. * @param pos is the iVector2 Coordinates of the Tile
  77116. * @param tile The SpriteIndex of the new Tile
  77117. */
  77118. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77119. /**
  77120. * Creates the animationMap texture Buffer
  77121. * @param buffer normally and array of numbers, or a false to generate from scratch
  77122. * @returns RawTexture of the animationMap
  77123. */
  77124. private _createTileAnimationBuffer;
  77125. /**
  77126. * Modifies the data of the animationMap
  77127. * @param cellID is the Index of the Sprite
  77128. * @param _frame is the target Animation frame
  77129. * @param toCell is the Target Index of the next frame of the animation
  77130. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77131. * @param speed is a global scalar of the time variable on the map.
  77132. */
  77133. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77134. /**
  77135. * Exports the .tilemaps file
  77136. */
  77137. saveTileMaps(): void;
  77138. /**
  77139. * Imports the .tilemaps file
  77140. * @param url of the .tilemaps file
  77141. */
  77142. loadTileMaps(url: string): void;
  77143. /**
  77144. * Release associated resources
  77145. */
  77146. dispose(): void;
  77147. }
  77148. }
  77149. declare module "babylonjs/Sprites/spritePackedManager" {
  77150. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77151. import { Scene } from "babylonjs/scene";
  77152. /**
  77153. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77154. * @see https://doc.babylonjs.com/babylon101/sprites
  77155. */
  77156. export class SpritePackedManager extends SpriteManager {
  77157. /** defines the packed manager's name */
  77158. name: string;
  77159. /**
  77160. * Creates a new sprite manager from a packed sprite sheet
  77161. * @param name defines the manager's name
  77162. * @param imgUrl defines the sprite sheet url
  77163. * @param capacity defines the maximum allowed number of sprites
  77164. * @param scene defines the hosting scene
  77165. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77166. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77167. * @param samplingMode defines the smapling mode to use with spritesheet
  77168. * @param fromPacked set to true; do not alter
  77169. */
  77170. constructor(
  77171. /** defines the packed manager's name */
  77172. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77173. }
  77174. }
  77175. declare module "babylonjs/Sprites/index" {
  77176. export * from "babylonjs/Sprites/sprite";
  77177. export * from "babylonjs/Sprites/ISprites";
  77178. export * from "babylonjs/Sprites/spriteManager";
  77179. export * from "babylonjs/Sprites/spriteMap";
  77180. export * from "babylonjs/Sprites/spritePackedManager";
  77181. export * from "babylonjs/Sprites/spriteSceneComponent";
  77182. }
  77183. declare module "babylonjs/States/index" {
  77184. export * from "babylonjs/States/alphaCullingState";
  77185. export * from "babylonjs/States/depthCullingState";
  77186. export * from "babylonjs/States/stencilState";
  77187. }
  77188. declare module "babylonjs/Misc/assetsManager" {
  77189. import { Scene } from "babylonjs/scene";
  77190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77191. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77192. import { Skeleton } from "babylonjs/Bones/skeleton";
  77193. import { Observable } from "babylonjs/Misc/observable";
  77194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77195. import { Texture } from "babylonjs/Materials/Textures/texture";
  77196. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77197. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77198. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77199. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77200. import { AssetContainer } from "babylonjs/assetContainer";
  77201. /**
  77202. * Defines the list of states available for a task inside a AssetsManager
  77203. */
  77204. export enum AssetTaskState {
  77205. /**
  77206. * Initialization
  77207. */
  77208. INIT = 0,
  77209. /**
  77210. * Running
  77211. */
  77212. RUNNING = 1,
  77213. /**
  77214. * Done
  77215. */
  77216. DONE = 2,
  77217. /**
  77218. * Error
  77219. */
  77220. ERROR = 3
  77221. }
  77222. /**
  77223. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77224. */
  77225. export abstract class AbstractAssetTask {
  77226. /**
  77227. * Task name
  77228. */ name: string;
  77229. /**
  77230. * Callback called when the task is successful
  77231. */
  77232. onSuccess: (task: any) => void;
  77233. /**
  77234. * Callback called when the task is not successful
  77235. */
  77236. onError: (task: any, message?: string, exception?: any) => void;
  77237. /**
  77238. * Creates a new AssetsManager
  77239. * @param name defines the name of the task
  77240. */
  77241. constructor(
  77242. /**
  77243. * Task name
  77244. */ name: string);
  77245. private _isCompleted;
  77246. private _taskState;
  77247. private _errorObject;
  77248. /**
  77249. * Get if the task is completed
  77250. */
  77251. get isCompleted(): boolean;
  77252. /**
  77253. * Gets the current state of the task
  77254. */
  77255. get taskState(): AssetTaskState;
  77256. /**
  77257. * Gets the current error object (if task is in error)
  77258. */
  77259. get errorObject(): {
  77260. message?: string;
  77261. exception?: any;
  77262. };
  77263. /**
  77264. * Internal only
  77265. * @hidden
  77266. */
  77267. _setErrorObject(message?: string, exception?: any): void;
  77268. /**
  77269. * Execute the current task
  77270. * @param scene defines the scene where you want your assets to be loaded
  77271. * @param onSuccess is a callback called when the task is successfully executed
  77272. * @param onError is a callback called if an error occurs
  77273. */
  77274. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77275. /**
  77276. * Execute the current task
  77277. * @param scene defines the scene where you want your assets to be loaded
  77278. * @param onSuccess is a callback called when the task is successfully executed
  77279. * @param onError is a callback called if an error occurs
  77280. */
  77281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77282. /**
  77283. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77284. * This can be used with failed tasks that have the reason for failure fixed.
  77285. */
  77286. reset(): void;
  77287. private onErrorCallback;
  77288. private onDoneCallback;
  77289. }
  77290. /**
  77291. * Define the interface used by progress events raised during assets loading
  77292. */
  77293. export interface IAssetsProgressEvent {
  77294. /**
  77295. * Defines the number of remaining tasks to process
  77296. */
  77297. remainingCount: number;
  77298. /**
  77299. * Defines the total number of tasks
  77300. */
  77301. totalCount: number;
  77302. /**
  77303. * Defines the task that was just processed
  77304. */
  77305. task: AbstractAssetTask;
  77306. }
  77307. /**
  77308. * Class used to share progress information about assets loading
  77309. */
  77310. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77311. /**
  77312. * Defines the number of remaining tasks to process
  77313. */
  77314. remainingCount: number;
  77315. /**
  77316. * Defines the total number of tasks
  77317. */
  77318. totalCount: number;
  77319. /**
  77320. * Defines the task that was just processed
  77321. */
  77322. task: AbstractAssetTask;
  77323. /**
  77324. * Creates a AssetsProgressEvent
  77325. * @param remainingCount defines the number of remaining tasks to process
  77326. * @param totalCount defines the total number of tasks
  77327. * @param task defines the task that was just processed
  77328. */
  77329. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77330. }
  77331. /**
  77332. * Define a task used by AssetsManager to load assets into a container
  77333. */
  77334. export class ContainerAssetTask extends AbstractAssetTask {
  77335. /**
  77336. * Defines the name of the task
  77337. */
  77338. name: string;
  77339. /**
  77340. * Defines the list of mesh's names you want to load
  77341. */
  77342. meshesNames: any;
  77343. /**
  77344. * Defines the root url to use as a base to load your meshes and associated resources
  77345. */
  77346. rootUrl: string;
  77347. /**
  77348. * Defines the filename or File of the scene to load from
  77349. */
  77350. sceneFilename: string | File;
  77351. /**
  77352. * Get the loaded asset container
  77353. */
  77354. loadedContainer: AssetContainer;
  77355. /**
  77356. * Gets the list of loaded meshes
  77357. */
  77358. loadedMeshes: Array<AbstractMesh>;
  77359. /**
  77360. * Gets the list of loaded particle systems
  77361. */
  77362. loadedParticleSystems: Array<IParticleSystem>;
  77363. /**
  77364. * Gets the list of loaded skeletons
  77365. */
  77366. loadedSkeletons: Array<Skeleton>;
  77367. /**
  77368. * Gets the list of loaded animation groups
  77369. */
  77370. loadedAnimationGroups: Array<AnimationGroup>;
  77371. /**
  77372. * Callback called when the task is successful
  77373. */
  77374. onSuccess: (task: ContainerAssetTask) => void;
  77375. /**
  77376. * Callback called when the task is successful
  77377. */
  77378. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77379. /**
  77380. * Creates a new ContainerAssetTask
  77381. * @param name defines the name of the task
  77382. * @param meshesNames defines the list of mesh's names you want to load
  77383. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77384. * @param sceneFilename defines the filename or File of the scene to load from
  77385. */
  77386. constructor(
  77387. /**
  77388. * Defines the name of the task
  77389. */
  77390. name: string,
  77391. /**
  77392. * Defines the list of mesh's names you want to load
  77393. */
  77394. meshesNames: any,
  77395. /**
  77396. * Defines the root url to use as a base to load your meshes and associated resources
  77397. */
  77398. rootUrl: string,
  77399. /**
  77400. * Defines the filename or File of the scene to load from
  77401. */
  77402. sceneFilename: string | File);
  77403. /**
  77404. * Execute the current task
  77405. * @param scene defines the scene where you want your assets to be loaded
  77406. * @param onSuccess is a callback called when the task is successfully executed
  77407. * @param onError is a callback called if an error occurs
  77408. */
  77409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77410. }
  77411. /**
  77412. * Define a task used by AssetsManager to load meshes
  77413. */
  77414. export class MeshAssetTask extends AbstractAssetTask {
  77415. /**
  77416. * Defines the name of the task
  77417. */
  77418. name: string;
  77419. /**
  77420. * Defines the list of mesh's names you want to load
  77421. */
  77422. meshesNames: any;
  77423. /**
  77424. * Defines the root url to use as a base to load your meshes and associated resources
  77425. */
  77426. rootUrl: string;
  77427. /**
  77428. * Defines the filename or File of the scene to load from
  77429. */
  77430. sceneFilename: string | File;
  77431. /**
  77432. * Gets the list of loaded meshes
  77433. */
  77434. loadedMeshes: Array<AbstractMesh>;
  77435. /**
  77436. * Gets the list of loaded particle systems
  77437. */
  77438. loadedParticleSystems: Array<IParticleSystem>;
  77439. /**
  77440. * Gets the list of loaded skeletons
  77441. */
  77442. loadedSkeletons: Array<Skeleton>;
  77443. /**
  77444. * Gets the list of loaded animation groups
  77445. */
  77446. loadedAnimationGroups: Array<AnimationGroup>;
  77447. /**
  77448. * Callback called when the task is successful
  77449. */
  77450. onSuccess: (task: MeshAssetTask) => void;
  77451. /**
  77452. * Callback called when the task is successful
  77453. */
  77454. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77455. /**
  77456. * Creates a new MeshAssetTask
  77457. * @param name defines the name of the task
  77458. * @param meshesNames defines the list of mesh's names you want to load
  77459. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77460. * @param sceneFilename defines the filename or File of the scene to load from
  77461. */
  77462. constructor(
  77463. /**
  77464. * Defines the name of the task
  77465. */
  77466. name: string,
  77467. /**
  77468. * Defines the list of mesh's names you want to load
  77469. */
  77470. meshesNames: any,
  77471. /**
  77472. * Defines the root url to use as a base to load your meshes and associated resources
  77473. */
  77474. rootUrl: string,
  77475. /**
  77476. * Defines the filename or File of the scene to load from
  77477. */
  77478. sceneFilename: string | File);
  77479. /**
  77480. * Execute the current task
  77481. * @param scene defines the scene where you want your assets to be loaded
  77482. * @param onSuccess is a callback called when the task is successfully executed
  77483. * @param onError is a callback called if an error occurs
  77484. */
  77485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77486. }
  77487. /**
  77488. * Define a task used by AssetsManager to load text content
  77489. */
  77490. export class TextFileAssetTask extends AbstractAssetTask {
  77491. /**
  77492. * Defines the name of the task
  77493. */
  77494. name: string;
  77495. /**
  77496. * Defines the location of the file to load
  77497. */
  77498. url: string;
  77499. /**
  77500. * Gets the loaded text string
  77501. */
  77502. text: string;
  77503. /**
  77504. * Callback called when the task is successful
  77505. */
  77506. onSuccess: (task: TextFileAssetTask) => void;
  77507. /**
  77508. * Callback called when the task is successful
  77509. */
  77510. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77511. /**
  77512. * Creates a new TextFileAssetTask object
  77513. * @param name defines the name of the task
  77514. * @param url defines the location of the file to load
  77515. */
  77516. constructor(
  77517. /**
  77518. * Defines the name of the task
  77519. */
  77520. name: string,
  77521. /**
  77522. * Defines the location of the file to load
  77523. */
  77524. url: string);
  77525. /**
  77526. * Execute the current task
  77527. * @param scene defines the scene where you want your assets to be loaded
  77528. * @param onSuccess is a callback called when the task is successfully executed
  77529. * @param onError is a callback called if an error occurs
  77530. */
  77531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77532. }
  77533. /**
  77534. * Define a task used by AssetsManager to load binary data
  77535. */
  77536. export class BinaryFileAssetTask extends AbstractAssetTask {
  77537. /**
  77538. * Defines the name of the task
  77539. */
  77540. name: string;
  77541. /**
  77542. * Defines the location of the file to load
  77543. */
  77544. url: string;
  77545. /**
  77546. * Gets the lodaded data (as an array buffer)
  77547. */
  77548. data: ArrayBuffer;
  77549. /**
  77550. * Callback called when the task is successful
  77551. */
  77552. onSuccess: (task: BinaryFileAssetTask) => void;
  77553. /**
  77554. * Callback called when the task is successful
  77555. */
  77556. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77557. /**
  77558. * Creates a new BinaryFileAssetTask object
  77559. * @param name defines the name of the new task
  77560. * @param url defines the location of the file to load
  77561. */
  77562. constructor(
  77563. /**
  77564. * Defines the name of the task
  77565. */
  77566. name: string,
  77567. /**
  77568. * Defines the location of the file to load
  77569. */
  77570. url: string);
  77571. /**
  77572. * Execute the current task
  77573. * @param scene defines the scene where you want your assets to be loaded
  77574. * @param onSuccess is a callback called when the task is successfully executed
  77575. * @param onError is a callback called if an error occurs
  77576. */
  77577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77578. }
  77579. /**
  77580. * Define a task used by AssetsManager to load images
  77581. */
  77582. export class ImageAssetTask extends AbstractAssetTask {
  77583. /**
  77584. * Defines the name of the task
  77585. */
  77586. name: string;
  77587. /**
  77588. * Defines the location of the image to load
  77589. */
  77590. url: string;
  77591. /**
  77592. * Gets the loaded images
  77593. */
  77594. image: HTMLImageElement;
  77595. /**
  77596. * Callback called when the task is successful
  77597. */
  77598. onSuccess: (task: ImageAssetTask) => void;
  77599. /**
  77600. * Callback called when the task is successful
  77601. */
  77602. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77603. /**
  77604. * Creates a new ImageAssetTask
  77605. * @param name defines the name of the task
  77606. * @param url defines the location of the image to load
  77607. */
  77608. constructor(
  77609. /**
  77610. * Defines the name of the task
  77611. */
  77612. name: string,
  77613. /**
  77614. * Defines the location of the image to load
  77615. */
  77616. url: string);
  77617. /**
  77618. * Execute the current task
  77619. * @param scene defines the scene where you want your assets to be loaded
  77620. * @param onSuccess is a callback called when the task is successfully executed
  77621. * @param onError is a callback called if an error occurs
  77622. */
  77623. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77624. }
  77625. /**
  77626. * Defines the interface used by texture loading tasks
  77627. */
  77628. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77629. /**
  77630. * Gets the loaded texture
  77631. */
  77632. texture: TEX;
  77633. }
  77634. /**
  77635. * Define a task used by AssetsManager to load 2D textures
  77636. */
  77637. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77638. /**
  77639. * Defines the name of the task
  77640. */
  77641. name: string;
  77642. /**
  77643. * Defines the location of the file to load
  77644. */
  77645. url: string;
  77646. /**
  77647. * Defines if mipmap should not be generated (default is false)
  77648. */
  77649. noMipmap?: boolean | undefined;
  77650. /**
  77651. * Defines if texture must be inverted on Y axis (default is true)
  77652. */
  77653. invertY: boolean;
  77654. /**
  77655. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77656. */
  77657. samplingMode: number;
  77658. /**
  77659. * Gets the loaded texture
  77660. */
  77661. texture: Texture;
  77662. /**
  77663. * Callback called when the task is successful
  77664. */
  77665. onSuccess: (task: TextureAssetTask) => void;
  77666. /**
  77667. * Callback called when the task is successful
  77668. */
  77669. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77670. /**
  77671. * Creates a new TextureAssetTask object
  77672. * @param name defines the name of the task
  77673. * @param url defines the location of the file to load
  77674. * @param noMipmap defines if mipmap should not be generated (default is false)
  77675. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77676. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77677. */
  77678. constructor(
  77679. /**
  77680. * Defines the name of the task
  77681. */
  77682. name: string,
  77683. /**
  77684. * Defines the location of the file to load
  77685. */
  77686. url: string,
  77687. /**
  77688. * Defines if mipmap should not be generated (default is false)
  77689. */
  77690. noMipmap?: boolean | undefined,
  77691. /**
  77692. * Defines if texture must be inverted on Y axis (default is true)
  77693. */
  77694. invertY?: boolean,
  77695. /**
  77696. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77697. */
  77698. samplingMode?: number);
  77699. /**
  77700. * Execute the current task
  77701. * @param scene defines the scene where you want your assets to be loaded
  77702. * @param onSuccess is a callback called when the task is successfully executed
  77703. * @param onError is a callback called if an error occurs
  77704. */
  77705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77706. }
  77707. /**
  77708. * Define a task used by AssetsManager to load cube textures
  77709. */
  77710. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77711. /**
  77712. * Defines the name of the task
  77713. */
  77714. name: string;
  77715. /**
  77716. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77717. */
  77718. url: string;
  77719. /**
  77720. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77721. */
  77722. extensions?: string[] | undefined;
  77723. /**
  77724. * Defines if mipmaps should not be generated (default is false)
  77725. */
  77726. noMipmap?: boolean | undefined;
  77727. /**
  77728. * Defines the explicit list of files (undefined by default)
  77729. */
  77730. files?: string[] | undefined;
  77731. /**
  77732. * Gets the loaded texture
  77733. */
  77734. texture: CubeTexture;
  77735. /**
  77736. * Callback called when the task is successful
  77737. */
  77738. onSuccess: (task: CubeTextureAssetTask) => void;
  77739. /**
  77740. * Callback called when the task is successful
  77741. */
  77742. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77743. /**
  77744. * Creates a new CubeTextureAssetTask
  77745. * @param name defines the name of the task
  77746. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77747. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77748. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77749. * @param files defines the explicit list of files (undefined by default)
  77750. */
  77751. constructor(
  77752. /**
  77753. * Defines the name of the task
  77754. */
  77755. name: string,
  77756. /**
  77757. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77758. */
  77759. url: string,
  77760. /**
  77761. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77762. */
  77763. extensions?: string[] | undefined,
  77764. /**
  77765. * Defines if mipmaps should not be generated (default is false)
  77766. */
  77767. noMipmap?: boolean | undefined,
  77768. /**
  77769. * Defines the explicit list of files (undefined by default)
  77770. */
  77771. files?: string[] | undefined);
  77772. /**
  77773. * Execute the current task
  77774. * @param scene defines the scene where you want your assets to be loaded
  77775. * @param onSuccess is a callback called when the task is successfully executed
  77776. * @param onError is a callback called if an error occurs
  77777. */
  77778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77779. }
  77780. /**
  77781. * Define a task used by AssetsManager to load HDR cube textures
  77782. */
  77783. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77784. /**
  77785. * Defines the name of the task
  77786. */
  77787. name: string;
  77788. /**
  77789. * Defines the location of the file to load
  77790. */
  77791. url: string;
  77792. /**
  77793. * Defines the desired size (the more it increases the longer the generation will be)
  77794. */
  77795. size: number;
  77796. /**
  77797. * Defines if mipmaps should not be generated (default is false)
  77798. */
  77799. noMipmap: boolean;
  77800. /**
  77801. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77802. */
  77803. generateHarmonics: boolean;
  77804. /**
  77805. * 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)
  77806. */
  77807. gammaSpace: boolean;
  77808. /**
  77809. * Internal Use Only
  77810. */
  77811. reserved: boolean;
  77812. /**
  77813. * Gets the loaded texture
  77814. */
  77815. texture: HDRCubeTexture;
  77816. /**
  77817. * Callback called when the task is successful
  77818. */
  77819. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77820. /**
  77821. * Callback called when the task is successful
  77822. */
  77823. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77824. /**
  77825. * Creates a new HDRCubeTextureAssetTask object
  77826. * @param name defines the name of the task
  77827. * @param url defines the location of the file to load
  77828. * @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.
  77829. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77830. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77831. * @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)
  77832. * @param reserved Internal use only
  77833. */
  77834. constructor(
  77835. /**
  77836. * Defines the name of the task
  77837. */
  77838. name: string,
  77839. /**
  77840. * Defines the location of the file to load
  77841. */
  77842. url: string,
  77843. /**
  77844. * Defines the desired size (the more it increases the longer the generation will be)
  77845. */
  77846. size: number,
  77847. /**
  77848. * Defines if mipmaps should not be generated (default is false)
  77849. */
  77850. noMipmap?: boolean,
  77851. /**
  77852. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77853. */
  77854. generateHarmonics?: boolean,
  77855. /**
  77856. * 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)
  77857. */
  77858. gammaSpace?: boolean,
  77859. /**
  77860. * Internal Use Only
  77861. */
  77862. reserved?: boolean);
  77863. /**
  77864. * Execute the current task
  77865. * @param scene defines the scene where you want your assets to be loaded
  77866. * @param onSuccess is a callback called when the task is successfully executed
  77867. * @param onError is a callback called if an error occurs
  77868. */
  77869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77870. }
  77871. /**
  77872. * Define a task used by AssetsManager to load Equirectangular cube textures
  77873. */
  77874. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77875. /**
  77876. * Defines the name of the task
  77877. */
  77878. name: string;
  77879. /**
  77880. * Defines the location of the file to load
  77881. */
  77882. url: string;
  77883. /**
  77884. * Defines the desired size (the more it increases the longer the generation will be)
  77885. */
  77886. size: number;
  77887. /**
  77888. * Defines if mipmaps should not be generated (default is false)
  77889. */
  77890. noMipmap: boolean;
  77891. /**
  77892. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77893. * but the standard material would require them in Gamma space) (default is true)
  77894. */
  77895. gammaSpace: boolean;
  77896. /**
  77897. * Gets the loaded texture
  77898. */
  77899. texture: EquiRectangularCubeTexture;
  77900. /**
  77901. * Callback called when the task is successful
  77902. */
  77903. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77904. /**
  77905. * Callback called when the task is successful
  77906. */
  77907. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77908. /**
  77909. * Creates a new EquiRectangularCubeTextureAssetTask object
  77910. * @param name defines the name of the task
  77911. * @param url defines the location of the file to load
  77912. * @param size defines the desired size (the more it increases the longer the generation will be)
  77913. * If the size is omitted this implies you are using a preprocessed cubemap.
  77914. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77915. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77916. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77917. * (default is true)
  77918. */
  77919. constructor(
  77920. /**
  77921. * Defines the name of the task
  77922. */
  77923. name: string,
  77924. /**
  77925. * Defines the location of the file to load
  77926. */
  77927. url: string,
  77928. /**
  77929. * Defines the desired size (the more it increases the longer the generation will be)
  77930. */
  77931. size: number,
  77932. /**
  77933. * Defines if mipmaps should not be generated (default is false)
  77934. */
  77935. noMipmap?: boolean,
  77936. /**
  77937. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77938. * but the standard material would require them in Gamma space) (default is true)
  77939. */
  77940. gammaSpace?: boolean);
  77941. /**
  77942. * Execute the current task
  77943. * @param scene defines the scene where you want your assets to be loaded
  77944. * @param onSuccess is a callback called when the task is successfully executed
  77945. * @param onError is a callback called if an error occurs
  77946. */
  77947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77948. }
  77949. /**
  77950. * This class can be used to easily import assets into a scene
  77951. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77952. */
  77953. export class AssetsManager {
  77954. private _scene;
  77955. private _isLoading;
  77956. protected _tasks: AbstractAssetTask[];
  77957. protected _waitingTasksCount: number;
  77958. protected _totalTasksCount: number;
  77959. /**
  77960. * Callback called when all tasks are processed
  77961. */
  77962. onFinish: (tasks: AbstractAssetTask[]) => void;
  77963. /**
  77964. * Callback called when a task is successful
  77965. */
  77966. onTaskSuccess: (task: AbstractAssetTask) => void;
  77967. /**
  77968. * Callback called when a task had an error
  77969. */
  77970. onTaskError: (task: AbstractAssetTask) => void;
  77971. /**
  77972. * Callback called when a task is done (whatever the result is)
  77973. */
  77974. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77975. /**
  77976. * Observable called when all tasks are processed
  77977. */
  77978. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77979. /**
  77980. * Observable called when a task had an error
  77981. */
  77982. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77983. /**
  77984. * Observable called when all tasks were executed
  77985. */
  77986. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77987. /**
  77988. * Observable called when a task is done (whatever the result is)
  77989. */
  77990. onProgressObservable: Observable<IAssetsProgressEvent>;
  77991. /**
  77992. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77993. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77994. */
  77995. useDefaultLoadingScreen: boolean;
  77996. /**
  77997. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77998. * when all assets have been downloaded.
  77999. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78000. */
  78001. autoHideLoadingUI: boolean;
  78002. /**
  78003. * Creates a new AssetsManager
  78004. * @param scene defines the scene to work on
  78005. */
  78006. constructor(scene: Scene);
  78007. /**
  78008. * Add a ContainerAssetTask to the list of active tasks
  78009. * @param taskName defines the name of the new task
  78010. * @param meshesNames defines the name of meshes to load
  78011. * @param rootUrl defines the root url to use to locate files
  78012. * @param sceneFilename defines the filename of the scene file
  78013. * @returns a new ContainerAssetTask object
  78014. */
  78015. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78016. /**
  78017. * Add a MeshAssetTask to the list of active tasks
  78018. * @param taskName defines the name of the new task
  78019. * @param meshesNames defines the name of meshes to load
  78020. * @param rootUrl defines the root url to use to locate files
  78021. * @param sceneFilename defines the filename of the scene file
  78022. * @returns a new MeshAssetTask object
  78023. */
  78024. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78025. /**
  78026. * Add a TextFileAssetTask to the list of active tasks
  78027. * @param taskName defines the name of the new task
  78028. * @param url defines the url of the file to load
  78029. * @returns a new TextFileAssetTask object
  78030. */
  78031. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78032. /**
  78033. * Add a BinaryFileAssetTask to the list of active tasks
  78034. * @param taskName defines the name of the new task
  78035. * @param url defines the url of the file to load
  78036. * @returns a new BinaryFileAssetTask object
  78037. */
  78038. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78039. /**
  78040. * Add a ImageAssetTask to the list of active tasks
  78041. * @param taskName defines the name of the new task
  78042. * @param url defines the url of the file to load
  78043. * @returns a new ImageAssetTask object
  78044. */
  78045. addImageTask(taskName: string, url: string): ImageAssetTask;
  78046. /**
  78047. * Add a TextureAssetTask to the list of active tasks
  78048. * @param taskName defines the name of the new task
  78049. * @param url defines the url of the file to load
  78050. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78051. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78052. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78053. * @returns a new TextureAssetTask object
  78054. */
  78055. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78056. /**
  78057. * Add a CubeTextureAssetTask to the list of active tasks
  78058. * @param taskName defines the name of the new task
  78059. * @param url defines the url of the file to load
  78060. * @param extensions defines the extension to use to load the cube map (can be null)
  78061. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78062. * @param files defines the list of files to load (can be null)
  78063. * @returns a new CubeTextureAssetTask object
  78064. */
  78065. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78066. /**
  78067. *
  78068. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78069. * @param taskName defines the name of the new task
  78070. * @param url defines the url of the file to load
  78071. * @param size defines the size you want for the cubemap (can be null)
  78072. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78073. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78074. * @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)
  78075. * @param reserved Internal use only
  78076. * @returns a new HDRCubeTextureAssetTask object
  78077. */
  78078. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78079. /**
  78080. *
  78081. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78082. * @param taskName defines the name of the new task
  78083. * @param url defines the url of the file to load
  78084. * @param size defines the size you want for the cubemap (can be null)
  78085. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78086. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78087. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78088. * @returns a new EquiRectangularCubeTextureAssetTask object
  78089. */
  78090. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78091. /**
  78092. * Remove a task from the assets manager.
  78093. * @param task the task to remove
  78094. */
  78095. removeTask(task: AbstractAssetTask): void;
  78096. private _decreaseWaitingTasksCount;
  78097. private _runTask;
  78098. /**
  78099. * Reset the AssetsManager and remove all tasks
  78100. * @return the current instance of the AssetsManager
  78101. */
  78102. reset(): AssetsManager;
  78103. /**
  78104. * Start the loading process
  78105. * @return the current instance of the AssetsManager
  78106. */
  78107. load(): AssetsManager;
  78108. /**
  78109. * Start the loading process as an async operation
  78110. * @return a promise returning the list of failed tasks
  78111. */
  78112. loadAsync(): Promise<void>;
  78113. }
  78114. }
  78115. declare module "babylonjs/Misc/deferred" {
  78116. /**
  78117. * Wrapper class for promise with external resolve and reject.
  78118. */
  78119. export class Deferred<T> {
  78120. /**
  78121. * The promise associated with this deferred object.
  78122. */
  78123. readonly promise: Promise<T>;
  78124. private _resolve;
  78125. private _reject;
  78126. /**
  78127. * The resolve method of the promise associated with this deferred object.
  78128. */
  78129. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78130. /**
  78131. * The reject method of the promise associated with this deferred object.
  78132. */
  78133. get reject(): (reason?: any) => void;
  78134. /**
  78135. * Constructor for this deferred object.
  78136. */
  78137. constructor();
  78138. }
  78139. }
  78140. declare module "babylonjs/Misc/meshExploder" {
  78141. import { Mesh } from "babylonjs/Meshes/mesh";
  78142. /**
  78143. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78144. */
  78145. export class MeshExploder {
  78146. private _centerMesh;
  78147. private _meshes;
  78148. private _meshesOrigins;
  78149. private _toCenterVectors;
  78150. private _scaledDirection;
  78151. private _newPosition;
  78152. private _centerPosition;
  78153. /**
  78154. * Explodes meshes from a center mesh.
  78155. * @param meshes The meshes to explode.
  78156. * @param centerMesh The mesh to be center of explosion.
  78157. */
  78158. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78159. private _setCenterMesh;
  78160. /**
  78161. * Get class name
  78162. * @returns "MeshExploder"
  78163. */
  78164. getClassName(): string;
  78165. /**
  78166. * "Exploded meshes"
  78167. * @returns Array of meshes with the centerMesh at index 0.
  78168. */
  78169. getMeshes(): Array<Mesh>;
  78170. /**
  78171. * Explodes meshes giving a specific direction
  78172. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78173. */
  78174. explode(direction?: number): void;
  78175. }
  78176. }
  78177. declare module "babylonjs/Misc/filesInput" {
  78178. import { Engine } from "babylonjs/Engines/engine";
  78179. import { Scene } from "babylonjs/scene";
  78180. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78181. import { Nullable } from "babylonjs/types";
  78182. /**
  78183. * Class used to help managing file picking and drag'n'drop
  78184. */
  78185. export class FilesInput {
  78186. /**
  78187. * List of files ready to be loaded
  78188. */
  78189. static get FilesToLoad(): {
  78190. [key: string]: File;
  78191. };
  78192. /**
  78193. * Callback called when a file is processed
  78194. */
  78195. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78196. private _engine;
  78197. private _currentScene;
  78198. private _sceneLoadedCallback;
  78199. private _progressCallback;
  78200. private _additionalRenderLoopLogicCallback;
  78201. private _textureLoadingCallback;
  78202. private _startingProcessingFilesCallback;
  78203. private _onReloadCallback;
  78204. private _errorCallback;
  78205. private _elementToMonitor;
  78206. private _sceneFileToLoad;
  78207. private _filesToLoad;
  78208. /**
  78209. * Creates a new FilesInput
  78210. * @param engine defines the rendering engine
  78211. * @param scene defines the hosting scene
  78212. * @param sceneLoadedCallback callback called when scene is loaded
  78213. * @param progressCallback callback called to track progress
  78214. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78215. * @param textureLoadingCallback callback called when a texture is loading
  78216. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78217. * @param onReloadCallback callback called when a reload is requested
  78218. * @param errorCallback callback call if an error occurs
  78219. */
  78220. 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>);
  78221. private _dragEnterHandler;
  78222. private _dragOverHandler;
  78223. private _dropHandler;
  78224. /**
  78225. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78226. * @param elementToMonitor defines the DOM element to track
  78227. */
  78228. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78229. /** Gets the current list of files to load */
  78230. get filesToLoad(): File[];
  78231. /**
  78232. * Release all associated resources
  78233. */
  78234. dispose(): void;
  78235. private renderFunction;
  78236. private drag;
  78237. private drop;
  78238. private _traverseFolder;
  78239. private _processFiles;
  78240. /**
  78241. * Load files from a drop event
  78242. * @param event defines the drop event to use as source
  78243. */
  78244. loadFiles(event: any): void;
  78245. private _processReload;
  78246. /**
  78247. * Reload the current scene from the loaded files
  78248. */
  78249. reload(): void;
  78250. }
  78251. }
  78252. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78253. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78254. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78255. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78256. }
  78257. declare module "babylonjs/Misc/sceneOptimizer" {
  78258. import { Scene, IDisposable } from "babylonjs/scene";
  78259. import { Observable } from "babylonjs/Misc/observable";
  78260. /**
  78261. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78262. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78263. */
  78264. export class SceneOptimization {
  78265. /**
  78266. * Defines the priority of this optimization (0 by default which means first in the list)
  78267. */
  78268. priority: number;
  78269. /**
  78270. * Gets a string describing the action executed by the current optimization
  78271. * @returns description string
  78272. */
  78273. getDescription(): string;
  78274. /**
  78275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78276. * @param scene defines the current scene where to apply this optimization
  78277. * @param optimizer defines the current optimizer
  78278. * @returns true if everything that can be done was applied
  78279. */
  78280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78281. /**
  78282. * Creates the SceneOptimization object
  78283. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78284. * @param desc defines the description associated with the optimization
  78285. */
  78286. constructor(
  78287. /**
  78288. * Defines the priority of this optimization (0 by default which means first in the list)
  78289. */
  78290. priority?: number);
  78291. }
  78292. /**
  78293. * Defines an optimization used to reduce the size of render target textures
  78294. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78295. */
  78296. export class TextureOptimization extends SceneOptimization {
  78297. /**
  78298. * Defines the priority of this optimization (0 by default which means first in the list)
  78299. */
  78300. priority: number;
  78301. /**
  78302. * 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
  78303. */
  78304. maximumSize: number;
  78305. /**
  78306. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78307. */
  78308. step: number;
  78309. /**
  78310. * Gets a string describing the action executed by the current optimization
  78311. * @returns description string
  78312. */
  78313. getDescription(): string;
  78314. /**
  78315. * Creates the TextureOptimization object
  78316. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78317. * @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
  78318. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78319. */
  78320. constructor(
  78321. /**
  78322. * Defines the priority of this optimization (0 by default which means first in the list)
  78323. */
  78324. priority?: number,
  78325. /**
  78326. * 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
  78327. */
  78328. maximumSize?: number,
  78329. /**
  78330. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78331. */
  78332. step?: number);
  78333. /**
  78334. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78335. * @param scene defines the current scene where to apply this optimization
  78336. * @param optimizer defines the current optimizer
  78337. * @returns true if everything that can be done was applied
  78338. */
  78339. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78340. }
  78341. /**
  78342. * Defines an optimization used to increase or decrease the rendering resolution
  78343. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78344. */
  78345. export class HardwareScalingOptimization extends SceneOptimization {
  78346. /**
  78347. * Defines the priority of this optimization (0 by default which means first in the list)
  78348. */
  78349. priority: number;
  78350. /**
  78351. * Defines the maximum scale to use (2 by default)
  78352. */
  78353. maximumScale: number;
  78354. /**
  78355. * Defines the step to use between two passes (0.5 by default)
  78356. */
  78357. step: number;
  78358. private _currentScale;
  78359. private _directionOffset;
  78360. /**
  78361. * Gets a string describing the action executed by the current optimization
  78362. * @return description string
  78363. */
  78364. getDescription(): string;
  78365. /**
  78366. * Creates the HardwareScalingOptimization object
  78367. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78368. * @param maximumScale defines the maximum scale to use (2 by default)
  78369. * @param step defines the step to use between two passes (0.5 by default)
  78370. */
  78371. constructor(
  78372. /**
  78373. * Defines the priority of this optimization (0 by default which means first in the list)
  78374. */
  78375. priority?: number,
  78376. /**
  78377. * Defines the maximum scale to use (2 by default)
  78378. */
  78379. maximumScale?: number,
  78380. /**
  78381. * Defines the step to use between two passes (0.5 by default)
  78382. */
  78383. step?: number);
  78384. /**
  78385. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78386. * @param scene defines the current scene where to apply this optimization
  78387. * @param optimizer defines the current optimizer
  78388. * @returns true if everything that can be done was applied
  78389. */
  78390. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78391. }
  78392. /**
  78393. * Defines an optimization used to remove shadows
  78394. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78395. */
  78396. export class ShadowsOptimization extends SceneOptimization {
  78397. /**
  78398. * Gets a string describing the action executed by the current optimization
  78399. * @return description string
  78400. */
  78401. getDescription(): string;
  78402. /**
  78403. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78404. * @param scene defines the current scene where to apply this optimization
  78405. * @param optimizer defines the current optimizer
  78406. * @returns true if everything that can be done was applied
  78407. */
  78408. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78409. }
  78410. /**
  78411. * Defines an optimization used to turn post-processes off
  78412. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78413. */
  78414. export class PostProcessesOptimization extends SceneOptimization {
  78415. /**
  78416. * Gets a string describing the action executed by the current optimization
  78417. * @return description string
  78418. */
  78419. getDescription(): string;
  78420. /**
  78421. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78422. * @param scene defines the current scene where to apply this optimization
  78423. * @param optimizer defines the current optimizer
  78424. * @returns true if everything that can be done was applied
  78425. */
  78426. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78427. }
  78428. /**
  78429. * Defines an optimization used to turn lens flares off
  78430. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78431. */
  78432. export class LensFlaresOptimization extends SceneOptimization {
  78433. /**
  78434. * Gets a string describing the action executed by the current optimization
  78435. * @return description string
  78436. */
  78437. getDescription(): string;
  78438. /**
  78439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78440. * @param scene defines the current scene where to apply this optimization
  78441. * @param optimizer defines the current optimizer
  78442. * @returns true if everything that can be done was applied
  78443. */
  78444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78445. }
  78446. /**
  78447. * Defines an optimization based on user defined callback.
  78448. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78449. */
  78450. export class CustomOptimization extends SceneOptimization {
  78451. /**
  78452. * Callback called to apply the custom optimization.
  78453. */
  78454. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78455. /**
  78456. * Callback called to get custom description
  78457. */
  78458. onGetDescription: () => string;
  78459. /**
  78460. * Gets a string describing the action executed by the current optimization
  78461. * @returns description string
  78462. */
  78463. getDescription(): string;
  78464. /**
  78465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78466. * @param scene defines the current scene where to apply this optimization
  78467. * @param optimizer defines the current optimizer
  78468. * @returns true if everything that can be done was applied
  78469. */
  78470. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78471. }
  78472. /**
  78473. * Defines an optimization used to turn particles off
  78474. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78475. */
  78476. export class ParticlesOptimization extends SceneOptimization {
  78477. /**
  78478. * Gets a string describing the action executed by the current optimization
  78479. * @return description string
  78480. */
  78481. getDescription(): string;
  78482. /**
  78483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78484. * @param scene defines the current scene where to apply this optimization
  78485. * @param optimizer defines the current optimizer
  78486. * @returns true if everything that can be done was applied
  78487. */
  78488. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78489. }
  78490. /**
  78491. * Defines an optimization used to turn render targets off
  78492. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78493. */
  78494. export class RenderTargetsOptimization extends SceneOptimization {
  78495. /**
  78496. * Gets a string describing the action executed by the current optimization
  78497. * @return description string
  78498. */
  78499. getDescription(): string;
  78500. /**
  78501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78502. * @param scene defines the current scene where to apply this optimization
  78503. * @param optimizer defines the current optimizer
  78504. * @returns true if everything that can be done was applied
  78505. */
  78506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78507. }
  78508. /**
  78509. * Defines an optimization used to merge meshes with compatible materials
  78510. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78511. */
  78512. export class MergeMeshesOptimization extends SceneOptimization {
  78513. private static _UpdateSelectionTree;
  78514. /**
  78515. * Gets or sets a boolean which defines if optimization octree has to be updated
  78516. */
  78517. static get UpdateSelectionTree(): boolean;
  78518. /**
  78519. * Gets or sets a boolean which defines if optimization octree has to be updated
  78520. */
  78521. static set UpdateSelectionTree(value: boolean);
  78522. /**
  78523. * Gets a string describing the action executed by the current optimization
  78524. * @return description string
  78525. */
  78526. getDescription(): string;
  78527. private _canBeMerged;
  78528. /**
  78529. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78530. * @param scene defines the current scene where to apply this optimization
  78531. * @param optimizer defines the current optimizer
  78532. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78533. * @returns true if everything that can be done was applied
  78534. */
  78535. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78536. }
  78537. /**
  78538. * Defines a list of options used by SceneOptimizer
  78539. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78540. */
  78541. export class SceneOptimizerOptions {
  78542. /**
  78543. * Defines the target frame rate to reach (60 by default)
  78544. */
  78545. targetFrameRate: number;
  78546. /**
  78547. * Defines the interval between two checkes (2000ms by default)
  78548. */
  78549. trackerDuration: number;
  78550. /**
  78551. * Gets the list of optimizations to apply
  78552. */
  78553. optimizations: SceneOptimization[];
  78554. /**
  78555. * Creates a new list of options used by SceneOptimizer
  78556. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78557. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78558. */
  78559. constructor(
  78560. /**
  78561. * Defines the target frame rate to reach (60 by default)
  78562. */
  78563. targetFrameRate?: number,
  78564. /**
  78565. * Defines the interval between two checkes (2000ms by default)
  78566. */
  78567. trackerDuration?: number);
  78568. /**
  78569. * Add a new optimization
  78570. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78571. * @returns the current SceneOptimizerOptions
  78572. */
  78573. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78574. /**
  78575. * Add a new custom optimization
  78576. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78577. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78578. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78579. * @returns the current SceneOptimizerOptions
  78580. */
  78581. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78582. /**
  78583. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78584. * @param targetFrameRate defines the target frame rate (60 by default)
  78585. * @returns a SceneOptimizerOptions object
  78586. */
  78587. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78588. /**
  78589. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78590. * @param targetFrameRate defines the target frame rate (60 by default)
  78591. * @returns a SceneOptimizerOptions object
  78592. */
  78593. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78594. /**
  78595. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78596. * @param targetFrameRate defines the target frame rate (60 by default)
  78597. * @returns a SceneOptimizerOptions object
  78598. */
  78599. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78600. }
  78601. /**
  78602. * Class used to run optimizations in order to reach a target frame rate
  78603. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78604. */
  78605. export class SceneOptimizer implements IDisposable {
  78606. private _isRunning;
  78607. private _options;
  78608. private _scene;
  78609. private _currentPriorityLevel;
  78610. private _targetFrameRate;
  78611. private _trackerDuration;
  78612. private _currentFrameRate;
  78613. private _sceneDisposeObserver;
  78614. private _improvementMode;
  78615. /**
  78616. * Defines an observable called when the optimizer reaches the target frame rate
  78617. */
  78618. onSuccessObservable: Observable<SceneOptimizer>;
  78619. /**
  78620. * Defines an observable called when the optimizer enables an optimization
  78621. */
  78622. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78623. /**
  78624. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78625. */
  78626. onFailureObservable: Observable<SceneOptimizer>;
  78627. /**
  78628. * Gets a boolean indicating if the optimizer is in improvement mode
  78629. */
  78630. get isInImprovementMode(): boolean;
  78631. /**
  78632. * Gets the current priority level (0 at start)
  78633. */
  78634. get currentPriorityLevel(): number;
  78635. /**
  78636. * Gets the current frame rate checked by the SceneOptimizer
  78637. */
  78638. get currentFrameRate(): number;
  78639. /**
  78640. * Gets or sets the current target frame rate (60 by default)
  78641. */
  78642. get targetFrameRate(): number;
  78643. /**
  78644. * Gets or sets the current target frame rate (60 by default)
  78645. */
  78646. set targetFrameRate(value: number);
  78647. /**
  78648. * Gets or sets the current interval between two checks (every 2000ms by default)
  78649. */
  78650. get trackerDuration(): number;
  78651. /**
  78652. * Gets or sets the current interval between two checks (every 2000ms by default)
  78653. */
  78654. set trackerDuration(value: number);
  78655. /**
  78656. * Gets the list of active optimizations
  78657. */
  78658. get optimizations(): SceneOptimization[];
  78659. /**
  78660. * Creates a new SceneOptimizer
  78661. * @param scene defines the scene to work on
  78662. * @param options defines the options to use with the SceneOptimizer
  78663. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78664. * @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)
  78665. */
  78666. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78667. /**
  78668. * Stops the current optimizer
  78669. */
  78670. stop(): void;
  78671. /**
  78672. * Reset the optimizer to initial step (current priority level = 0)
  78673. */
  78674. reset(): void;
  78675. /**
  78676. * Start the optimizer. By default it will try to reach a specific framerate
  78677. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78678. */
  78679. start(): void;
  78680. private _checkCurrentState;
  78681. /**
  78682. * Release all resources
  78683. */
  78684. dispose(): void;
  78685. /**
  78686. * Helper function to create a SceneOptimizer with one single line of code
  78687. * @param scene defines the scene to work on
  78688. * @param options defines the options to use with the SceneOptimizer
  78689. * @param onSuccess defines a callback to call on success
  78690. * @param onFailure defines a callback to call on failure
  78691. * @returns the new SceneOptimizer object
  78692. */
  78693. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78694. }
  78695. }
  78696. declare module "babylonjs/Misc/sceneSerializer" {
  78697. import { Scene } from "babylonjs/scene";
  78698. /**
  78699. * Class used to serialize a scene into a string
  78700. */
  78701. export class SceneSerializer {
  78702. /**
  78703. * Clear cache used by a previous serialization
  78704. */
  78705. static ClearCache(): void;
  78706. /**
  78707. * Serialize a scene into a JSON compatible object
  78708. * @param scene defines the scene to serialize
  78709. * @returns a JSON compatible object
  78710. */
  78711. static Serialize(scene: Scene): any;
  78712. /**
  78713. * Serialize a mesh into a JSON compatible object
  78714. * @param toSerialize defines the mesh to serialize
  78715. * @param withParents defines if parents must be serialized as well
  78716. * @param withChildren defines if children must be serialized as well
  78717. * @returns a JSON compatible object
  78718. */
  78719. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78720. }
  78721. }
  78722. declare module "babylonjs/Misc/textureTools" {
  78723. import { Texture } from "babylonjs/Materials/Textures/texture";
  78724. /**
  78725. * Class used to host texture specific utilities
  78726. */
  78727. export class TextureTools {
  78728. /**
  78729. * Uses the GPU to create a copy texture rescaled at a given size
  78730. * @param texture Texture to copy from
  78731. * @param width defines the desired width
  78732. * @param height defines the desired height
  78733. * @param useBilinearMode defines if bilinear mode has to be used
  78734. * @return the generated texture
  78735. */
  78736. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78737. }
  78738. }
  78739. declare module "babylonjs/Misc/videoRecorder" {
  78740. import { Nullable } from "babylonjs/types";
  78741. import { Engine } from "babylonjs/Engines/engine";
  78742. /**
  78743. * This represents the different options available for the video capture.
  78744. */
  78745. export interface VideoRecorderOptions {
  78746. /** Defines the mime type of the video. */
  78747. mimeType: string;
  78748. /** Defines the FPS the video should be recorded at. */
  78749. fps: number;
  78750. /** Defines the chunk size for the recording data. */
  78751. recordChunckSize: number;
  78752. /** The audio tracks to attach to the recording. */
  78753. audioTracks?: MediaStreamTrack[];
  78754. }
  78755. /**
  78756. * This can help with recording videos from BabylonJS.
  78757. * This is based on the available WebRTC functionalities of the browser.
  78758. *
  78759. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78760. */
  78761. export class VideoRecorder {
  78762. private static readonly _defaultOptions;
  78763. /**
  78764. * Returns whether or not the VideoRecorder is available in your browser.
  78765. * @param engine Defines the Babylon Engine.
  78766. * @returns true if supported otherwise false.
  78767. */
  78768. static IsSupported(engine: Engine): boolean;
  78769. private readonly _options;
  78770. private _canvas;
  78771. private _mediaRecorder;
  78772. private _recordedChunks;
  78773. private _fileName;
  78774. private _resolve;
  78775. private _reject;
  78776. /**
  78777. * True when a recording is already in progress.
  78778. */
  78779. get isRecording(): boolean;
  78780. /**
  78781. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78782. * @param engine Defines the BabylonJS Engine you wish to record.
  78783. * @param options Defines options that can be used to customize the capture.
  78784. */
  78785. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78786. /**
  78787. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78788. */
  78789. stopRecording(): void;
  78790. /**
  78791. * Starts recording the canvas for a max duration specified in parameters.
  78792. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78793. * If null no automatic download will start and you can rely on the promise to get the data back.
  78794. * @param maxDuration Defines the maximum recording time in seconds.
  78795. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78796. * @return A promise callback at the end of the recording with the video data in Blob.
  78797. */
  78798. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78799. /**
  78800. * Releases internal resources used during the recording.
  78801. */
  78802. dispose(): void;
  78803. private _handleDataAvailable;
  78804. private _handleError;
  78805. private _handleStop;
  78806. }
  78807. }
  78808. declare module "babylonjs/Misc/screenshotTools" {
  78809. import { Camera } from "babylonjs/Cameras/camera";
  78810. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78811. import { Engine } from "babylonjs/Engines/engine";
  78812. /**
  78813. * Class containing a set of static utilities functions for screenshots
  78814. */
  78815. export class ScreenshotTools {
  78816. /**
  78817. * Captures a screenshot of the current rendering
  78818. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78819. * @param engine defines the rendering engine
  78820. * @param camera defines the source camera
  78821. * @param size This parameter can be set to a single number or to an object with the
  78822. * following (optional) properties: precision, width, height. If a single number is passed,
  78823. * it will be used for both width and height. If an object is passed, the screenshot size
  78824. * will be derived from the parameters. The precision property is a multiplier allowing
  78825. * rendering at a higher or lower resolution
  78826. * @param successCallback defines the callback receives a single parameter which contains the
  78827. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78828. * src parameter of an <img> to display it
  78829. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78830. * Check your browser for supported MIME types
  78831. */
  78832. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78833. /**
  78834. * Captures a screenshot of the current rendering
  78835. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78836. * @param engine defines the rendering engine
  78837. * @param camera defines the source camera
  78838. * @param size This parameter can be set to a single number or to an object with the
  78839. * following (optional) properties: precision, width, height. If a single number is passed,
  78840. * it will be used for both width and height. If an object is passed, the screenshot size
  78841. * will be derived from the parameters. The precision property is a multiplier allowing
  78842. * rendering at a higher or lower resolution
  78843. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78844. * Check your browser for supported MIME types
  78845. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78846. * to the src parameter of an <img> to display it
  78847. */
  78848. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78849. /**
  78850. * Generates an image screenshot from the specified camera.
  78851. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78852. * @param engine The engine to use for rendering
  78853. * @param camera The camera to use for rendering
  78854. * @param size This parameter can be set to a single number or to an object with the
  78855. * following (optional) properties: precision, width, height. If a single number is passed,
  78856. * it will be used for both width and height. If an object is passed, the screenshot size
  78857. * will be derived from the parameters. The precision property is a multiplier allowing
  78858. * rendering at a higher or lower resolution
  78859. * @param successCallback The callback receives a single parameter which contains the
  78860. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78861. * src parameter of an <img> to display it
  78862. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78863. * Check your browser for supported MIME types
  78864. * @param samples Texture samples (default: 1)
  78865. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78866. * @param fileName A name for for the downloaded file.
  78867. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78868. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78869. */
  78870. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  78871. /**
  78872. * Generates an image screenshot from the specified camera.
  78873. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78874. * @param engine The engine to use for rendering
  78875. * @param camera The camera to use for rendering
  78876. * @param size This parameter can be set to a single number or to an object with the
  78877. * following (optional) properties: precision, width, height. If a single number is passed,
  78878. * it will be used for both width and height. If an object is passed, the screenshot size
  78879. * will be derived from the parameters. The precision property is a multiplier allowing
  78880. * rendering at a higher or lower resolution
  78881. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78882. * Check your browser for supported MIME types
  78883. * @param samples Texture samples (default: 1)
  78884. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78885. * @param fileName A name for for the downloaded file.
  78886. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78887. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78888. * to the src parameter of an <img> to display it
  78889. */
  78890. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78891. /**
  78892. * Gets height and width for screenshot size
  78893. * @private
  78894. */
  78895. private static _getScreenshotSize;
  78896. }
  78897. }
  78898. declare module "babylonjs/Misc/dataReader" {
  78899. /**
  78900. * Interface for a data buffer
  78901. */
  78902. export interface IDataBuffer {
  78903. /**
  78904. * Reads bytes from the data buffer.
  78905. * @param byteOffset The byte offset to read
  78906. * @param byteLength The byte length to read
  78907. * @returns A promise that resolves when the bytes are read
  78908. */
  78909. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78910. /**
  78911. * The byte length of the buffer.
  78912. */
  78913. readonly byteLength: number;
  78914. }
  78915. /**
  78916. * Utility class for reading from a data buffer
  78917. */
  78918. export class DataReader {
  78919. /**
  78920. * The data buffer associated with this data reader.
  78921. */
  78922. readonly buffer: IDataBuffer;
  78923. /**
  78924. * The current byte offset from the beginning of the data buffer.
  78925. */
  78926. byteOffset: number;
  78927. private _dataView;
  78928. private _dataByteOffset;
  78929. /**
  78930. * Constructor
  78931. * @param buffer The buffer to read
  78932. */
  78933. constructor(buffer: IDataBuffer);
  78934. /**
  78935. * Loads the given byte length.
  78936. * @param byteLength The byte length to load
  78937. * @returns A promise that resolves when the load is complete
  78938. */
  78939. loadAsync(byteLength: number): Promise<void>;
  78940. /**
  78941. * Read a unsigned 32-bit integer from the currently loaded data range.
  78942. * @returns The 32-bit integer read
  78943. */
  78944. readUint32(): number;
  78945. /**
  78946. * Read a byte array from the currently loaded data range.
  78947. * @param byteLength The byte length to read
  78948. * @returns The byte array read
  78949. */
  78950. readUint8Array(byteLength: number): Uint8Array;
  78951. /**
  78952. * Read a string from the currently loaded data range.
  78953. * @param byteLength The byte length to read
  78954. * @returns The string read
  78955. */
  78956. readString(byteLength: number): string;
  78957. /**
  78958. * Skips the given byte length the currently loaded data range.
  78959. * @param byteLength The byte length to skip
  78960. */
  78961. skipBytes(byteLength: number): void;
  78962. }
  78963. }
  78964. declare module "babylonjs/Misc/dataStorage" {
  78965. /**
  78966. * Class for storing data to local storage if available or in-memory storage otherwise
  78967. */
  78968. export class DataStorage {
  78969. private static _Storage;
  78970. private static _GetStorage;
  78971. /**
  78972. * Reads a string from the data storage
  78973. * @param key The key to read
  78974. * @param defaultValue The value if the key doesn't exist
  78975. * @returns The string value
  78976. */
  78977. static ReadString(key: string, defaultValue: string): string;
  78978. /**
  78979. * Writes a string to the data storage
  78980. * @param key The key to write
  78981. * @param value The value to write
  78982. */
  78983. static WriteString(key: string, value: string): void;
  78984. /**
  78985. * Reads a boolean from the data storage
  78986. * @param key The key to read
  78987. * @param defaultValue The value if the key doesn't exist
  78988. * @returns The boolean value
  78989. */
  78990. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78991. /**
  78992. * Writes a boolean to the data storage
  78993. * @param key The key to write
  78994. * @param value The value to write
  78995. */
  78996. static WriteBoolean(key: string, value: boolean): void;
  78997. /**
  78998. * Reads a number from the data storage
  78999. * @param key The key to read
  79000. * @param defaultValue The value if the key doesn't exist
  79001. * @returns The number value
  79002. */
  79003. static ReadNumber(key: string, defaultValue: number): number;
  79004. /**
  79005. * Writes a number to the data storage
  79006. * @param key The key to write
  79007. * @param value The value to write
  79008. */
  79009. static WriteNumber(key: string, value: number): void;
  79010. }
  79011. }
  79012. declare module "babylonjs/Misc/sceneRecorder" {
  79013. import { Scene } from "babylonjs/scene";
  79014. /**
  79015. * Class used to record delta files between 2 scene states
  79016. */
  79017. export class SceneRecorder {
  79018. private _trackedScene;
  79019. private _savedJSON;
  79020. /**
  79021. * Track a given scene. This means the current scene state will be considered the original state
  79022. * @param scene defines the scene to track
  79023. */
  79024. track(scene: Scene): void;
  79025. /**
  79026. * Get the delta between current state and original state
  79027. * @returns a string containing the delta
  79028. */
  79029. getDelta(): any;
  79030. private _compareArray;
  79031. private _compareObjects;
  79032. private _compareCollections;
  79033. private static GetShadowGeneratorById;
  79034. /**
  79035. * Apply a given delta to a given scene
  79036. * @param deltaJSON defines the JSON containing the delta
  79037. * @param scene defines the scene to apply the delta to
  79038. */
  79039. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79040. private static _ApplyPropertiesToEntity;
  79041. private static _ApplyDeltaForEntity;
  79042. }
  79043. }
  79044. declare module "babylonjs/Misc/trajectoryClassifier" {
  79045. import { DeepImmutable, Nullable } from "babylonjs/types";
  79046. import { Vector3 } from "babylonjs/Maths/math.vector";
  79047. /**
  79048. * A 3D trajectory consisting of an order list of vectors describing a
  79049. * path of motion through 3D space.
  79050. */
  79051. export class Trajectory {
  79052. private _points;
  79053. private readonly _segmentLength;
  79054. /**
  79055. * Serialize to JSON.
  79056. * @returns serialized JSON string
  79057. */
  79058. serialize(): string;
  79059. /**
  79060. * Deserialize from JSON.
  79061. * @param json serialized JSON string
  79062. * @returns deserialized Trajectory
  79063. */
  79064. static Deserialize(json: string): Trajectory;
  79065. /**
  79066. * Create a new empty Trajectory.
  79067. * @param segmentLength radius of discretization for Trajectory points
  79068. */
  79069. constructor(segmentLength?: number);
  79070. /**
  79071. * Get the length of the Trajectory.
  79072. * @returns length of the Trajectory
  79073. */
  79074. getLength(): number;
  79075. /**
  79076. * Append a new point to the Trajectory.
  79077. * NOTE: This implementation has many allocations.
  79078. * @param point point to append to the Trajectory
  79079. */
  79080. add(point: DeepImmutable<Vector3>): void;
  79081. /**
  79082. * Create a new Trajectory with a segment length chosen to make it
  79083. * probable that the new Trajectory will have a specified number of
  79084. * segments. This operation is imprecise.
  79085. * @param targetResolution number of segments desired
  79086. * @returns new Trajectory with approximately the requested number of segments
  79087. */
  79088. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79089. /**
  79090. * Convert Trajectory segments into tokenized representation. This
  79091. * representation is an array of numbers where each nth number is the
  79092. * index of the token which is most similar to the nth segment of the
  79093. * Trajectory.
  79094. * @param tokens list of vectors which serve as discrete tokens
  79095. * @returns list of indices of most similar token per segment
  79096. */
  79097. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79098. private static _forwardDir;
  79099. private static _inverseFromVec;
  79100. private static _upDir;
  79101. private static _fromToVec;
  79102. private static _lookMatrix;
  79103. /**
  79104. * Transform the rotation (i.e., direction) of a segment to isolate
  79105. * the relative transformation represented by the segment. This operation
  79106. * may or may not succeed due to singularities in the equations that define
  79107. * motion relativity in this context.
  79108. * @param priorVec the origin of the prior segment
  79109. * @param fromVec the origin of the current segment
  79110. * @param toVec the destination of the current segment
  79111. * @param result reference to output variable
  79112. * @returns whether or not transformation was successful
  79113. */
  79114. private static _transformSegmentDirToRef;
  79115. private static _bestMatch;
  79116. private static _score;
  79117. private static _bestScore;
  79118. /**
  79119. * Determine which token vector is most similar to the
  79120. * segment vector.
  79121. * @param segment segment vector
  79122. * @param tokens token vector list
  79123. * @returns index of the most similar token to the segment
  79124. */
  79125. private static _tokenizeSegment;
  79126. }
  79127. /**
  79128. * Class representing a set of known, named trajectories to which Trajectories can be
  79129. * added and using which Trajectories can be recognized.
  79130. */
  79131. export class TrajectoryClassifier {
  79132. private _maximumAllowableMatchCost;
  79133. private _vector3Alphabet;
  79134. private _levenshteinAlphabet;
  79135. private _nameToDescribedTrajectory;
  79136. /**
  79137. * Serialize to JSON.
  79138. * @returns JSON serialization
  79139. */
  79140. serialize(): string;
  79141. /**
  79142. * Deserialize from JSON.
  79143. * @param json JSON serialization
  79144. * @returns deserialized TrajectorySet
  79145. */
  79146. static Deserialize(json: string): TrajectoryClassifier;
  79147. /**
  79148. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79149. * VERY naive, need to be generating these things from known
  79150. * sets. Better version later, probably eliminating this one.
  79151. * @returns auto-generated TrajectorySet
  79152. */
  79153. static Generate(): TrajectoryClassifier;
  79154. private constructor();
  79155. /**
  79156. * Add a new Trajectory to the set with a given name.
  79157. * @param trajectory new Trajectory to be added
  79158. * @param classification name to which to add the Trajectory
  79159. */
  79160. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79161. /**
  79162. * Remove a known named trajectory and all Trajectories associated with it.
  79163. * @param classification name to remove
  79164. * @returns whether anything was removed
  79165. */
  79166. deleteClassification(classification: string): boolean;
  79167. /**
  79168. * Attempt to recognize a Trajectory from among all the classifications
  79169. * already known to the classifier.
  79170. * @param trajectory Trajectory to be recognized
  79171. * @returns classification of Trajectory if recognized, null otherwise
  79172. */
  79173. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79174. }
  79175. }
  79176. declare module "babylonjs/Misc/index" {
  79177. export * from "babylonjs/Misc/andOrNotEvaluator";
  79178. export * from "babylonjs/Misc/assetsManager";
  79179. export * from "babylonjs/Misc/basis";
  79180. export * from "babylonjs/Misc/dds";
  79181. export * from "babylonjs/Misc/decorators";
  79182. export * from "babylonjs/Misc/deferred";
  79183. export * from "babylonjs/Misc/environmentTextureTools";
  79184. export * from "babylonjs/Misc/meshExploder";
  79185. export * from "babylonjs/Misc/filesInput";
  79186. export * from "babylonjs/Misc/HighDynamicRange/index";
  79187. export * from "babylonjs/Misc/khronosTextureContainer";
  79188. export * from "babylonjs/Misc/observable";
  79189. export * from "babylonjs/Misc/performanceMonitor";
  79190. export * from "babylonjs/Misc/promise";
  79191. export * from "babylonjs/Misc/sceneOptimizer";
  79192. export * from "babylonjs/Misc/sceneSerializer";
  79193. export * from "babylonjs/Misc/smartArray";
  79194. export * from "babylonjs/Misc/stringDictionary";
  79195. export * from "babylonjs/Misc/tags";
  79196. export * from "babylonjs/Misc/textureTools";
  79197. export * from "babylonjs/Misc/tga";
  79198. export * from "babylonjs/Misc/tools";
  79199. export * from "babylonjs/Misc/videoRecorder";
  79200. export * from "babylonjs/Misc/virtualJoystick";
  79201. export * from "babylonjs/Misc/workerPool";
  79202. export * from "babylonjs/Misc/logger";
  79203. export * from "babylonjs/Misc/typeStore";
  79204. export * from "babylonjs/Misc/filesInputStore";
  79205. export * from "babylonjs/Misc/deepCopier";
  79206. export * from "babylonjs/Misc/pivotTools";
  79207. export * from "babylonjs/Misc/precisionDate";
  79208. export * from "babylonjs/Misc/screenshotTools";
  79209. export * from "babylonjs/Misc/typeStore";
  79210. export * from "babylonjs/Misc/webRequest";
  79211. export * from "babylonjs/Misc/iInspectable";
  79212. export * from "babylonjs/Misc/brdfTextureTools";
  79213. export * from "babylonjs/Misc/rgbdTextureTools";
  79214. export * from "babylonjs/Misc/gradients";
  79215. export * from "babylonjs/Misc/perfCounter";
  79216. export * from "babylonjs/Misc/fileRequest";
  79217. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79218. export * from "babylonjs/Misc/retryStrategy";
  79219. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79220. export * from "babylonjs/Misc/canvasGenerator";
  79221. export * from "babylonjs/Misc/fileTools";
  79222. export * from "babylonjs/Misc/stringTools";
  79223. export * from "babylonjs/Misc/dataReader";
  79224. export * from "babylonjs/Misc/minMaxReducer";
  79225. export * from "babylonjs/Misc/depthReducer";
  79226. export * from "babylonjs/Misc/dataStorage";
  79227. export * from "babylonjs/Misc/sceneRecorder";
  79228. export * from "babylonjs/Misc/khronosTextureContainer2";
  79229. export * from "babylonjs/Misc/trajectoryClassifier";
  79230. export * from "babylonjs/Misc/timer";
  79231. }
  79232. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79233. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79234. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79235. import { Observable } from "babylonjs/Misc/observable";
  79236. import { Matrix } from "babylonjs/Maths/math.vector";
  79237. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79238. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79239. /**
  79240. * An interface for all Hit test features
  79241. */
  79242. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79243. /**
  79244. * Triggered when new babylon (transformed) hit test results are available
  79245. */
  79246. onHitTestResultObservable: Observable<T[]>;
  79247. }
  79248. /**
  79249. * Options used for hit testing
  79250. */
  79251. export interface IWebXRLegacyHitTestOptions {
  79252. /**
  79253. * Only test when user interacted with the scene. Default - hit test every frame
  79254. */
  79255. testOnPointerDownOnly?: boolean;
  79256. /**
  79257. * The node to use to transform the local results to world coordinates
  79258. */
  79259. worldParentNode?: TransformNode;
  79260. }
  79261. /**
  79262. * Interface defining the babylon result of raycasting/hit-test
  79263. */
  79264. export interface IWebXRLegacyHitResult {
  79265. /**
  79266. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79267. */
  79268. transformationMatrix: Matrix;
  79269. /**
  79270. * The native hit test result
  79271. */
  79272. xrHitResult: XRHitResult | XRHitTestResult;
  79273. }
  79274. /**
  79275. * The currently-working hit-test module.
  79276. * Hit test (or Ray-casting) is used to interact with the real world.
  79277. * For further information read here - https://github.com/immersive-web/hit-test
  79278. */
  79279. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79280. /**
  79281. * options to use when constructing this feature
  79282. */
  79283. readonly options: IWebXRLegacyHitTestOptions;
  79284. private _direction;
  79285. private _mat;
  79286. private _onSelectEnabled;
  79287. private _origin;
  79288. /**
  79289. * The module's name
  79290. */
  79291. static readonly Name: string;
  79292. /**
  79293. * The (Babylon) version of this module.
  79294. * This is an integer representing the implementation version.
  79295. * This number does not correspond to the WebXR specs version
  79296. */
  79297. static readonly Version: number;
  79298. /**
  79299. * Populated with the last native XR Hit Results
  79300. */
  79301. lastNativeXRHitResults: XRHitResult[];
  79302. /**
  79303. * Triggered when new babylon (transformed) hit test results are available
  79304. */
  79305. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79306. /**
  79307. * Creates a new instance of the (legacy version) hit test feature
  79308. * @param _xrSessionManager an instance of WebXRSessionManager
  79309. * @param options options to use when constructing this feature
  79310. */
  79311. constructor(_xrSessionManager: WebXRSessionManager,
  79312. /**
  79313. * options to use when constructing this feature
  79314. */
  79315. options?: IWebXRLegacyHitTestOptions);
  79316. /**
  79317. * execute a hit test with an XR Ray
  79318. *
  79319. * @param xrSession a native xrSession that will execute this hit test
  79320. * @param xrRay the ray (position and direction) to use for ray-casting
  79321. * @param referenceSpace native XR reference space to use for the hit-test
  79322. * @param filter filter function that will filter the results
  79323. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79324. */
  79325. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79326. /**
  79327. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79328. * @param event the (select) event to use to select with
  79329. * @param referenceSpace the reference space to use for this hit test
  79330. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79331. */
  79332. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79333. /**
  79334. * attach this feature
  79335. * Will usually be called by the features manager
  79336. *
  79337. * @returns true if successful.
  79338. */
  79339. attach(): boolean;
  79340. /**
  79341. * detach this feature.
  79342. * Will usually be called by the features manager
  79343. *
  79344. * @returns true if successful.
  79345. */
  79346. detach(): boolean;
  79347. /**
  79348. * Dispose this feature and all of the resources attached
  79349. */
  79350. dispose(): void;
  79351. protected _onXRFrame(frame: XRFrame): void;
  79352. private _onHitTestResults;
  79353. private _onSelect;
  79354. }
  79355. }
  79356. declare module "babylonjs/XR/features/WebXRHitTest" {
  79357. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79358. import { Observable } from "babylonjs/Misc/observable";
  79359. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79360. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79361. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79362. /**
  79363. * Options used for hit testing (version 2)
  79364. */
  79365. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79366. /**
  79367. * Do not create a permanent hit test. Will usually be used when only
  79368. * transient inputs are needed.
  79369. */
  79370. disablePermanentHitTest?: boolean;
  79371. /**
  79372. * Enable transient (for example touch-based) hit test inspections
  79373. */
  79374. enableTransientHitTest?: boolean;
  79375. /**
  79376. * Offset ray for the permanent hit test
  79377. */
  79378. offsetRay?: Vector3;
  79379. /**
  79380. * Offset ray for the transient hit test
  79381. */
  79382. transientOffsetRay?: Vector3;
  79383. /**
  79384. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79385. */
  79386. useReferenceSpace?: boolean;
  79387. /**
  79388. * Override the default entity type(s) of the hit-test result
  79389. */
  79390. entityTypes?: XRHitTestTrackableType[];
  79391. }
  79392. /**
  79393. * Interface defining the babylon result of hit-test
  79394. */
  79395. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79396. /**
  79397. * The input source that generated this hit test (if transient)
  79398. */
  79399. inputSource?: XRInputSource;
  79400. /**
  79401. * Is this a transient hit test
  79402. */
  79403. isTransient?: boolean;
  79404. /**
  79405. * Position of the hit test result
  79406. */
  79407. position: Vector3;
  79408. /**
  79409. * Rotation of the hit test result
  79410. */
  79411. rotationQuaternion: Quaternion;
  79412. /**
  79413. * The native hit test result
  79414. */
  79415. xrHitResult: XRHitTestResult;
  79416. }
  79417. /**
  79418. * The currently-working hit-test module.
  79419. * Hit test (or Ray-casting) is used to interact with the real world.
  79420. * For further information read here - https://github.com/immersive-web/hit-test
  79421. *
  79422. * Tested on chrome (mobile) 80.
  79423. */
  79424. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79425. /**
  79426. * options to use when constructing this feature
  79427. */
  79428. readonly options: IWebXRHitTestOptions;
  79429. private _tmpMat;
  79430. private _tmpPos;
  79431. private _tmpQuat;
  79432. private _transientXrHitTestSource;
  79433. private _xrHitTestSource;
  79434. private initHitTestSource;
  79435. /**
  79436. * The module's name
  79437. */
  79438. static readonly Name: string;
  79439. /**
  79440. * The (Babylon) version of this module.
  79441. * This is an integer representing the implementation version.
  79442. * This number does not correspond to the WebXR specs version
  79443. */
  79444. static readonly Version: number;
  79445. /**
  79446. * When set to true, each hit test will have its own position/rotation objects
  79447. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79448. * the developers will clone them or copy them as they see fit.
  79449. */
  79450. autoCloneTransformation: boolean;
  79451. /**
  79452. * Triggered when new babylon (transformed) hit test results are available
  79453. * Note - this will be called when results come back from the device. It can be an empty array!!
  79454. */
  79455. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79456. /**
  79457. * Use this to temporarily pause hit test checks.
  79458. */
  79459. paused: boolean;
  79460. /**
  79461. * Creates a new instance of the hit test feature
  79462. * @param _xrSessionManager an instance of WebXRSessionManager
  79463. * @param options options to use when constructing this feature
  79464. */
  79465. constructor(_xrSessionManager: WebXRSessionManager,
  79466. /**
  79467. * options to use when constructing this feature
  79468. */
  79469. options?: IWebXRHitTestOptions);
  79470. /**
  79471. * attach this feature
  79472. * Will usually be called by the features manager
  79473. *
  79474. * @returns true if successful.
  79475. */
  79476. attach(): boolean;
  79477. /**
  79478. * detach this feature.
  79479. * Will usually be called by the features manager
  79480. *
  79481. * @returns true if successful.
  79482. */
  79483. detach(): boolean;
  79484. /**
  79485. * Dispose this feature and all of the resources attached
  79486. */
  79487. dispose(): void;
  79488. protected _onXRFrame(frame: XRFrame): void;
  79489. private _processWebXRHitTestResult;
  79490. }
  79491. }
  79492. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79493. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79494. import { Observable } from "babylonjs/Misc/observable";
  79495. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79497. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79498. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79499. /**
  79500. * Configuration options of the anchor system
  79501. */
  79502. export interface IWebXRAnchorSystemOptions {
  79503. /**
  79504. * a node that will be used to convert local to world coordinates
  79505. */
  79506. worldParentNode?: TransformNode;
  79507. /**
  79508. * If set to true a reference of the created anchors will be kept until the next session starts
  79509. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79510. */
  79511. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79512. }
  79513. /**
  79514. * A babylon container for an XR Anchor
  79515. */
  79516. export interface IWebXRAnchor {
  79517. /**
  79518. * A babylon-assigned ID for this anchor
  79519. */
  79520. id: number;
  79521. /**
  79522. * Transformation matrix to apply to an object attached to this anchor
  79523. */
  79524. transformationMatrix: Matrix;
  79525. /**
  79526. * The native anchor object
  79527. */
  79528. xrAnchor: XRAnchor;
  79529. /**
  79530. * if defined, this object will be constantly updated by the anchor's position and rotation
  79531. */
  79532. attachedNode?: TransformNode;
  79533. }
  79534. /**
  79535. * An implementation of the anchor system for WebXR.
  79536. * For further information see https://github.com/immersive-web/anchors/
  79537. */
  79538. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79539. private _options;
  79540. private _lastFrameDetected;
  79541. private _trackedAnchors;
  79542. private _referenceSpaceForFrameAnchors;
  79543. private _futureAnchors;
  79544. /**
  79545. * The module's name
  79546. */
  79547. static readonly Name: string;
  79548. /**
  79549. * The (Babylon) version of this module.
  79550. * This is an integer representing the implementation version.
  79551. * This number does not correspond to the WebXR specs version
  79552. */
  79553. static readonly Version: number;
  79554. /**
  79555. * Observers registered here will be executed when a new anchor was added to the session
  79556. */
  79557. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79558. /**
  79559. * Observers registered here will be executed when an anchor was removed from the session
  79560. */
  79561. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79562. /**
  79563. * Observers registered here will be executed when an existing anchor updates
  79564. * This can execute N times every frame
  79565. */
  79566. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79567. /**
  79568. * Set the reference space to use for anchor creation, when not using a hit test.
  79569. * Will default to the session's reference space if not defined
  79570. */
  79571. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79572. /**
  79573. * constructs a new anchor system
  79574. * @param _xrSessionManager an instance of WebXRSessionManager
  79575. * @param _options configuration object for this feature
  79576. */
  79577. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79578. private _tmpVector;
  79579. private _tmpQuaternion;
  79580. private _populateTmpTransformation;
  79581. /**
  79582. * Create a new anchor point using a hit test result at a specific point in the scene
  79583. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79584. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79585. *
  79586. * @param hitTestResult The hit test result to use for this anchor creation
  79587. * @param position an optional position offset for this anchor
  79588. * @param rotationQuaternion an optional rotation offset for this anchor
  79589. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79590. */
  79591. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79592. /**
  79593. * Add a new anchor at a specific position and rotation
  79594. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79595. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79596. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79597. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79598. *
  79599. * @param position the position in which to add an anchor
  79600. * @param rotationQuaternion an optional rotation for the anchor transformation
  79601. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79602. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79603. */
  79604. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79605. /**
  79606. * detach this feature.
  79607. * Will usually be called by the features manager
  79608. *
  79609. * @returns true if successful.
  79610. */
  79611. detach(): boolean;
  79612. /**
  79613. * Dispose this feature and all of the resources attached
  79614. */
  79615. dispose(): void;
  79616. protected _onXRFrame(frame: XRFrame): void;
  79617. /**
  79618. * avoiding using Array.find for global support.
  79619. * @param xrAnchor the plane to find in the array
  79620. */
  79621. private _findIndexInAnchorArray;
  79622. private _updateAnchorWithXRFrame;
  79623. private _createAnchorAtTransformation;
  79624. }
  79625. }
  79626. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79627. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79628. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79629. import { Observable } from "babylonjs/Misc/observable";
  79630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79631. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79632. /**
  79633. * Options used in the plane detector module
  79634. */
  79635. export interface IWebXRPlaneDetectorOptions {
  79636. /**
  79637. * The node to use to transform the local results to world coordinates
  79638. */
  79639. worldParentNode?: TransformNode;
  79640. /**
  79641. * If set to true a reference of the created planes will be kept until the next session starts
  79642. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79643. */
  79644. doNotRemovePlanesOnSessionEnded?: boolean;
  79645. }
  79646. /**
  79647. * A babylon interface for a WebXR plane.
  79648. * A Plane is actually a polygon, built from N points in space
  79649. *
  79650. * Supported in chrome 79, not supported in canary 81 ATM
  79651. */
  79652. export interface IWebXRPlane {
  79653. /**
  79654. * a babylon-assigned ID for this polygon
  79655. */
  79656. id: number;
  79657. /**
  79658. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79659. */
  79660. polygonDefinition: Array<Vector3>;
  79661. /**
  79662. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79663. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79664. */
  79665. transformationMatrix: Matrix;
  79666. /**
  79667. * the native xr-plane object
  79668. */
  79669. xrPlane: XRPlane;
  79670. }
  79671. /**
  79672. * The plane detector is used to detect planes in the real world when in AR
  79673. * For more information see https://github.com/immersive-web/real-world-geometry/
  79674. */
  79675. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79676. private _options;
  79677. private _detectedPlanes;
  79678. private _enabled;
  79679. private _lastFrameDetected;
  79680. /**
  79681. * The module's name
  79682. */
  79683. static readonly Name: string;
  79684. /**
  79685. * The (Babylon) version of this module.
  79686. * This is an integer representing the implementation version.
  79687. * This number does not correspond to the WebXR specs version
  79688. */
  79689. static readonly Version: number;
  79690. /**
  79691. * Observers registered here will be executed when a new plane was added to the session
  79692. */
  79693. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79694. /**
  79695. * Observers registered here will be executed when a plane is no longer detected in the session
  79696. */
  79697. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79698. /**
  79699. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79700. * This can execute N times every frame
  79701. */
  79702. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79703. /**
  79704. * construct a new Plane Detector
  79705. * @param _xrSessionManager an instance of xr Session manager
  79706. * @param _options configuration to use when constructing this feature
  79707. */
  79708. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79709. /**
  79710. * detach this feature.
  79711. * Will usually be called by the features manager
  79712. *
  79713. * @returns true if successful.
  79714. */
  79715. detach(): boolean;
  79716. /**
  79717. * Dispose this feature and all of the resources attached
  79718. */
  79719. dispose(): void;
  79720. protected _onXRFrame(frame: XRFrame): void;
  79721. private _init;
  79722. private _updatePlaneWithXRPlane;
  79723. /**
  79724. * avoiding using Array.find for global support.
  79725. * @param xrPlane the plane to find in the array
  79726. */
  79727. private findIndexInPlaneArray;
  79728. }
  79729. }
  79730. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79731. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79733. import { Observable } from "babylonjs/Misc/observable";
  79734. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79735. /**
  79736. * Options interface for the background remover plugin
  79737. */
  79738. export interface IWebXRBackgroundRemoverOptions {
  79739. /**
  79740. * Further background meshes to disable when entering AR
  79741. */
  79742. backgroundMeshes?: AbstractMesh[];
  79743. /**
  79744. * flags to configure the removal of the environment helper.
  79745. * If not set, the entire background will be removed. If set, flags should be set as well.
  79746. */
  79747. environmentHelperRemovalFlags?: {
  79748. /**
  79749. * Should the skybox be removed (default false)
  79750. */
  79751. skyBox?: boolean;
  79752. /**
  79753. * Should the ground be removed (default false)
  79754. */
  79755. ground?: boolean;
  79756. };
  79757. /**
  79758. * don't disable the environment helper
  79759. */
  79760. ignoreEnvironmentHelper?: boolean;
  79761. }
  79762. /**
  79763. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79764. */
  79765. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79766. /**
  79767. * read-only options to be used in this module
  79768. */
  79769. readonly options: IWebXRBackgroundRemoverOptions;
  79770. /**
  79771. * The module's name
  79772. */
  79773. static readonly Name: string;
  79774. /**
  79775. * The (Babylon) version of this module.
  79776. * This is an integer representing the implementation version.
  79777. * This number does not correspond to the WebXR specs version
  79778. */
  79779. static readonly Version: number;
  79780. /**
  79781. * registered observers will be triggered when the background state changes
  79782. */
  79783. onBackgroundStateChangedObservable: Observable<boolean>;
  79784. /**
  79785. * constructs a new background remover module
  79786. * @param _xrSessionManager the session manager for this module
  79787. * @param options read-only options to be used in this module
  79788. */
  79789. constructor(_xrSessionManager: WebXRSessionManager,
  79790. /**
  79791. * read-only options to be used in this module
  79792. */
  79793. options?: IWebXRBackgroundRemoverOptions);
  79794. /**
  79795. * attach this feature
  79796. * Will usually be called by the features manager
  79797. *
  79798. * @returns true if successful.
  79799. */
  79800. attach(): boolean;
  79801. /**
  79802. * detach this feature.
  79803. * Will usually be called by the features manager
  79804. *
  79805. * @returns true if successful.
  79806. */
  79807. detach(): boolean;
  79808. /**
  79809. * Dispose this feature and all of the resources attached
  79810. */
  79811. dispose(): void;
  79812. protected _onXRFrame(_xrFrame: XRFrame): void;
  79813. private _setBackgroundState;
  79814. }
  79815. }
  79816. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79817. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79818. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79819. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79820. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79821. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79822. import { Nullable } from "babylonjs/types";
  79823. /**
  79824. * Options for the controller physics feature
  79825. */
  79826. export class IWebXRControllerPhysicsOptions {
  79827. /**
  79828. * Should the headset get its own impostor
  79829. */
  79830. enableHeadsetImpostor?: boolean;
  79831. /**
  79832. * Optional parameters for the headset impostor
  79833. */
  79834. headsetImpostorParams?: {
  79835. /**
  79836. * The type of impostor to create. Default is sphere
  79837. */
  79838. impostorType: number;
  79839. /**
  79840. * the size of the impostor. Defaults to 10cm
  79841. */
  79842. impostorSize?: number | {
  79843. width: number;
  79844. height: number;
  79845. depth: number;
  79846. };
  79847. /**
  79848. * Friction definitions
  79849. */
  79850. friction?: number;
  79851. /**
  79852. * Restitution
  79853. */
  79854. restitution?: number;
  79855. };
  79856. /**
  79857. * The physics properties of the future impostors
  79858. */
  79859. physicsProperties?: {
  79860. /**
  79861. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79862. * Note that this requires a physics engine that supports mesh impostors!
  79863. */
  79864. useControllerMesh?: boolean;
  79865. /**
  79866. * The type of impostor to create. Default is sphere
  79867. */
  79868. impostorType?: number;
  79869. /**
  79870. * the size of the impostor. Defaults to 10cm
  79871. */
  79872. impostorSize?: number | {
  79873. width: number;
  79874. height: number;
  79875. depth: number;
  79876. };
  79877. /**
  79878. * Friction definitions
  79879. */
  79880. friction?: number;
  79881. /**
  79882. * Restitution
  79883. */
  79884. restitution?: number;
  79885. };
  79886. /**
  79887. * the xr input to use with this pointer selection
  79888. */
  79889. xrInput: WebXRInput;
  79890. }
  79891. /**
  79892. * Add physics impostor to your webxr controllers,
  79893. * including naive calculation of their linear and angular velocity
  79894. */
  79895. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79896. private readonly _options;
  79897. private _attachController;
  79898. private _controllers;
  79899. private _debugMode;
  79900. private _delta;
  79901. private _headsetImpostor?;
  79902. private _headsetMesh?;
  79903. private _lastTimestamp;
  79904. private _tmpQuaternion;
  79905. private _tmpVector;
  79906. /**
  79907. * The module's name
  79908. */
  79909. static readonly Name: string;
  79910. /**
  79911. * The (Babylon) version of this module.
  79912. * This is an integer representing the implementation version.
  79913. * This number does not correspond to the webxr specs version
  79914. */
  79915. static readonly Version: number;
  79916. /**
  79917. * Construct a new Controller Physics Feature
  79918. * @param _xrSessionManager the corresponding xr session manager
  79919. * @param _options options to create this feature with
  79920. */
  79921. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79922. /**
  79923. * @hidden
  79924. * enable debugging - will show console outputs and the impostor mesh
  79925. */
  79926. _enablePhysicsDebug(): void;
  79927. /**
  79928. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79929. * @param xrController the controller to add
  79930. */
  79931. addController(xrController: WebXRInputSource): void;
  79932. /**
  79933. * attach this feature
  79934. * Will usually be called by the features manager
  79935. *
  79936. * @returns true if successful.
  79937. */
  79938. attach(): boolean;
  79939. /**
  79940. * detach this feature.
  79941. * Will usually be called by the features manager
  79942. *
  79943. * @returns true if successful.
  79944. */
  79945. detach(): boolean;
  79946. /**
  79947. * Get the headset impostor, if enabled
  79948. * @returns the impostor
  79949. */
  79950. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79951. /**
  79952. * Get the physics impostor of a specific controller.
  79953. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79954. * @param controller the controller or the controller id of which to get the impostor
  79955. * @returns the impostor or null
  79956. */
  79957. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79958. /**
  79959. * Update the physics properties provided in the constructor
  79960. * @param newProperties the new properties object
  79961. */
  79962. setPhysicsProperties(newProperties: {
  79963. impostorType?: number;
  79964. impostorSize?: number | {
  79965. width: number;
  79966. height: number;
  79967. depth: number;
  79968. };
  79969. friction?: number;
  79970. restitution?: number;
  79971. }): void;
  79972. protected _onXRFrame(_xrFrame: any): void;
  79973. private _detachController;
  79974. }
  79975. }
  79976. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79977. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79978. import { Observable } from "babylonjs/Misc/observable";
  79979. import { Vector3 } from "babylonjs/Maths/math.vector";
  79980. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79981. /**
  79982. * A babylon interface for a "WebXR" feature point.
  79983. * Represents the position and confidence value of a given feature point.
  79984. */
  79985. export interface IWebXRFeaturePoint {
  79986. /**
  79987. * Represents the position of the feature point in world space.
  79988. */
  79989. position: Vector3;
  79990. /**
  79991. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79992. */
  79993. confidenceValue: number;
  79994. }
  79995. /**
  79996. * The feature point system is used to detect feature points from real world geometry.
  79997. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79998. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79999. */
  80000. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80001. private _enabled;
  80002. private _featurePointCloud;
  80003. /**
  80004. * The module's name
  80005. */
  80006. static readonly Name: string;
  80007. /**
  80008. * The (Babylon) version of this module.
  80009. * This is an integer representing the implementation version.
  80010. * This number does not correspond to the WebXR specs version
  80011. */
  80012. static readonly Version: number;
  80013. /**
  80014. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80015. * Will notify the observers about which feature points have been added.
  80016. */
  80017. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80018. /**
  80019. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80020. * Will notify the observers about which feature points have been updated.
  80021. */
  80022. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80023. /**
  80024. * The current feature point cloud maintained across frames.
  80025. */
  80026. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80027. /**
  80028. * construct the feature point system
  80029. * @param _xrSessionManager an instance of xr Session manager
  80030. */
  80031. constructor(_xrSessionManager: WebXRSessionManager);
  80032. /**
  80033. * Detach this feature.
  80034. * Will usually be called by the features manager
  80035. *
  80036. * @returns true if successful.
  80037. */
  80038. detach(): boolean;
  80039. /**
  80040. * Dispose this feature and all of the resources attached
  80041. */
  80042. dispose(): void;
  80043. /**
  80044. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80045. */
  80046. protected _onXRFrame(frame: XRFrame): void;
  80047. /**
  80048. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80049. */
  80050. private _init;
  80051. }
  80052. }
  80053. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80054. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80055. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80057. import { Mesh } from "babylonjs/Meshes/mesh";
  80058. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80059. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80060. import { Nullable } from "babylonjs/types";
  80061. import { IDisposable } from "babylonjs/scene";
  80062. import { Observable } from "babylonjs/Misc/observable";
  80063. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80064. /**
  80065. * Configuration interface for the hand tracking feature
  80066. */
  80067. export interface IWebXRHandTrackingOptions {
  80068. /**
  80069. * The xrInput that will be used as source for new hands
  80070. */
  80071. xrInput: WebXRInput;
  80072. /**
  80073. * Configuration object for the joint meshes
  80074. */
  80075. jointMeshes?: {
  80076. /**
  80077. * Should the meshes created be invisible (defaults to false)
  80078. */
  80079. invisible?: boolean;
  80080. /**
  80081. * A source mesh to be used to create instances. Defaults to a sphere.
  80082. * This mesh will be the source for all other (25) meshes.
  80083. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80084. */
  80085. sourceMesh?: Mesh;
  80086. /**
  80087. * This function will be called after a mesh was created for a specific joint.
  80088. * Using this function you can either manipulate the instance or return a new mesh.
  80089. * When returning a new mesh the instance created before will be disposed
  80090. */
  80091. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80092. /**
  80093. * Should the source mesh stay visible. Defaults to false
  80094. */
  80095. keepOriginalVisible?: boolean;
  80096. /**
  80097. * Scale factor for all instances (defaults to 2)
  80098. */
  80099. scaleFactor?: number;
  80100. /**
  80101. * Should each instance have its own physics impostor
  80102. */
  80103. enablePhysics?: boolean;
  80104. /**
  80105. * If enabled, override default physics properties
  80106. */
  80107. physicsProps?: {
  80108. friction?: number;
  80109. restitution?: number;
  80110. impostorType?: number;
  80111. };
  80112. /**
  80113. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80114. */
  80115. handMesh?: AbstractMesh;
  80116. };
  80117. }
  80118. /**
  80119. * Parts of the hands divided to writs and finger names
  80120. */
  80121. export const enum HandPart {
  80122. /**
  80123. * HandPart - Wrist
  80124. */
  80125. WRIST = "wrist",
  80126. /**
  80127. * HandPart - The THumb
  80128. */
  80129. THUMB = "thumb",
  80130. /**
  80131. * HandPart - Index finger
  80132. */
  80133. INDEX = "index",
  80134. /**
  80135. * HandPart - Middle finger
  80136. */
  80137. MIDDLE = "middle",
  80138. /**
  80139. * HandPart - Ring finger
  80140. */
  80141. RING = "ring",
  80142. /**
  80143. * HandPart - Little finger
  80144. */
  80145. LITTLE = "little"
  80146. }
  80147. /**
  80148. * Representing a single hand (with its corresponding native XRHand object)
  80149. */
  80150. export class WebXRHand implements IDisposable {
  80151. /** the controller to which the hand correlates */
  80152. readonly xrController: WebXRInputSource;
  80153. /** the meshes to be used to track the hand joints */
  80154. readonly trackedMeshes: AbstractMesh[];
  80155. /**
  80156. * Hand-parts definition (key is HandPart)
  80157. */
  80158. handPartsDefinition: {
  80159. [key: string]: number[];
  80160. };
  80161. /**
  80162. * Populate the HandPartsDefinition object.
  80163. * This is called as a side effect since certain browsers don't have XRHand defined.
  80164. */
  80165. private generateHandPartsDefinition;
  80166. /**
  80167. * Construct a new hand object
  80168. * @param xrController the controller to which the hand correlates
  80169. * @param trackedMeshes the meshes to be used to track the hand joints
  80170. */
  80171. constructor(
  80172. /** the controller to which the hand correlates */
  80173. xrController: WebXRInputSource,
  80174. /** the meshes to be used to track the hand joints */
  80175. trackedMeshes: AbstractMesh[]);
  80176. /**
  80177. * Update this hand from the latest xr frame
  80178. * @param xrFrame xrFrame to update from
  80179. * @param referenceSpace The current viewer reference space
  80180. * @param scaleFactor optional scale factor for the meshes
  80181. */
  80182. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80183. /**
  80184. * Get meshes of part of the hand
  80185. * @param part the part of hand to get
  80186. * @returns An array of meshes that correlate to the hand part requested
  80187. */
  80188. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80189. /**
  80190. * Dispose this Hand object
  80191. */
  80192. dispose(): void;
  80193. }
  80194. /**
  80195. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80196. */
  80197. export class WebXRHandTracking extends WebXRAbstractFeature {
  80198. /**
  80199. * options to use when constructing this feature
  80200. */
  80201. readonly options: IWebXRHandTrackingOptions;
  80202. private static _idCounter;
  80203. /**
  80204. * The module's name
  80205. */
  80206. static readonly Name: string;
  80207. /**
  80208. * The (Babylon) version of this module.
  80209. * This is an integer representing the implementation version.
  80210. * This number does not correspond to the WebXR specs version
  80211. */
  80212. static readonly Version: number;
  80213. /**
  80214. * This observable will notify registered observers when a new hand object was added and initialized
  80215. */
  80216. onHandAddedObservable: Observable<WebXRHand>;
  80217. /**
  80218. * This observable will notify its observers right before the hand object is disposed
  80219. */
  80220. onHandRemovedObservable: Observable<WebXRHand>;
  80221. private _hands;
  80222. /**
  80223. * Creates a new instance of the hit test feature
  80224. * @param _xrSessionManager an instance of WebXRSessionManager
  80225. * @param options options to use when constructing this feature
  80226. */
  80227. constructor(_xrSessionManager: WebXRSessionManager,
  80228. /**
  80229. * options to use when constructing this feature
  80230. */
  80231. options: IWebXRHandTrackingOptions);
  80232. /**
  80233. * Check if the needed objects are defined.
  80234. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80235. */
  80236. isCompatible(): boolean;
  80237. /**
  80238. * attach this feature
  80239. * Will usually be called by the features manager
  80240. *
  80241. * @returns true if successful.
  80242. */
  80243. attach(): boolean;
  80244. /**
  80245. * detach this feature.
  80246. * Will usually be called by the features manager
  80247. *
  80248. * @returns true if successful.
  80249. */
  80250. detach(): boolean;
  80251. /**
  80252. * Dispose this feature and all of the resources attached
  80253. */
  80254. dispose(): void;
  80255. /**
  80256. * Get the hand object according to the controller id
  80257. * @param controllerId the controller id to which we want to get the hand
  80258. * @returns null if not found or the WebXRHand object if found
  80259. */
  80260. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80261. /**
  80262. * Get a hand object according to the requested handedness
  80263. * @param handedness the handedness to request
  80264. * @returns null if not found or the WebXRHand object if found
  80265. */
  80266. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80267. protected _onXRFrame(_xrFrame: XRFrame): void;
  80268. private _attachHand;
  80269. private _detachHand;
  80270. }
  80271. }
  80272. declare module "babylonjs/XR/features/index" {
  80273. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80274. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80275. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80276. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80277. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80278. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80279. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80280. export * from "babylonjs/XR/features/WebXRHitTest";
  80281. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80282. export * from "babylonjs/XR/features/WebXRHandTracking";
  80283. }
  80284. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80285. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80287. import { Scene } from "babylonjs/scene";
  80288. /**
  80289. * The motion controller class for all microsoft mixed reality controllers
  80290. */
  80291. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80292. protected readonly _mapping: {
  80293. defaultButton: {
  80294. valueNodeName: string;
  80295. unpressedNodeName: string;
  80296. pressedNodeName: string;
  80297. };
  80298. defaultAxis: {
  80299. valueNodeName: string;
  80300. minNodeName: string;
  80301. maxNodeName: string;
  80302. };
  80303. buttons: {
  80304. "xr-standard-trigger": {
  80305. rootNodeName: string;
  80306. componentProperty: string;
  80307. states: string[];
  80308. };
  80309. "xr-standard-squeeze": {
  80310. rootNodeName: string;
  80311. componentProperty: string;
  80312. states: string[];
  80313. };
  80314. "xr-standard-touchpad": {
  80315. rootNodeName: string;
  80316. labelAnchorNodeName: string;
  80317. touchPointNodeName: string;
  80318. };
  80319. "xr-standard-thumbstick": {
  80320. rootNodeName: string;
  80321. componentProperty: string;
  80322. states: string[];
  80323. };
  80324. };
  80325. axes: {
  80326. "xr-standard-touchpad": {
  80327. "x-axis": {
  80328. rootNodeName: string;
  80329. };
  80330. "y-axis": {
  80331. rootNodeName: string;
  80332. };
  80333. };
  80334. "xr-standard-thumbstick": {
  80335. "x-axis": {
  80336. rootNodeName: string;
  80337. };
  80338. "y-axis": {
  80339. rootNodeName: string;
  80340. };
  80341. };
  80342. };
  80343. };
  80344. /**
  80345. * The base url used to load the left and right controller models
  80346. */
  80347. static MODEL_BASE_URL: string;
  80348. /**
  80349. * The name of the left controller model file
  80350. */
  80351. static MODEL_LEFT_FILENAME: string;
  80352. /**
  80353. * The name of the right controller model file
  80354. */
  80355. static MODEL_RIGHT_FILENAME: string;
  80356. profileId: string;
  80357. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80358. protected _getFilenameAndPath(): {
  80359. filename: string;
  80360. path: string;
  80361. };
  80362. protected _getModelLoadingConstraints(): boolean;
  80363. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80364. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80365. protected _updateModel(): void;
  80366. }
  80367. }
  80368. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80369. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80371. import { Scene } from "babylonjs/scene";
  80372. /**
  80373. * The motion controller class for oculus touch (quest, rift).
  80374. * This class supports legacy mapping as well the standard xr mapping
  80375. */
  80376. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80377. private _forceLegacyControllers;
  80378. private _modelRootNode;
  80379. /**
  80380. * The base url used to load the left and right controller models
  80381. */
  80382. static MODEL_BASE_URL: string;
  80383. /**
  80384. * The name of the left controller model file
  80385. */
  80386. static MODEL_LEFT_FILENAME: string;
  80387. /**
  80388. * The name of the right controller model file
  80389. */
  80390. static MODEL_RIGHT_FILENAME: string;
  80391. /**
  80392. * Base Url for the Quest controller model.
  80393. */
  80394. static QUEST_MODEL_BASE_URL: string;
  80395. profileId: string;
  80396. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80397. protected _getFilenameAndPath(): {
  80398. filename: string;
  80399. path: string;
  80400. };
  80401. protected _getModelLoadingConstraints(): boolean;
  80402. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80403. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80404. protected _updateModel(): void;
  80405. /**
  80406. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80407. * between the touch and touch 2.
  80408. */
  80409. private _isQuest;
  80410. }
  80411. }
  80412. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80413. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80414. import { Scene } from "babylonjs/scene";
  80415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80416. /**
  80417. * The motion controller class for the standard HTC-Vive controllers
  80418. */
  80419. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80420. private _modelRootNode;
  80421. /**
  80422. * The base url used to load the left and right controller models
  80423. */
  80424. static MODEL_BASE_URL: string;
  80425. /**
  80426. * File name for the controller model.
  80427. */
  80428. static MODEL_FILENAME: string;
  80429. profileId: string;
  80430. /**
  80431. * Create a new Vive motion controller object
  80432. * @param scene the scene to use to create this controller
  80433. * @param gamepadObject the corresponding gamepad object
  80434. * @param handedness the handedness of the controller
  80435. */
  80436. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80437. protected _getFilenameAndPath(): {
  80438. filename: string;
  80439. path: string;
  80440. };
  80441. protected _getModelLoadingConstraints(): boolean;
  80442. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80443. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80444. protected _updateModel(): void;
  80445. }
  80446. }
  80447. declare module "babylonjs/XR/motionController/index" {
  80448. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80449. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80450. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80451. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80452. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80453. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80454. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80455. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80456. }
  80457. declare module "babylonjs/XR/index" {
  80458. export * from "babylonjs/XR/webXRCamera";
  80459. export * from "babylonjs/XR/webXREnterExitUI";
  80460. export * from "babylonjs/XR/webXRExperienceHelper";
  80461. export * from "babylonjs/XR/webXRInput";
  80462. export * from "babylonjs/XR/webXRInputSource";
  80463. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80464. export * from "babylonjs/XR/webXRTypes";
  80465. export * from "babylonjs/XR/webXRSessionManager";
  80466. export * from "babylonjs/XR/webXRDefaultExperience";
  80467. export * from "babylonjs/XR/webXRFeaturesManager";
  80468. export * from "babylonjs/XR/features/index";
  80469. export * from "babylonjs/XR/motionController/index";
  80470. }
  80471. declare module "babylonjs/index" {
  80472. export * from "babylonjs/abstractScene";
  80473. export * from "babylonjs/Actions/index";
  80474. export * from "babylonjs/Animations/index";
  80475. export * from "babylonjs/assetContainer";
  80476. export * from "babylonjs/Audio/index";
  80477. export * from "babylonjs/Behaviors/index";
  80478. export * from "babylonjs/Bones/index";
  80479. export * from "babylonjs/Cameras/index";
  80480. export * from "babylonjs/Collisions/index";
  80481. export * from "babylonjs/Culling/index";
  80482. export * from "babylonjs/Debug/index";
  80483. export * from "babylonjs/DeviceInput/index";
  80484. export * from "babylonjs/Engines/index";
  80485. export * from "babylonjs/Events/index";
  80486. export * from "babylonjs/Gamepads/index";
  80487. export * from "babylonjs/Gizmos/index";
  80488. export * from "babylonjs/Helpers/index";
  80489. export * from "babylonjs/Instrumentation/index";
  80490. export * from "babylonjs/Layers/index";
  80491. export * from "babylonjs/LensFlares/index";
  80492. export * from "babylonjs/Lights/index";
  80493. export * from "babylonjs/Loading/index";
  80494. export * from "babylonjs/Materials/index";
  80495. export * from "babylonjs/Maths/index";
  80496. export * from "babylonjs/Meshes/index";
  80497. export * from "babylonjs/Morph/index";
  80498. export * from "babylonjs/Navigation/index";
  80499. export * from "babylonjs/node";
  80500. export * from "babylonjs/Offline/index";
  80501. export * from "babylonjs/Particles/index";
  80502. export * from "babylonjs/Physics/index";
  80503. export * from "babylonjs/PostProcesses/index";
  80504. export * from "babylonjs/Probes/index";
  80505. export * from "babylonjs/Rendering/index";
  80506. export * from "babylonjs/scene";
  80507. export * from "babylonjs/sceneComponent";
  80508. export * from "babylonjs/Sprites/index";
  80509. export * from "babylonjs/States/index";
  80510. export * from "babylonjs/Misc/index";
  80511. export * from "babylonjs/XR/index";
  80512. export * from "babylonjs/types";
  80513. }
  80514. declare module "babylonjs/Animations/pathCursor" {
  80515. import { Vector3 } from "babylonjs/Maths/math.vector";
  80516. import { Path2 } from "babylonjs/Maths/math.path";
  80517. /**
  80518. * A cursor which tracks a point on a path
  80519. */
  80520. export class PathCursor {
  80521. private path;
  80522. /**
  80523. * Stores path cursor callbacks for when an onchange event is triggered
  80524. */
  80525. private _onchange;
  80526. /**
  80527. * The value of the path cursor
  80528. */
  80529. value: number;
  80530. /**
  80531. * The animation array of the path cursor
  80532. */
  80533. animations: Animation[];
  80534. /**
  80535. * Initializes the path cursor
  80536. * @param path The path to track
  80537. */
  80538. constructor(path: Path2);
  80539. /**
  80540. * Gets the cursor point on the path
  80541. * @returns A point on the path cursor at the cursor location
  80542. */
  80543. getPoint(): Vector3;
  80544. /**
  80545. * Moves the cursor ahead by the step amount
  80546. * @param step The amount to move the cursor forward
  80547. * @returns This path cursor
  80548. */
  80549. moveAhead(step?: number): PathCursor;
  80550. /**
  80551. * Moves the cursor behind by the step amount
  80552. * @param step The amount to move the cursor back
  80553. * @returns This path cursor
  80554. */
  80555. moveBack(step?: number): PathCursor;
  80556. /**
  80557. * Moves the cursor by the step amount
  80558. * If the step amount is greater than one, an exception is thrown
  80559. * @param step The amount to move the cursor
  80560. * @returns This path cursor
  80561. */
  80562. move(step: number): PathCursor;
  80563. /**
  80564. * Ensures that the value is limited between zero and one
  80565. * @returns This path cursor
  80566. */
  80567. private ensureLimits;
  80568. /**
  80569. * Runs onchange callbacks on change (used by the animation engine)
  80570. * @returns This path cursor
  80571. */
  80572. private raiseOnChange;
  80573. /**
  80574. * Executes a function on change
  80575. * @param f A path cursor onchange callback
  80576. * @returns This path cursor
  80577. */
  80578. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80579. }
  80580. }
  80581. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80582. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80583. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80584. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80585. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80586. }
  80587. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80588. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80589. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80590. }
  80591. declare module "babylonjs/Engines/Processors/index" {
  80592. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80593. export * from "babylonjs/Engines/Processors/Expressions/index";
  80594. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80595. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80596. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80597. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80598. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80599. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80600. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80601. }
  80602. declare module "babylonjs/Legacy/legacy" {
  80603. import * as Babylon from "babylonjs/index";
  80604. export * from "babylonjs/index";
  80605. }
  80606. declare module "babylonjs/Shaders/blur.fragment" {
  80607. /** @hidden */
  80608. export var blurPixelShader: {
  80609. name: string;
  80610. shader: string;
  80611. };
  80612. }
  80613. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80614. /** @hidden */
  80615. export var pointCloudVertexDeclaration: {
  80616. name: string;
  80617. shader: string;
  80618. };
  80619. }
  80620. declare module "babylonjs" {
  80621. export * from "babylonjs/Legacy/legacy";
  80622. }
  80623. declare module BABYLON {
  80624. /** Alias type for value that can be null */
  80625. export type Nullable<T> = T | null;
  80626. /**
  80627. * Alias type for number that are floats
  80628. * @ignorenaming
  80629. */
  80630. export type float = number;
  80631. /**
  80632. * Alias type for number that are doubles.
  80633. * @ignorenaming
  80634. */
  80635. export type double = number;
  80636. /**
  80637. * Alias type for number that are integer
  80638. * @ignorenaming
  80639. */
  80640. export type int = number;
  80641. /** Alias type for number array or Float32Array */
  80642. export type FloatArray = number[] | Float32Array;
  80643. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80644. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80645. /**
  80646. * Alias for types that can be used by a Buffer or VertexBuffer.
  80647. */
  80648. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80649. /**
  80650. * Alias type for primitive types
  80651. * @ignorenaming
  80652. */
  80653. type Primitive = undefined | null | boolean | string | number | Function;
  80654. /**
  80655. * Type modifier to make all the properties of an object Readonly
  80656. */
  80657. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80658. /**
  80659. * Type modifier to make all the properties of an object Readonly recursively
  80660. */
  80661. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80662. /**
  80663. * Type modifier to make object properties readonly.
  80664. */
  80665. export type DeepImmutableObject<T> = {
  80666. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80667. };
  80668. /** @hidden */
  80669. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80670. }
  80671. }
  80672. declare module BABYLON {
  80673. /**
  80674. * A class serves as a medium between the observable and its observers
  80675. */
  80676. export class EventState {
  80677. /**
  80678. * Create a new EventState
  80679. * @param mask defines the mask associated with this state
  80680. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80681. * @param target defines the original target of the state
  80682. * @param currentTarget defines the current target of the state
  80683. */
  80684. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80685. /**
  80686. * Initialize the current event state
  80687. * @param mask defines the mask associated with this state
  80688. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80689. * @param target defines the original target of the state
  80690. * @param currentTarget defines the current target of the state
  80691. * @returns the current event state
  80692. */
  80693. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80694. /**
  80695. * An Observer can set this property to true to prevent subsequent observers of being notified
  80696. */
  80697. skipNextObservers: boolean;
  80698. /**
  80699. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80700. */
  80701. mask: number;
  80702. /**
  80703. * The object that originally notified the event
  80704. */
  80705. target?: any;
  80706. /**
  80707. * The current object in the bubbling phase
  80708. */
  80709. currentTarget?: any;
  80710. /**
  80711. * This will be populated with the return value of the last function that was executed.
  80712. * If it is the first function in the callback chain it will be the event data.
  80713. */
  80714. lastReturnValue?: any;
  80715. }
  80716. /**
  80717. * Represent an Observer registered to a given Observable object.
  80718. */
  80719. export class Observer<T> {
  80720. /**
  80721. * Defines the callback to call when the observer is notified
  80722. */
  80723. callback: (eventData: T, eventState: EventState) => void;
  80724. /**
  80725. * Defines the mask of the observer (used to filter notifications)
  80726. */
  80727. mask: number;
  80728. /**
  80729. * Defines the current scope used to restore the JS context
  80730. */
  80731. scope: any;
  80732. /** @hidden */
  80733. _willBeUnregistered: boolean;
  80734. /**
  80735. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80736. */
  80737. unregisterOnNextCall: boolean;
  80738. /**
  80739. * Creates a new observer
  80740. * @param callback defines the callback to call when the observer is notified
  80741. * @param mask defines the mask of the observer (used to filter notifications)
  80742. * @param scope defines the current scope used to restore the JS context
  80743. */
  80744. constructor(
  80745. /**
  80746. * Defines the callback to call when the observer is notified
  80747. */
  80748. callback: (eventData: T, eventState: EventState) => void,
  80749. /**
  80750. * Defines the mask of the observer (used to filter notifications)
  80751. */
  80752. mask: number,
  80753. /**
  80754. * Defines the current scope used to restore the JS context
  80755. */
  80756. scope?: any);
  80757. }
  80758. /**
  80759. * Represent a list of observers registered to multiple Observables object.
  80760. */
  80761. export class MultiObserver<T> {
  80762. private _observers;
  80763. private _observables;
  80764. /**
  80765. * Release associated resources
  80766. */
  80767. dispose(): void;
  80768. /**
  80769. * Raise a callback when one of the observable will notify
  80770. * @param observables defines a list of observables to watch
  80771. * @param callback defines the callback to call on notification
  80772. * @param mask defines the mask used to filter notifications
  80773. * @param scope defines the current scope used to restore the JS context
  80774. * @returns the new MultiObserver
  80775. */
  80776. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80777. }
  80778. /**
  80779. * The Observable class is a simple implementation of the Observable pattern.
  80780. *
  80781. * 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.
  80782. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80783. * 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).
  80784. * 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.
  80785. */
  80786. export class Observable<T> {
  80787. private _observers;
  80788. private _eventState;
  80789. private _onObserverAdded;
  80790. /**
  80791. * Gets the list of observers
  80792. */
  80793. get observers(): Array<Observer<T>>;
  80794. /**
  80795. * Creates a new observable
  80796. * @param onObserverAdded defines a callback to call when a new observer is added
  80797. */
  80798. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80799. /**
  80800. * Create a new Observer with the specified callback
  80801. * @param callback the callback that will be executed for that Observer
  80802. * @param mask the mask used to filter observers
  80803. * @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.
  80804. * @param scope optional scope for the callback to be called from
  80805. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80806. * @returns the new observer created for the callback
  80807. */
  80808. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80809. /**
  80810. * Create a new Observer with the specified callback and unregisters after the next notification
  80811. * @param callback the callback that will be executed for that Observer
  80812. * @returns the new observer created for the callback
  80813. */
  80814. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80815. /**
  80816. * Remove an Observer from the Observable object
  80817. * @param observer the instance of the Observer to remove
  80818. * @returns false if it doesn't belong to this Observable
  80819. */
  80820. remove(observer: Nullable<Observer<T>>): boolean;
  80821. /**
  80822. * Remove a callback from the Observable object
  80823. * @param callback the callback to remove
  80824. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80825. * @returns false if it doesn't belong to this Observable
  80826. */
  80827. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80828. private _deferUnregister;
  80829. private _remove;
  80830. /**
  80831. * Moves the observable to the top of the observer list making it get called first when notified
  80832. * @param observer the observer to move
  80833. */
  80834. makeObserverTopPriority(observer: Observer<T>): void;
  80835. /**
  80836. * Moves the observable to the bottom of the observer list making it get called last when notified
  80837. * @param observer the observer to move
  80838. */
  80839. makeObserverBottomPriority(observer: Observer<T>): void;
  80840. /**
  80841. * Notify all Observers by calling their respective callback with the given data
  80842. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80843. * @param eventData defines the data to send to all observers
  80844. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80845. * @param target defines the original target of the state
  80846. * @param currentTarget defines the current target of the state
  80847. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80848. */
  80849. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80850. /**
  80851. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80852. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80853. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80854. * and it is crucial that all callbacks will be executed.
  80855. * The order of the callbacks is kept, callbacks are not executed parallel.
  80856. *
  80857. * @param eventData The data to be sent to each callback
  80858. * @param mask is used to filter observers defaults to -1
  80859. * @param target defines the callback target (see EventState)
  80860. * @param currentTarget defines he current object in the bubbling phase
  80861. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80862. */
  80863. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80864. /**
  80865. * Notify a specific observer
  80866. * @param observer defines the observer to notify
  80867. * @param eventData defines the data to be sent to each callback
  80868. * @param mask is used to filter observers defaults to -1
  80869. */
  80870. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80871. /**
  80872. * Gets a boolean indicating if the observable has at least one observer
  80873. * @returns true is the Observable has at least one Observer registered
  80874. */
  80875. hasObservers(): boolean;
  80876. /**
  80877. * Clear the list of observers
  80878. */
  80879. clear(): void;
  80880. /**
  80881. * Clone the current observable
  80882. * @returns a new observable
  80883. */
  80884. clone(): Observable<T>;
  80885. /**
  80886. * Does this observable handles observer registered with a given mask
  80887. * @param mask defines the mask to be tested
  80888. * @return whether or not one observer registered with the given mask is handeled
  80889. **/
  80890. hasSpecificMask(mask?: number): boolean;
  80891. }
  80892. }
  80893. declare module BABYLON {
  80894. /**
  80895. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80896. * Babylon.js
  80897. */
  80898. export class DomManagement {
  80899. /**
  80900. * Checks if the window object exists
  80901. * @returns true if the window object exists
  80902. */
  80903. static IsWindowObjectExist(): boolean;
  80904. /**
  80905. * Checks if the navigator object exists
  80906. * @returns true if the navigator object exists
  80907. */
  80908. static IsNavigatorAvailable(): boolean;
  80909. /**
  80910. * Check if the document object exists
  80911. * @returns true if the document object exists
  80912. */
  80913. static IsDocumentAvailable(): boolean;
  80914. /**
  80915. * Extracts text content from a DOM element hierarchy
  80916. * @param element defines the root element
  80917. * @returns a string
  80918. */
  80919. static GetDOMTextContent(element: HTMLElement): string;
  80920. }
  80921. }
  80922. declare module BABYLON {
  80923. /**
  80924. * Logger used througouht the application to allow configuration of
  80925. * the log level required for the messages.
  80926. */
  80927. export class Logger {
  80928. /**
  80929. * No log
  80930. */
  80931. static readonly NoneLogLevel: number;
  80932. /**
  80933. * Only message logs
  80934. */
  80935. static readonly MessageLogLevel: number;
  80936. /**
  80937. * Only warning logs
  80938. */
  80939. static readonly WarningLogLevel: number;
  80940. /**
  80941. * Only error logs
  80942. */
  80943. static readonly ErrorLogLevel: number;
  80944. /**
  80945. * All logs
  80946. */
  80947. static readonly AllLogLevel: number;
  80948. private static _LogCache;
  80949. /**
  80950. * Gets a value indicating the number of loading errors
  80951. * @ignorenaming
  80952. */
  80953. static errorsCount: number;
  80954. /**
  80955. * Callback called when a new log is added
  80956. */
  80957. static OnNewCacheEntry: (entry: string) => void;
  80958. private static _AddLogEntry;
  80959. private static _FormatMessage;
  80960. private static _LogDisabled;
  80961. private static _LogEnabled;
  80962. private static _WarnDisabled;
  80963. private static _WarnEnabled;
  80964. private static _ErrorDisabled;
  80965. private static _ErrorEnabled;
  80966. /**
  80967. * Log a message to the console
  80968. */
  80969. static Log: (message: string) => void;
  80970. /**
  80971. * Write a warning message to the console
  80972. */
  80973. static Warn: (message: string) => void;
  80974. /**
  80975. * Write an error message to the console
  80976. */
  80977. static Error: (message: string) => void;
  80978. /**
  80979. * Gets current log cache (list of logs)
  80980. */
  80981. static get LogCache(): string;
  80982. /**
  80983. * Clears the log cache
  80984. */
  80985. static ClearLogCache(): void;
  80986. /**
  80987. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80988. */
  80989. static set LogLevels(level: number);
  80990. }
  80991. }
  80992. declare module BABYLON {
  80993. /** @hidden */
  80994. export class _TypeStore {
  80995. /** @hidden */
  80996. static RegisteredTypes: {
  80997. [key: string]: Object;
  80998. };
  80999. /** @hidden */
  81000. static GetClass(fqdn: string): any;
  81001. }
  81002. }
  81003. declare module BABYLON {
  81004. /**
  81005. * Helper to manipulate strings
  81006. */
  81007. export class StringTools {
  81008. /**
  81009. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81010. * @param str Source string
  81011. * @param suffix Suffix to search for in the source string
  81012. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81013. */
  81014. static EndsWith(str: string, suffix: string): boolean;
  81015. /**
  81016. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81017. * @param str Source string
  81018. * @param suffix Suffix to search for in the source string
  81019. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81020. */
  81021. static StartsWith(str: string, suffix: string): boolean;
  81022. /**
  81023. * Decodes a buffer into a string
  81024. * @param buffer The buffer to decode
  81025. * @returns The decoded string
  81026. */
  81027. static Decode(buffer: Uint8Array | Uint16Array): string;
  81028. /**
  81029. * Encode a buffer to a base64 string
  81030. * @param buffer defines the buffer to encode
  81031. * @returns the encoded string
  81032. */
  81033. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81034. /**
  81035. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81036. * @param num the number to convert and pad
  81037. * @param length the expected length of the string
  81038. * @returns the padded string
  81039. */
  81040. static PadNumber(num: number, length: number): string;
  81041. }
  81042. }
  81043. declare module BABYLON {
  81044. /**
  81045. * Class containing a set of static utilities functions for deep copy.
  81046. */
  81047. export class DeepCopier {
  81048. /**
  81049. * Tries to copy an object by duplicating every property
  81050. * @param source defines the source object
  81051. * @param destination defines the target object
  81052. * @param doNotCopyList defines a list of properties to avoid
  81053. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81054. */
  81055. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81056. }
  81057. }
  81058. declare module BABYLON {
  81059. /**
  81060. * Class containing a set of static utilities functions for precision date
  81061. */
  81062. export class PrecisionDate {
  81063. /**
  81064. * Gets either window.performance.now() if supported or Date.now() else
  81065. */
  81066. static get Now(): number;
  81067. }
  81068. }
  81069. declare module BABYLON {
  81070. /** @hidden */
  81071. export class _DevTools {
  81072. static WarnImport(name: string): string;
  81073. }
  81074. }
  81075. declare module BABYLON {
  81076. /**
  81077. * Interface used to define the mechanism to get data from the network
  81078. */
  81079. export interface IWebRequest {
  81080. /**
  81081. * Returns client's response url
  81082. */
  81083. responseURL: string;
  81084. /**
  81085. * Returns client's status
  81086. */
  81087. status: number;
  81088. /**
  81089. * Returns client's status as a text
  81090. */
  81091. statusText: string;
  81092. }
  81093. }
  81094. declare module BABYLON {
  81095. /**
  81096. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81097. */
  81098. export class WebRequest implements IWebRequest {
  81099. private _xhr;
  81100. /**
  81101. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81102. * i.e. when loading files, where the server/service expects an Authorization header
  81103. */
  81104. static CustomRequestHeaders: {
  81105. [key: string]: string;
  81106. };
  81107. /**
  81108. * Add callback functions in this array to update all the requests before they get sent to the network
  81109. */
  81110. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81111. private _injectCustomRequestHeaders;
  81112. /**
  81113. * Gets or sets a function to be called when loading progress changes
  81114. */
  81115. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81116. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81117. /**
  81118. * Returns client's state
  81119. */
  81120. get readyState(): number;
  81121. /**
  81122. * Returns client's status
  81123. */
  81124. get status(): number;
  81125. /**
  81126. * Returns client's status as a text
  81127. */
  81128. get statusText(): string;
  81129. /**
  81130. * Returns client's response
  81131. */
  81132. get response(): any;
  81133. /**
  81134. * Returns client's response url
  81135. */
  81136. get responseURL(): string;
  81137. /**
  81138. * Returns client's response as text
  81139. */
  81140. get responseText(): string;
  81141. /**
  81142. * Gets or sets the expected response type
  81143. */
  81144. get responseType(): XMLHttpRequestResponseType;
  81145. set responseType(value: XMLHttpRequestResponseType);
  81146. /** @hidden */
  81147. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81148. /** @hidden */
  81149. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81150. /**
  81151. * Cancels any network activity
  81152. */
  81153. abort(): void;
  81154. /**
  81155. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81156. * @param body defines an optional request body
  81157. */
  81158. send(body?: Document | BodyInit | null): void;
  81159. /**
  81160. * Sets the request method, request URL
  81161. * @param method defines the method to use (GET, POST, etc..)
  81162. * @param url defines the url to connect with
  81163. */
  81164. open(method: string, url: string): void;
  81165. /**
  81166. * Sets the value of a request header.
  81167. * @param name The name of the header whose value is to be set
  81168. * @param value The value to set as the body of the header
  81169. */
  81170. setRequestHeader(name: string, value: string): void;
  81171. /**
  81172. * Get the string containing the text of a particular header's value.
  81173. * @param name The name of the header
  81174. * @returns The string containing the text of the given header name
  81175. */
  81176. getResponseHeader(name: string): Nullable<string>;
  81177. }
  81178. }
  81179. declare module BABYLON {
  81180. /**
  81181. * File request interface
  81182. */
  81183. export interface IFileRequest {
  81184. /**
  81185. * Raised when the request is complete (success or error).
  81186. */
  81187. onCompleteObservable: Observable<IFileRequest>;
  81188. /**
  81189. * Aborts the request for a file.
  81190. */
  81191. abort: () => void;
  81192. }
  81193. }
  81194. declare module BABYLON {
  81195. /**
  81196. * Define options used to create a render target texture
  81197. */
  81198. export class RenderTargetCreationOptions {
  81199. /**
  81200. * Specifies is mipmaps must be generated
  81201. */
  81202. generateMipMaps?: boolean;
  81203. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81204. generateDepthBuffer?: boolean;
  81205. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81206. generateStencilBuffer?: boolean;
  81207. /** Defines texture type (int by default) */
  81208. type?: number;
  81209. /** Defines sampling mode (trilinear by default) */
  81210. samplingMode?: number;
  81211. /** Defines format (RGBA by default) */
  81212. format?: number;
  81213. }
  81214. }
  81215. declare module BABYLON {
  81216. /** Defines the cross module used constants to avoid circular dependncies */
  81217. export class Constants {
  81218. /** Defines that alpha blending is disabled */
  81219. static readonly ALPHA_DISABLE: number;
  81220. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81221. static readonly ALPHA_ADD: number;
  81222. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81223. static readonly ALPHA_COMBINE: number;
  81224. /** Defines that alpha blending is DEST - SRC * DEST */
  81225. static readonly ALPHA_SUBTRACT: number;
  81226. /** Defines that alpha blending is SRC * DEST */
  81227. static readonly ALPHA_MULTIPLY: number;
  81228. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81229. static readonly ALPHA_MAXIMIZED: number;
  81230. /** Defines that alpha blending is SRC + DEST */
  81231. static readonly ALPHA_ONEONE: number;
  81232. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81233. static readonly ALPHA_PREMULTIPLIED: number;
  81234. /**
  81235. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81236. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81237. */
  81238. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81239. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81240. static readonly ALPHA_INTERPOLATE: number;
  81241. /**
  81242. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81243. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81244. */
  81245. static readonly ALPHA_SCREENMODE: number;
  81246. /**
  81247. * Defines that alpha blending is SRC + DST
  81248. * Alpha will be set to SRC ALPHA + DST ALPHA
  81249. */
  81250. static readonly ALPHA_ONEONE_ONEONE: number;
  81251. /**
  81252. * Defines that alpha blending is SRC * DST ALPHA + DST
  81253. * Alpha will be set to 0
  81254. */
  81255. static readonly ALPHA_ALPHATOCOLOR: number;
  81256. /**
  81257. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81258. */
  81259. static readonly ALPHA_REVERSEONEMINUS: number;
  81260. /**
  81261. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81262. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81263. */
  81264. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81265. /**
  81266. * Defines that alpha blending is SRC + DST
  81267. * Alpha will be set to SRC ALPHA
  81268. */
  81269. static readonly ALPHA_ONEONE_ONEZERO: number;
  81270. /**
  81271. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81272. * Alpha will be set to DST ALPHA
  81273. */
  81274. static readonly ALPHA_EXCLUSION: number;
  81275. /** Defines that alpha blending equation a SUM */
  81276. static readonly ALPHA_EQUATION_ADD: number;
  81277. /** Defines that alpha blending equation a SUBSTRACTION */
  81278. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81279. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81280. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81281. /** Defines that alpha blending equation a MAX operation */
  81282. static readonly ALPHA_EQUATION_MAX: number;
  81283. /** Defines that alpha blending equation a MIN operation */
  81284. static readonly ALPHA_EQUATION_MIN: number;
  81285. /**
  81286. * Defines that alpha blending equation a DARKEN operation:
  81287. * It takes the min of the src and sums the alpha channels.
  81288. */
  81289. static readonly ALPHA_EQUATION_DARKEN: number;
  81290. /** Defines that the ressource is not delayed*/
  81291. static readonly DELAYLOADSTATE_NONE: number;
  81292. /** Defines that the ressource was successfully delay loaded */
  81293. static readonly DELAYLOADSTATE_LOADED: number;
  81294. /** Defines that the ressource is currently delay loading */
  81295. static readonly DELAYLOADSTATE_LOADING: number;
  81296. /** Defines that the ressource is delayed and has not started loading */
  81297. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81298. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81299. static readonly NEVER: number;
  81300. /** 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 */
  81301. static readonly ALWAYS: number;
  81302. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81303. static readonly LESS: number;
  81304. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81305. static readonly EQUAL: number;
  81306. /** 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 */
  81307. static readonly LEQUAL: number;
  81308. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81309. static readonly GREATER: number;
  81310. /** 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 */
  81311. static readonly GEQUAL: number;
  81312. /** 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 */
  81313. static readonly NOTEQUAL: number;
  81314. /** Passed to stencilOperation to specify that stencil value must be kept */
  81315. static readonly KEEP: number;
  81316. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81317. static readonly REPLACE: number;
  81318. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81319. static readonly INCR: number;
  81320. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81321. static readonly DECR: number;
  81322. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81323. static readonly INVERT: number;
  81324. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81325. static readonly INCR_WRAP: number;
  81326. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81327. static readonly DECR_WRAP: number;
  81328. /** Texture is not repeating outside of 0..1 UVs */
  81329. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81330. /** Texture is repeating outside of 0..1 UVs */
  81331. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81332. /** Texture is repeating and mirrored */
  81333. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81334. /** ALPHA */
  81335. static readonly TEXTUREFORMAT_ALPHA: number;
  81336. /** LUMINANCE */
  81337. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81338. /** LUMINANCE_ALPHA */
  81339. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81340. /** RGB */
  81341. static readonly TEXTUREFORMAT_RGB: number;
  81342. /** RGBA */
  81343. static readonly TEXTUREFORMAT_RGBA: number;
  81344. /** RED */
  81345. static readonly TEXTUREFORMAT_RED: number;
  81346. /** RED (2nd reference) */
  81347. static readonly TEXTUREFORMAT_R: number;
  81348. /** RG */
  81349. static readonly TEXTUREFORMAT_RG: number;
  81350. /** RED_INTEGER */
  81351. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81352. /** RED_INTEGER (2nd reference) */
  81353. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81354. /** RG_INTEGER */
  81355. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81356. /** RGB_INTEGER */
  81357. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81358. /** RGBA_INTEGER */
  81359. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81360. /** UNSIGNED_BYTE */
  81361. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81362. /** UNSIGNED_BYTE (2nd reference) */
  81363. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81364. /** FLOAT */
  81365. static readonly TEXTURETYPE_FLOAT: number;
  81366. /** HALF_FLOAT */
  81367. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81368. /** BYTE */
  81369. static readonly TEXTURETYPE_BYTE: number;
  81370. /** SHORT */
  81371. static readonly TEXTURETYPE_SHORT: number;
  81372. /** UNSIGNED_SHORT */
  81373. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81374. /** INT */
  81375. static readonly TEXTURETYPE_INT: number;
  81376. /** UNSIGNED_INT */
  81377. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81378. /** UNSIGNED_SHORT_4_4_4_4 */
  81379. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81380. /** UNSIGNED_SHORT_5_5_5_1 */
  81381. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81382. /** UNSIGNED_SHORT_5_6_5 */
  81383. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81384. /** UNSIGNED_INT_2_10_10_10_REV */
  81385. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81386. /** UNSIGNED_INT_24_8 */
  81387. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81388. /** UNSIGNED_INT_10F_11F_11F_REV */
  81389. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81390. /** UNSIGNED_INT_5_9_9_9_REV */
  81391. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81392. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81393. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81394. /** nearest is mag = nearest and min = nearest and no mip */
  81395. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81396. /** mag = nearest and min = nearest and mip = none */
  81397. static readonly TEXTURE_NEAREST_NEAREST: number;
  81398. /** Bilinear is mag = linear and min = linear and no mip */
  81399. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81400. /** mag = linear and min = linear and mip = none */
  81401. static readonly TEXTURE_LINEAR_LINEAR: number;
  81402. /** Trilinear is mag = linear and min = linear and mip = linear */
  81403. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81404. /** Trilinear is mag = linear and min = linear and mip = linear */
  81405. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81406. /** mag = nearest and min = nearest and mip = nearest */
  81407. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81408. /** mag = nearest and min = linear and mip = nearest */
  81409. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81410. /** mag = nearest and min = linear and mip = linear */
  81411. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81412. /** mag = nearest and min = linear and mip = none */
  81413. static readonly TEXTURE_NEAREST_LINEAR: number;
  81414. /** nearest is mag = nearest and min = nearest and mip = linear */
  81415. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81416. /** mag = linear and min = nearest and mip = nearest */
  81417. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81418. /** mag = linear and min = nearest and mip = linear */
  81419. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81420. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81421. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81422. /** mag = linear and min = nearest and mip = none */
  81423. static readonly TEXTURE_LINEAR_NEAREST: number;
  81424. /** Explicit coordinates mode */
  81425. static readonly TEXTURE_EXPLICIT_MODE: number;
  81426. /** Spherical coordinates mode */
  81427. static readonly TEXTURE_SPHERICAL_MODE: number;
  81428. /** Planar coordinates mode */
  81429. static readonly TEXTURE_PLANAR_MODE: number;
  81430. /** Cubic coordinates mode */
  81431. static readonly TEXTURE_CUBIC_MODE: number;
  81432. /** Projection coordinates mode */
  81433. static readonly TEXTURE_PROJECTION_MODE: number;
  81434. /** Skybox coordinates mode */
  81435. static readonly TEXTURE_SKYBOX_MODE: number;
  81436. /** Inverse Cubic coordinates mode */
  81437. static readonly TEXTURE_INVCUBIC_MODE: number;
  81438. /** Equirectangular coordinates mode */
  81439. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81440. /** Equirectangular Fixed coordinates mode */
  81441. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81442. /** Equirectangular Fixed Mirrored coordinates mode */
  81443. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81444. /** Offline (baking) quality for texture filtering */
  81445. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81446. /** High quality for texture filtering */
  81447. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81448. /** Medium quality for texture filtering */
  81449. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81450. /** Low quality for texture filtering */
  81451. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81452. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81453. static readonly SCALEMODE_FLOOR: number;
  81454. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81455. static readonly SCALEMODE_NEAREST: number;
  81456. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81457. static readonly SCALEMODE_CEILING: number;
  81458. /**
  81459. * The dirty texture flag value
  81460. */
  81461. static readonly MATERIAL_TextureDirtyFlag: number;
  81462. /**
  81463. * The dirty light flag value
  81464. */
  81465. static readonly MATERIAL_LightDirtyFlag: number;
  81466. /**
  81467. * The dirty fresnel flag value
  81468. */
  81469. static readonly MATERIAL_FresnelDirtyFlag: number;
  81470. /**
  81471. * The dirty attribute flag value
  81472. */
  81473. static readonly MATERIAL_AttributesDirtyFlag: number;
  81474. /**
  81475. * The dirty misc flag value
  81476. */
  81477. static readonly MATERIAL_MiscDirtyFlag: number;
  81478. /**
  81479. * The dirty prepass flag value
  81480. */
  81481. static readonly MATERIAL_PrePassDirtyFlag: number;
  81482. /**
  81483. * The all dirty flag value
  81484. */
  81485. static readonly MATERIAL_AllDirtyFlag: number;
  81486. /**
  81487. * Returns the triangle fill mode
  81488. */
  81489. static readonly MATERIAL_TriangleFillMode: number;
  81490. /**
  81491. * Returns the wireframe mode
  81492. */
  81493. static readonly MATERIAL_WireFrameFillMode: number;
  81494. /**
  81495. * Returns the point fill mode
  81496. */
  81497. static readonly MATERIAL_PointFillMode: number;
  81498. /**
  81499. * Returns the point list draw mode
  81500. */
  81501. static readonly MATERIAL_PointListDrawMode: number;
  81502. /**
  81503. * Returns the line list draw mode
  81504. */
  81505. static readonly MATERIAL_LineListDrawMode: number;
  81506. /**
  81507. * Returns the line loop draw mode
  81508. */
  81509. static readonly MATERIAL_LineLoopDrawMode: number;
  81510. /**
  81511. * Returns the line strip draw mode
  81512. */
  81513. static readonly MATERIAL_LineStripDrawMode: number;
  81514. /**
  81515. * Returns the triangle strip draw mode
  81516. */
  81517. static readonly MATERIAL_TriangleStripDrawMode: number;
  81518. /**
  81519. * Returns the triangle fan draw mode
  81520. */
  81521. static readonly MATERIAL_TriangleFanDrawMode: number;
  81522. /**
  81523. * Stores the clock-wise side orientation
  81524. */
  81525. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81526. /**
  81527. * Stores the counter clock-wise side orientation
  81528. */
  81529. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81530. /**
  81531. * Nothing
  81532. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81533. */
  81534. static readonly ACTION_NothingTrigger: number;
  81535. /**
  81536. * On pick
  81537. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81538. */
  81539. static readonly ACTION_OnPickTrigger: number;
  81540. /**
  81541. * On left pick
  81542. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81543. */
  81544. static readonly ACTION_OnLeftPickTrigger: number;
  81545. /**
  81546. * On right pick
  81547. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81548. */
  81549. static readonly ACTION_OnRightPickTrigger: number;
  81550. /**
  81551. * On center pick
  81552. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81553. */
  81554. static readonly ACTION_OnCenterPickTrigger: number;
  81555. /**
  81556. * On pick down
  81557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81558. */
  81559. static readonly ACTION_OnPickDownTrigger: number;
  81560. /**
  81561. * On double pick
  81562. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81563. */
  81564. static readonly ACTION_OnDoublePickTrigger: number;
  81565. /**
  81566. * On pick up
  81567. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81568. */
  81569. static readonly ACTION_OnPickUpTrigger: number;
  81570. /**
  81571. * On pick out.
  81572. * This trigger will only be raised if you also declared a OnPickDown
  81573. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81574. */
  81575. static readonly ACTION_OnPickOutTrigger: number;
  81576. /**
  81577. * On long press
  81578. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81579. */
  81580. static readonly ACTION_OnLongPressTrigger: number;
  81581. /**
  81582. * On pointer over
  81583. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81584. */
  81585. static readonly ACTION_OnPointerOverTrigger: number;
  81586. /**
  81587. * On pointer out
  81588. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81589. */
  81590. static readonly ACTION_OnPointerOutTrigger: number;
  81591. /**
  81592. * On every frame
  81593. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81594. */
  81595. static readonly ACTION_OnEveryFrameTrigger: number;
  81596. /**
  81597. * On intersection enter
  81598. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81599. */
  81600. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81601. /**
  81602. * On intersection exit
  81603. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81604. */
  81605. static readonly ACTION_OnIntersectionExitTrigger: number;
  81606. /**
  81607. * On key down
  81608. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81609. */
  81610. static readonly ACTION_OnKeyDownTrigger: number;
  81611. /**
  81612. * On key up
  81613. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81614. */
  81615. static readonly ACTION_OnKeyUpTrigger: number;
  81616. /**
  81617. * Billboard mode will only apply to Y axis
  81618. */
  81619. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81620. /**
  81621. * Billboard mode will apply to all axes
  81622. */
  81623. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81624. /**
  81625. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81626. */
  81627. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81628. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81629. * Test order :
  81630. * Is the bounding sphere outside the frustum ?
  81631. * If not, are the bounding box vertices outside the frustum ?
  81632. * It not, then the cullable object is in the frustum.
  81633. */
  81634. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81635. /** Culling strategy : Bounding Sphere Only.
  81636. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81637. * It's also less accurate than the standard because some not visible objects can still be selected.
  81638. * Test : is the bounding sphere outside the frustum ?
  81639. * If not, then the cullable object is in the frustum.
  81640. */
  81641. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81642. /** Culling strategy : Optimistic Inclusion.
  81643. * This in an inclusion test first, then the standard exclusion test.
  81644. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81645. * 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.
  81646. * Anyway, it's as accurate as the standard strategy.
  81647. * Test :
  81648. * Is the cullable object bounding sphere center in the frustum ?
  81649. * If not, apply the default culling strategy.
  81650. */
  81651. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81652. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81653. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81654. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81655. * 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.
  81656. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81657. * Test :
  81658. * Is the cullable object bounding sphere center in the frustum ?
  81659. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81660. */
  81661. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81662. /**
  81663. * No logging while loading
  81664. */
  81665. static readonly SCENELOADER_NO_LOGGING: number;
  81666. /**
  81667. * Minimal logging while loading
  81668. */
  81669. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81670. /**
  81671. * Summary logging while loading
  81672. */
  81673. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81674. /**
  81675. * Detailled logging while loading
  81676. */
  81677. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81678. /**
  81679. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81680. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81681. */
  81682. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81683. /**
  81684. * Constant used to retrieve the position texture index in the textures array in the prepass
  81685. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81686. */
  81687. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81688. /**
  81689. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81690. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81691. */
  81692. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81693. /**
  81694. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81695. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81696. */
  81697. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81698. /**
  81699. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81700. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81701. */
  81702. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81703. /**
  81704. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81705. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81706. */
  81707. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81708. /**
  81709. * Constant used to retrieve albedo index in the textures array in the prepass
  81710. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81711. */
  81712. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81713. }
  81714. }
  81715. declare module BABYLON {
  81716. /**
  81717. * This represents the required contract to create a new type of texture loader.
  81718. */
  81719. export interface IInternalTextureLoader {
  81720. /**
  81721. * Defines wether the loader supports cascade loading the different faces.
  81722. */
  81723. supportCascades: boolean;
  81724. /**
  81725. * This returns if the loader support the current file information.
  81726. * @param extension defines the file extension of the file being loaded
  81727. * @param mimeType defines the optional mime type of the file being loaded
  81728. * @returns true if the loader can load the specified file
  81729. */
  81730. canLoad(extension: string, mimeType?: string): boolean;
  81731. /**
  81732. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81733. * @param data contains the texture data
  81734. * @param texture defines the BabylonJS internal texture
  81735. * @param createPolynomials will be true if polynomials have been requested
  81736. * @param onLoad defines the callback to trigger once the texture is ready
  81737. * @param onError defines the callback to trigger in case of error
  81738. */
  81739. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81740. /**
  81741. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81742. * @param data contains the texture data
  81743. * @param texture defines the BabylonJS internal texture
  81744. * @param callback defines the method to call once ready to upload
  81745. */
  81746. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81747. }
  81748. }
  81749. declare module BABYLON {
  81750. /**
  81751. * Class used to store and describe the pipeline context associated with an effect
  81752. */
  81753. export interface IPipelineContext {
  81754. /**
  81755. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81756. */
  81757. isAsync: boolean;
  81758. /**
  81759. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81760. */
  81761. isReady: boolean;
  81762. /** @hidden */
  81763. _getVertexShaderCode(): string | null;
  81764. /** @hidden */
  81765. _getFragmentShaderCode(): string | null;
  81766. /** @hidden */
  81767. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81768. }
  81769. }
  81770. declare module BABYLON {
  81771. /**
  81772. * Class used to store gfx data (like WebGLBuffer)
  81773. */
  81774. export class DataBuffer {
  81775. /**
  81776. * Gets or sets the number of objects referencing this buffer
  81777. */
  81778. references: number;
  81779. /** Gets or sets the size of the underlying buffer */
  81780. capacity: number;
  81781. /**
  81782. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81783. */
  81784. is32Bits: boolean;
  81785. /**
  81786. * Gets the underlying buffer
  81787. */
  81788. get underlyingResource(): any;
  81789. }
  81790. }
  81791. declare module BABYLON {
  81792. /** @hidden */
  81793. export interface IShaderProcessor {
  81794. attributeProcessor?: (attribute: string) => string;
  81795. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81796. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81797. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81798. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81799. lineProcessor?: (line: string, isFragment: boolean) => string;
  81800. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81801. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81802. }
  81803. }
  81804. declare module BABYLON {
  81805. /** @hidden */
  81806. export interface ProcessingOptions {
  81807. defines: string[];
  81808. indexParameters: any;
  81809. isFragment: boolean;
  81810. shouldUseHighPrecisionShader: boolean;
  81811. supportsUniformBuffers: boolean;
  81812. shadersRepository: string;
  81813. includesShadersStore: {
  81814. [key: string]: string;
  81815. };
  81816. processor?: IShaderProcessor;
  81817. version: string;
  81818. platformName: string;
  81819. lookForClosingBracketForUniformBuffer?: boolean;
  81820. }
  81821. }
  81822. declare module BABYLON {
  81823. /** @hidden */
  81824. export class ShaderCodeNode {
  81825. line: string;
  81826. children: ShaderCodeNode[];
  81827. additionalDefineKey?: string;
  81828. additionalDefineValue?: string;
  81829. isValid(preprocessors: {
  81830. [key: string]: string;
  81831. }): boolean;
  81832. process(preprocessors: {
  81833. [key: string]: string;
  81834. }, options: ProcessingOptions): string;
  81835. }
  81836. }
  81837. declare module BABYLON {
  81838. /** @hidden */
  81839. export class ShaderCodeCursor {
  81840. private _lines;
  81841. lineIndex: number;
  81842. get currentLine(): string;
  81843. get canRead(): boolean;
  81844. set lines(value: string[]);
  81845. }
  81846. }
  81847. declare module BABYLON {
  81848. /** @hidden */
  81849. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81850. process(preprocessors: {
  81851. [key: string]: string;
  81852. }, options: ProcessingOptions): string;
  81853. }
  81854. }
  81855. declare module BABYLON {
  81856. /** @hidden */
  81857. export class ShaderDefineExpression {
  81858. isTrue(preprocessors: {
  81859. [key: string]: string;
  81860. }): boolean;
  81861. private static _OperatorPriority;
  81862. private static _Stack;
  81863. static postfixToInfix(postfix: string[]): string;
  81864. static infixToPostfix(infix: string): string[];
  81865. }
  81866. }
  81867. declare module BABYLON {
  81868. /** @hidden */
  81869. export class ShaderCodeTestNode extends ShaderCodeNode {
  81870. testExpression: ShaderDefineExpression;
  81871. isValid(preprocessors: {
  81872. [key: string]: string;
  81873. }): boolean;
  81874. }
  81875. }
  81876. declare module BABYLON {
  81877. /** @hidden */
  81878. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81879. define: string;
  81880. not: boolean;
  81881. constructor(define: string, not?: boolean);
  81882. isTrue(preprocessors: {
  81883. [key: string]: string;
  81884. }): boolean;
  81885. }
  81886. }
  81887. declare module BABYLON {
  81888. /** @hidden */
  81889. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81890. leftOperand: ShaderDefineExpression;
  81891. rightOperand: ShaderDefineExpression;
  81892. isTrue(preprocessors: {
  81893. [key: string]: string;
  81894. }): boolean;
  81895. }
  81896. }
  81897. declare module BABYLON {
  81898. /** @hidden */
  81899. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81900. leftOperand: ShaderDefineExpression;
  81901. rightOperand: ShaderDefineExpression;
  81902. isTrue(preprocessors: {
  81903. [key: string]: string;
  81904. }): boolean;
  81905. }
  81906. }
  81907. declare module BABYLON {
  81908. /** @hidden */
  81909. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81910. define: string;
  81911. operand: string;
  81912. testValue: string;
  81913. constructor(define: string, operand: string, testValue: string);
  81914. isTrue(preprocessors: {
  81915. [key: string]: string;
  81916. }): boolean;
  81917. }
  81918. }
  81919. declare module BABYLON {
  81920. /**
  81921. * Class used to enable access to offline support
  81922. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81923. */
  81924. export interface IOfflineProvider {
  81925. /**
  81926. * Gets a boolean indicating if scene must be saved in the database
  81927. */
  81928. enableSceneOffline: boolean;
  81929. /**
  81930. * Gets a boolean indicating if textures must be saved in the database
  81931. */
  81932. enableTexturesOffline: boolean;
  81933. /**
  81934. * Open the offline support and make it available
  81935. * @param successCallback defines the callback to call on success
  81936. * @param errorCallback defines the callback to call on error
  81937. */
  81938. open(successCallback: () => void, errorCallback: () => void): void;
  81939. /**
  81940. * Loads an image from the offline support
  81941. * @param url defines the url to load from
  81942. * @param image defines the target DOM image
  81943. */
  81944. loadImage(url: string, image: HTMLImageElement): void;
  81945. /**
  81946. * Loads a file from offline support
  81947. * @param url defines the URL to load from
  81948. * @param sceneLoaded defines a callback to call on success
  81949. * @param progressCallBack defines a callback to call when progress changed
  81950. * @param errorCallback defines a callback to call on error
  81951. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81952. */
  81953. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81954. }
  81955. }
  81956. declare module BABYLON {
  81957. /**
  81958. * Class used to help managing file picking and drag'n'drop
  81959. * File Storage
  81960. */
  81961. export class FilesInputStore {
  81962. /**
  81963. * List of files ready to be loaded
  81964. */
  81965. static FilesToLoad: {
  81966. [key: string]: File;
  81967. };
  81968. }
  81969. }
  81970. declare module BABYLON {
  81971. /**
  81972. * Class used to define a retry strategy when error happens while loading assets
  81973. */
  81974. export class RetryStrategy {
  81975. /**
  81976. * Function used to defines an exponential back off strategy
  81977. * @param maxRetries defines the maximum number of retries (3 by default)
  81978. * @param baseInterval defines the interval between retries
  81979. * @returns the strategy function to use
  81980. */
  81981. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81982. }
  81983. }
  81984. declare module BABYLON {
  81985. /**
  81986. * @ignore
  81987. * Application error to support additional information when loading a file
  81988. */
  81989. export abstract class BaseError extends Error {
  81990. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81991. }
  81992. }
  81993. declare module BABYLON {
  81994. /** @ignore */
  81995. export class LoadFileError extends BaseError {
  81996. request?: WebRequest;
  81997. file?: File;
  81998. /**
  81999. * Creates a new LoadFileError
  82000. * @param message defines the message of the error
  82001. * @param request defines the optional web request
  82002. * @param file defines the optional file
  82003. */
  82004. constructor(message: string, object?: WebRequest | File);
  82005. }
  82006. /** @ignore */
  82007. export class RequestFileError extends BaseError {
  82008. request: WebRequest;
  82009. /**
  82010. * Creates a new LoadFileError
  82011. * @param message defines the message of the error
  82012. * @param request defines the optional web request
  82013. */
  82014. constructor(message: string, request: WebRequest);
  82015. }
  82016. /** @ignore */
  82017. export class ReadFileError extends BaseError {
  82018. file: File;
  82019. /**
  82020. * Creates a new ReadFileError
  82021. * @param message defines the message of the error
  82022. * @param file defines the optional file
  82023. */
  82024. constructor(message: string, file: File);
  82025. }
  82026. /**
  82027. * @hidden
  82028. */
  82029. export class FileTools {
  82030. /**
  82031. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82032. */
  82033. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82034. /**
  82035. * Gets or sets the base URL to use to load assets
  82036. */
  82037. static BaseUrl: string;
  82038. /**
  82039. * Default behaviour for cors in the application.
  82040. * It can be a string if the expected behavior is identical in the entire app.
  82041. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82042. */
  82043. static CorsBehavior: string | ((url: string | string[]) => string);
  82044. /**
  82045. * Gets or sets a function used to pre-process url before using them to load assets
  82046. */
  82047. static PreprocessUrl: (url: string) => string;
  82048. /**
  82049. * Removes unwanted characters from an url
  82050. * @param url defines the url to clean
  82051. * @returns the cleaned url
  82052. */
  82053. private static _CleanUrl;
  82054. /**
  82055. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82056. * @param url define the url we are trying
  82057. * @param element define the dom element where to configure the cors policy
  82058. */
  82059. static SetCorsBehavior(url: string | string[], element: {
  82060. crossOrigin: string | null;
  82061. }): void;
  82062. /**
  82063. * Loads an image as an HTMLImageElement.
  82064. * @param input url string, ArrayBuffer, or Blob to load
  82065. * @param onLoad callback called when the image successfully loads
  82066. * @param onError callback called when the image fails to load
  82067. * @param offlineProvider offline provider for caching
  82068. * @param mimeType optional mime type
  82069. * @returns the HTMLImageElement of the loaded image
  82070. */
  82071. 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>;
  82072. /**
  82073. * Reads a file from a File object
  82074. * @param file defines the file to load
  82075. * @param onSuccess defines the callback to call when data is loaded
  82076. * @param onProgress defines the callback to call during loading process
  82077. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82078. * @param onError defines the callback to call when an error occurs
  82079. * @returns a file request object
  82080. */
  82081. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82082. /**
  82083. * Loads a file from a url
  82084. * @param url url to load
  82085. * @param onSuccess callback called when the file successfully loads
  82086. * @param onProgress callback called while file is loading (if the server supports this mode)
  82087. * @param offlineProvider defines the offline provider for caching
  82088. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82089. * @param onError callback called when the file fails to load
  82090. * @returns a file request object
  82091. */
  82092. 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;
  82093. /**
  82094. * Loads a file
  82095. * @param url url to load
  82096. * @param onSuccess callback called when the file successfully loads
  82097. * @param onProgress callback called while file is loading (if the server supports this mode)
  82098. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82099. * @param onError callback called when the file fails to load
  82100. * @param onOpened callback called when the web request is opened
  82101. * @returns a file request object
  82102. */
  82103. 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;
  82104. /**
  82105. * Checks if the loaded document was accessed via `file:`-Protocol.
  82106. * @returns boolean
  82107. */
  82108. static IsFileURL(): boolean;
  82109. }
  82110. }
  82111. declare module BABYLON {
  82112. /** @hidden */
  82113. export class ShaderProcessor {
  82114. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82115. private static _ProcessPrecision;
  82116. private static _ExtractOperation;
  82117. private static _BuildSubExpression;
  82118. private static _BuildExpression;
  82119. private static _MoveCursorWithinIf;
  82120. private static _MoveCursor;
  82121. private static _EvaluatePreProcessors;
  82122. private static _PreparePreProcessors;
  82123. private static _ProcessShaderConversion;
  82124. private static _ProcessIncludes;
  82125. /**
  82126. * Loads a file from a url
  82127. * @param url url to load
  82128. * @param onSuccess callback called when the file successfully loads
  82129. * @param onProgress callback called while file is loading (if the server supports this mode)
  82130. * @param offlineProvider defines the offline provider for caching
  82131. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82132. * @param onError callback called when the file fails to load
  82133. * @returns a file request object
  82134. * @hidden
  82135. */
  82136. 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;
  82137. }
  82138. }
  82139. declare module BABYLON {
  82140. /**
  82141. * @hidden
  82142. */
  82143. export interface IColor4Like {
  82144. r: float;
  82145. g: float;
  82146. b: float;
  82147. a: float;
  82148. }
  82149. /**
  82150. * @hidden
  82151. */
  82152. export interface IColor3Like {
  82153. r: float;
  82154. g: float;
  82155. b: float;
  82156. }
  82157. /**
  82158. * @hidden
  82159. */
  82160. export interface IVector4Like {
  82161. x: float;
  82162. y: float;
  82163. z: float;
  82164. w: float;
  82165. }
  82166. /**
  82167. * @hidden
  82168. */
  82169. export interface IVector3Like {
  82170. x: float;
  82171. y: float;
  82172. z: float;
  82173. }
  82174. /**
  82175. * @hidden
  82176. */
  82177. export interface IVector2Like {
  82178. x: float;
  82179. y: float;
  82180. }
  82181. /**
  82182. * @hidden
  82183. */
  82184. export interface IMatrixLike {
  82185. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82186. updateFlag: int;
  82187. }
  82188. /**
  82189. * @hidden
  82190. */
  82191. export interface IViewportLike {
  82192. x: float;
  82193. y: float;
  82194. width: float;
  82195. height: float;
  82196. }
  82197. /**
  82198. * @hidden
  82199. */
  82200. export interface IPlaneLike {
  82201. normal: IVector3Like;
  82202. d: float;
  82203. normalize(): void;
  82204. }
  82205. }
  82206. declare module BABYLON {
  82207. /**
  82208. * Interface used to define common properties for effect fallbacks
  82209. */
  82210. export interface IEffectFallbacks {
  82211. /**
  82212. * Removes the defines that should be removed when falling back.
  82213. * @param currentDefines defines the current define statements for the shader.
  82214. * @param effect defines the current effect we try to compile
  82215. * @returns The resulting defines with defines of the current rank removed.
  82216. */
  82217. reduce(currentDefines: string, effect: Effect): string;
  82218. /**
  82219. * Removes the fallback from the bound mesh.
  82220. */
  82221. unBindMesh(): void;
  82222. /**
  82223. * Checks to see if more fallbacks are still availible.
  82224. */
  82225. hasMoreFallbacks: boolean;
  82226. }
  82227. }
  82228. declare module BABYLON {
  82229. /**
  82230. * Class used to evalaute queries containing `and` and `or` operators
  82231. */
  82232. export class AndOrNotEvaluator {
  82233. /**
  82234. * Evaluate a query
  82235. * @param query defines the query to evaluate
  82236. * @param evaluateCallback defines the callback used to filter result
  82237. * @returns true if the query matches
  82238. */
  82239. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82240. private static _HandleParenthesisContent;
  82241. private static _SimplifyNegation;
  82242. }
  82243. }
  82244. declare module BABYLON {
  82245. /**
  82246. * Class used to store custom tags
  82247. */
  82248. export class Tags {
  82249. /**
  82250. * Adds support for tags on the given object
  82251. * @param obj defines the object to use
  82252. */
  82253. static EnableFor(obj: any): void;
  82254. /**
  82255. * Removes tags support
  82256. * @param obj defines the object to use
  82257. */
  82258. static DisableFor(obj: any): void;
  82259. /**
  82260. * Gets a boolean indicating if the given object has tags
  82261. * @param obj defines the object to use
  82262. * @returns a boolean
  82263. */
  82264. static HasTags(obj: any): boolean;
  82265. /**
  82266. * Gets the tags available on a given object
  82267. * @param obj defines the object to use
  82268. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82269. * @returns the tags
  82270. */
  82271. static GetTags(obj: any, asString?: boolean): any;
  82272. /**
  82273. * Adds tags to an object
  82274. * @param obj defines the object to use
  82275. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82276. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82277. */
  82278. static AddTagsTo(obj: any, tagsString: string): void;
  82279. /**
  82280. * @hidden
  82281. */
  82282. static _AddTagTo(obj: any, tag: string): void;
  82283. /**
  82284. * Removes specific tags from a specific object
  82285. * @param obj defines the object to use
  82286. * @param tagsString defines the tags to remove
  82287. */
  82288. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82289. /**
  82290. * @hidden
  82291. */
  82292. static _RemoveTagFrom(obj: any, tag: string): void;
  82293. /**
  82294. * Defines if tags hosted on an object match a given query
  82295. * @param obj defines the object to use
  82296. * @param tagsQuery defines the tag query
  82297. * @returns a boolean
  82298. */
  82299. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82300. }
  82301. }
  82302. declare module BABYLON {
  82303. /**
  82304. * Scalar computation library
  82305. */
  82306. export class Scalar {
  82307. /**
  82308. * Two pi constants convenient for computation.
  82309. */
  82310. static TwoPi: number;
  82311. /**
  82312. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82313. * @param a number
  82314. * @param b number
  82315. * @param epsilon (default = 1.401298E-45)
  82316. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82317. */
  82318. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82319. /**
  82320. * Returns a string : the upper case translation of the number i to hexadecimal.
  82321. * @param i number
  82322. * @returns the upper case translation of the number i to hexadecimal.
  82323. */
  82324. static ToHex(i: number): string;
  82325. /**
  82326. * Returns -1 if value is negative and +1 is value is positive.
  82327. * @param value the value
  82328. * @returns the value itself if it's equal to zero.
  82329. */
  82330. static Sign(value: number): number;
  82331. /**
  82332. * Returns the value itself if it's between min and max.
  82333. * Returns min if the value is lower than min.
  82334. * Returns max if the value is greater than max.
  82335. * @param value the value to clmap
  82336. * @param min the min value to clamp to (default: 0)
  82337. * @param max the max value to clamp to (default: 1)
  82338. * @returns the clamped value
  82339. */
  82340. static Clamp(value: number, min?: number, max?: number): number;
  82341. /**
  82342. * the log2 of value.
  82343. * @param value the value to compute log2 of
  82344. * @returns the log2 of value.
  82345. */
  82346. static Log2(value: number): number;
  82347. /**
  82348. * Loops the value, so that it is never larger than length and never smaller than 0.
  82349. *
  82350. * This is similar to the modulo operator but it works with floating point numbers.
  82351. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82352. * With t = 5 and length = 2.5, the result would be 0.0.
  82353. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82354. * @param value the value
  82355. * @param length the length
  82356. * @returns the looped value
  82357. */
  82358. static Repeat(value: number, length: number): number;
  82359. /**
  82360. * Normalize the value between 0.0 and 1.0 using min and max values
  82361. * @param value value to normalize
  82362. * @param min max to normalize between
  82363. * @param max min to normalize between
  82364. * @returns the normalized value
  82365. */
  82366. static Normalize(value: number, min: number, max: number): number;
  82367. /**
  82368. * Denormalize the value from 0.0 and 1.0 using min and max values
  82369. * @param normalized value to denormalize
  82370. * @param min max to denormalize between
  82371. * @param max min to denormalize between
  82372. * @returns the denormalized value
  82373. */
  82374. static Denormalize(normalized: number, min: number, max: number): number;
  82375. /**
  82376. * Calculates the shortest difference between two given angles given in degrees.
  82377. * @param current current angle in degrees
  82378. * @param target target angle in degrees
  82379. * @returns the delta
  82380. */
  82381. static DeltaAngle(current: number, target: number): number;
  82382. /**
  82383. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82384. * @param tx value
  82385. * @param length length
  82386. * @returns The returned value will move back and forth between 0 and length
  82387. */
  82388. static PingPong(tx: number, length: number): number;
  82389. /**
  82390. * Interpolates between min and max with smoothing at the limits.
  82391. *
  82392. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82393. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82394. * @param from from
  82395. * @param to to
  82396. * @param tx value
  82397. * @returns the smooth stepped value
  82398. */
  82399. static SmoothStep(from: number, to: number, tx: number): number;
  82400. /**
  82401. * Moves a value current towards target.
  82402. *
  82403. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82404. * Negative values of maxDelta pushes the value away from target.
  82405. * @param current current value
  82406. * @param target target value
  82407. * @param maxDelta max distance to move
  82408. * @returns resulting value
  82409. */
  82410. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82411. /**
  82412. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82413. *
  82414. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82415. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82416. * @param current current value
  82417. * @param target target value
  82418. * @param maxDelta max distance to move
  82419. * @returns resulting angle
  82420. */
  82421. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82422. /**
  82423. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82424. * @param start start value
  82425. * @param end target value
  82426. * @param amount amount to lerp between
  82427. * @returns the lerped value
  82428. */
  82429. static Lerp(start: number, end: number, amount: number): number;
  82430. /**
  82431. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82432. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82433. * @param start start value
  82434. * @param end target value
  82435. * @param amount amount to lerp between
  82436. * @returns the lerped value
  82437. */
  82438. static LerpAngle(start: number, end: number, amount: number): number;
  82439. /**
  82440. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82441. * @param a start value
  82442. * @param b target value
  82443. * @param value value between a and b
  82444. * @returns the inverseLerp value
  82445. */
  82446. static InverseLerp(a: number, b: number, value: number): number;
  82447. /**
  82448. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82449. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82450. * @param value1 spline value
  82451. * @param tangent1 spline value
  82452. * @param value2 spline value
  82453. * @param tangent2 spline value
  82454. * @param amount input value
  82455. * @returns hermite result
  82456. */
  82457. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82458. /**
  82459. * Returns a random float number between and min and max values
  82460. * @param min min value of random
  82461. * @param max max value of random
  82462. * @returns random value
  82463. */
  82464. static RandomRange(min: number, max: number): number;
  82465. /**
  82466. * This function returns percentage of a number in a given range.
  82467. *
  82468. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82469. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82470. * @param number to convert to percentage
  82471. * @param min min range
  82472. * @param max max range
  82473. * @returns the percentage
  82474. */
  82475. static RangeToPercent(number: number, min: number, max: number): number;
  82476. /**
  82477. * This function returns number that corresponds to the percentage in a given range.
  82478. *
  82479. * PercentToRange(0.34,0,100) will return 34.
  82480. * @param percent to convert to number
  82481. * @param min min range
  82482. * @param max max range
  82483. * @returns the number
  82484. */
  82485. static PercentToRange(percent: number, min: number, max: number): number;
  82486. /**
  82487. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82488. * @param angle The angle to normalize in radian.
  82489. * @return The converted angle.
  82490. */
  82491. static NormalizeRadians(angle: number): number;
  82492. }
  82493. }
  82494. declare module BABYLON {
  82495. /**
  82496. * Constant used to convert a value to gamma space
  82497. * @ignorenaming
  82498. */
  82499. export const ToGammaSpace: number;
  82500. /**
  82501. * Constant used to convert a value to linear space
  82502. * @ignorenaming
  82503. */
  82504. export const ToLinearSpace = 2.2;
  82505. /**
  82506. * Constant used to define the minimal number value in Babylon.js
  82507. * @ignorenaming
  82508. */
  82509. let Epsilon: number;
  82510. }
  82511. declare module BABYLON {
  82512. /**
  82513. * Class used to represent a viewport on screen
  82514. */
  82515. export class Viewport {
  82516. /** viewport left coordinate */
  82517. x: number;
  82518. /** viewport top coordinate */
  82519. y: number;
  82520. /**viewport width */
  82521. width: number;
  82522. /** viewport height */
  82523. height: number;
  82524. /**
  82525. * Creates a Viewport object located at (x, y) and sized (width, height)
  82526. * @param x defines viewport left coordinate
  82527. * @param y defines viewport top coordinate
  82528. * @param width defines the viewport width
  82529. * @param height defines the viewport height
  82530. */
  82531. constructor(
  82532. /** viewport left coordinate */
  82533. x: number,
  82534. /** viewport top coordinate */
  82535. y: number,
  82536. /**viewport width */
  82537. width: number,
  82538. /** viewport height */
  82539. height: number);
  82540. /**
  82541. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82542. * @param renderWidth defines the rendering width
  82543. * @param renderHeight defines the rendering height
  82544. * @returns a new Viewport
  82545. */
  82546. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82547. /**
  82548. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82549. * @param renderWidth defines the rendering width
  82550. * @param renderHeight defines the rendering height
  82551. * @param ref defines the target viewport
  82552. * @returns the current viewport
  82553. */
  82554. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82555. /**
  82556. * Returns a new Viewport copied from the current one
  82557. * @returns a new Viewport
  82558. */
  82559. clone(): Viewport;
  82560. }
  82561. }
  82562. declare module BABYLON {
  82563. /**
  82564. * Class containing a set of static utilities functions for arrays.
  82565. */
  82566. export class ArrayTools {
  82567. /**
  82568. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82569. * @param size the number of element to construct and put in the array
  82570. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82571. * @returns a new array filled with new objects
  82572. */
  82573. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82574. }
  82575. }
  82576. declare module BABYLON {
  82577. /**
  82578. * Represents a plane by the equation ax + by + cz + d = 0
  82579. */
  82580. export class Plane {
  82581. private static _TmpMatrix;
  82582. /**
  82583. * Normal of the plane (a,b,c)
  82584. */
  82585. normal: Vector3;
  82586. /**
  82587. * d component of the plane
  82588. */
  82589. d: number;
  82590. /**
  82591. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82592. * @param a a component of the plane
  82593. * @param b b component of the plane
  82594. * @param c c component of the plane
  82595. * @param d d component of the plane
  82596. */
  82597. constructor(a: number, b: number, c: number, d: number);
  82598. /**
  82599. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82600. */
  82601. asArray(): number[];
  82602. /**
  82603. * @returns a new plane copied from the current Plane.
  82604. */
  82605. clone(): Plane;
  82606. /**
  82607. * @returns the string "Plane".
  82608. */
  82609. getClassName(): string;
  82610. /**
  82611. * @returns the Plane hash code.
  82612. */
  82613. getHashCode(): number;
  82614. /**
  82615. * Normalize the current Plane in place.
  82616. * @returns the updated Plane.
  82617. */
  82618. normalize(): Plane;
  82619. /**
  82620. * Applies a transformation the plane and returns the result
  82621. * @param transformation the transformation matrix to be applied to the plane
  82622. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82623. */
  82624. transform(transformation: DeepImmutable<Matrix>): Plane;
  82625. /**
  82626. * Compute the dot product between the point and the plane normal
  82627. * @param point point to calculate the dot product with
  82628. * @returns the dot product (float) of the point coordinates and the plane normal.
  82629. */
  82630. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82631. /**
  82632. * Updates the current Plane from the plane defined by the three given points.
  82633. * @param point1 one of the points used to contruct the plane
  82634. * @param point2 one of the points used to contruct the plane
  82635. * @param point3 one of the points used to contruct the plane
  82636. * @returns the updated Plane.
  82637. */
  82638. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82639. /**
  82640. * Checks if the plane is facing a given direction
  82641. * @param direction the direction to check if the plane is facing
  82642. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82643. * @returns True is the vector "direction" is the same side than the plane normal.
  82644. */
  82645. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82646. /**
  82647. * Calculates the distance to a point
  82648. * @param point point to calculate distance to
  82649. * @returns the signed distance (float) from the given point to the Plane.
  82650. */
  82651. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82652. /**
  82653. * Creates a plane from an array
  82654. * @param array the array to create a plane from
  82655. * @returns a new Plane from the given array.
  82656. */
  82657. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82658. /**
  82659. * Creates a plane from three points
  82660. * @param point1 point used to create the plane
  82661. * @param point2 point used to create the plane
  82662. * @param point3 point used to create the plane
  82663. * @returns a new Plane defined by the three given points.
  82664. */
  82665. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82666. /**
  82667. * Creates a plane from an origin point and a normal
  82668. * @param origin origin of the plane to be constructed
  82669. * @param normal normal of the plane to be constructed
  82670. * @returns a new Plane the normal vector to this plane at the given origin point.
  82671. * Note : the vector "normal" is updated because normalized.
  82672. */
  82673. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82674. /**
  82675. * Calculates the distance from a plane and a point
  82676. * @param origin origin of the plane to be constructed
  82677. * @param normal normal of the plane to be constructed
  82678. * @param point point to calculate distance to
  82679. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82680. */
  82681. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82682. }
  82683. }
  82684. declare module BABYLON {
  82685. /** @hidden */
  82686. export class PerformanceConfigurator {
  82687. /** @hidden */
  82688. static MatrixUse64Bits: boolean;
  82689. /** @hidden */
  82690. static MatrixTrackPrecisionChange: boolean;
  82691. /** @hidden */
  82692. static MatrixCurrentType: any;
  82693. /** @hidden */
  82694. static MatrixTrackedMatrices: Array<any> | null;
  82695. /** @hidden */
  82696. static SetMatrixPrecision(use64bits: boolean): void;
  82697. }
  82698. }
  82699. declare module BABYLON {
  82700. /**
  82701. * Class representing a vector containing 2 coordinates
  82702. */
  82703. export class Vector2 {
  82704. /** defines the first coordinate */
  82705. x: number;
  82706. /** defines the second coordinate */
  82707. y: number;
  82708. /**
  82709. * Creates a new Vector2 from the given x and y coordinates
  82710. * @param x defines the first coordinate
  82711. * @param y defines the second coordinate
  82712. */
  82713. constructor(
  82714. /** defines the first coordinate */
  82715. x?: number,
  82716. /** defines the second coordinate */
  82717. y?: number);
  82718. /**
  82719. * Gets a string with the Vector2 coordinates
  82720. * @returns a string with the Vector2 coordinates
  82721. */
  82722. toString(): string;
  82723. /**
  82724. * Gets class name
  82725. * @returns the string "Vector2"
  82726. */
  82727. getClassName(): string;
  82728. /**
  82729. * Gets current vector hash code
  82730. * @returns the Vector2 hash code as a number
  82731. */
  82732. getHashCode(): number;
  82733. /**
  82734. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82735. * @param array defines the source array
  82736. * @param index defines the offset in source array
  82737. * @returns the current Vector2
  82738. */
  82739. toArray(array: FloatArray, index?: number): Vector2;
  82740. /**
  82741. * Update the current vector from an array
  82742. * @param array defines the destination array
  82743. * @param index defines the offset in the destination array
  82744. * @returns the current Vector3
  82745. */
  82746. fromArray(array: FloatArray, index?: number): Vector2;
  82747. /**
  82748. * Copy the current vector to an array
  82749. * @returns a new array with 2 elements: the Vector2 coordinates.
  82750. */
  82751. asArray(): number[];
  82752. /**
  82753. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82754. * @param source defines the source Vector2
  82755. * @returns the current updated Vector2
  82756. */
  82757. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82758. /**
  82759. * Sets the Vector2 coordinates with the given floats
  82760. * @param x defines the first coordinate
  82761. * @param y defines the second coordinate
  82762. * @returns the current updated Vector2
  82763. */
  82764. copyFromFloats(x: number, y: number): Vector2;
  82765. /**
  82766. * Sets the Vector2 coordinates with the given floats
  82767. * @param x defines the first coordinate
  82768. * @param y defines the second coordinate
  82769. * @returns the current updated Vector2
  82770. */
  82771. set(x: number, y: number): Vector2;
  82772. /**
  82773. * Add another vector with the current one
  82774. * @param otherVector defines the other vector
  82775. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82776. */
  82777. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82778. /**
  82779. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82780. * @param otherVector defines the other vector
  82781. * @param result defines the target vector
  82782. * @returns the unmodified current Vector2
  82783. */
  82784. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82785. /**
  82786. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82787. * @param otherVector defines the other vector
  82788. * @returns the current updated Vector2
  82789. */
  82790. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82791. /**
  82792. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82793. * @param otherVector defines the other vector
  82794. * @returns a new Vector2
  82795. */
  82796. addVector3(otherVector: Vector3): Vector2;
  82797. /**
  82798. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82799. * @param otherVector defines the other vector
  82800. * @returns a new Vector2
  82801. */
  82802. subtract(otherVector: Vector2): Vector2;
  82803. /**
  82804. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82805. * @param otherVector defines the other vector
  82806. * @param result defines the target vector
  82807. * @returns the unmodified current Vector2
  82808. */
  82809. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82810. /**
  82811. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82812. * @param otherVector defines the other vector
  82813. * @returns the current updated Vector2
  82814. */
  82815. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82816. /**
  82817. * Multiplies in place the current Vector2 coordinates by the given ones
  82818. * @param otherVector defines the other vector
  82819. * @returns the current updated Vector2
  82820. */
  82821. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82822. /**
  82823. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82824. * @param otherVector defines the other vector
  82825. * @returns a new Vector2
  82826. */
  82827. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82828. /**
  82829. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82830. * @param otherVector defines the other vector
  82831. * @param result defines the target vector
  82832. * @returns the unmodified current Vector2
  82833. */
  82834. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82835. /**
  82836. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82837. * @param x defines the first coordinate
  82838. * @param y defines the second coordinate
  82839. * @returns a new Vector2
  82840. */
  82841. multiplyByFloats(x: number, y: number): Vector2;
  82842. /**
  82843. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82844. * @param otherVector defines the other vector
  82845. * @returns a new Vector2
  82846. */
  82847. divide(otherVector: Vector2): Vector2;
  82848. /**
  82849. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82850. * @param otherVector defines the other vector
  82851. * @param result defines the target vector
  82852. * @returns the unmodified current Vector2
  82853. */
  82854. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82855. /**
  82856. * Divides the current Vector2 coordinates by the given ones
  82857. * @param otherVector defines the other vector
  82858. * @returns the current updated Vector2
  82859. */
  82860. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82861. /**
  82862. * Gets a new Vector2 with current Vector2 negated coordinates
  82863. * @returns a new Vector2
  82864. */
  82865. negate(): Vector2;
  82866. /**
  82867. * Negate this vector in place
  82868. * @returns this
  82869. */
  82870. negateInPlace(): Vector2;
  82871. /**
  82872. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82873. * @param result defines the Vector3 object where to store the result
  82874. * @returns the current Vector2
  82875. */
  82876. negateToRef(result: Vector2): Vector2;
  82877. /**
  82878. * Multiply the Vector2 coordinates by scale
  82879. * @param scale defines the scaling factor
  82880. * @returns the current updated Vector2
  82881. */
  82882. scaleInPlace(scale: number): Vector2;
  82883. /**
  82884. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82885. * @param scale defines the scaling factor
  82886. * @returns a new Vector2
  82887. */
  82888. scale(scale: number): Vector2;
  82889. /**
  82890. * Scale the current Vector2 values by a factor to a given Vector2
  82891. * @param scale defines the scale factor
  82892. * @param result defines the Vector2 object where to store the result
  82893. * @returns the unmodified current Vector2
  82894. */
  82895. scaleToRef(scale: number, result: Vector2): Vector2;
  82896. /**
  82897. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82898. * @param scale defines the scale factor
  82899. * @param result defines the Vector2 object where to store the result
  82900. * @returns the unmodified current Vector2
  82901. */
  82902. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82903. /**
  82904. * Gets a boolean if two vectors are equals
  82905. * @param otherVector defines the other vector
  82906. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82907. */
  82908. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82909. /**
  82910. * Gets a boolean if two vectors are equals (using an epsilon value)
  82911. * @param otherVector defines the other vector
  82912. * @param epsilon defines the minimal distance to consider equality
  82913. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82914. */
  82915. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82916. /**
  82917. * Gets a new Vector2 from current Vector2 floored values
  82918. * @returns a new Vector2
  82919. */
  82920. floor(): Vector2;
  82921. /**
  82922. * Gets a new Vector2 from current Vector2 floored values
  82923. * @returns a new Vector2
  82924. */
  82925. fract(): Vector2;
  82926. /**
  82927. * Gets the length of the vector
  82928. * @returns the vector length (float)
  82929. */
  82930. length(): number;
  82931. /**
  82932. * Gets the vector squared length
  82933. * @returns the vector squared length (float)
  82934. */
  82935. lengthSquared(): number;
  82936. /**
  82937. * Normalize the vector
  82938. * @returns the current updated Vector2
  82939. */
  82940. normalize(): Vector2;
  82941. /**
  82942. * Gets a new Vector2 copied from the Vector2
  82943. * @returns a new Vector2
  82944. */
  82945. clone(): Vector2;
  82946. /**
  82947. * Gets a new Vector2(0, 0)
  82948. * @returns a new Vector2
  82949. */
  82950. static Zero(): Vector2;
  82951. /**
  82952. * Gets a new Vector2(1, 1)
  82953. * @returns a new Vector2
  82954. */
  82955. static One(): Vector2;
  82956. /**
  82957. * Gets a new Vector2 set from the given index element of the given array
  82958. * @param array defines the data source
  82959. * @param offset defines the offset in the data source
  82960. * @returns a new Vector2
  82961. */
  82962. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82963. /**
  82964. * Sets "result" from the given index element of the given array
  82965. * @param array defines the data source
  82966. * @param offset defines the offset in the data source
  82967. * @param result defines the target vector
  82968. */
  82969. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82970. /**
  82971. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82972. * @param value1 defines 1st point of control
  82973. * @param value2 defines 2nd point of control
  82974. * @param value3 defines 3rd point of control
  82975. * @param value4 defines 4th point of control
  82976. * @param amount defines the interpolation factor
  82977. * @returns a new Vector2
  82978. */
  82979. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82980. /**
  82981. * 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".
  82982. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82983. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82984. * @param value defines the value to clamp
  82985. * @param min defines the lower limit
  82986. * @param max defines the upper limit
  82987. * @returns a new Vector2
  82988. */
  82989. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82990. /**
  82991. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82992. * @param value1 defines the 1st control point
  82993. * @param tangent1 defines the outgoing tangent
  82994. * @param value2 defines the 2nd control point
  82995. * @param tangent2 defines the incoming tangent
  82996. * @param amount defines the interpolation factor
  82997. * @returns a new Vector2
  82998. */
  82999. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83000. /**
  83001. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83002. * @param start defines the start vector
  83003. * @param end defines the end vector
  83004. * @param amount defines the interpolation factor
  83005. * @returns a new Vector2
  83006. */
  83007. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83008. /**
  83009. * Gets the dot product of the vector "left" and the vector "right"
  83010. * @param left defines first vector
  83011. * @param right defines second vector
  83012. * @returns the dot product (float)
  83013. */
  83014. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83015. /**
  83016. * Returns a new Vector2 equal to the normalized given vector
  83017. * @param vector defines the vector to normalize
  83018. * @returns a new Vector2
  83019. */
  83020. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83021. /**
  83022. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83023. * @param left defines 1st vector
  83024. * @param right defines 2nd vector
  83025. * @returns a new Vector2
  83026. */
  83027. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83028. /**
  83029. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83030. * @param left defines 1st vector
  83031. * @param right defines 2nd vector
  83032. * @returns a new Vector2
  83033. */
  83034. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83035. /**
  83036. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83037. * @param vector defines the vector to transform
  83038. * @param transformation defines the matrix to apply
  83039. * @returns a new Vector2
  83040. */
  83041. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83042. /**
  83043. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83044. * @param vector defines the vector to transform
  83045. * @param transformation defines the matrix to apply
  83046. * @param result defines the target vector
  83047. */
  83048. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83049. /**
  83050. * Determines if a given vector is included in a triangle
  83051. * @param p defines the vector to test
  83052. * @param p0 defines 1st triangle point
  83053. * @param p1 defines 2nd triangle point
  83054. * @param p2 defines 3rd triangle point
  83055. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83056. */
  83057. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83058. /**
  83059. * Gets the distance between the vectors "value1" and "value2"
  83060. * @param value1 defines first vector
  83061. * @param value2 defines second vector
  83062. * @returns the distance between vectors
  83063. */
  83064. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83065. /**
  83066. * Returns the squared distance between the vectors "value1" and "value2"
  83067. * @param value1 defines first vector
  83068. * @param value2 defines second vector
  83069. * @returns the squared distance between vectors
  83070. */
  83071. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83072. /**
  83073. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83074. * @param value1 defines first vector
  83075. * @param value2 defines second vector
  83076. * @returns a new Vector2
  83077. */
  83078. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83079. /**
  83080. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83081. * @param p defines the middle point
  83082. * @param segA defines one point of the segment
  83083. * @param segB defines the other point of the segment
  83084. * @returns the shortest distance
  83085. */
  83086. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83087. }
  83088. /**
  83089. * Class used to store (x,y,z) vector representation
  83090. * A Vector3 is the main object used in 3D geometry
  83091. * It can represent etiher the coordinates of a point the space, either a direction
  83092. * Reminder: js uses a left handed forward facing system
  83093. */
  83094. export class Vector3 {
  83095. private static _UpReadOnly;
  83096. private static _ZeroReadOnly;
  83097. /** @hidden */
  83098. _x: number;
  83099. /** @hidden */
  83100. _y: number;
  83101. /** @hidden */
  83102. _z: number;
  83103. /** @hidden */
  83104. _isDirty: boolean;
  83105. /** Gets or sets the x coordinate */
  83106. get x(): number;
  83107. set x(value: number);
  83108. /** Gets or sets the y coordinate */
  83109. get y(): number;
  83110. set y(value: number);
  83111. /** Gets or sets the z coordinate */
  83112. get z(): number;
  83113. set z(value: number);
  83114. /**
  83115. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83116. * @param x defines the first coordinates (on X axis)
  83117. * @param y defines the second coordinates (on Y axis)
  83118. * @param z defines the third coordinates (on Z axis)
  83119. */
  83120. constructor(x?: number, y?: number, z?: number);
  83121. /**
  83122. * Creates a string representation of the Vector3
  83123. * @returns a string with the Vector3 coordinates.
  83124. */
  83125. toString(): string;
  83126. /**
  83127. * Gets the class name
  83128. * @returns the string "Vector3"
  83129. */
  83130. getClassName(): string;
  83131. /**
  83132. * Creates the Vector3 hash code
  83133. * @returns a number which tends to be unique between Vector3 instances
  83134. */
  83135. getHashCode(): number;
  83136. /**
  83137. * Creates an array containing three elements : the coordinates of the Vector3
  83138. * @returns a new array of numbers
  83139. */
  83140. asArray(): number[];
  83141. /**
  83142. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83143. * @param array defines the destination array
  83144. * @param index defines the offset in the destination array
  83145. * @returns the current Vector3
  83146. */
  83147. toArray(array: FloatArray, index?: number): Vector3;
  83148. /**
  83149. * Update the current vector from an array
  83150. * @param array defines the destination array
  83151. * @param index defines the offset in the destination array
  83152. * @returns the current Vector3
  83153. */
  83154. fromArray(array: FloatArray, index?: number): Vector3;
  83155. /**
  83156. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83157. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83158. */
  83159. toQuaternion(): Quaternion;
  83160. /**
  83161. * Adds the given vector to the current Vector3
  83162. * @param otherVector defines the second operand
  83163. * @returns the current updated Vector3
  83164. */
  83165. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83166. /**
  83167. * Adds the given coordinates to the current Vector3
  83168. * @param x defines the x coordinate of the operand
  83169. * @param y defines the y coordinate of the operand
  83170. * @param z defines the z coordinate of the operand
  83171. * @returns the current updated Vector3
  83172. */
  83173. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83174. /**
  83175. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83176. * @param otherVector defines the second operand
  83177. * @returns the resulting Vector3
  83178. */
  83179. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83180. /**
  83181. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83182. * @param otherVector defines the second operand
  83183. * @param result defines the Vector3 object where to store the result
  83184. * @returns the current Vector3
  83185. */
  83186. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83187. /**
  83188. * Subtract the given vector from the current Vector3
  83189. * @param otherVector defines the second operand
  83190. * @returns the current updated Vector3
  83191. */
  83192. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83193. /**
  83194. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83195. * @param otherVector defines the second operand
  83196. * @returns the resulting Vector3
  83197. */
  83198. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83199. /**
  83200. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83201. * @param otherVector defines the second operand
  83202. * @param result defines the Vector3 object where to store the result
  83203. * @returns the current Vector3
  83204. */
  83205. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83206. /**
  83207. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83208. * @param x defines the x coordinate of the operand
  83209. * @param y defines the y coordinate of the operand
  83210. * @param z defines the z coordinate of the operand
  83211. * @returns the resulting Vector3
  83212. */
  83213. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83214. /**
  83215. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83216. * @param x defines the x coordinate of the operand
  83217. * @param y defines the y coordinate of the operand
  83218. * @param z defines the z coordinate of the operand
  83219. * @param result defines the Vector3 object where to store the result
  83220. * @returns the current Vector3
  83221. */
  83222. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83223. /**
  83224. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83225. * @returns a new Vector3
  83226. */
  83227. negate(): Vector3;
  83228. /**
  83229. * Negate this vector in place
  83230. * @returns this
  83231. */
  83232. negateInPlace(): Vector3;
  83233. /**
  83234. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83235. * @param result defines the Vector3 object where to store the result
  83236. * @returns the current Vector3
  83237. */
  83238. negateToRef(result: Vector3): Vector3;
  83239. /**
  83240. * Multiplies the Vector3 coordinates by the float "scale"
  83241. * @param scale defines the multiplier factor
  83242. * @returns the current updated Vector3
  83243. */
  83244. scaleInPlace(scale: number): Vector3;
  83245. /**
  83246. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83247. * @param scale defines the multiplier factor
  83248. * @returns a new Vector3
  83249. */
  83250. scale(scale: number): Vector3;
  83251. /**
  83252. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83253. * @param scale defines the multiplier factor
  83254. * @param result defines the Vector3 object where to store the result
  83255. * @returns the current Vector3
  83256. */
  83257. scaleToRef(scale: number, result: Vector3): Vector3;
  83258. /**
  83259. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83260. * @param scale defines the scale factor
  83261. * @param result defines the Vector3 object where to store the result
  83262. * @returns the unmodified current Vector3
  83263. */
  83264. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83265. /**
  83266. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83267. * @param origin defines the origin of the projection ray
  83268. * @param plane defines the plane to project to
  83269. * @returns the projected vector3
  83270. */
  83271. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83272. /**
  83273. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83274. * @param origin defines the origin of the projection ray
  83275. * @param plane defines the plane to project to
  83276. * @param result defines the Vector3 where to store the result
  83277. */
  83278. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83279. /**
  83280. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83281. * @param otherVector defines the second operand
  83282. * @returns true if both vectors are equals
  83283. */
  83284. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83285. /**
  83286. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83287. * @param otherVector defines the second operand
  83288. * @param epsilon defines the minimal distance to define values as equals
  83289. * @returns true if both vectors are distant less than epsilon
  83290. */
  83291. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83292. /**
  83293. * Returns true if the current Vector3 coordinates equals the given floats
  83294. * @param x defines the x coordinate of the operand
  83295. * @param y defines the y coordinate of the operand
  83296. * @param z defines the z coordinate of the operand
  83297. * @returns true if both vectors are equals
  83298. */
  83299. equalsToFloats(x: number, y: number, z: number): boolean;
  83300. /**
  83301. * Multiplies the current Vector3 coordinates by the given ones
  83302. * @param otherVector defines the second operand
  83303. * @returns the current updated Vector3
  83304. */
  83305. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83306. /**
  83307. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83308. * @param otherVector defines the second operand
  83309. * @returns the new Vector3
  83310. */
  83311. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83312. /**
  83313. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83314. * @param otherVector defines the second operand
  83315. * @param result defines the Vector3 object where to store the result
  83316. * @returns the current Vector3
  83317. */
  83318. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83319. /**
  83320. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83321. * @param x defines the x coordinate of the operand
  83322. * @param y defines the y coordinate of the operand
  83323. * @param z defines the z coordinate of the operand
  83324. * @returns the new Vector3
  83325. */
  83326. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83327. /**
  83328. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83329. * @param otherVector defines the second operand
  83330. * @returns the new Vector3
  83331. */
  83332. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83333. /**
  83334. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83335. * @param otherVector defines the second operand
  83336. * @param result defines the Vector3 object where to store the result
  83337. * @returns the current Vector3
  83338. */
  83339. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83340. /**
  83341. * Divides the current Vector3 coordinates by the given ones.
  83342. * @param otherVector defines the second operand
  83343. * @returns the current updated Vector3
  83344. */
  83345. divideInPlace(otherVector: Vector3): Vector3;
  83346. /**
  83347. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83348. * @param other defines the second operand
  83349. * @returns the current updated Vector3
  83350. */
  83351. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83352. /**
  83353. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83354. * @param other defines the second operand
  83355. * @returns the current updated Vector3
  83356. */
  83357. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83358. /**
  83359. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83360. * @param x defines the x coordinate of the operand
  83361. * @param y defines the y coordinate of the operand
  83362. * @param z defines the z coordinate of the operand
  83363. * @returns the current updated Vector3
  83364. */
  83365. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83366. /**
  83367. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83368. * @param x defines the x coordinate of the operand
  83369. * @param y defines the y coordinate of the operand
  83370. * @param z defines the z coordinate of the operand
  83371. * @returns the current updated Vector3
  83372. */
  83373. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83374. /**
  83375. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83376. * Check if is non uniform within a certain amount of decimal places to account for this
  83377. * @param epsilon the amount the values can differ
  83378. * @returns if the the vector is non uniform to a certain number of decimal places
  83379. */
  83380. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83381. /**
  83382. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83383. */
  83384. get isNonUniform(): boolean;
  83385. /**
  83386. * Gets a new Vector3 from current Vector3 floored values
  83387. * @returns a new Vector3
  83388. */
  83389. floor(): Vector3;
  83390. /**
  83391. * Gets a new Vector3 from current Vector3 floored values
  83392. * @returns a new Vector3
  83393. */
  83394. fract(): Vector3;
  83395. /**
  83396. * Gets the length of the Vector3
  83397. * @returns the length of the Vector3
  83398. */
  83399. length(): number;
  83400. /**
  83401. * Gets the squared length of the Vector3
  83402. * @returns squared length of the Vector3
  83403. */
  83404. lengthSquared(): number;
  83405. /**
  83406. * Normalize the current Vector3.
  83407. * Please note that this is an in place operation.
  83408. * @returns the current updated Vector3
  83409. */
  83410. normalize(): Vector3;
  83411. /**
  83412. * Reorders the x y z properties of the vector in place
  83413. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83414. * @returns the current updated vector
  83415. */
  83416. reorderInPlace(order: string): this;
  83417. /**
  83418. * Rotates the vector around 0,0,0 by a quaternion
  83419. * @param quaternion the rotation quaternion
  83420. * @param result vector to store the result
  83421. * @returns the resulting vector
  83422. */
  83423. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83424. /**
  83425. * Rotates a vector around a given point
  83426. * @param quaternion the rotation quaternion
  83427. * @param point the point to rotate around
  83428. * @param result vector to store the result
  83429. * @returns the resulting vector
  83430. */
  83431. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83432. /**
  83433. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83434. * The cross product is then orthogonal to both current and "other"
  83435. * @param other defines the right operand
  83436. * @returns the cross product
  83437. */
  83438. cross(other: Vector3): Vector3;
  83439. /**
  83440. * Normalize the current Vector3 with the given input length.
  83441. * Please note that this is an in place operation.
  83442. * @param len the length of the vector
  83443. * @returns the current updated Vector3
  83444. */
  83445. normalizeFromLength(len: number): Vector3;
  83446. /**
  83447. * Normalize the current Vector3 to a new vector
  83448. * @returns the new Vector3
  83449. */
  83450. normalizeToNew(): Vector3;
  83451. /**
  83452. * Normalize the current Vector3 to the reference
  83453. * @param reference define the Vector3 to update
  83454. * @returns the updated Vector3
  83455. */
  83456. normalizeToRef(reference: Vector3): Vector3;
  83457. /**
  83458. * Creates a new Vector3 copied from the current Vector3
  83459. * @returns the new Vector3
  83460. */
  83461. clone(): Vector3;
  83462. /**
  83463. * Copies the given vector coordinates to the current Vector3 ones
  83464. * @param source defines the source Vector3
  83465. * @returns the current updated Vector3
  83466. */
  83467. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83468. /**
  83469. * Copies the given floats to the current Vector3 coordinates
  83470. * @param x defines the x coordinate of the operand
  83471. * @param y defines the y coordinate of the operand
  83472. * @param z defines the z coordinate of the operand
  83473. * @returns the current updated Vector3
  83474. */
  83475. copyFromFloats(x: number, y: number, z: number): Vector3;
  83476. /**
  83477. * Copies the given floats to the current Vector3 coordinates
  83478. * @param x defines the x coordinate of the operand
  83479. * @param y defines the y coordinate of the operand
  83480. * @param z defines the z coordinate of the operand
  83481. * @returns the current updated Vector3
  83482. */
  83483. set(x: number, y: number, z: number): Vector3;
  83484. /**
  83485. * Copies the given float to the current Vector3 coordinates
  83486. * @param v defines the x, y and z coordinates of the operand
  83487. * @returns the current updated Vector3
  83488. */
  83489. setAll(v: number): Vector3;
  83490. /**
  83491. * Get the clip factor between two vectors
  83492. * @param vector0 defines the first operand
  83493. * @param vector1 defines the second operand
  83494. * @param axis defines the axis to use
  83495. * @param size defines the size along the axis
  83496. * @returns the clip factor
  83497. */
  83498. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83499. /**
  83500. * Get angle between two vectors
  83501. * @param vector0 angle between vector0 and vector1
  83502. * @param vector1 angle between vector0 and vector1
  83503. * @param normal direction of the normal
  83504. * @return the angle between vector0 and vector1
  83505. */
  83506. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83507. /**
  83508. * Returns a new Vector3 set from the index "offset" of the given array
  83509. * @param array defines the source array
  83510. * @param offset defines the offset in the source array
  83511. * @returns the new Vector3
  83512. */
  83513. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83514. /**
  83515. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83516. * @param array defines the source array
  83517. * @param offset defines the offset in the source array
  83518. * @returns the new Vector3
  83519. * @deprecated Please use FromArray instead.
  83520. */
  83521. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83522. /**
  83523. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83524. * @param array defines the source array
  83525. * @param offset defines the offset in the source array
  83526. * @param result defines the Vector3 where to store the result
  83527. */
  83528. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83529. /**
  83530. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83531. * @param array defines the source array
  83532. * @param offset defines the offset in the source array
  83533. * @param result defines the Vector3 where to store the result
  83534. * @deprecated Please use FromArrayToRef instead.
  83535. */
  83536. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83537. /**
  83538. * Sets the given vector "result" with the given floats.
  83539. * @param x defines the x coordinate of the source
  83540. * @param y defines the y coordinate of the source
  83541. * @param z defines the z coordinate of the source
  83542. * @param result defines the Vector3 where to store the result
  83543. */
  83544. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83545. /**
  83546. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83547. * @returns a new empty Vector3
  83548. */
  83549. static Zero(): Vector3;
  83550. /**
  83551. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83552. * @returns a new unit Vector3
  83553. */
  83554. static One(): Vector3;
  83555. /**
  83556. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83557. * @returns a new up Vector3
  83558. */
  83559. static Up(): Vector3;
  83560. /**
  83561. * Gets a up Vector3 that must not be updated
  83562. */
  83563. static get UpReadOnly(): DeepImmutable<Vector3>;
  83564. /**
  83565. * Gets a zero Vector3 that must not be updated
  83566. */
  83567. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83568. /**
  83569. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83570. * @returns a new down Vector3
  83571. */
  83572. static Down(): Vector3;
  83573. /**
  83574. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83575. * @param rightHandedSystem is the scene right-handed (negative z)
  83576. * @returns a new forward Vector3
  83577. */
  83578. static Forward(rightHandedSystem?: boolean): Vector3;
  83579. /**
  83580. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83581. * @param rightHandedSystem is the scene right-handed (negative-z)
  83582. * @returns a new forward Vector3
  83583. */
  83584. static Backward(rightHandedSystem?: boolean): Vector3;
  83585. /**
  83586. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83587. * @returns a new right Vector3
  83588. */
  83589. static Right(): Vector3;
  83590. /**
  83591. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83592. * @returns a new left Vector3
  83593. */
  83594. static Left(): Vector3;
  83595. /**
  83596. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83597. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83598. * @param vector defines the Vector3 to transform
  83599. * @param transformation defines the transformation matrix
  83600. * @returns the transformed Vector3
  83601. */
  83602. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83603. /**
  83604. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83605. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83606. * @param vector defines the Vector3 to transform
  83607. * @param transformation defines the transformation matrix
  83608. * @param result defines the Vector3 where to store the result
  83609. */
  83610. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83611. /**
  83612. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83613. * This method computes tranformed coordinates only, not transformed direction vectors
  83614. * @param x define the x coordinate of the source vector
  83615. * @param y define the y coordinate of the source vector
  83616. * @param z define the z coordinate of the source vector
  83617. * @param transformation defines the transformation matrix
  83618. * @param result defines the Vector3 where to store the result
  83619. */
  83620. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83621. /**
  83622. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83623. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83624. * @param vector defines the Vector3 to transform
  83625. * @param transformation defines the transformation matrix
  83626. * @returns the new Vector3
  83627. */
  83628. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83629. /**
  83630. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83631. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83632. * @param vector defines the Vector3 to transform
  83633. * @param transformation defines the transformation matrix
  83634. * @param result defines the Vector3 where to store the result
  83635. */
  83636. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83637. /**
  83638. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83639. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83640. * @param x define the x coordinate of the source vector
  83641. * @param y define the y coordinate of the source vector
  83642. * @param z define the z coordinate of the source vector
  83643. * @param transformation defines the transformation matrix
  83644. * @param result defines the Vector3 where to store the result
  83645. */
  83646. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83647. /**
  83648. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83649. * @param value1 defines the first control point
  83650. * @param value2 defines the second control point
  83651. * @param value3 defines the third control point
  83652. * @param value4 defines the fourth control point
  83653. * @param amount defines the amount on the spline to use
  83654. * @returns the new Vector3
  83655. */
  83656. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83657. /**
  83658. * 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"
  83659. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83660. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83661. * @param value defines the current value
  83662. * @param min defines the lower range value
  83663. * @param max defines the upper range value
  83664. * @returns the new Vector3
  83665. */
  83666. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83667. /**
  83668. * 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"
  83669. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83670. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83671. * @param value defines the current value
  83672. * @param min defines the lower range value
  83673. * @param max defines the upper range value
  83674. * @param result defines the Vector3 where to store the result
  83675. */
  83676. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83677. /**
  83678. * Checks if a given vector is inside a specific range
  83679. * @param v defines the vector to test
  83680. * @param min defines the minimum range
  83681. * @param max defines the maximum range
  83682. */
  83683. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83684. /**
  83685. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83686. * @param value1 defines the first control point
  83687. * @param tangent1 defines the first tangent vector
  83688. * @param value2 defines the second control point
  83689. * @param tangent2 defines the second tangent vector
  83690. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83691. * @returns the new Vector3
  83692. */
  83693. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83694. /**
  83695. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83696. * @param start defines the start value
  83697. * @param end defines the end value
  83698. * @param amount max defines amount between both (between 0 and 1)
  83699. * @returns the new Vector3
  83700. */
  83701. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83702. /**
  83703. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83704. * @param start defines the start value
  83705. * @param end defines the end value
  83706. * @param amount max defines amount between both (between 0 and 1)
  83707. * @param result defines the Vector3 where to store the result
  83708. */
  83709. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83710. /**
  83711. * Returns the dot product (float) between the vectors "left" and "right"
  83712. * @param left defines the left operand
  83713. * @param right defines the right operand
  83714. * @returns the dot product
  83715. */
  83716. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83717. /**
  83718. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83719. * The cross product is then orthogonal to both "left" and "right"
  83720. * @param left defines the left operand
  83721. * @param right defines the right operand
  83722. * @returns the cross product
  83723. */
  83724. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83725. /**
  83726. * Sets the given vector "result" with the cross product of "left" and "right"
  83727. * The cross product is then orthogonal to both "left" and "right"
  83728. * @param left defines the left operand
  83729. * @param right defines the right operand
  83730. * @param result defines the Vector3 where to store the result
  83731. */
  83732. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83733. /**
  83734. * Returns a new Vector3 as the normalization of the given vector
  83735. * @param vector defines the Vector3 to normalize
  83736. * @returns the new Vector3
  83737. */
  83738. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83739. /**
  83740. * Sets the given vector "result" with the normalization of the given first vector
  83741. * @param vector defines the Vector3 to normalize
  83742. * @param result defines the Vector3 where to store the result
  83743. */
  83744. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83745. /**
  83746. * Project a Vector3 onto screen space
  83747. * @param vector defines the Vector3 to project
  83748. * @param world defines the world matrix to use
  83749. * @param transform defines the transform (view x projection) matrix to use
  83750. * @param viewport defines the screen viewport to use
  83751. * @returns the new Vector3
  83752. */
  83753. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83754. /** @hidden */
  83755. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83756. /**
  83757. * Unproject from screen space to object space
  83758. * @param source defines the screen space Vector3 to use
  83759. * @param viewportWidth defines the current width of the viewport
  83760. * @param viewportHeight defines the current height of the viewport
  83761. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83762. * @param transform defines the transform (view x projection) matrix to use
  83763. * @returns the new Vector3
  83764. */
  83765. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83766. /**
  83767. * Unproject from screen space to object space
  83768. * @param source defines the screen space Vector3 to use
  83769. * @param viewportWidth defines the current width of the viewport
  83770. * @param viewportHeight defines the current height of the viewport
  83771. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83772. * @param view defines the view matrix to use
  83773. * @param projection defines the projection matrix to use
  83774. * @returns the new Vector3
  83775. */
  83776. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83777. /**
  83778. * Unproject from screen space to object space
  83779. * @param source defines the screen space Vector3 to use
  83780. * @param viewportWidth defines the current width of the viewport
  83781. * @param viewportHeight defines the current height of the viewport
  83782. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83783. * @param view defines the view matrix to use
  83784. * @param projection defines the projection matrix to use
  83785. * @param result defines the Vector3 where to store the result
  83786. */
  83787. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83788. /**
  83789. * Unproject from screen space to object space
  83790. * @param sourceX defines the screen space x coordinate to use
  83791. * @param sourceY defines the screen space y coordinate to use
  83792. * @param sourceZ defines the screen space z coordinate to use
  83793. * @param viewportWidth defines the current width of the viewport
  83794. * @param viewportHeight defines the current height of the viewport
  83795. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83796. * @param view defines the view matrix to use
  83797. * @param projection defines the projection matrix to use
  83798. * @param result defines the Vector3 where to store the result
  83799. */
  83800. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83801. /**
  83802. * Gets the minimal coordinate values between two Vector3
  83803. * @param left defines the first operand
  83804. * @param right defines the second operand
  83805. * @returns the new Vector3
  83806. */
  83807. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83808. /**
  83809. * Gets the maximal coordinate values between two Vector3
  83810. * @param left defines the first operand
  83811. * @param right defines the second operand
  83812. * @returns the new Vector3
  83813. */
  83814. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83815. /**
  83816. * Returns the distance between the vectors "value1" and "value2"
  83817. * @param value1 defines the first operand
  83818. * @param value2 defines the second operand
  83819. * @returns the distance
  83820. */
  83821. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83822. /**
  83823. * Returns the squared distance between the vectors "value1" and "value2"
  83824. * @param value1 defines the first operand
  83825. * @param value2 defines the second operand
  83826. * @returns the squared distance
  83827. */
  83828. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83829. /**
  83830. * Returns a new Vector3 located at the center between "value1" and "value2"
  83831. * @param value1 defines the first operand
  83832. * @param value2 defines the second operand
  83833. * @returns the new Vector3
  83834. */
  83835. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83836. /**
  83837. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83838. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83839. * to something in order to rotate it from its local system to the given target system
  83840. * Note: axis1, axis2 and axis3 are normalized during this operation
  83841. * @param axis1 defines the first axis
  83842. * @param axis2 defines the second axis
  83843. * @param axis3 defines the third axis
  83844. * @returns a new Vector3
  83845. */
  83846. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83847. /**
  83848. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83849. * @param axis1 defines the first axis
  83850. * @param axis2 defines the second axis
  83851. * @param axis3 defines the third axis
  83852. * @param ref defines the Vector3 where to store the result
  83853. */
  83854. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83855. }
  83856. /**
  83857. * Vector4 class created for EulerAngle class conversion to Quaternion
  83858. */
  83859. export class Vector4 {
  83860. /** x value of the vector */
  83861. x: number;
  83862. /** y value of the vector */
  83863. y: number;
  83864. /** z value of the vector */
  83865. z: number;
  83866. /** w value of the vector */
  83867. w: number;
  83868. /**
  83869. * Creates a Vector4 object from the given floats.
  83870. * @param x x value of the vector
  83871. * @param y y value of the vector
  83872. * @param z z value of the vector
  83873. * @param w w value of the vector
  83874. */
  83875. constructor(
  83876. /** x value of the vector */
  83877. x: number,
  83878. /** y value of the vector */
  83879. y: number,
  83880. /** z value of the vector */
  83881. z: number,
  83882. /** w value of the vector */
  83883. w: number);
  83884. /**
  83885. * Returns the string with the Vector4 coordinates.
  83886. * @returns a string containing all the vector values
  83887. */
  83888. toString(): string;
  83889. /**
  83890. * Returns the string "Vector4".
  83891. * @returns "Vector4"
  83892. */
  83893. getClassName(): string;
  83894. /**
  83895. * Returns the Vector4 hash code.
  83896. * @returns a unique hash code
  83897. */
  83898. getHashCode(): number;
  83899. /**
  83900. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83901. * @returns the resulting array
  83902. */
  83903. asArray(): number[];
  83904. /**
  83905. * Populates the given array from the given index with the Vector4 coordinates.
  83906. * @param array array to populate
  83907. * @param index index of the array to start at (default: 0)
  83908. * @returns the Vector4.
  83909. */
  83910. toArray(array: FloatArray, index?: number): Vector4;
  83911. /**
  83912. * Update the current vector from an array
  83913. * @param array defines the destination array
  83914. * @param index defines the offset in the destination array
  83915. * @returns the current Vector3
  83916. */
  83917. fromArray(array: FloatArray, index?: number): Vector4;
  83918. /**
  83919. * Adds the given vector to the current Vector4.
  83920. * @param otherVector the vector to add
  83921. * @returns the updated Vector4.
  83922. */
  83923. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83924. /**
  83925. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83926. * @param otherVector the vector to add
  83927. * @returns the resulting vector
  83928. */
  83929. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83930. /**
  83931. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83932. * @param otherVector the vector to add
  83933. * @param result the vector to store the result
  83934. * @returns the current Vector4.
  83935. */
  83936. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83937. /**
  83938. * Subtract in place the given vector from the current Vector4.
  83939. * @param otherVector the vector to subtract
  83940. * @returns the updated Vector4.
  83941. */
  83942. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83943. /**
  83944. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83945. * @param otherVector the vector to add
  83946. * @returns the new vector with the result
  83947. */
  83948. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83949. /**
  83950. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83951. * @param otherVector the vector to subtract
  83952. * @param result the vector to store the result
  83953. * @returns the current Vector4.
  83954. */
  83955. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83956. /**
  83957. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83958. */
  83959. /**
  83960. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83961. * @param x value to subtract
  83962. * @param y value to subtract
  83963. * @param z value to subtract
  83964. * @param w value to subtract
  83965. * @returns new vector containing the result
  83966. */
  83967. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83968. /**
  83969. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83970. * @param x value to subtract
  83971. * @param y value to subtract
  83972. * @param z value to subtract
  83973. * @param w value to subtract
  83974. * @param result the vector to store the result in
  83975. * @returns the current Vector4.
  83976. */
  83977. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83978. /**
  83979. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83980. * @returns a new vector with the negated values
  83981. */
  83982. negate(): Vector4;
  83983. /**
  83984. * Negate this vector in place
  83985. * @returns this
  83986. */
  83987. negateInPlace(): Vector4;
  83988. /**
  83989. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83990. * @param result defines the Vector3 object where to store the result
  83991. * @returns the current Vector4
  83992. */
  83993. negateToRef(result: Vector4): Vector4;
  83994. /**
  83995. * Multiplies the current Vector4 coordinates by scale (float).
  83996. * @param scale the number to scale with
  83997. * @returns the updated Vector4.
  83998. */
  83999. scaleInPlace(scale: number): Vector4;
  84000. /**
  84001. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84002. * @param scale the number to scale with
  84003. * @returns a new vector with the result
  84004. */
  84005. scale(scale: number): Vector4;
  84006. /**
  84007. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84008. * @param scale the number to scale with
  84009. * @param result a vector to store the result in
  84010. * @returns the current Vector4.
  84011. */
  84012. scaleToRef(scale: number, result: Vector4): Vector4;
  84013. /**
  84014. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84015. * @param scale defines the scale factor
  84016. * @param result defines the Vector4 object where to store the result
  84017. * @returns the unmodified current Vector4
  84018. */
  84019. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84020. /**
  84021. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84022. * @param otherVector the vector to compare against
  84023. * @returns true if they are equal
  84024. */
  84025. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84026. /**
  84027. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84028. * @param otherVector vector to compare against
  84029. * @param epsilon (Default: very small number)
  84030. * @returns true if they are equal
  84031. */
  84032. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84033. /**
  84034. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84035. * @param x x value to compare against
  84036. * @param y y value to compare against
  84037. * @param z z value to compare against
  84038. * @param w w value to compare against
  84039. * @returns true if equal
  84040. */
  84041. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84042. /**
  84043. * Multiplies in place the current Vector4 by the given one.
  84044. * @param otherVector vector to multiple with
  84045. * @returns the updated Vector4.
  84046. */
  84047. multiplyInPlace(otherVector: Vector4): Vector4;
  84048. /**
  84049. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84050. * @param otherVector vector to multiple with
  84051. * @returns resulting new vector
  84052. */
  84053. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84054. /**
  84055. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84056. * @param otherVector vector to multiple with
  84057. * @param result vector to store the result
  84058. * @returns the current Vector4.
  84059. */
  84060. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84061. /**
  84062. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84063. * @param x x value multiply with
  84064. * @param y y value multiply with
  84065. * @param z z value multiply with
  84066. * @param w w value multiply with
  84067. * @returns resulting new vector
  84068. */
  84069. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84070. /**
  84071. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84072. * @param otherVector vector to devide with
  84073. * @returns resulting new vector
  84074. */
  84075. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84076. /**
  84077. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84078. * @param otherVector vector to devide with
  84079. * @param result vector to store the result
  84080. * @returns the current Vector4.
  84081. */
  84082. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84083. /**
  84084. * Divides the current Vector3 coordinates by the given ones.
  84085. * @param otherVector vector to devide with
  84086. * @returns the updated Vector3.
  84087. */
  84088. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84089. /**
  84090. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84091. * @param other defines the second operand
  84092. * @returns the current updated Vector4
  84093. */
  84094. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84095. /**
  84096. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84097. * @param other defines the second operand
  84098. * @returns the current updated Vector4
  84099. */
  84100. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84101. /**
  84102. * Gets a new Vector4 from current Vector4 floored values
  84103. * @returns a new Vector4
  84104. */
  84105. floor(): Vector4;
  84106. /**
  84107. * Gets a new Vector4 from current Vector3 floored values
  84108. * @returns a new Vector4
  84109. */
  84110. fract(): Vector4;
  84111. /**
  84112. * Returns the Vector4 length (float).
  84113. * @returns the length
  84114. */
  84115. length(): number;
  84116. /**
  84117. * Returns the Vector4 squared length (float).
  84118. * @returns the length squared
  84119. */
  84120. lengthSquared(): number;
  84121. /**
  84122. * Normalizes in place the Vector4.
  84123. * @returns the updated Vector4.
  84124. */
  84125. normalize(): Vector4;
  84126. /**
  84127. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84128. * @returns this converted to a new vector3
  84129. */
  84130. toVector3(): Vector3;
  84131. /**
  84132. * Returns a new Vector4 copied from the current one.
  84133. * @returns the new cloned vector
  84134. */
  84135. clone(): Vector4;
  84136. /**
  84137. * Updates the current Vector4 with the given one coordinates.
  84138. * @param source the source vector to copy from
  84139. * @returns the updated Vector4.
  84140. */
  84141. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84142. /**
  84143. * Updates the current Vector4 coordinates with the given floats.
  84144. * @param x float to copy from
  84145. * @param y float to copy from
  84146. * @param z float to copy from
  84147. * @param w float to copy from
  84148. * @returns the updated Vector4.
  84149. */
  84150. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84151. /**
  84152. * Updates the current Vector4 coordinates with the given floats.
  84153. * @param x float to set from
  84154. * @param y float to set from
  84155. * @param z float to set from
  84156. * @param w float to set from
  84157. * @returns the updated Vector4.
  84158. */
  84159. set(x: number, y: number, z: number, w: number): Vector4;
  84160. /**
  84161. * Copies the given float to the current Vector3 coordinates
  84162. * @param v defines the x, y, z and w coordinates of the operand
  84163. * @returns the current updated Vector3
  84164. */
  84165. setAll(v: number): Vector4;
  84166. /**
  84167. * Returns a new Vector4 set from the starting index of the given array.
  84168. * @param array the array to pull values from
  84169. * @param offset the offset into the array to start at
  84170. * @returns the new vector
  84171. */
  84172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84173. /**
  84174. * Updates the given vector "result" from the starting index of the given array.
  84175. * @param array the array to pull values from
  84176. * @param offset the offset into the array to start at
  84177. * @param result the vector to store the result in
  84178. */
  84179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84180. /**
  84181. * Updates the given vector "result" from the starting index of the given Float32Array.
  84182. * @param array the array to pull values from
  84183. * @param offset the offset into the array to start at
  84184. * @param result the vector to store the result in
  84185. */
  84186. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84187. /**
  84188. * Updates the given vector "result" coordinates from the given floats.
  84189. * @param x float to set from
  84190. * @param y float to set from
  84191. * @param z float to set from
  84192. * @param w float to set from
  84193. * @param result the vector to the floats in
  84194. */
  84195. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84196. /**
  84197. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84198. * @returns the new vector
  84199. */
  84200. static Zero(): Vector4;
  84201. /**
  84202. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84203. * @returns the new vector
  84204. */
  84205. static One(): Vector4;
  84206. /**
  84207. * Returns a new normalized Vector4 from the given one.
  84208. * @param vector the vector to normalize
  84209. * @returns the vector
  84210. */
  84211. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84212. /**
  84213. * Updates the given vector "result" from the normalization of the given one.
  84214. * @param vector the vector to normalize
  84215. * @param result the vector to store the result in
  84216. */
  84217. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84218. /**
  84219. * Returns a vector with the minimum values from the left and right vectors
  84220. * @param left left vector to minimize
  84221. * @param right right vector to minimize
  84222. * @returns a new vector with the minimum of the left and right vector values
  84223. */
  84224. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84225. /**
  84226. * Returns a vector with the maximum values from the left and right vectors
  84227. * @param left left vector to maximize
  84228. * @param right right vector to maximize
  84229. * @returns a new vector with the maximum of the left and right vector values
  84230. */
  84231. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84232. /**
  84233. * Returns the distance (float) between the vectors "value1" and "value2".
  84234. * @param value1 value to calulate the distance between
  84235. * @param value2 value to calulate the distance between
  84236. * @return the distance between the two vectors
  84237. */
  84238. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84239. /**
  84240. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84241. * @param value1 value to calulate the distance between
  84242. * @param value2 value to calulate the distance between
  84243. * @return the distance between the two vectors squared
  84244. */
  84245. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84246. /**
  84247. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84248. * @param value1 value to calulate the center between
  84249. * @param value2 value to calulate the center between
  84250. * @return the center between the two vectors
  84251. */
  84252. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84253. /**
  84254. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84255. * This methods computes transformed normalized direction vectors only.
  84256. * @param vector the vector to transform
  84257. * @param transformation the transformation matrix to apply
  84258. * @returns the new vector
  84259. */
  84260. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84261. /**
  84262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84263. * This methods computes transformed normalized direction vectors only.
  84264. * @param vector the vector to transform
  84265. * @param transformation the transformation matrix to apply
  84266. * @param result the vector to store the result in
  84267. */
  84268. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84269. /**
  84270. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84271. * This methods computes transformed normalized direction vectors only.
  84272. * @param x value to transform
  84273. * @param y value to transform
  84274. * @param z value to transform
  84275. * @param w value to transform
  84276. * @param transformation the transformation matrix to apply
  84277. * @param result the vector to store the results in
  84278. */
  84279. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84280. /**
  84281. * Creates a new Vector4 from a Vector3
  84282. * @param source defines the source data
  84283. * @param w defines the 4th component (default is 0)
  84284. * @returns a new Vector4
  84285. */
  84286. static FromVector3(source: Vector3, w?: number): Vector4;
  84287. }
  84288. /**
  84289. * Class used to store quaternion data
  84290. * @see https://en.wikipedia.org/wiki/Quaternion
  84291. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84292. */
  84293. export class Quaternion {
  84294. /** @hidden */
  84295. _x: number;
  84296. /** @hidden */
  84297. _y: number;
  84298. /** @hidden */
  84299. _z: number;
  84300. /** @hidden */
  84301. _w: number;
  84302. /** @hidden */
  84303. _isDirty: boolean;
  84304. /** Gets or sets the x coordinate */
  84305. get x(): number;
  84306. set x(value: number);
  84307. /** Gets or sets the y coordinate */
  84308. get y(): number;
  84309. set y(value: number);
  84310. /** Gets or sets the z coordinate */
  84311. get z(): number;
  84312. set z(value: number);
  84313. /** Gets or sets the w coordinate */
  84314. get w(): number;
  84315. set w(value: number);
  84316. /**
  84317. * Creates a new Quaternion from the given floats
  84318. * @param x defines the first component (0 by default)
  84319. * @param y defines the second component (0 by default)
  84320. * @param z defines the third component (0 by default)
  84321. * @param w defines the fourth component (1.0 by default)
  84322. */
  84323. constructor(x?: number, y?: number, z?: number, w?: number);
  84324. /**
  84325. * Gets a string representation for the current quaternion
  84326. * @returns a string with the Quaternion coordinates
  84327. */
  84328. toString(): string;
  84329. /**
  84330. * Gets the class name of the quaternion
  84331. * @returns the string "Quaternion"
  84332. */
  84333. getClassName(): string;
  84334. /**
  84335. * Gets a hash code for this quaternion
  84336. * @returns the quaternion hash code
  84337. */
  84338. getHashCode(): number;
  84339. /**
  84340. * Copy the quaternion to an array
  84341. * @returns a new array populated with 4 elements from the quaternion coordinates
  84342. */
  84343. asArray(): number[];
  84344. /**
  84345. * Check if two quaternions are equals
  84346. * @param otherQuaternion defines the second operand
  84347. * @return true if the current quaternion and the given one coordinates are strictly equals
  84348. */
  84349. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84350. /**
  84351. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84352. * @param otherQuaternion defines the other quaternion
  84353. * @param epsilon defines the minimal distance to consider equality
  84354. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84355. */
  84356. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84357. /**
  84358. * Clone the current quaternion
  84359. * @returns a new quaternion copied from the current one
  84360. */
  84361. clone(): Quaternion;
  84362. /**
  84363. * Copy a quaternion to the current one
  84364. * @param other defines the other quaternion
  84365. * @returns the updated current quaternion
  84366. */
  84367. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84368. /**
  84369. * Updates the current quaternion with the given float coordinates
  84370. * @param x defines the x coordinate
  84371. * @param y defines the y coordinate
  84372. * @param z defines the z coordinate
  84373. * @param w defines the w coordinate
  84374. * @returns the updated current quaternion
  84375. */
  84376. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84377. /**
  84378. * Updates the current quaternion from the given float coordinates
  84379. * @param x defines the x coordinate
  84380. * @param y defines the y coordinate
  84381. * @param z defines the z coordinate
  84382. * @param w defines the w coordinate
  84383. * @returns the updated current quaternion
  84384. */
  84385. set(x: number, y: number, z: number, w: number): Quaternion;
  84386. /**
  84387. * Adds two quaternions
  84388. * @param other defines the second operand
  84389. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84390. */
  84391. add(other: DeepImmutable<Quaternion>): Quaternion;
  84392. /**
  84393. * Add a quaternion to the current one
  84394. * @param other defines the quaternion to add
  84395. * @returns the current quaternion
  84396. */
  84397. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84398. /**
  84399. * Subtract two quaternions
  84400. * @param other defines the second operand
  84401. * @returns a new quaternion as the subtraction result of the given one from the current one
  84402. */
  84403. subtract(other: Quaternion): Quaternion;
  84404. /**
  84405. * Multiplies the current quaternion by a scale factor
  84406. * @param value defines the scale factor
  84407. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84408. */
  84409. scale(value: number): Quaternion;
  84410. /**
  84411. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84412. * @param scale defines the scale factor
  84413. * @param result defines the Quaternion object where to store the result
  84414. * @returns the unmodified current quaternion
  84415. */
  84416. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84417. /**
  84418. * Multiplies in place the current quaternion by a scale factor
  84419. * @param value defines the scale factor
  84420. * @returns the current modified quaternion
  84421. */
  84422. scaleInPlace(value: number): Quaternion;
  84423. /**
  84424. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84425. * @param scale defines the scale factor
  84426. * @param result defines the Quaternion object where to store the result
  84427. * @returns the unmodified current quaternion
  84428. */
  84429. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84430. /**
  84431. * Multiplies two quaternions
  84432. * @param q1 defines the second operand
  84433. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84434. */
  84435. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84436. /**
  84437. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84438. * @param q1 defines the second operand
  84439. * @param result defines the target quaternion
  84440. * @returns the current quaternion
  84441. */
  84442. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84443. /**
  84444. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84445. * @param q1 defines the second operand
  84446. * @returns the currentupdated quaternion
  84447. */
  84448. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84449. /**
  84450. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84451. * @param ref defines the target quaternion
  84452. * @returns the current quaternion
  84453. */
  84454. conjugateToRef(ref: Quaternion): Quaternion;
  84455. /**
  84456. * Conjugates in place (1-q) the current quaternion
  84457. * @returns the current updated quaternion
  84458. */
  84459. conjugateInPlace(): Quaternion;
  84460. /**
  84461. * Conjugates in place (1-q) the current quaternion
  84462. * @returns a new quaternion
  84463. */
  84464. conjugate(): Quaternion;
  84465. /**
  84466. * Gets length of current quaternion
  84467. * @returns the quaternion length (float)
  84468. */
  84469. length(): number;
  84470. /**
  84471. * Normalize in place the current quaternion
  84472. * @returns the current updated quaternion
  84473. */
  84474. normalize(): Quaternion;
  84475. /**
  84476. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84477. * @param order is a reserved parameter and is ignored for now
  84478. * @returns a new Vector3 containing the Euler angles
  84479. */
  84480. toEulerAngles(order?: string): Vector3;
  84481. /**
  84482. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84483. * @param result defines the vector which will be filled with the Euler angles
  84484. * @returns the current unchanged quaternion
  84485. */
  84486. toEulerAnglesToRef(result: Vector3): Quaternion;
  84487. /**
  84488. * Updates the given rotation matrix with the current quaternion values
  84489. * @param result defines the target matrix
  84490. * @returns the current unchanged quaternion
  84491. */
  84492. toRotationMatrix(result: Matrix): Quaternion;
  84493. /**
  84494. * Updates the current quaternion from the given rotation matrix values
  84495. * @param matrix defines the source matrix
  84496. * @returns the current updated quaternion
  84497. */
  84498. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84499. /**
  84500. * Creates a new quaternion from a rotation matrix
  84501. * @param matrix defines the source matrix
  84502. * @returns a new quaternion created from the given rotation matrix values
  84503. */
  84504. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84505. /**
  84506. * Updates the given quaternion with the given rotation matrix values
  84507. * @param matrix defines the source matrix
  84508. * @param result defines the target quaternion
  84509. */
  84510. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84511. /**
  84512. * Returns the dot product (float) between the quaternions "left" and "right"
  84513. * @param left defines the left operand
  84514. * @param right defines the right operand
  84515. * @returns the dot product
  84516. */
  84517. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84518. /**
  84519. * Checks if the two quaternions are close to each other
  84520. * @param quat0 defines the first quaternion to check
  84521. * @param quat1 defines the second quaternion to check
  84522. * @returns true if the two quaternions are close to each other
  84523. */
  84524. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84525. /**
  84526. * Creates an empty quaternion
  84527. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84528. */
  84529. static Zero(): Quaternion;
  84530. /**
  84531. * Inverse a given quaternion
  84532. * @param q defines the source quaternion
  84533. * @returns a new quaternion as the inverted current quaternion
  84534. */
  84535. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84536. /**
  84537. * Inverse a given quaternion
  84538. * @param q defines the source quaternion
  84539. * @param result the quaternion the result will be stored in
  84540. * @returns the result quaternion
  84541. */
  84542. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84543. /**
  84544. * Creates an identity quaternion
  84545. * @returns the identity quaternion
  84546. */
  84547. static Identity(): Quaternion;
  84548. /**
  84549. * Gets a boolean indicating if the given quaternion is identity
  84550. * @param quaternion defines the quaternion to check
  84551. * @returns true if the quaternion is identity
  84552. */
  84553. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84554. /**
  84555. * Creates a quaternion from a rotation around an axis
  84556. * @param axis defines the axis to use
  84557. * @param angle defines the angle to use
  84558. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84559. */
  84560. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84561. /**
  84562. * Creates a rotation around an axis and stores it into the given quaternion
  84563. * @param axis defines the axis to use
  84564. * @param angle defines the angle to use
  84565. * @param result defines the target quaternion
  84566. * @returns the target quaternion
  84567. */
  84568. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84569. /**
  84570. * Creates a new quaternion from data stored into an array
  84571. * @param array defines the data source
  84572. * @param offset defines the offset in the source array where the data starts
  84573. * @returns a new quaternion
  84574. */
  84575. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84576. /**
  84577. * Updates the given quaternion "result" from the starting index of the given array.
  84578. * @param array the array to pull values from
  84579. * @param offset the offset into the array to start at
  84580. * @param result the quaternion to store the result in
  84581. */
  84582. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84583. /**
  84584. * Create a quaternion from Euler rotation angles
  84585. * @param x Pitch
  84586. * @param y Yaw
  84587. * @param z Roll
  84588. * @returns the new Quaternion
  84589. */
  84590. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84591. /**
  84592. * Updates a quaternion from Euler rotation angles
  84593. * @param x Pitch
  84594. * @param y Yaw
  84595. * @param z Roll
  84596. * @param result the quaternion to store the result
  84597. * @returns the updated quaternion
  84598. */
  84599. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84600. /**
  84601. * Create a quaternion from Euler rotation vector
  84602. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84603. * @returns the new Quaternion
  84604. */
  84605. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84606. /**
  84607. * Updates a quaternion from Euler rotation vector
  84608. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84609. * @param result the quaternion to store the result
  84610. * @returns the updated quaternion
  84611. */
  84612. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84613. /**
  84614. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84615. * @param yaw defines the rotation around Y axis
  84616. * @param pitch defines the rotation around X axis
  84617. * @param roll defines the rotation around Z axis
  84618. * @returns the new quaternion
  84619. */
  84620. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84621. /**
  84622. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84623. * @param yaw defines the rotation around Y axis
  84624. * @param pitch defines the rotation around X axis
  84625. * @param roll defines the rotation around Z axis
  84626. * @param result defines the target quaternion
  84627. */
  84628. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84629. /**
  84630. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84631. * @param alpha defines the rotation around first axis
  84632. * @param beta defines the rotation around second axis
  84633. * @param gamma defines the rotation around third axis
  84634. * @returns the new quaternion
  84635. */
  84636. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84637. /**
  84638. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84639. * @param alpha defines the rotation around first axis
  84640. * @param beta defines the rotation around second axis
  84641. * @param gamma defines the rotation around third axis
  84642. * @param result defines the target quaternion
  84643. */
  84644. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84645. /**
  84646. * 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)
  84647. * @param axis1 defines the first axis
  84648. * @param axis2 defines the second axis
  84649. * @param axis3 defines the third axis
  84650. * @returns the new quaternion
  84651. */
  84652. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84653. /**
  84654. * 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
  84655. * @param axis1 defines the first axis
  84656. * @param axis2 defines the second axis
  84657. * @param axis3 defines the third axis
  84658. * @param ref defines the target quaternion
  84659. */
  84660. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84661. /**
  84662. * Interpolates between two quaternions
  84663. * @param left defines first quaternion
  84664. * @param right defines second quaternion
  84665. * @param amount defines the gradient to use
  84666. * @returns the new interpolated quaternion
  84667. */
  84668. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84669. /**
  84670. * Interpolates between two quaternions and stores it into a target quaternion
  84671. * @param left defines first quaternion
  84672. * @param right defines second quaternion
  84673. * @param amount defines the gradient to use
  84674. * @param result defines the target quaternion
  84675. */
  84676. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84677. /**
  84678. * Interpolate between two quaternions using Hermite interpolation
  84679. * @param value1 defines first quaternion
  84680. * @param tangent1 defines the incoming tangent
  84681. * @param value2 defines second quaternion
  84682. * @param tangent2 defines the outgoing tangent
  84683. * @param amount defines the target quaternion
  84684. * @returns the new interpolated quaternion
  84685. */
  84686. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84687. }
  84688. /**
  84689. * Class used to store matrix data (4x4)
  84690. */
  84691. export class Matrix {
  84692. /**
  84693. * Gets the precision of matrix computations
  84694. */
  84695. static get Use64Bits(): boolean;
  84696. private static _updateFlagSeed;
  84697. private static _identityReadOnly;
  84698. private _isIdentity;
  84699. private _isIdentityDirty;
  84700. private _isIdentity3x2;
  84701. private _isIdentity3x2Dirty;
  84702. /**
  84703. * Gets the update flag of the matrix which is an unique number for the matrix.
  84704. * It will be incremented every time the matrix data change.
  84705. * You can use it to speed the comparison between two versions of the same matrix.
  84706. */
  84707. updateFlag: number;
  84708. private readonly _m;
  84709. /**
  84710. * Gets the internal data of the matrix
  84711. */
  84712. get m(): DeepImmutable<Float32Array | Array<number>>;
  84713. /** @hidden */
  84714. _markAsUpdated(): void;
  84715. /** @hidden */
  84716. private _updateIdentityStatus;
  84717. /**
  84718. * Creates an empty matrix (filled with zeros)
  84719. */
  84720. constructor();
  84721. /**
  84722. * Check if the current matrix is identity
  84723. * @returns true is the matrix is the identity matrix
  84724. */
  84725. isIdentity(): boolean;
  84726. /**
  84727. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84728. * @returns true is the matrix is the identity matrix
  84729. */
  84730. isIdentityAs3x2(): boolean;
  84731. /**
  84732. * Gets the determinant of the matrix
  84733. * @returns the matrix determinant
  84734. */
  84735. determinant(): number;
  84736. /**
  84737. * Returns the matrix as a Float32Array or Array<number>
  84738. * @returns the matrix underlying array
  84739. */
  84740. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84741. /**
  84742. * Returns the matrix as a Float32Array or Array<number>
  84743. * @returns the matrix underlying array.
  84744. */
  84745. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84746. /**
  84747. * Inverts the current matrix in place
  84748. * @returns the current inverted matrix
  84749. */
  84750. invert(): Matrix;
  84751. /**
  84752. * Sets all the matrix elements to zero
  84753. * @returns the current matrix
  84754. */
  84755. reset(): Matrix;
  84756. /**
  84757. * Adds the current matrix with a second one
  84758. * @param other defines the matrix to add
  84759. * @returns a new matrix as the addition of the current matrix and the given one
  84760. */
  84761. add(other: DeepImmutable<Matrix>): Matrix;
  84762. /**
  84763. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84764. * @param other defines the matrix to add
  84765. * @param result defines the target matrix
  84766. * @returns the current matrix
  84767. */
  84768. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84769. /**
  84770. * Adds in place the given matrix to the current matrix
  84771. * @param other defines the second operand
  84772. * @returns the current updated matrix
  84773. */
  84774. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84775. /**
  84776. * Sets the given matrix to the current inverted Matrix
  84777. * @param other defines the target matrix
  84778. * @returns the unmodified current matrix
  84779. */
  84780. invertToRef(other: Matrix): Matrix;
  84781. /**
  84782. * add a value at the specified position in the current Matrix
  84783. * @param index the index of the value within the matrix. between 0 and 15.
  84784. * @param value the value to be added
  84785. * @returns the current updated matrix
  84786. */
  84787. addAtIndex(index: number, value: number): Matrix;
  84788. /**
  84789. * mutiply the specified position in the current Matrix by a value
  84790. * @param index the index of the value within the matrix. between 0 and 15.
  84791. * @param value the value to be added
  84792. * @returns the current updated matrix
  84793. */
  84794. multiplyAtIndex(index: number, value: number): Matrix;
  84795. /**
  84796. * Inserts the translation vector (using 3 floats) in the current matrix
  84797. * @param x defines the 1st component of the translation
  84798. * @param y defines the 2nd component of the translation
  84799. * @param z defines the 3rd component of the translation
  84800. * @returns the current updated matrix
  84801. */
  84802. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84803. /**
  84804. * Adds the translation vector (using 3 floats) in the current matrix
  84805. * @param x defines the 1st component of the translation
  84806. * @param y defines the 2nd component of the translation
  84807. * @param z defines the 3rd component of the translation
  84808. * @returns the current updated matrix
  84809. */
  84810. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84811. /**
  84812. * Inserts the translation vector in the current matrix
  84813. * @param vector3 defines the translation to insert
  84814. * @returns the current updated matrix
  84815. */
  84816. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84817. /**
  84818. * Gets the translation value of the current matrix
  84819. * @returns a new Vector3 as the extracted translation from the matrix
  84820. */
  84821. getTranslation(): Vector3;
  84822. /**
  84823. * Fill a Vector3 with the extracted translation from the matrix
  84824. * @param result defines the Vector3 where to store the translation
  84825. * @returns the current matrix
  84826. */
  84827. getTranslationToRef(result: Vector3): Matrix;
  84828. /**
  84829. * Remove rotation and scaling part from the matrix
  84830. * @returns the updated matrix
  84831. */
  84832. removeRotationAndScaling(): Matrix;
  84833. /**
  84834. * Multiply two matrices
  84835. * @param other defines the second operand
  84836. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84837. */
  84838. multiply(other: DeepImmutable<Matrix>): Matrix;
  84839. /**
  84840. * Copy the current matrix from the given one
  84841. * @param other defines the source matrix
  84842. * @returns the current updated matrix
  84843. */
  84844. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84845. /**
  84846. * Populates the given array from the starting index with the current matrix values
  84847. * @param array defines the target array
  84848. * @param offset defines the offset in the target array where to start storing values
  84849. * @returns the current matrix
  84850. */
  84851. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84852. /**
  84853. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84854. * @param other defines the second operand
  84855. * @param result defines the matrix where to store the multiplication
  84856. * @returns the current matrix
  84857. */
  84858. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84859. /**
  84860. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84861. * @param other defines the second operand
  84862. * @param result defines the array where to store the multiplication
  84863. * @param offset defines the offset in the target array where to start storing values
  84864. * @returns the current matrix
  84865. */
  84866. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84867. /**
  84868. * Check equality between this matrix and a second one
  84869. * @param value defines the second matrix to compare
  84870. * @returns true is the current matrix and the given one values are strictly equal
  84871. */
  84872. equals(value: DeepImmutable<Matrix>): boolean;
  84873. /**
  84874. * Clone the current matrix
  84875. * @returns a new matrix from the current matrix
  84876. */
  84877. clone(): Matrix;
  84878. /**
  84879. * Returns the name of the current matrix class
  84880. * @returns the string "Matrix"
  84881. */
  84882. getClassName(): string;
  84883. /**
  84884. * Gets the hash code of the current matrix
  84885. * @returns the hash code
  84886. */
  84887. getHashCode(): number;
  84888. /**
  84889. * Decomposes the current Matrix into a translation, rotation and scaling components
  84890. * @param scale defines the scale vector3 given as a reference to update
  84891. * @param rotation defines the rotation quaternion given as a reference to update
  84892. * @param translation defines the translation vector3 given as a reference to update
  84893. * @returns true if operation was successful
  84894. */
  84895. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84896. /**
  84897. * Gets specific row of the matrix
  84898. * @param index defines the number of the row to get
  84899. * @returns the index-th row of the current matrix as a new Vector4
  84900. */
  84901. getRow(index: number): Nullable<Vector4>;
  84902. /**
  84903. * Sets the index-th row of the current matrix to the vector4 values
  84904. * @param index defines the number of the row to set
  84905. * @param row defines the target vector4
  84906. * @returns the updated current matrix
  84907. */
  84908. setRow(index: number, row: Vector4): Matrix;
  84909. /**
  84910. * Compute the transpose of the matrix
  84911. * @returns the new transposed matrix
  84912. */
  84913. transpose(): Matrix;
  84914. /**
  84915. * Compute the transpose of the matrix and store it in a given matrix
  84916. * @param result defines the target matrix
  84917. * @returns the current matrix
  84918. */
  84919. transposeToRef(result: Matrix): Matrix;
  84920. /**
  84921. * Sets the index-th row of the current matrix with the given 4 x float values
  84922. * @param index defines the row index
  84923. * @param x defines the x component to set
  84924. * @param y defines the y component to set
  84925. * @param z defines the z component to set
  84926. * @param w defines the w component to set
  84927. * @returns the updated current matrix
  84928. */
  84929. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84930. /**
  84931. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84932. * @param scale defines the scale factor
  84933. * @returns a new matrix
  84934. */
  84935. scale(scale: number): Matrix;
  84936. /**
  84937. * Scale the current matrix values by a factor to a given result matrix
  84938. * @param scale defines the scale factor
  84939. * @param result defines the matrix to store the result
  84940. * @returns the current matrix
  84941. */
  84942. scaleToRef(scale: number, result: Matrix): Matrix;
  84943. /**
  84944. * Scale the current matrix values by a factor and add the result to a given matrix
  84945. * @param scale defines the scale factor
  84946. * @param result defines the Matrix to store the result
  84947. * @returns the current matrix
  84948. */
  84949. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84950. /**
  84951. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84952. * @param ref matrix to store the result
  84953. */
  84954. toNormalMatrix(ref: Matrix): void;
  84955. /**
  84956. * Gets only rotation part of the current matrix
  84957. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84958. */
  84959. getRotationMatrix(): Matrix;
  84960. /**
  84961. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84962. * @param result defines the target matrix to store data to
  84963. * @returns the current matrix
  84964. */
  84965. getRotationMatrixToRef(result: Matrix): Matrix;
  84966. /**
  84967. * Toggles model matrix from being right handed to left handed in place and vice versa
  84968. */
  84969. toggleModelMatrixHandInPlace(): void;
  84970. /**
  84971. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84972. */
  84973. toggleProjectionMatrixHandInPlace(): void;
  84974. /**
  84975. * Creates a matrix from an array
  84976. * @param array defines the source array
  84977. * @param offset defines an offset in the source array
  84978. * @returns a new Matrix set from the starting index of the given array
  84979. */
  84980. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84981. /**
  84982. * Copy the content of an array into a given matrix
  84983. * @param array defines the source array
  84984. * @param offset defines an offset in the source array
  84985. * @param result defines the target matrix
  84986. */
  84987. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84988. /**
  84989. * Stores an array into a matrix after having multiplied each component by a given factor
  84990. * @param array defines the source array
  84991. * @param offset defines the offset in the source array
  84992. * @param scale defines the scaling factor
  84993. * @param result defines the target matrix
  84994. */
  84995. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84996. /**
  84997. * Gets an identity matrix that must not be updated
  84998. */
  84999. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85000. /**
  85001. * Stores a list of values (16) inside a given matrix
  85002. * @param initialM11 defines 1st value of 1st row
  85003. * @param initialM12 defines 2nd value of 1st row
  85004. * @param initialM13 defines 3rd value of 1st row
  85005. * @param initialM14 defines 4th value of 1st row
  85006. * @param initialM21 defines 1st value of 2nd row
  85007. * @param initialM22 defines 2nd value of 2nd row
  85008. * @param initialM23 defines 3rd value of 2nd row
  85009. * @param initialM24 defines 4th value of 2nd row
  85010. * @param initialM31 defines 1st value of 3rd row
  85011. * @param initialM32 defines 2nd value of 3rd row
  85012. * @param initialM33 defines 3rd value of 3rd row
  85013. * @param initialM34 defines 4th value of 3rd row
  85014. * @param initialM41 defines 1st value of 4th row
  85015. * @param initialM42 defines 2nd value of 4th row
  85016. * @param initialM43 defines 3rd value of 4th row
  85017. * @param initialM44 defines 4th value of 4th row
  85018. * @param result defines the target matrix
  85019. */
  85020. 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;
  85021. /**
  85022. * Creates new matrix from a list of values (16)
  85023. * @param initialM11 defines 1st value of 1st row
  85024. * @param initialM12 defines 2nd value of 1st row
  85025. * @param initialM13 defines 3rd value of 1st row
  85026. * @param initialM14 defines 4th value of 1st row
  85027. * @param initialM21 defines 1st value of 2nd row
  85028. * @param initialM22 defines 2nd value of 2nd row
  85029. * @param initialM23 defines 3rd value of 2nd row
  85030. * @param initialM24 defines 4th value of 2nd row
  85031. * @param initialM31 defines 1st value of 3rd row
  85032. * @param initialM32 defines 2nd value of 3rd row
  85033. * @param initialM33 defines 3rd value of 3rd row
  85034. * @param initialM34 defines 4th value of 3rd row
  85035. * @param initialM41 defines 1st value of 4th row
  85036. * @param initialM42 defines 2nd value of 4th row
  85037. * @param initialM43 defines 3rd value of 4th row
  85038. * @param initialM44 defines 4th value of 4th row
  85039. * @returns the new matrix
  85040. */
  85041. 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;
  85042. /**
  85043. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85044. * @param scale defines the scale vector3
  85045. * @param rotation defines the rotation quaternion
  85046. * @param translation defines the translation vector3
  85047. * @returns a new matrix
  85048. */
  85049. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85050. /**
  85051. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85052. * @param scale defines the scale vector3
  85053. * @param rotation defines the rotation quaternion
  85054. * @param translation defines the translation vector3
  85055. * @param result defines the target matrix
  85056. */
  85057. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85058. /**
  85059. * Creates a new identity matrix
  85060. * @returns a new identity matrix
  85061. */
  85062. static Identity(): Matrix;
  85063. /**
  85064. * Creates a new identity matrix and stores the result in a given matrix
  85065. * @param result defines the target matrix
  85066. */
  85067. static IdentityToRef(result: Matrix): void;
  85068. /**
  85069. * Creates a new zero matrix
  85070. * @returns a new zero matrix
  85071. */
  85072. static Zero(): Matrix;
  85073. /**
  85074. * Creates a new rotation matrix for "angle" radians around the X axis
  85075. * @param angle defines the angle (in radians) to use
  85076. * @return the new matrix
  85077. */
  85078. static RotationX(angle: number): Matrix;
  85079. /**
  85080. * Creates a new matrix as the invert of a given matrix
  85081. * @param source defines the source matrix
  85082. * @returns the new matrix
  85083. */
  85084. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85085. /**
  85086. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85087. * @param angle defines the angle (in radians) to use
  85088. * @param result defines the target matrix
  85089. */
  85090. static RotationXToRef(angle: number, result: Matrix): void;
  85091. /**
  85092. * Creates a new rotation matrix for "angle" radians around the Y axis
  85093. * @param angle defines the angle (in radians) to use
  85094. * @return the new matrix
  85095. */
  85096. static RotationY(angle: number): Matrix;
  85097. /**
  85098. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85099. * @param angle defines the angle (in radians) to use
  85100. * @param result defines the target matrix
  85101. */
  85102. static RotationYToRef(angle: number, result: Matrix): void;
  85103. /**
  85104. * Creates a new rotation matrix for "angle" radians around the Z axis
  85105. * @param angle defines the angle (in radians) to use
  85106. * @return the new matrix
  85107. */
  85108. static RotationZ(angle: number): Matrix;
  85109. /**
  85110. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85111. * @param angle defines the angle (in radians) to use
  85112. * @param result defines the target matrix
  85113. */
  85114. static RotationZToRef(angle: number, result: Matrix): void;
  85115. /**
  85116. * Creates a new rotation matrix for "angle" radians around the given axis
  85117. * @param axis defines the axis to use
  85118. * @param angle defines the angle (in radians) to use
  85119. * @return the new matrix
  85120. */
  85121. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85122. /**
  85123. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85124. * @param axis defines the axis to use
  85125. * @param angle defines the angle (in radians) to use
  85126. * @param result defines the target matrix
  85127. */
  85128. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85129. /**
  85130. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85131. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85132. * @param from defines the vector to align
  85133. * @param to defines the vector to align to
  85134. * @param result defines the target matrix
  85135. */
  85136. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85137. /**
  85138. * Creates a rotation matrix
  85139. * @param yaw defines the yaw angle in radians (Y axis)
  85140. * @param pitch defines the pitch angle in radians (X axis)
  85141. * @param roll defines the roll angle in radians (Z axis)
  85142. * @returns the new rotation matrix
  85143. */
  85144. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85145. /**
  85146. * Creates a rotation matrix and stores it in a given matrix
  85147. * @param yaw defines the yaw angle in radians (Y axis)
  85148. * @param pitch defines the pitch angle in radians (X axis)
  85149. * @param roll defines the roll angle in radians (Z axis)
  85150. * @param result defines the target matrix
  85151. */
  85152. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85153. /**
  85154. * Creates a scaling matrix
  85155. * @param x defines the scale factor on X axis
  85156. * @param y defines the scale factor on Y axis
  85157. * @param z defines the scale factor on Z axis
  85158. * @returns the new matrix
  85159. */
  85160. static Scaling(x: number, y: number, z: number): Matrix;
  85161. /**
  85162. * Creates a scaling matrix and stores it in a given matrix
  85163. * @param x defines the scale factor on X axis
  85164. * @param y defines the scale factor on Y axis
  85165. * @param z defines the scale factor on Z axis
  85166. * @param result defines the target matrix
  85167. */
  85168. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85169. /**
  85170. * Creates a translation matrix
  85171. * @param x defines the translation on X axis
  85172. * @param y defines the translation on Y axis
  85173. * @param z defines the translationon Z axis
  85174. * @returns the new matrix
  85175. */
  85176. static Translation(x: number, y: number, z: number): Matrix;
  85177. /**
  85178. * Creates a translation matrix and stores it in a given matrix
  85179. * @param x defines the translation on X axis
  85180. * @param y defines the translation on Y axis
  85181. * @param z defines the translationon Z axis
  85182. * @param result defines the target matrix
  85183. */
  85184. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85185. /**
  85186. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85187. * @param startValue defines the start value
  85188. * @param endValue defines the end value
  85189. * @param gradient defines the gradient factor
  85190. * @returns the new matrix
  85191. */
  85192. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85193. /**
  85194. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85195. * @param startValue defines the start value
  85196. * @param endValue defines the end value
  85197. * @param gradient defines the gradient factor
  85198. * @param result defines the Matrix object where to store data
  85199. */
  85200. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85201. /**
  85202. * Builds a new matrix whose values are computed by:
  85203. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85204. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85205. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85206. * @param startValue defines the first matrix
  85207. * @param endValue defines the second matrix
  85208. * @param gradient defines the gradient between the two matrices
  85209. * @returns the new matrix
  85210. */
  85211. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85212. /**
  85213. * Update a matrix to values which are computed by:
  85214. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85215. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85216. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85217. * @param startValue defines the first matrix
  85218. * @param endValue defines the second matrix
  85219. * @param gradient defines the gradient between the two matrices
  85220. * @param result defines the target matrix
  85221. */
  85222. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85223. /**
  85224. * 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"
  85225. * This function works in left handed mode
  85226. * @param eye defines the final position of the entity
  85227. * @param target defines where the entity should look at
  85228. * @param up defines the up vector for the entity
  85229. * @returns the new matrix
  85230. */
  85231. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85232. /**
  85233. * 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".
  85234. * This function works in left handed mode
  85235. * @param eye defines the final position of the entity
  85236. * @param target defines where the entity should look at
  85237. * @param up defines the up vector for the entity
  85238. * @param result defines the target matrix
  85239. */
  85240. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85241. /**
  85242. * 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"
  85243. * This function works in right handed mode
  85244. * @param eye defines the final position of the entity
  85245. * @param target defines where the entity should look at
  85246. * @param up defines the up vector for the entity
  85247. * @returns the new matrix
  85248. */
  85249. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85250. /**
  85251. * 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".
  85252. * This function works in right handed mode
  85253. * @param eye defines the final position of the entity
  85254. * @param target defines where the entity should look at
  85255. * @param up defines the up vector for the entity
  85256. * @param result defines the target matrix
  85257. */
  85258. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85259. /**
  85260. * Create a left-handed orthographic projection matrix
  85261. * @param width defines the viewport width
  85262. * @param height defines the viewport height
  85263. * @param znear defines the near clip plane
  85264. * @param zfar defines the far clip plane
  85265. * @returns a new matrix as a left-handed orthographic projection matrix
  85266. */
  85267. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85268. /**
  85269. * Store a left-handed orthographic projection to a given matrix
  85270. * @param width defines the viewport width
  85271. * @param height defines the viewport height
  85272. * @param znear defines the near clip plane
  85273. * @param zfar defines the far clip plane
  85274. * @param result defines the target matrix
  85275. */
  85276. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85277. /**
  85278. * Create a left-handed orthographic projection matrix
  85279. * @param left defines the viewport left coordinate
  85280. * @param right defines the viewport right coordinate
  85281. * @param bottom defines the viewport bottom coordinate
  85282. * @param top defines the viewport top coordinate
  85283. * @param znear defines the near clip plane
  85284. * @param zfar defines the far clip plane
  85285. * @returns a new matrix as a left-handed orthographic projection matrix
  85286. */
  85287. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85288. /**
  85289. * Stores a left-handed orthographic projection into a given matrix
  85290. * @param left defines the viewport left coordinate
  85291. * @param right defines the viewport right coordinate
  85292. * @param bottom defines the viewport bottom coordinate
  85293. * @param top defines the viewport top coordinate
  85294. * @param znear defines the near clip plane
  85295. * @param zfar defines the far clip plane
  85296. * @param result defines the target matrix
  85297. */
  85298. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85299. /**
  85300. * Creates a right-handed orthographic projection matrix
  85301. * @param left defines the viewport left coordinate
  85302. * @param right defines the viewport right coordinate
  85303. * @param bottom defines the viewport bottom coordinate
  85304. * @param top defines the viewport top coordinate
  85305. * @param znear defines the near clip plane
  85306. * @param zfar defines the far clip plane
  85307. * @returns a new matrix as a right-handed orthographic projection matrix
  85308. */
  85309. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85310. /**
  85311. * Stores a right-handed orthographic projection into a given matrix
  85312. * @param left defines the viewport left coordinate
  85313. * @param right defines the viewport right coordinate
  85314. * @param bottom defines the viewport bottom coordinate
  85315. * @param top defines the viewport top coordinate
  85316. * @param znear defines the near clip plane
  85317. * @param zfar defines the far clip plane
  85318. * @param result defines the target matrix
  85319. */
  85320. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85321. /**
  85322. * Creates a left-handed perspective projection matrix
  85323. * @param width defines the viewport width
  85324. * @param height defines the viewport height
  85325. * @param znear defines the near clip plane
  85326. * @param zfar defines the far clip plane
  85327. * @returns a new matrix as a left-handed perspective projection matrix
  85328. */
  85329. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85330. /**
  85331. * Creates a left-handed perspective projection matrix
  85332. * @param fov defines the horizontal field of view
  85333. * @param aspect defines the aspect ratio
  85334. * @param znear defines the near clip plane
  85335. * @param zfar defines the far clip plane
  85336. * @returns a new matrix as a left-handed perspective projection matrix
  85337. */
  85338. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85339. /**
  85340. * Stores a left-handed perspective projection into a given matrix
  85341. * @param fov defines the horizontal field of view
  85342. * @param aspect defines the aspect ratio
  85343. * @param znear defines the near clip plane
  85344. * @param zfar defines the far clip plane
  85345. * @param result defines the target matrix
  85346. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85347. */
  85348. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85349. /**
  85350. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85351. * @param fov defines the horizontal field of view
  85352. * @param aspect defines the aspect ratio
  85353. * @param znear defines the near clip plane
  85354. * @param zfar not used as infinity is used as far clip
  85355. * @param result defines the target matrix
  85356. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85357. */
  85358. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85359. /**
  85360. * Creates a right-handed perspective projection matrix
  85361. * @param fov defines the horizontal field of view
  85362. * @param aspect defines the aspect ratio
  85363. * @param znear defines the near clip plane
  85364. * @param zfar defines the far clip plane
  85365. * @returns a new matrix as a right-handed perspective projection matrix
  85366. */
  85367. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85368. /**
  85369. * Stores a right-handed perspective projection into a given matrix
  85370. * @param fov defines the horizontal field of view
  85371. * @param aspect defines the aspect ratio
  85372. * @param znear defines the near clip plane
  85373. * @param zfar defines the far clip plane
  85374. * @param result defines the target matrix
  85375. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85376. */
  85377. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85378. /**
  85379. * Stores a right-handed perspective projection into a given matrix
  85380. * @param fov defines the horizontal field of view
  85381. * @param aspect defines the aspect ratio
  85382. * @param znear defines the near clip plane
  85383. * @param zfar not used as infinity is used as far clip
  85384. * @param result defines the target matrix
  85385. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85386. */
  85387. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85388. /**
  85389. * Stores a perspective projection for WebVR info a given matrix
  85390. * @param fov defines the field of view
  85391. * @param znear defines the near clip plane
  85392. * @param zfar defines the far clip plane
  85393. * @param result defines the target matrix
  85394. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85395. */
  85396. static PerspectiveFovWebVRToRef(fov: {
  85397. upDegrees: number;
  85398. downDegrees: number;
  85399. leftDegrees: number;
  85400. rightDegrees: number;
  85401. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85402. /**
  85403. * Computes a complete transformation matrix
  85404. * @param viewport defines the viewport to use
  85405. * @param world defines the world matrix
  85406. * @param view defines the view matrix
  85407. * @param projection defines the projection matrix
  85408. * @param zmin defines the near clip plane
  85409. * @param zmax defines the far clip plane
  85410. * @returns the transformation matrix
  85411. */
  85412. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85413. /**
  85414. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85415. * @param matrix defines the matrix to use
  85416. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85417. */
  85418. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85419. /**
  85420. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85421. * @param matrix defines the matrix to use
  85422. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85423. */
  85424. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85425. /**
  85426. * Compute the transpose of a given matrix
  85427. * @param matrix defines the matrix to transpose
  85428. * @returns the new matrix
  85429. */
  85430. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85431. /**
  85432. * Compute the transpose of a matrix and store it in a target matrix
  85433. * @param matrix defines the matrix to transpose
  85434. * @param result defines the target matrix
  85435. */
  85436. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85437. /**
  85438. * Computes a reflection matrix from a plane
  85439. * @param plane defines the reflection plane
  85440. * @returns a new matrix
  85441. */
  85442. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85443. /**
  85444. * Computes a reflection matrix from a plane
  85445. * @param plane defines the reflection plane
  85446. * @param result defines the target matrix
  85447. */
  85448. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85449. /**
  85450. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85451. * @param xaxis defines the value of the 1st axis
  85452. * @param yaxis defines the value of the 2nd axis
  85453. * @param zaxis defines the value of the 3rd axis
  85454. * @param result defines the target matrix
  85455. */
  85456. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85457. /**
  85458. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85459. * @param quat defines the quaternion to use
  85460. * @param result defines the target matrix
  85461. */
  85462. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85463. }
  85464. /**
  85465. * @hidden
  85466. */
  85467. export class TmpVectors {
  85468. static Vector2: Vector2[];
  85469. static Vector3: Vector3[];
  85470. static Vector4: Vector4[];
  85471. static Quaternion: Quaternion[];
  85472. static Matrix: Matrix[];
  85473. }
  85474. }
  85475. declare module BABYLON {
  85476. /**
  85477. * Defines potential orientation for back face culling
  85478. */
  85479. export enum Orientation {
  85480. /**
  85481. * Clockwise
  85482. */
  85483. CW = 0,
  85484. /** Counter clockwise */
  85485. CCW = 1
  85486. }
  85487. /** Class used to represent a Bezier curve */
  85488. export class BezierCurve {
  85489. /**
  85490. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85491. * @param t defines the time
  85492. * @param x1 defines the left coordinate on X axis
  85493. * @param y1 defines the left coordinate on Y axis
  85494. * @param x2 defines the right coordinate on X axis
  85495. * @param y2 defines the right coordinate on Y axis
  85496. * @returns the interpolated value
  85497. */
  85498. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85499. }
  85500. /**
  85501. * Defines angle representation
  85502. */
  85503. export class Angle {
  85504. private _radians;
  85505. /**
  85506. * Creates an Angle object of "radians" radians (float).
  85507. * @param radians the angle in radians
  85508. */
  85509. constructor(radians: number);
  85510. /**
  85511. * Get value in degrees
  85512. * @returns the Angle value in degrees (float)
  85513. */
  85514. degrees(): number;
  85515. /**
  85516. * Get value in radians
  85517. * @returns the Angle value in radians (float)
  85518. */
  85519. radians(): number;
  85520. /**
  85521. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85522. * @param a defines first point as the origin
  85523. * @param b defines point
  85524. * @returns a new Angle
  85525. */
  85526. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85527. /**
  85528. * Gets a new Angle object from the given float in radians
  85529. * @param radians defines the angle value in radians
  85530. * @returns a new Angle
  85531. */
  85532. static FromRadians(radians: number): Angle;
  85533. /**
  85534. * Gets a new Angle object from the given float in degrees
  85535. * @param degrees defines the angle value in degrees
  85536. * @returns a new Angle
  85537. */
  85538. static FromDegrees(degrees: number): Angle;
  85539. }
  85540. /**
  85541. * This represents an arc in a 2d space.
  85542. */
  85543. export class Arc2 {
  85544. /** Defines the start point of the arc */
  85545. startPoint: Vector2;
  85546. /** Defines the mid point of the arc */
  85547. midPoint: Vector2;
  85548. /** Defines the end point of the arc */
  85549. endPoint: Vector2;
  85550. /**
  85551. * Defines the center point of the arc.
  85552. */
  85553. centerPoint: Vector2;
  85554. /**
  85555. * Defines the radius of the arc.
  85556. */
  85557. radius: number;
  85558. /**
  85559. * Defines the angle of the arc (from mid point to end point).
  85560. */
  85561. angle: Angle;
  85562. /**
  85563. * Defines the start angle of the arc (from start point to middle point).
  85564. */
  85565. startAngle: Angle;
  85566. /**
  85567. * Defines the orientation of the arc (clock wise/counter clock wise).
  85568. */
  85569. orientation: Orientation;
  85570. /**
  85571. * Creates an Arc object from the three given points : start, middle and end.
  85572. * @param startPoint Defines the start point of the arc
  85573. * @param midPoint Defines the midlle point of the arc
  85574. * @param endPoint Defines the end point of the arc
  85575. */
  85576. constructor(
  85577. /** Defines the start point of the arc */
  85578. startPoint: Vector2,
  85579. /** Defines the mid point of the arc */
  85580. midPoint: Vector2,
  85581. /** Defines the end point of the arc */
  85582. endPoint: Vector2);
  85583. }
  85584. /**
  85585. * Represents a 2D path made up of multiple 2D points
  85586. */
  85587. export class Path2 {
  85588. private _points;
  85589. private _length;
  85590. /**
  85591. * If the path start and end point are the same
  85592. */
  85593. closed: boolean;
  85594. /**
  85595. * Creates a Path2 object from the starting 2D coordinates x and y.
  85596. * @param x the starting points x value
  85597. * @param y the starting points y value
  85598. */
  85599. constructor(x: number, y: number);
  85600. /**
  85601. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85602. * @param x the added points x value
  85603. * @param y the added points y value
  85604. * @returns the updated Path2.
  85605. */
  85606. addLineTo(x: number, y: number): Path2;
  85607. /**
  85608. * 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.
  85609. * @param midX middle point x value
  85610. * @param midY middle point y value
  85611. * @param endX end point x value
  85612. * @param endY end point y value
  85613. * @param numberOfSegments (default: 36)
  85614. * @returns the updated Path2.
  85615. */
  85616. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85617. /**
  85618. * Closes the Path2.
  85619. * @returns the Path2.
  85620. */
  85621. close(): Path2;
  85622. /**
  85623. * Gets the sum of the distance between each sequential point in the path
  85624. * @returns the Path2 total length (float).
  85625. */
  85626. length(): number;
  85627. /**
  85628. * Gets the points which construct the path
  85629. * @returns the Path2 internal array of points.
  85630. */
  85631. getPoints(): Vector2[];
  85632. /**
  85633. * Retreives the point at the distance aways from the starting point
  85634. * @param normalizedLengthPosition the length along the path to retreive the point from
  85635. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85636. */
  85637. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85638. /**
  85639. * Creates a new path starting from an x and y position
  85640. * @param x starting x value
  85641. * @param y starting y value
  85642. * @returns a new Path2 starting at the coordinates (x, y).
  85643. */
  85644. static StartingAt(x: number, y: number): Path2;
  85645. }
  85646. /**
  85647. * Represents a 3D path made up of multiple 3D points
  85648. */
  85649. export class Path3D {
  85650. /**
  85651. * an array of Vector3, the curve axis of the Path3D
  85652. */
  85653. path: Vector3[];
  85654. private _curve;
  85655. private _distances;
  85656. private _tangents;
  85657. private _normals;
  85658. private _binormals;
  85659. private _raw;
  85660. private _alignTangentsWithPath;
  85661. private readonly _pointAtData;
  85662. /**
  85663. * new Path3D(path, normal, raw)
  85664. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85665. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85666. * @param path an array of Vector3, the curve axis of the Path3D
  85667. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85668. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85669. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85670. */
  85671. constructor(
  85672. /**
  85673. * an array of Vector3, the curve axis of the Path3D
  85674. */
  85675. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85676. /**
  85677. * Returns the Path3D array of successive Vector3 designing its curve.
  85678. * @returns the Path3D array of successive Vector3 designing its curve.
  85679. */
  85680. getCurve(): Vector3[];
  85681. /**
  85682. * Returns the Path3D array of successive Vector3 designing its curve.
  85683. * @returns the Path3D array of successive Vector3 designing its curve.
  85684. */
  85685. getPoints(): Vector3[];
  85686. /**
  85687. * @returns the computed length (float) of the path.
  85688. */
  85689. length(): number;
  85690. /**
  85691. * Returns an array populated with tangent vectors on each Path3D curve point.
  85692. * @returns an array populated with tangent vectors on each Path3D curve point.
  85693. */
  85694. getTangents(): Vector3[];
  85695. /**
  85696. * Returns an array populated with normal vectors on each Path3D curve point.
  85697. * @returns an array populated with normal vectors on each Path3D curve point.
  85698. */
  85699. getNormals(): Vector3[];
  85700. /**
  85701. * Returns an array populated with binormal vectors on each Path3D curve point.
  85702. * @returns an array populated with binormal vectors on each Path3D curve point.
  85703. */
  85704. getBinormals(): Vector3[];
  85705. /**
  85706. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85707. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85708. */
  85709. getDistances(): number[];
  85710. /**
  85711. * Returns an interpolated point along this path
  85712. * @param position the position of the point along this path, from 0.0 to 1.0
  85713. * @returns a new Vector3 as the point
  85714. */
  85715. getPointAt(position: number): Vector3;
  85716. /**
  85717. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85718. * @param position the position of the point along this path, from 0.0 to 1.0
  85719. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85720. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85721. */
  85722. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85723. /**
  85724. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85725. * @param position the position of the point along this path, from 0.0 to 1.0
  85726. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85727. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85728. */
  85729. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85730. /**
  85731. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85732. * @param position the position of the point along this path, from 0.0 to 1.0
  85733. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85734. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85735. */
  85736. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85737. /**
  85738. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85739. * @param position the position of the point along this path, from 0.0 to 1.0
  85740. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85741. */
  85742. getDistanceAt(position: number): number;
  85743. /**
  85744. * Returns the array index of the previous point of an interpolated point along this path
  85745. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85746. * @returns the array index
  85747. */
  85748. getPreviousPointIndexAt(position: number): number;
  85749. /**
  85750. * 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)
  85751. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85752. * @returns the sub position
  85753. */
  85754. getSubPositionAt(position: number): number;
  85755. /**
  85756. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85757. * @param target the vector of which to get the closest position to
  85758. * @returns the position of the closest virtual point on this path to the target vector
  85759. */
  85760. getClosestPositionTo(target: Vector3): number;
  85761. /**
  85762. * Returns a sub path (slice) of this path
  85763. * @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
  85764. * @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
  85765. * @returns a sub path (slice) of this path
  85766. */
  85767. slice(start?: number, end?: number): Path3D;
  85768. /**
  85769. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85770. * @param path path which all values are copied into the curves points
  85771. * @param firstNormal which should be projected onto the curve
  85772. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85773. * @returns the same object updated.
  85774. */
  85775. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85776. private _compute;
  85777. private _getFirstNonNullVector;
  85778. private _getLastNonNullVector;
  85779. private _normalVector;
  85780. /**
  85781. * Updates the point at data for an interpolated point along this curve
  85782. * @param position the position of the point along this curve, from 0.0 to 1.0
  85783. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85784. * @returns the (updated) point at data
  85785. */
  85786. private _updatePointAtData;
  85787. /**
  85788. * Updates the point at data from the specified parameters
  85789. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85790. * @param point the interpolated point
  85791. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85792. */
  85793. private _setPointAtData;
  85794. /**
  85795. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85796. */
  85797. private _updateInterpolationMatrix;
  85798. }
  85799. /**
  85800. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85801. * A Curve3 is designed from a series of successive Vector3.
  85802. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85803. */
  85804. export class Curve3 {
  85805. private _points;
  85806. private _length;
  85807. /**
  85808. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85809. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85810. * @param v1 (Vector3) the control point
  85811. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85812. * @param nbPoints (integer) the wanted number of points in the curve
  85813. * @returns the created Curve3
  85814. */
  85815. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85816. /**
  85817. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85818. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85819. * @param v1 (Vector3) the first control point
  85820. * @param v2 (Vector3) the second control point
  85821. * @param v3 (Vector3) the end point of the Cubic Bezier
  85822. * @param nbPoints (integer) the wanted number of points in the curve
  85823. * @returns the created Curve3
  85824. */
  85825. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85826. /**
  85827. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85828. * @param p1 (Vector3) the origin point of the Hermite Spline
  85829. * @param t1 (Vector3) the tangent vector at the origin point
  85830. * @param p2 (Vector3) the end point of the Hermite Spline
  85831. * @param t2 (Vector3) the tangent vector at the end point
  85832. * @param nbPoints (integer) the wanted number of points in the curve
  85833. * @returns the created Curve3
  85834. */
  85835. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85836. /**
  85837. * Returns a Curve3 object along a CatmullRom Spline curve :
  85838. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85839. * @param nbPoints (integer) the wanted number of points between each curve control points
  85840. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85841. * @returns the created Curve3
  85842. */
  85843. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85844. /**
  85845. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85846. * A Curve3 is designed from a series of successive Vector3.
  85847. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85848. * @param points points which make up the curve
  85849. */
  85850. constructor(points: Vector3[]);
  85851. /**
  85852. * @returns the Curve3 stored array of successive Vector3
  85853. */
  85854. getPoints(): Vector3[];
  85855. /**
  85856. * @returns the computed length (float) of the curve.
  85857. */
  85858. length(): number;
  85859. /**
  85860. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85861. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85862. * curveA and curveB keep unchanged.
  85863. * @param curve the curve to continue from this curve
  85864. * @returns the newly constructed curve
  85865. */
  85866. continue(curve: DeepImmutable<Curve3>): Curve3;
  85867. private _computeLength;
  85868. }
  85869. }
  85870. declare module BABYLON {
  85871. /**
  85872. * This represents the main contract an easing function should follow.
  85873. * Easing functions are used throughout the animation system.
  85874. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85875. */
  85876. export interface IEasingFunction {
  85877. /**
  85878. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85879. * of the easing function.
  85880. * The link below provides some of the most common examples of easing functions.
  85881. * @see https://easings.net/
  85882. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85883. * @returns the corresponding value on the curve defined by the easing function
  85884. */
  85885. ease(gradient: number): number;
  85886. }
  85887. /**
  85888. * Base class used for every default easing function.
  85889. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85890. */
  85891. export class EasingFunction implements IEasingFunction {
  85892. /**
  85893. * Interpolation follows the mathematical formula associated with the easing function.
  85894. */
  85895. static readonly EASINGMODE_EASEIN: number;
  85896. /**
  85897. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85898. */
  85899. static readonly EASINGMODE_EASEOUT: number;
  85900. /**
  85901. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85902. */
  85903. static readonly EASINGMODE_EASEINOUT: number;
  85904. private _easingMode;
  85905. /**
  85906. * Sets the easing mode of the current function.
  85907. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85908. */
  85909. setEasingMode(easingMode: number): void;
  85910. /**
  85911. * Gets the current easing mode.
  85912. * @returns the easing mode
  85913. */
  85914. getEasingMode(): number;
  85915. /**
  85916. * @hidden
  85917. */
  85918. easeInCore(gradient: number): number;
  85919. /**
  85920. * Given an input gradient between 0 and 1, this returns the corresponding value
  85921. * of the easing function.
  85922. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85923. * @returns the corresponding value on the curve defined by the easing function
  85924. */
  85925. ease(gradient: number): number;
  85926. }
  85927. /**
  85928. * Easing function with a circle shape (see link below).
  85929. * @see https://easings.net/#easeInCirc
  85930. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85931. */
  85932. export class CircleEase extends EasingFunction implements IEasingFunction {
  85933. /** @hidden */
  85934. easeInCore(gradient: number): number;
  85935. }
  85936. /**
  85937. * Easing function with a ease back shape (see link below).
  85938. * @see https://easings.net/#easeInBack
  85939. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85940. */
  85941. export class BackEase extends EasingFunction implements IEasingFunction {
  85942. /** Defines the amplitude of the function */
  85943. amplitude: number;
  85944. /**
  85945. * Instantiates a back ease easing
  85946. * @see https://easings.net/#easeInBack
  85947. * @param amplitude Defines the amplitude of the function
  85948. */
  85949. constructor(
  85950. /** Defines the amplitude of the function */
  85951. amplitude?: number);
  85952. /** @hidden */
  85953. easeInCore(gradient: number): number;
  85954. }
  85955. /**
  85956. * Easing function with a bouncing shape (see link below).
  85957. * @see https://easings.net/#easeInBounce
  85958. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85959. */
  85960. export class BounceEase extends EasingFunction implements IEasingFunction {
  85961. /** Defines the number of bounces */
  85962. bounces: number;
  85963. /** Defines the amplitude of the bounce */
  85964. bounciness: number;
  85965. /**
  85966. * Instantiates a bounce easing
  85967. * @see https://easings.net/#easeInBounce
  85968. * @param bounces Defines the number of bounces
  85969. * @param bounciness Defines the amplitude of the bounce
  85970. */
  85971. constructor(
  85972. /** Defines the number of bounces */
  85973. bounces?: number,
  85974. /** Defines the amplitude of the bounce */
  85975. bounciness?: number);
  85976. /** @hidden */
  85977. easeInCore(gradient: number): number;
  85978. }
  85979. /**
  85980. * Easing function with a power of 3 shape (see link below).
  85981. * @see https://easings.net/#easeInCubic
  85982. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85983. */
  85984. export class CubicEase extends EasingFunction implements IEasingFunction {
  85985. /** @hidden */
  85986. easeInCore(gradient: number): number;
  85987. }
  85988. /**
  85989. * Easing function with an elastic shape (see link below).
  85990. * @see https://easings.net/#easeInElastic
  85991. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85992. */
  85993. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85994. /** Defines the number of oscillations*/
  85995. oscillations: number;
  85996. /** Defines the amplitude of the oscillations*/
  85997. springiness: number;
  85998. /**
  85999. * Instantiates an elastic easing function
  86000. * @see https://easings.net/#easeInElastic
  86001. * @param oscillations Defines the number of oscillations
  86002. * @param springiness Defines the amplitude of the oscillations
  86003. */
  86004. constructor(
  86005. /** Defines the number of oscillations*/
  86006. oscillations?: number,
  86007. /** Defines the amplitude of the oscillations*/
  86008. springiness?: number);
  86009. /** @hidden */
  86010. easeInCore(gradient: number): number;
  86011. }
  86012. /**
  86013. * Easing function with an exponential shape (see link below).
  86014. * @see https://easings.net/#easeInExpo
  86015. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86016. */
  86017. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86018. /** Defines the exponent of the function */
  86019. exponent: number;
  86020. /**
  86021. * Instantiates an exponential easing function
  86022. * @see https://easings.net/#easeInExpo
  86023. * @param exponent Defines the exponent of the function
  86024. */
  86025. constructor(
  86026. /** Defines the exponent of the function */
  86027. exponent?: number);
  86028. /** @hidden */
  86029. easeInCore(gradient: number): number;
  86030. }
  86031. /**
  86032. * Easing function with a power shape (see link below).
  86033. * @see https://easings.net/#easeInQuad
  86034. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86035. */
  86036. export class PowerEase extends EasingFunction implements IEasingFunction {
  86037. /** Defines the power of the function */
  86038. power: number;
  86039. /**
  86040. * Instantiates an power base easing function
  86041. * @see https://easings.net/#easeInQuad
  86042. * @param power Defines the power of the function
  86043. */
  86044. constructor(
  86045. /** Defines the power of the function */
  86046. power?: number);
  86047. /** @hidden */
  86048. easeInCore(gradient: number): number;
  86049. }
  86050. /**
  86051. * Easing function with a power of 2 shape (see link below).
  86052. * @see https://easings.net/#easeInQuad
  86053. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86054. */
  86055. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86056. /** @hidden */
  86057. easeInCore(gradient: number): number;
  86058. }
  86059. /**
  86060. * Easing function with a power of 4 shape (see link below).
  86061. * @see https://easings.net/#easeInQuart
  86062. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86063. */
  86064. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86065. /** @hidden */
  86066. easeInCore(gradient: number): number;
  86067. }
  86068. /**
  86069. * Easing function with a power of 5 shape (see link below).
  86070. * @see https://easings.net/#easeInQuint
  86071. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86072. */
  86073. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86074. /** @hidden */
  86075. easeInCore(gradient: number): number;
  86076. }
  86077. /**
  86078. * Easing function with a sin shape (see link below).
  86079. * @see https://easings.net/#easeInSine
  86080. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86081. */
  86082. export class SineEase extends EasingFunction implements IEasingFunction {
  86083. /** @hidden */
  86084. easeInCore(gradient: number): number;
  86085. }
  86086. /**
  86087. * Easing function with a bezier shape (see link below).
  86088. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86089. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86090. */
  86091. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86092. /** Defines the x component of the start tangent in the bezier curve */
  86093. x1: number;
  86094. /** Defines the y component of the start tangent in the bezier curve */
  86095. y1: number;
  86096. /** Defines the x component of the end tangent in the bezier curve */
  86097. x2: number;
  86098. /** Defines the y component of the end tangent in the bezier curve */
  86099. y2: number;
  86100. /**
  86101. * Instantiates a bezier function
  86102. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86103. * @param x1 Defines the x component of the start tangent in the bezier curve
  86104. * @param y1 Defines the y component of the start tangent in the bezier curve
  86105. * @param x2 Defines the x component of the end tangent in the bezier curve
  86106. * @param y2 Defines the y component of the end tangent in the bezier curve
  86107. */
  86108. constructor(
  86109. /** Defines the x component of the start tangent in the bezier curve */
  86110. x1?: number,
  86111. /** Defines the y component of the start tangent in the bezier curve */
  86112. y1?: number,
  86113. /** Defines the x component of the end tangent in the bezier curve */
  86114. x2?: number,
  86115. /** Defines the y component of the end tangent in the bezier curve */
  86116. y2?: number);
  86117. /** @hidden */
  86118. easeInCore(gradient: number): number;
  86119. }
  86120. }
  86121. declare module BABYLON {
  86122. /**
  86123. * Class used to hold a RBG color
  86124. */
  86125. export class Color3 {
  86126. /**
  86127. * Defines the red component (between 0 and 1, default is 0)
  86128. */
  86129. r: number;
  86130. /**
  86131. * Defines the green component (between 0 and 1, default is 0)
  86132. */
  86133. g: number;
  86134. /**
  86135. * Defines the blue component (between 0 and 1, default is 0)
  86136. */
  86137. b: number;
  86138. /**
  86139. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86140. * @param r defines the red component (between 0 and 1, default is 0)
  86141. * @param g defines the green component (between 0 and 1, default is 0)
  86142. * @param b defines the blue component (between 0 and 1, default is 0)
  86143. */
  86144. constructor(
  86145. /**
  86146. * Defines the red component (between 0 and 1, default is 0)
  86147. */
  86148. r?: number,
  86149. /**
  86150. * Defines the green component (between 0 and 1, default is 0)
  86151. */
  86152. g?: number,
  86153. /**
  86154. * Defines the blue component (between 0 and 1, default is 0)
  86155. */
  86156. b?: number);
  86157. /**
  86158. * Creates a string with the Color3 current values
  86159. * @returns the string representation of the Color3 object
  86160. */
  86161. toString(): string;
  86162. /**
  86163. * Returns the string "Color3"
  86164. * @returns "Color3"
  86165. */
  86166. getClassName(): string;
  86167. /**
  86168. * Compute the Color3 hash code
  86169. * @returns an unique number that can be used to hash Color3 objects
  86170. */
  86171. getHashCode(): number;
  86172. /**
  86173. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86174. * @param array defines the array where to store the r,g,b components
  86175. * @param index defines an optional index in the target array to define where to start storing values
  86176. * @returns the current Color3 object
  86177. */
  86178. toArray(array: FloatArray, index?: number): Color3;
  86179. /**
  86180. * Update the current color with values stored in an array from the starting index of the given array
  86181. * @param array defines the source array
  86182. * @param offset defines an offset in the source array
  86183. * @returns the current Color3 object
  86184. */
  86185. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86186. /**
  86187. * Returns a new Color4 object from the current Color3 and the given alpha
  86188. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86189. * @returns a new Color4 object
  86190. */
  86191. toColor4(alpha?: number): Color4;
  86192. /**
  86193. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86194. * @returns the new array
  86195. */
  86196. asArray(): number[];
  86197. /**
  86198. * Returns the luminance value
  86199. * @returns a float value
  86200. */
  86201. toLuminance(): number;
  86202. /**
  86203. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86204. * @param otherColor defines the second operand
  86205. * @returns the new Color3 object
  86206. */
  86207. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86208. /**
  86209. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86210. * @param otherColor defines the second operand
  86211. * @param result defines the Color3 object where to store the result
  86212. * @returns the current Color3
  86213. */
  86214. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86215. /**
  86216. * Determines equality between Color3 objects
  86217. * @param otherColor defines the second operand
  86218. * @returns true if the rgb values are equal to the given ones
  86219. */
  86220. equals(otherColor: DeepImmutable<Color3>): boolean;
  86221. /**
  86222. * Determines equality between the current Color3 object and a set of r,b,g values
  86223. * @param r defines the red component to check
  86224. * @param g defines the green component to check
  86225. * @param b defines the blue component to check
  86226. * @returns true if the rgb values are equal to the given ones
  86227. */
  86228. equalsFloats(r: number, g: number, b: number): boolean;
  86229. /**
  86230. * Multiplies in place each rgb value by scale
  86231. * @param scale defines the scaling factor
  86232. * @returns the updated Color3
  86233. */
  86234. scale(scale: number): Color3;
  86235. /**
  86236. * Multiplies the rgb values by scale and stores the result into "result"
  86237. * @param scale defines the scaling factor
  86238. * @param result defines the Color3 object where to store the result
  86239. * @returns the unmodified current Color3
  86240. */
  86241. scaleToRef(scale: number, result: Color3): Color3;
  86242. /**
  86243. * Scale the current Color3 values by a factor and add the result to a given Color3
  86244. * @param scale defines the scale factor
  86245. * @param result defines color to store the result into
  86246. * @returns the unmodified current Color3
  86247. */
  86248. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86249. /**
  86250. * Clamps the rgb values by the min and max values and stores the result into "result"
  86251. * @param min defines minimum clamping value (default is 0)
  86252. * @param max defines maximum clamping value (default is 1)
  86253. * @param result defines color to store the result into
  86254. * @returns the original Color3
  86255. */
  86256. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86257. /**
  86258. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86259. * @param otherColor defines the second operand
  86260. * @returns the new Color3
  86261. */
  86262. add(otherColor: DeepImmutable<Color3>): Color3;
  86263. /**
  86264. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86265. * @param otherColor defines the second operand
  86266. * @param result defines Color3 object to store the result into
  86267. * @returns the unmodified current Color3
  86268. */
  86269. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86270. /**
  86271. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86272. * @param otherColor defines the second operand
  86273. * @returns the new Color3
  86274. */
  86275. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86276. /**
  86277. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86278. * @param otherColor defines the second operand
  86279. * @param result defines Color3 object to store the result into
  86280. * @returns the unmodified current Color3
  86281. */
  86282. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86283. /**
  86284. * Copy the current object
  86285. * @returns a new Color3 copied the current one
  86286. */
  86287. clone(): Color3;
  86288. /**
  86289. * Copies the rgb values from the source in the current Color3
  86290. * @param source defines the source Color3 object
  86291. * @returns the updated Color3 object
  86292. */
  86293. copyFrom(source: DeepImmutable<Color3>): Color3;
  86294. /**
  86295. * Updates the Color3 rgb values from the given floats
  86296. * @param r defines the red component to read from
  86297. * @param g defines the green component to read from
  86298. * @param b defines the blue component to read from
  86299. * @returns the current Color3 object
  86300. */
  86301. copyFromFloats(r: number, g: number, b: number): Color3;
  86302. /**
  86303. * Updates the Color3 rgb values from the given floats
  86304. * @param r defines the red component to read from
  86305. * @param g defines the green component to read from
  86306. * @param b defines the blue component to read from
  86307. * @returns the current Color3 object
  86308. */
  86309. set(r: number, g: number, b: number): Color3;
  86310. /**
  86311. * Compute the Color3 hexadecimal code as a string
  86312. * @returns a string containing the hexadecimal representation of the Color3 object
  86313. */
  86314. toHexString(): string;
  86315. /**
  86316. * Computes a new Color3 converted from the current one to linear space
  86317. * @returns a new Color3 object
  86318. */
  86319. toLinearSpace(): Color3;
  86320. /**
  86321. * Converts current color in rgb space to HSV values
  86322. * @returns a new color3 representing the HSV values
  86323. */
  86324. toHSV(): Color3;
  86325. /**
  86326. * Converts current color in rgb space to HSV values
  86327. * @param result defines the Color3 where to store the HSV values
  86328. */
  86329. toHSVToRef(result: Color3): void;
  86330. /**
  86331. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86332. * @param convertedColor defines the Color3 object where to store the linear space version
  86333. * @returns the unmodified Color3
  86334. */
  86335. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86336. /**
  86337. * Computes a new Color3 converted from the current one to gamma space
  86338. * @returns a new Color3 object
  86339. */
  86340. toGammaSpace(): Color3;
  86341. /**
  86342. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86343. * @param convertedColor defines the Color3 object where to store the gamma space version
  86344. * @returns the unmodified Color3
  86345. */
  86346. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86347. private static _BlackReadOnly;
  86348. /**
  86349. * Convert Hue, saturation and value to a Color3 (RGB)
  86350. * @param hue defines the hue
  86351. * @param saturation defines the saturation
  86352. * @param value defines the value
  86353. * @param result defines the Color3 where to store the RGB values
  86354. */
  86355. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86356. /**
  86357. * Creates a new Color3 from the string containing valid hexadecimal values
  86358. * @param hex defines a string containing valid hexadecimal values
  86359. * @returns a new Color3 object
  86360. */
  86361. static FromHexString(hex: string): Color3;
  86362. /**
  86363. * Creates a new Color3 from the starting index of the given array
  86364. * @param array defines the source array
  86365. * @param offset defines an offset in the source array
  86366. * @returns a new Color3 object
  86367. */
  86368. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86369. /**
  86370. * Creates a new Color3 from the starting index element of the given array
  86371. * @param array defines the source array to read from
  86372. * @param offset defines the offset in the source array
  86373. * @param result defines the target Color3 object
  86374. */
  86375. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86376. /**
  86377. * Creates a new Color3 from integer values (< 256)
  86378. * @param r defines the red component to read from (value between 0 and 255)
  86379. * @param g defines the green component to read from (value between 0 and 255)
  86380. * @param b defines the blue component to read from (value between 0 and 255)
  86381. * @returns a new Color3 object
  86382. */
  86383. static FromInts(r: number, g: number, b: number): Color3;
  86384. /**
  86385. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86386. * @param start defines the start Color3 value
  86387. * @param end defines the end Color3 value
  86388. * @param amount defines the gradient value between start and end
  86389. * @returns a new Color3 object
  86390. */
  86391. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86392. /**
  86393. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86394. * @param left defines the start value
  86395. * @param right defines the end value
  86396. * @param amount defines the gradient factor
  86397. * @param result defines the Color3 object where to store the result
  86398. */
  86399. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86400. /**
  86401. * Returns a Color3 value containing a red color
  86402. * @returns a new Color3 object
  86403. */
  86404. static Red(): Color3;
  86405. /**
  86406. * Returns a Color3 value containing a green color
  86407. * @returns a new Color3 object
  86408. */
  86409. static Green(): Color3;
  86410. /**
  86411. * Returns a Color3 value containing a blue color
  86412. * @returns a new Color3 object
  86413. */
  86414. static Blue(): Color3;
  86415. /**
  86416. * Returns a Color3 value containing a black color
  86417. * @returns a new Color3 object
  86418. */
  86419. static Black(): Color3;
  86420. /**
  86421. * Gets a Color3 value containing a black color that must not be updated
  86422. */
  86423. static get BlackReadOnly(): DeepImmutable<Color3>;
  86424. /**
  86425. * Returns a Color3 value containing a white color
  86426. * @returns a new Color3 object
  86427. */
  86428. static White(): Color3;
  86429. /**
  86430. * Returns a Color3 value containing a purple color
  86431. * @returns a new Color3 object
  86432. */
  86433. static Purple(): Color3;
  86434. /**
  86435. * Returns a Color3 value containing a magenta color
  86436. * @returns a new Color3 object
  86437. */
  86438. static Magenta(): Color3;
  86439. /**
  86440. * Returns a Color3 value containing a yellow color
  86441. * @returns a new Color3 object
  86442. */
  86443. static Yellow(): Color3;
  86444. /**
  86445. * Returns a Color3 value containing a gray color
  86446. * @returns a new Color3 object
  86447. */
  86448. static Gray(): Color3;
  86449. /**
  86450. * Returns a Color3 value containing a teal color
  86451. * @returns a new Color3 object
  86452. */
  86453. static Teal(): Color3;
  86454. /**
  86455. * Returns a Color3 value containing a random color
  86456. * @returns a new Color3 object
  86457. */
  86458. static Random(): Color3;
  86459. }
  86460. /**
  86461. * Class used to hold a RBGA color
  86462. */
  86463. export class Color4 {
  86464. /**
  86465. * Defines the red component (between 0 and 1, default is 0)
  86466. */
  86467. r: number;
  86468. /**
  86469. * Defines the green component (between 0 and 1, default is 0)
  86470. */
  86471. g: number;
  86472. /**
  86473. * Defines the blue component (between 0 and 1, default is 0)
  86474. */
  86475. b: number;
  86476. /**
  86477. * Defines the alpha component (between 0 and 1, default is 1)
  86478. */
  86479. a: number;
  86480. /**
  86481. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86482. * @param r defines the red component (between 0 and 1, default is 0)
  86483. * @param g defines the green component (between 0 and 1, default is 0)
  86484. * @param b defines the blue component (between 0 and 1, default is 0)
  86485. * @param a defines the alpha component (between 0 and 1, default is 1)
  86486. */
  86487. constructor(
  86488. /**
  86489. * Defines the red component (between 0 and 1, default is 0)
  86490. */
  86491. r?: number,
  86492. /**
  86493. * Defines the green component (between 0 and 1, default is 0)
  86494. */
  86495. g?: number,
  86496. /**
  86497. * Defines the blue component (between 0 and 1, default is 0)
  86498. */
  86499. b?: number,
  86500. /**
  86501. * Defines the alpha component (between 0 and 1, default is 1)
  86502. */
  86503. a?: number);
  86504. /**
  86505. * Adds in place the given Color4 values to the current Color4 object
  86506. * @param right defines the second operand
  86507. * @returns the current updated Color4 object
  86508. */
  86509. addInPlace(right: DeepImmutable<Color4>): Color4;
  86510. /**
  86511. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86512. * @returns the new array
  86513. */
  86514. asArray(): number[];
  86515. /**
  86516. * Stores from the starting index in the given array the Color4 successive values
  86517. * @param array defines the array where to store the r,g,b components
  86518. * @param index defines an optional index in the target array to define where to start storing values
  86519. * @returns the current Color4 object
  86520. */
  86521. toArray(array: number[], index?: number): Color4;
  86522. /**
  86523. * Update the current color with values stored in an array from the starting index of the given array
  86524. * @param array defines the source array
  86525. * @param offset defines an offset in the source array
  86526. * @returns the current Color4 object
  86527. */
  86528. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86529. /**
  86530. * Determines equality between Color4 objects
  86531. * @param otherColor defines the second operand
  86532. * @returns true if the rgba values are equal to the given ones
  86533. */
  86534. equals(otherColor: DeepImmutable<Color4>): boolean;
  86535. /**
  86536. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86537. * @param right defines the second operand
  86538. * @returns a new Color4 object
  86539. */
  86540. add(right: DeepImmutable<Color4>): Color4;
  86541. /**
  86542. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86543. * @param right defines the second operand
  86544. * @returns a new Color4 object
  86545. */
  86546. subtract(right: DeepImmutable<Color4>): Color4;
  86547. /**
  86548. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86549. * @param right defines the second operand
  86550. * @param result defines the Color4 object where to store the result
  86551. * @returns the current Color4 object
  86552. */
  86553. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86554. /**
  86555. * Creates a new Color4 with the current Color4 values multiplied by scale
  86556. * @param scale defines the scaling factor to apply
  86557. * @returns a new Color4 object
  86558. */
  86559. scale(scale: number): Color4;
  86560. /**
  86561. * Multiplies the current Color4 values by scale and stores the result in "result"
  86562. * @param scale defines the scaling factor to apply
  86563. * @param result defines the Color4 object where to store the result
  86564. * @returns the current unmodified Color4
  86565. */
  86566. scaleToRef(scale: number, result: Color4): Color4;
  86567. /**
  86568. * Scale the current Color4 values by a factor and add the result to a given Color4
  86569. * @param scale defines the scale factor
  86570. * @param result defines the Color4 object where to store the result
  86571. * @returns the unmodified current Color4
  86572. */
  86573. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86574. /**
  86575. * Clamps the rgb values by the min and max values and stores the result into "result"
  86576. * @param min defines minimum clamping value (default is 0)
  86577. * @param max defines maximum clamping value (default is 1)
  86578. * @param result defines color to store the result into.
  86579. * @returns the cuurent Color4
  86580. */
  86581. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86582. /**
  86583. * Multipy an Color4 value by another and return a new Color4 object
  86584. * @param color defines the Color4 value to multiply by
  86585. * @returns a new Color4 object
  86586. */
  86587. multiply(color: Color4): Color4;
  86588. /**
  86589. * Multipy a Color4 value by another and push the result in a reference value
  86590. * @param color defines the Color4 value to multiply by
  86591. * @param result defines the Color4 to fill the result in
  86592. * @returns the result Color4
  86593. */
  86594. multiplyToRef(color: Color4, result: Color4): Color4;
  86595. /**
  86596. * Creates a string with the Color4 current values
  86597. * @returns the string representation of the Color4 object
  86598. */
  86599. toString(): string;
  86600. /**
  86601. * Returns the string "Color4"
  86602. * @returns "Color4"
  86603. */
  86604. getClassName(): string;
  86605. /**
  86606. * Compute the Color4 hash code
  86607. * @returns an unique number that can be used to hash Color4 objects
  86608. */
  86609. getHashCode(): number;
  86610. /**
  86611. * Creates a new Color4 copied from the current one
  86612. * @returns a new Color4 object
  86613. */
  86614. clone(): Color4;
  86615. /**
  86616. * Copies the given Color4 values into the current one
  86617. * @param source defines the source Color4 object
  86618. * @returns the current updated Color4 object
  86619. */
  86620. copyFrom(source: Color4): Color4;
  86621. /**
  86622. * Copies the given float values into the current one
  86623. * @param r defines the red component to read from
  86624. * @param g defines the green component to read from
  86625. * @param b defines the blue component to read from
  86626. * @param a defines the alpha component to read from
  86627. * @returns the current updated Color4 object
  86628. */
  86629. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86630. /**
  86631. * Copies the given float values into the current one
  86632. * @param r defines the red component to read from
  86633. * @param g defines the green component to read from
  86634. * @param b defines the blue component to read from
  86635. * @param a defines the alpha component to read from
  86636. * @returns the current updated Color4 object
  86637. */
  86638. set(r: number, g: number, b: number, a: number): Color4;
  86639. /**
  86640. * Compute the Color4 hexadecimal code as a string
  86641. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86642. * @returns a string containing the hexadecimal representation of the Color4 object
  86643. */
  86644. toHexString(returnAsColor3?: boolean): string;
  86645. /**
  86646. * Computes a new Color4 converted from the current one to linear space
  86647. * @returns a new Color4 object
  86648. */
  86649. toLinearSpace(): Color4;
  86650. /**
  86651. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86652. * @param convertedColor defines the Color4 object where to store the linear space version
  86653. * @returns the unmodified Color4
  86654. */
  86655. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86656. /**
  86657. * Computes a new Color4 converted from the current one to gamma space
  86658. * @returns a new Color4 object
  86659. */
  86660. toGammaSpace(): Color4;
  86661. /**
  86662. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86663. * @param convertedColor defines the Color4 object where to store the gamma space version
  86664. * @returns the unmodified Color4
  86665. */
  86666. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86667. /**
  86668. * Creates a new Color4 from the string containing valid hexadecimal values
  86669. * @param hex defines a string containing valid hexadecimal values
  86670. * @returns a new Color4 object
  86671. */
  86672. static FromHexString(hex: string): Color4;
  86673. /**
  86674. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86675. * @param left defines the start value
  86676. * @param right defines the end value
  86677. * @param amount defines the gradient factor
  86678. * @returns a new Color4 object
  86679. */
  86680. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86681. /**
  86682. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86683. * @param left defines the start value
  86684. * @param right defines the end value
  86685. * @param amount defines the gradient factor
  86686. * @param result defines the Color4 object where to store data
  86687. */
  86688. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86689. /**
  86690. * Creates a new Color4 from a Color3 and an alpha value
  86691. * @param color3 defines the source Color3 to read from
  86692. * @param alpha defines the alpha component (1.0 by default)
  86693. * @returns a new Color4 object
  86694. */
  86695. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86696. /**
  86697. * Creates a new Color4 from the starting index element of the given array
  86698. * @param array defines the source array to read from
  86699. * @param offset defines the offset in the source array
  86700. * @returns a new Color4 object
  86701. */
  86702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86703. /**
  86704. * Creates a new Color4 from the starting index element of the given array
  86705. * @param array defines the source array to read from
  86706. * @param offset defines the offset in the source array
  86707. * @param result defines the target Color4 object
  86708. */
  86709. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86710. /**
  86711. * Creates a new Color3 from integer values (< 256)
  86712. * @param r defines the red component to read from (value between 0 and 255)
  86713. * @param g defines the green component to read from (value between 0 and 255)
  86714. * @param b defines the blue component to read from (value between 0 and 255)
  86715. * @param a defines the alpha component to read from (value between 0 and 255)
  86716. * @returns a new Color3 object
  86717. */
  86718. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86719. /**
  86720. * Check the content of a given array and convert it to an array containing RGBA data
  86721. * If the original array was already containing count * 4 values then it is returned directly
  86722. * @param colors defines the array to check
  86723. * @param count defines the number of RGBA data to expect
  86724. * @returns an array containing count * 4 values (RGBA)
  86725. */
  86726. static CheckColors4(colors: number[], count: number): number[];
  86727. }
  86728. /**
  86729. * @hidden
  86730. */
  86731. export class TmpColors {
  86732. static Color3: Color3[];
  86733. static Color4: Color4[];
  86734. }
  86735. }
  86736. declare module BABYLON {
  86737. /**
  86738. * Defines an interface which represents an animation key frame
  86739. */
  86740. export interface IAnimationKey {
  86741. /**
  86742. * Frame of the key frame
  86743. */
  86744. frame: number;
  86745. /**
  86746. * Value at the specifies key frame
  86747. */
  86748. value: any;
  86749. /**
  86750. * The input tangent for the cubic hermite spline
  86751. */
  86752. inTangent?: any;
  86753. /**
  86754. * The output tangent for the cubic hermite spline
  86755. */
  86756. outTangent?: any;
  86757. /**
  86758. * The animation interpolation type
  86759. */
  86760. interpolation?: AnimationKeyInterpolation;
  86761. }
  86762. /**
  86763. * Enum for the animation key frame interpolation type
  86764. */
  86765. export enum AnimationKeyInterpolation {
  86766. /**
  86767. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86768. */
  86769. STEP = 1
  86770. }
  86771. }
  86772. declare module BABYLON {
  86773. /**
  86774. * Represents the range of an animation
  86775. */
  86776. export class AnimationRange {
  86777. /**The name of the animation range**/
  86778. name: string;
  86779. /**The starting frame of the animation */
  86780. from: number;
  86781. /**The ending frame of the animation*/
  86782. to: number;
  86783. /**
  86784. * Initializes the range of an animation
  86785. * @param name The name of the animation range
  86786. * @param from The starting frame of the animation
  86787. * @param to The ending frame of the animation
  86788. */
  86789. constructor(
  86790. /**The name of the animation range**/
  86791. name: string,
  86792. /**The starting frame of the animation */
  86793. from: number,
  86794. /**The ending frame of the animation*/
  86795. to: number);
  86796. /**
  86797. * Makes a copy of the animation range
  86798. * @returns A copy of the animation range
  86799. */
  86800. clone(): AnimationRange;
  86801. }
  86802. }
  86803. declare module BABYLON {
  86804. /**
  86805. * Composed of a frame, and an action function
  86806. */
  86807. export class AnimationEvent {
  86808. /** The frame for which the event is triggered **/
  86809. frame: number;
  86810. /** The event to perform when triggered **/
  86811. action: (currentFrame: number) => void;
  86812. /** Specifies if the event should be triggered only once**/
  86813. onlyOnce?: boolean | undefined;
  86814. /**
  86815. * Specifies if the animation event is done
  86816. */
  86817. isDone: boolean;
  86818. /**
  86819. * Initializes the animation event
  86820. * @param frame The frame for which the event is triggered
  86821. * @param action The event to perform when triggered
  86822. * @param onlyOnce Specifies if the event should be triggered only once
  86823. */
  86824. constructor(
  86825. /** The frame for which the event is triggered **/
  86826. frame: number,
  86827. /** The event to perform when triggered **/
  86828. action: (currentFrame: number) => void,
  86829. /** Specifies if the event should be triggered only once**/
  86830. onlyOnce?: boolean | undefined);
  86831. /** @hidden */
  86832. _clone(): AnimationEvent;
  86833. }
  86834. }
  86835. declare module BABYLON {
  86836. /**
  86837. * Interface used to define a behavior
  86838. */
  86839. export interface Behavior<T> {
  86840. /** gets or sets behavior's name */
  86841. name: string;
  86842. /**
  86843. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86844. */
  86845. init(): void;
  86846. /**
  86847. * Called when the behavior is attached to a target
  86848. * @param target defines the target where the behavior is attached to
  86849. */
  86850. attach(target: T): void;
  86851. /**
  86852. * Called when the behavior is detached from its target
  86853. */
  86854. detach(): void;
  86855. }
  86856. /**
  86857. * Interface implemented by classes supporting behaviors
  86858. */
  86859. export interface IBehaviorAware<T> {
  86860. /**
  86861. * Attach a behavior
  86862. * @param behavior defines the behavior to attach
  86863. * @returns the current host
  86864. */
  86865. addBehavior(behavior: Behavior<T>): T;
  86866. /**
  86867. * Remove a behavior from the current object
  86868. * @param behavior defines the behavior to detach
  86869. * @returns the current host
  86870. */
  86871. removeBehavior(behavior: Behavior<T>): T;
  86872. /**
  86873. * Gets a behavior using its name to search
  86874. * @param name defines the name to search
  86875. * @returns the behavior or null if not found
  86876. */
  86877. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86878. }
  86879. }
  86880. declare module BABYLON {
  86881. /**
  86882. * Defines an array and its length.
  86883. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86884. */
  86885. export interface ISmartArrayLike<T> {
  86886. /**
  86887. * The data of the array.
  86888. */
  86889. data: Array<T>;
  86890. /**
  86891. * The active length of the array.
  86892. */
  86893. length: number;
  86894. }
  86895. /**
  86896. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86897. */
  86898. export class SmartArray<T> implements ISmartArrayLike<T> {
  86899. /**
  86900. * The full set of data from the array.
  86901. */
  86902. data: Array<T>;
  86903. /**
  86904. * The active length of the array.
  86905. */
  86906. length: number;
  86907. protected _id: number;
  86908. /**
  86909. * Instantiates a Smart Array.
  86910. * @param capacity defines the default capacity of the array.
  86911. */
  86912. constructor(capacity: number);
  86913. /**
  86914. * Pushes a value at the end of the active data.
  86915. * @param value defines the object to push in the array.
  86916. */
  86917. push(value: T): void;
  86918. /**
  86919. * Iterates over the active data and apply the lambda to them.
  86920. * @param func defines the action to apply on each value.
  86921. */
  86922. forEach(func: (content: T) => void): void;
  86923. /**
  86924. * Sorts the full sets of data.
  86925. * @param compareFn defines the comparison function to apply.
  86926. */
  86927. sort(compareFn: (a: T, b: T) => number): void;
  86928. /**
  86929. * Resets the active data to an empty array.
  86930. */
  86931. reset(): void;
  86932. /**
  86933. * Releases all the data from the array as well as the array.
  86934. */
  86935. dispose(): void;
  86936. /**
  86937. * Concats the active data with a given array.
  86938. * @param array defines the data to concatenate with.
  86939. */
  86940. concat(array: any): void;
  86941. /**
  86942. * Returns the position of a value in the active data.
  86943. * @param value defines the value to find the index for
  86944. * @returns the index if found in the active data otherwise -1
  86945. */
  86946. indexOf(value: T): number;
  86947. /**
  86948. * Returns whether an element is part of the active data.
  86949. * @param value defines the value to look for
  86950. * @returns true if found in the active data otherwise false
  86951. */
  86952. contains(value: T): boolean;
  86953. private static _GlobalId;
  86954. }
  86955. /**
  86956. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86957. * The data in this array can only be present once
  86958. */
  86959. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86960. private _duplicateId;
  86961. /**
  86962. * Pushes a value at the end of the active data.
  86963. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86964. * @param value defines the object to push in the array.
  86965. */
  86966. push(value: T): void;
  86967. /**
  86968. * Pushes a value at the end of the active data.
  86969. * If the data is already present, it won t be added again
  86970. * @param value defines the object to push in the array.
  86971. * @returns true if added false if it was already present
  86972. */
  86973. pushNoDuplicate(value: T): boolean;
  86974. /**
  86975. * Resets the active data to an empty array.
  86976. */
  86977. reset(): void;
  86978. /**
  86979. * Concats the active data with a given array.
  86980. * This ensures no dupplicate will be present in the result.
  86981. * @param array defines the data to concatenate with.
  86982. */
  86983. concatWithNoDuplicate(array: any): void;
  86984. }
  86985. }
  86986. declare module BABYLON {
  86987. /**
  86988. * @ignore
  86989. * This is a list of all the different input types that are available in the application.
  86990. * Fo instance: ArcRotateCameraGamepadInput...
  86991. */
  86992. export var CameraInputTypes: {};
  86993. /**
  86994. * This is the contract to implement in order to create a new input class.
  86995. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86996. */
  86997. export interface ICameraInput<TCamera extends Camera> {
  86998. /**
  86999. * Defines the camera the input is attached to.
  87000. */
  87001. camera: Nullable<TCamera>;
  87002. /**
  87003. * Gets the class name of the current intput.
  87004. * @returns the class name
  87005. */
  87006. getClassName(): string;
  87007. /**
  87008. * Get the friendly name associated with the input class.
  87009. * @returns the input friendly name
  87010. */
  87011. getSimpleName(): string;
  87012. /**
  87013. * Attach the input controls to a specific dom element to get the input from.
  87014. * @param element Defines the element the controls should be listened from
  87015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87016. */
  87017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87018. /**
  87019. * Detach the current controls from the specified dom element.
  87020. * @param element Defines the element to stop listening the inputs from
  87021. */
  87022. detachControl(element: Nullable<HTMLElement>): void;
  87023. /**
  87024. * Update the current camera state depending on the inputs that have been used this frame.
  87025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87026. */
  87027. checkInputs?: () => void;
  87028. }
  87029. /**
  87030. * Represents a map of input types to input instance or input index to input instance.
  87031. */
  87032. export interface CameraInputsMap<TCamera extends Camera> {
  87033. /**
  87034. * Accessor to the input by input type.
  87035. */
  87036. [name: string]: ICameraInput<TCamera>;
  87037. /**
  87038. * Accessor to the input by input index.
  87039. */
  87040. [idx: number]: ICameraInput<TCamera>;
  87041. }
  87042. /**
  87043. * This represents the input manager used within a camera.
  87044. * It helps dealing with all the different kind of input attached to a camera.
  87045. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87046. */
  87047. export class CameraInputsManager<TCamera extends Camera> {
  87048. /**
  87049. * Defines the list of inputs attahed to the camera.
  87050. */
  87051. attached: CameraInputsMap<TCamera>;
  87052. /**
  87053. * Defines the dom element the camera is collecting inputs from.
  87054. * This is null if the controls have not been attached.
  87055. */
  87056. attachedElement: Nullable<HTMLElement>;
  87057. /**
  87058. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87059. */
  87060. noPreventDefault: boolean;
  87061. /**
  87062. * Defined the camera the input manager belongs to.
  87063. */
  87064. camera: TCamera;
  87065. /**
  87066. * Update the current camera state depending on the inputs that have been used this frame.
  87067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87068. */
  87069. checkInputs: () => void;
  87070. /**
  87071. * Instantiate a new Camera Input Manager.
  87072. * @param camera Defines the camera the input manager blongs to
  87073. */
  87074. constructor(camera: TCamera);
  87075. /**
  87076. * Add an input method to a camera
  87077. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87078. * @param input camera input method
  87079. */
  87080. add(input: ICameraInput<TCamera>): void;
  87081. /**
  87082. * Remove a specific input method from a camera
  87083. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87084. * @param inputToRemove camera input method
  87085. */
  87086. remove(inputToRemove: ICameraInput<TCamera>): void;
  87087. /**
  87088. * Remove a specific input type from a camera
  87089. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87090. * @param inputType the type of the input to remove
  87091. */
  87092. removeByType(inputType: string): void;
  87093. private _addCheckInputs;
  87094. /**
  87095. * Attach the input controls to the currently attached dom element to listen the events from.
  87096. * @param input Defines the input to attach
  87097. */
  87098. attachInput(input: ICameraInput<TCamera>): void;
  87099. /**
  87100. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87101. * @param element Defines the dom element to collect the events from
  87102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87103. */
  87104. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87105. /**
  87106. * Detach the current manager inputs controls from a specific dom element.
  87107. * @param element Defines the dom element to collect the events from
  87108. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87109. */
  87110. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87111. /**
  87112. * Rebuild the dynamic inputCheck function from the current list of
  87113. * defined inputs in the manager.
  87114. */
  87115. rebuildInputCheck(): void;
  87116. /**
  87117. * Remove all attached input methods from a camera
  87118. */
  87119. clear(): void;
  87120. /**
  87121. * Serialize the current input manager attached to a camera.
  87122. * This ensures than once parsed,
  87123. * the input associated to the camera will be identical to the current ones
  87124. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87125. */
  87126. serialize(serializedCamera: any): void;
  87127. /**
  87128. * Parses an input manager serialized JSON to restore the previous list of inputs
  87129. * and states associated to a camera.
  87130. * @param parsedCamera Defines the JSON to parse
  87131. */
  87132. parse(parsedCamera: any): void;
  87133. }
  87134. }
  87135. declare module BABYLON {
  87136. /**
  87137. * Class used to store data that will be store in GPU memory
  87138. */
  87139. export class Buffer {
  87140. private _engine;
  87141. private _buffer;
  87142. /** @hidden */
  87143. _data: Nullable<DataArray>;
  87144. private _updatable;
  87145. private _instanced;
  87146. private _divisor;
  87147. /**
  87148. * Gets the byte stride.
  87149. */
  87150. readonly byteStride: number;
  87151. /**
  87152. * Constructor
  87153. * @param engine the engine
  87154. * @param data the data to use for this buffer
  87155. * @param updatable whether the data is updatable
  87156. * @param stride the stride (optional)
  87157. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87158. * @param instanced whether the buffer is instanced (optional)
  87159. * @param useBytes set to true if the stride in in bytes (optional)
  87160. * @param divisor sets an optional divisor for instances (1 by default)
  87161. */
  87162. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87163. /**
  87164. * Create a new VertexBuffer based on the current buffer
  87165. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87166. * @param offset defines offset in the buffer (0 by default)
  87167. * @param size defines the size in floats of attributes (position is 3 for instance)
  87168. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87169. * @param instanced defines if the vertex buffer contains indexed data
  87170. * @param useBytes defines if the offset and stride are in bytes *
  87171. * @param divisor sets an optional divisor for instances (1 by default)
  87172. * @returns the new vertex buffer
  87173. */
  87174. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87175. /**
  87176. * Gets a boolean indicating if the Buffer is updatable?
  87177. * @returns true if the buffer is updatable
  87178. */
  87179. isUpdatable(): boolean;
  87180. /**
  87181. * Gets current buffer's data
  87182. * @returns a DataArray or null
  87183. */
  87184. getData(): Nullable<DataArray>;
  87185. /**
  87186. * Gets underlying native buffer
  87187. * @returns underlying native buffer
  87188. */
  87189. getBuffer(): Nullable<DataBuffer>;
  87190. /**
  87191. * Gets the stride in float32 units (i.e. byte stride / 4).
  87192. * May not be an integer if the byte stride is not divisible by 4.
  87193. * @returns the stride in float32 units
  87194. * @deprecated Please use byteStride instead.
  87195. */
  87196. getStrideSize(): number;
  87197. /**
  87198. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87199. * @param data defines the data to store
  87200. */
  87201. create(data?: Nullable<DataArray>): void;
  87202. /** @hidden */
  87203. _rebuild(): void;
  87204. /**
  87205. * Update current buffer data
  87206. * @param data defines the data to store
  87207. */
  87208. update(data: DataArray): void;
  87209. /**
  87210. * Updates the data directly.
  87211. * @param data the new data
  87212. * @param offset the new offset
  87213. * @param vertexCount the vertex count (optional)
  87214. * @param useBytes set to true if the offset is in bytes
  87215. */
  87216. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87217. /**
  87218. * Release all resources
  87219. */
  87220. dispose(): void;
  87221. }
  87222. /**
  87223. * Specialized buffer used to store vertex data
  87224. */
  87225. export class VertexBuffer {
  87226. /** @hidden */
  87227. _buffer: Buffer;
  87228. private _kind;
  87229. private _size;
  87230. private _ownsBuffer;
  87231. private _instanced;
  87232. private _instanceDivisor;
  87233. /**
  87234. * The byte type.
  87235. */
  87236. static readonly BYTE: number;
  87237. /**
  87238. * The unsigned byte type.
  87239. */
  87240. static readonly UNSIGNED_BYTE: number;
  87241. /**
  87242. * The short type.
  87243. */
  87244. static readonly SHORT: number;
  87245. /**
  87246. * The unsigned short type.
  87247. */
  87248. static readonly UNSIGNED_SHORT: number;
  87249. /**
  87250. * The integer type.
  87251. */
  87252. static readonly INT: number;
  87253. /**
  87254. * The unsigned integer type.
  87255. */
  87256. static readonly UNSIGNED_INT: number;
  87257. /**
  87258. * The float type.
  87259. */
  87260. static readonly FLOAT: number;
  87261. /**
  87262. * Gets or sets the instance divisor when in instanced mode
  87263. */
  87264. get instanceDivisor(): number;
  87265. set instanceDivisor(value: number);
  87266. /**
  87267. * Gets the byte stride.
  87268. */
  87269. readonly byteStride: number;
  87270. /**
  87271. * Gets the byte offset.
  87272. */
  87273. readonly byteOffset: number;
  87274. /**
  87275. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87276. */
  87277. readonly normalized: boolean;
  87278. /**
  87279. * Gets the data type of each component in the array.
  87280. */
  87281. readonly type: number;
  87282. /**
  87283. * Constructor
  87284. * @param engine the engine
  87285. * @param data the data to use for this vertex buffer
  87286. * @param kind the vertex buffer kind
  87287. * @param updatable whether the data is updatable
  87288. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87289. * @param stride the stride (optional)
  87290. * @param instanced whether the buffer is instanced (optional)
  87291. * @param offset the offset of the data (optional)
  87292. * @param size the number of components (optional)
  87293. * @param type the type of the component (optional)
  87294. * @param normalized whether the data contains normalized data (optional)
  87295. * @param useBytes set to true if stride and offset are in bytes (optional)
  87296. * @param divisor defines the instance divisor to use (1 by default)
  87297. */
  87298. 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);
  87299. /** @hidden */
  87300. _rebuild(): void;
  87301. /**
  87302. * Returns the kind of the VertexBuffer (string)
  87303. * @returns a string
  87304. */
  87305. getKind(): string;
  87306. /**
  87307. * Gets a boolean indicating if the VertexBuffer is updatable?
  87308. * @returns true if the buffer is updatable
  87309. */
  87310. isUpdatable(): boolean;
  87311. /**
  87312. * Gets current buffer's data
  87313. * @returns a DataArray or null
  87314. */
  87315. getData(): Nullable<DataArray>;
  87316. /**
  87317. * Gets underlying native buffer
  87318. * @returns underlying native buffer
  87319. */
  87320. getBuffer(): Nullable<DataBuffer>;
  87321. /**
  87322. * Gets the stride in float32 units (i.e. byte stride / 4).
  87323. * May not be an integer if the byte stride is not divisible by 4.
  87324. * @returns the stride in float32 units
  87325. * @deprecated Please use byteStride instead.
  87326. */
  87327. getStrideSize(): number;
  87328. /**
  87329. * Returns the offset as a multiple of the type byte length.
  87330. * @returns the offset in bytes
  87331. * @deprecated Please use byteOffset instead.
  87332. */
  87333. getOffset(): number;
  87334. /**
  87335. * Returns the number of components per vertex attribute (integer)
  87336. * @returns the size in float
  87337. */
  87338. getSize(): number;
  87339. /**
  87340. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87341. * @returns true if this buffer is instanced
  87342. */
  87343. getIsInstanced(): boolean;
  87344. /**
  87345. * Returns the instancing divisor, zero for non-instanced (integer).
  87346. * @returns a number
  87347. */
  87348. getInstanceDivisor(): number;
  87349. /**
  87350. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87351. * @param data defines the data to store
  87352. */
  87353. create(data?: DataArray): void;
  87354. /**
  87355. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87356. * This function will create a new buffer if the current one is not updatable
  87357. * @param data defines the data to store
  87358. */
  87359. update(data: DataArray): void;
  87360. /**
  87361. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87362. * Returns the directly updated WebGLBuffer.
  87363. * @param data the new data
  87364. * @param offset the new offset
  87365. * @param useBytes set to true if the offset is in bytes
  87366. */
  87367. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87368. /**
  87369. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87370. */
  87371. dispose(): void;
  87372. /**
  87373. * Enumerates each value of this vertex buffer as numbers.
  87374. * @param count the number of values to enumerate
  87375. * @param callback the callback function called for each value
  87376. */
  87377. forEach(count: number, callback: (value: number, index: number) => void): void;
  87378. /**
  87379. * Positions
  87380. */
  87381. static readonly PositionKind: string;
  87382. /**
  87383. * Normals
  87384. */
  87385. static readonly NormalKind: string;
  87386. /**
  87387. * Tangents
  87388. */
  87389. static readonly TangentKind: string;
  87390. /**
  87391. * Texture coordinates
  87392. */
  87393. static readonly UVKind: string;
  87394. /**
  87395. * Texture coordinates 2
  87396. */
  87397. static readonly UV2Kind: string;
  87398. /**
  87399. * Texture coordinates 3
  87400. */
  87401. static readonly UV3Kind: string;
  87402. /**
  87403. * Texture coordinates 4
  87404. */
  87405. static readonly UV4Kind: string;
  87406. /**
  87407. * Texture coordinates 5
  87408. */
  87409. static readonly UV5Kind: string;
  87410. /**
  87411. * Texture coordinates 6
  87412. */
  87413. static readonly UV6Kind: string;
  87414. /**
  87415. * Colors
  87416. */
  87417. static readonly ColorKind: string;
  87418. /**
  87419. * Matrix indices (for bones)
  87420. */
  87421. static readonly MatricesIndicesKind: string;
  87422. /**
  87423. * Matrix weights (for bones)
  87424. */
  87425. static readonly MatricesWeightsKind: string;
  87426. /**
  87427. * Additional matrix indices (for bones)
  87428. */
  87429. static readonly MatricesIndicesExtraKind: string;
  87430. /**
  87431. * Additional matrix weights (for bones)
  87432. */
  87433. static readonly MatricesWeightsExtraKind: string;
  87434. /**
  87435. * Deduces the stride given a kind.
  87436. * @param kind The kind string to deduce
  87437. * @returns The deduced stride
  87438. */
  87439. static DeduceStride(kind: string): number;
  87440. /**
  87441. * Gets the byte length of the given type.
  87442. * @param type the type
  87443. * @returns the number of bytes
  87444. */
  87445. static GetTypeByteLength(type: number): number;
  87446. /**
  87447. * Enumerates each value of the given parameters as numbers.
  87448. * @param data the data to enumerate
  87449. * @param byteOffset the byte offset of the data
  87450. * @param byteStride the byte stride of the data
  87451. * @param componentCount the number of components per element
  87452. * @param componentType the type of the component
  87453. * @param count the number of values to enumerate
  87454. * @param normalized whether the data is normalized
  87455. * @param callback the callback function called for each value
  87456. */
  87457. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87458. private static _GetFloatValue;
  87459. }
  87460. }
  87461. declare module BABYLON {
  87462. /**
  87463. * The options Interface for creating a Capsule Mesh
  87464. */
  87465. export interface ICreateCapsuleOptions {
  87466. /** The Orientation of the capsule. Default : Vector3.Up() */
  87467. orientation?: Vector3;
  87468. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87469. subdivisions: number;
  87470. /** Number of cylindrical segments on the capsule. */
  87471. tessellation: number;
  87472. /** Height or Length of the capsule. */
  87473. height: number;
  87474. /** Radius of the capsule. */
  87475. radius: number;
  87476. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87477. capSubdivisions: number;
  87478. /** Overwrite for the top radius. */
  87479. radiusTop?: number;
  87480. /** Overwrite for the bottom radius. */
  87481. radiusBottom?: number;
  87482. /** Overwrite for the top capSubdivisions. */
  87483. topCapSubdivisions?: number;
  87484. /** Overwrite for the bottom capSubdivisions. */
  87485. bottomCapSubdivisions?: number;
  87486. }
  87487. /**
  87488. * Class containing static functions to help procedurally build meshes
  87489. */
  87490. export class CapsuleBuilder {
  87491. /**
  87492. * Creates a capsule or a pill mesh
  87493. * @param name defines the name of the mesh
  87494. * @param options The constructors options.
  87495. * @param scene The scene the mesh is scoped to.
  87496. * @returns Capsule Mesh
  87497. */
  87498. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87499. }
  87500. }
  87501. declare module BABYLON {
  87502. /**
  87503. * @hidden
  87504. */
  87505. export class IntersectionInfo {
  87506. bu: Nullable<number>;
  87507. bv: Nullable<number>;
  87508. distance: number;
  87509. faceId: number;
  87510. subMeshId: number;
  87511. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87512. }
  87513. }
  87514. declare module BABYLON {
  87515. /**
  87516. * Class used to store bounding sphere information
  87517. */
  87518. export class BoundingSphere {
  87519. /**
  87520. * Gets the center of the bounding sphere in local space
  87521. */
  87522. readonly center: Vector3;
  87523. /**
  87524. * Radius of the bounding sphere in local space
  87525. */
  87526. radius: number;
  87527. /**
  87528. * Gets the center of the bounding sphere in world space
  87529. */
  87530. readonly centerWorld: Vector3;
  87531. /**
  87532. * Radius of the bounding sphere in world space
  87533. */
  87534. radiusWorld: number;
  87535. /**
  87536. * Gets the minimum vector in local space
  87537. */
  87538. readonly minimum: Vector3;
  87539. /**
  87540. * Gets the maximum vector in local space
  87541. */
  87542. readonly maximum: Vector3;
  87543. private _worldMatrix;
  87544. private static readonly TmpVector3;
  87545. /**
  87546. * Creates a new bounding sphere
  87547. * @param min defines the minimum vector (in local space)
  87548. * @param max defines the maximum vector (in local space)
  87549. * @param worldMatrix defines the new world matrix
  87550. */
  87551. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87552. /**
  87553. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87554. * @param min defines the new minimum vector (in local space)
  87555. * @param max defines the new maximum vector (in local space)
  87556. * @param worldMatrix defines the new world matrix
  87557. */
  87558. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87559. /**
  87560. * Scale the current bounding sphere by applying a scale factor
  87561. * @param factor defines the scale factor to apply
  87562. * @returns the current bounding box
  87563. */
  87564. scale(factor: number): BoundingSphere;
  87565. /**
  87566. * Gets the world matrix of the bounding box
  87567. * @returns a matrix
  87568. */
  87569. getWorldMatrix(): DeepImmutable<Matrix>;
  87570. /** @hidden */
  87571. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87572. /**
  87573. * Tests if the bounding sphere is intersecting the frustum planes
  87574. * @param frustumPlanes defines the frustum planes to test
  87575. * @returns true if there is an intersection
  87576. */
  87577. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87578. /**
  87579. * Tests if the bounding sphere center is in between the frustum planes.
  87580. * Used for optimistic fast inclusion.
  87581. * @param frustumPlanes defines the frustum planes to test
  87582. * @returns true if the sphere center is in between the frustum planes
  87583. */
  87584. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87585. /**
  87586. * Tests if a point is inside the bounding sphere
  87587. * @param point defines the point to test
  87588. * @returns true if the point is inside the bounding sphere
  87589. */
  87590. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87591. /**
  87592. * Checks if two sphere intersct
  87593. * @param sphere0 sphere 0
  87594. * @param sphere1 sphere 1
  87595. * @returns true if the speres intersect
  87596. */
  87597. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87598. }
  87599. }
  87600. declare module BABYLON {
  87601. /**
  87602. * Class used to store bounding box information
  87603. */
  87604. export class BoundingBox implements ICullable {
  87605. /**
  87606. * Gets the 8 vectors representing the bounding box in local space
  87607. */
  87608. readonly vectors: Vector3[];
  87609. /**
  87610. * Gets the center of the bounding box in local space
  87611. */
  87612. readonly center: Vector3;
  87613. /**
  87614. * Gets the center of the bounding box in world space
  87615. */
  87616. readonly centerWorld: Vector3;
  87617. /**
  87618. * Gets the extend size in local space
  87619. */
  87620. readonly extendSize: Vector3;
  87621. /**
  87622. * Gets the extend size in world space
  87623. */
  87624. readonly extendSizeWorld: Vector3;
  87625. /**
  87626. * Gets the OBB (object bounding box) directions
  87627. */
  87628. readonly directions: Vector3[];
  87629. /**
  87630. * Gets the 8 vectors representing the bounding box in world space
  87631. */
  87632. readonly vectorsWorld: Vector3[];
  87633. /**
  87634. * Gets the minimum vector in world space
  87635. */
  87636. readonly minimumWorld: Vector3;
  87637. /**
  87638. * Gets the maximum vector in world space
  87639. */
  87640. readonly maximumWorld: Vector3;
  87641. /**
  87642. * Gets the minimum vector in local space
  87643. */
  87644. readonly minimum: Vector3;
  87645. /**
  87646. * Gets the maximum vector in local space
  87647. */
  87648. readonly maximum: Vector3;
  87649. private _worldMatrix;
  87650. private static readonly TmpVector3;
  87651. /**
  87652. * @hidden
  87653. */
  87654. _tag: number;
  87655. /**
  87656. * Creates a new bounding box
  87657. * @param min defines the minimum vector (in local space)
  87658. * @param max defines the maximum vector (in local space)
  87659. * @param worldMatrix defines the new world matrix
  87660. */
  87661. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87662. /**
  87663. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87664. * @param min defines the new minimum vector (in local space)
  87665. * @param max defines the new maximum vector (in local space)
  87666. * @param worldMatrix defines the new world matrix
  87667. */
  87668. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87669. /**
  87670. * Scale the current bounding box by applying a scale factor
  87671. * @param factor defines the scale factor to apply
  87672. * @returns the current bounding box
  87673. */
  87674. scale(factor: number): BoundingBox;
  87675. /**
  87676. * Gets the world matrix of the bounding box
  87677. * @returns a matrix
  87678. */
  87679. getWorldMatrix(): DeepImmutable<Matrix>;
  87680. /** @hidden */
  87681. _update(world: DeepImmutable<Matrix>): void;
  87682. /**
  87683. * Tests if the bounding box is intersecting the frustum planes
  87684. * @param frustumPlanes defines the frustum planes to test
  87685. * @returns true if there is an intersection
  87686. */
  87687. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87688. /**
  87689. * Tests if the bounding box is entirely inside the frustum planes
  87690. * @param frustumPlanes defines the frustum planes to test
  87691. * @returns true if there is an inclusion
  87692. */
  87693. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87694. /**
  87695. * Tests if a point is inside the bounding box
  87696. * @param point defines the point to test
  87697. * @returns true if the point is inside the bounding box
  87698. */
  87699. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87700. /**
  87701. * Tests if the bounding box intersects with a bounding sphere
  87702. * @param sphere defines the sphere to test
  87703. * @returns true if there is an intersection
  87704. */
  87705. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87706. /**
  87707. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87708. * @param min defines the min vector to use
  87709. * @param max defines the max vector to use
  87710. * @returns true if there is an intersection
  87711. */
  87712. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87713. /**
  87714. * Tests if two bounding boxes are intersections
  87715. * @param box0 defines the first box to test
  87716. * @param box1 defines the second box to test
  87717. * @returns true if there is an intersection
  87718. */
  87719. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87720. /**
  87721. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87722. * @param minPoint defines the minimum vector of the bounding box
  87723. * @param maxPoint defines the maximum vector of the bounding box
  87724. * @param sphereCenter defines the sphere center
  87725. * @param sphereRadius defines the sphere radius
  87726. * @returns true if there is an intersection
  87727. */
  87728. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87729. /**
  87730. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87731. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87732. * @param frustumPlanes defines the frustum planes to test
  87733. * @return true if there is an inclusion
  87734. */
  87735. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87736. /**
  87737. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87738. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87739. * @param frustumPlanes defines the frustum planes to test
  87740. * @return true if there is an intersection
  87741. */
  87742. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87743. }
  87744. }
  87745. declare module BABYLON {
  87746. /** @hidden */
  87747. export class Collider {
  87748. /** Define if a collision was found */
  87749. collisionFound: boolean;
  87750. /**
  87751. * Define last intersection point in local space
  87752. */
  87753. intersectionPoint: Vector3;
  87754. /**
  87755. * Define last collided mesh
  87756. */
  87757. collidedMesh: Nullable<AbstractMesh>;
  87758. private _collisionPoint;
  87759. private _planeIntersectionPoint;
  87760. private _tempVector;
  87761. private _tempVector2;
  87762. private _tempVector3;
  87763. private _tempVector4;
  87764. private _edge;
  87765. private _baseToVertex;
  87766. private _destinationPoint;
  87767. private _slidePlaneNormal;
  87768. private _displacementVector;
  87769. /** @hidden */
  87770. _radius: Vector3;
  87771. /** @hidden */
  87772. _retry: number;
  87773. private _velocity;
  87774. private _basePoint;
  87775. private _epsilon;
  87776. /** @hidden */
  87777. _velocityWorldLength: number;
  87778. /** @hidden */
  87779. _basePointWorld: Vector3;
  87780. private _velocityWorld;
  87781. private _normalizedVelocity;
  87782. /** @hidden */
  87783. _initialVelocity: Vector3;
  87784. /** @hidden */
  87785. _initialPosition: Vector3;
  87786. private _nearestDistance;
  87787. private _collisionMask;
  87788. get collisionMask(): number;
  87789. set collisionMask(mask: number);
  87790. /**
  87791. * Gets the plane normal used to compute the sliding response (in local space)
  87792. */
  87793. get slidePlaneNormal(): Vector3;
  87794. /** @hidden */
  87795. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87796. /** @hidden */
  87797. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87798. /** @hidden */
  87799. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87800. /** @hidden */
  87801. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87802. /** @hidden */
  87803. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87804. /** @hidden */
  87805. _getResponse(pos: Vector3, vel: Vector3): void;
  87806. }
  87807. }
  87808. declare module BABYLON {
  87809. /**
  87810. * Interface for cullable objects
  87811. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87812. */
  87813. export interface ICullable {
  87814. /**
  87815. * Checks if the object or part of the object is in the frustum
  87816. * @param frustumPlanes Camera near/planes
  87817. * @returns true if the object is in frustum otherwise false
  87818. */
  87819. isInFrustum(frustumPlanes: Plane[]): boolean;
  87820. /**
  87821. * Checks if a cullable object (mesh...) is in the camera frustum
  87822. * Unlike isInFrustum this cheks the full bounding box
  87823. * @param frustumPlanes Camera near/planes
  87824. * @returns true if the object is in frustum otherwise false
  87825. */
  87826. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87827. }
  87828. /**
  87829. * Info for a bounding data of a mesh
  87830. */
  87831. export class BoundingInfo implements ICullable {
  87832. /**
  87833. * Bounding box for the mesh
  87834. */
  87835. readonly boundingBox: BoundingBox;
  87836. /**
  87837. * Bounding sphere for the mesh
  87838. */
  87839. readonly boundingSphere: BoundingSphere;
  87840. private _isLocked;
  87841. private static readonly TmpVector3;
  87842. /**
  87843. * Constructs bounding info
  87844. * @param minimum min vector of the bounding box/sphere
  87845. * @param maximum max vector of the bounding box/sphere
  87846. * @param worldMatrix defines the new world matrix
  87847. */
  87848. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87849. /**
  87850. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87851. * @param min defines the new minimum vector (in local space)
  87852. * @param max defines the new maximum vector (in local space)
  87853. * @param worldMatrix defines the new world matrix
  87854. */
  87855. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87856. /**
  87857. * min vector of the bounding box/sphere
  87858. */
  87859. get minimum(): Vector3;
  87860. /**
  87861. * max vector of the bounding box/sphere
  87862. */
  87863. get maximum(): Vector3;
  87864. /**
  87865. * If the info is locked and won't be updated to avoid perf overhead
  87866. */
  87867. get isLocked(): boolean;
  87868. set isLocked(value: boolean);
  87869. /**
  87870. * Updates the bounding sphere and box
  87871. * @param world world matrix to be used to update
  87872. */
  87873. update(world: DeepImmutable<Matrix>): void;
  87874. /**
  87875. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87876. * @param center New center of the bounding info
  87877. * @param extend New extend of the bounding info
  87878. * @returns the current bounding info
  87879. */
  87880. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87881. /**
  87882. * Scale the current bounding info by applying a scale factor
  87883. * @param factor defines the scale factor to apply
  87884. * @returns the current bounding info
  87885. */
  87886. scale(factor: number): BoundingInfo;
  87887. /**
  87888. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87889. * @param frustumPlanes defines the frustum to test
  87890. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87891. * @returns true if the bounding info is in the frustum planes
  87892. */
  87893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87894. /**
  87895. * Gets the world distance between the min and max points of the bounding box
  87896. */
  87897. get diagonalLength(): number;
  87898. /**
  87899. * Checks if a cullable object (mesh...) is in the camera frustum
  87900. * Unlike isInFrustum this cheks the full bounding box
  87901. * @param frustumPlanes Camera near/planes
  87902. * @returns true if the object is in frustum otherwise false
  87903. */
  87904. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87905. /** @hidden */
  87906. _checkCollision(collider: Collider): boolean;
  87907. /**
  87908. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87909. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87910. * @param point the point to check intersection with
  87911. * @returns if the point intersects
  87912. */
  87913. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87914. /**
  87915. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87916. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87917. * @param boundingInfo the bounding info to check intersection with
  87918. * @param precise if the intersection should be done using OBB
  87919. * @returns if the bounding info intersects
  87920. */
  87921. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87922. }
  87923. }
  87924. declare module BABYLON {
  87925. /**
  87926. * Extracts minimum and maximum values from a list of indexed positions
  87927. * @param positions defines the positions to use
  87928. * @param indices defines the indices to the positions
  87929. * @param indexStart defines the start index
  87930. * @param indexCount defines the end index
  87931. * @param bias defines bias value to add to the result
  87932. * @return minimum and maximum values
  87933. */
  87934. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87935. minimum: Vector3;
  87936. maximum: Vector3;
  87937. };
  87938. /**
  87939. * Extracts minimum and maximum values from a list of positions
  87940. * @param positions defines the positions to use
  87941. * @param start defines the start index in the positions array
  87942. * @param count defines the number of positions to handle
  87943. * @param bias defines bias value to add to the result
  87944. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87945. * @return minimum and maximum values
  87946. */
  87947. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87948. minimum: Vector3;
  87949. maximum: Vector3;
  87950. };
  87951. }
  87952. declare module BABYLON {
  87953. /** @hidden */
  87954. export class WebGLDataBuffer extends DataBuffer {
  87955. private _buffer;
  87956. constructor(resource: WebGLBuffer);
  87957. get underlyingResource(): any;
  87958. }
  87959. }
  87960. declare module BABYLON {
  87961. /** @hidden */
  87962. export class WebGLPipelineContext implements IPipelineContext {
  87963. engine: ThinEngine;
  87964. program: Nullable<WebGLProgram>;
  87965. context?: WebGLRenderingContext;
  87966. vertexShader?: WebGLShader;
  87967. fragmentShader?: WebGLShader;
  87968. isParallelCompiled: boolean;
  87969. onCompiled?: () => void;
  87970. transformFeedback?: WebGLTransformFeedback | null;
  87971. vertexCompilationError: Nullable<string>;
  87972. fragmentCompilationError: Nullable<string>;
  87973. programLinkError: Nullable<string>;
  87974. programValidationError: Nullable<string>;
  87975. get isAsync(): boolean;
  87976. get isReady(): boolean;
  87977. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87978. _getVertexShaderCode(): string | null;
  87979. _getFragmentShaderCode(): string | null;
  87980. }
  87981. }
  87982. declare module BABYLON {
  87983. interface ThinEngine {
  87984. /**
  87985. * Create an uniform buffer
  87986. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87987. * @param elements defines the content of the uniform buffer
  87988. * @returns the webGL uniform buffer
  87989. */
  87990. createUniformBuffer(elements: FloatArray): DataBuffer;
  87991. /**
  87992. * Create a dynamic uniform buffer
  87993. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87994. * @param elements defines the content of the uniform buffer
  87995. * @returns the webGL uniform buffer
  87996. */
  87997. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87998. /**
  87999. * Update an existing uniform buffer
  88000. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88001. * @param uniformBuffer defines the target uniform buffer
  88002. * @param elements defines the content to update
  88003. * @param offset defines the offset in the uniform buffer where update should start
  88004. * @param count defines the size of the data to update
  88005. */
  88006. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88007. /**
  88008. * Bind an uniform buffer to the current webGL context
  88009. * @param buffer defines the buffer to bind
  88010. */
  88011. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88012. /**
  88013. * Bind a buffer to the current webGL context at a given location
  88014. * @param buffer defines the buffer to bind
  88015. * @param location defines the index where to bind the buffer
  88016. */
  88017. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88018. /**
  88019. * Bind a specific block at a given index in a specific shader program
  88020. * @param pipelineContext defines the pipeline context to use
  88021. * @param blockName defines the block name
  88022. * @param index defines the index where to bind the block
  88023. */
  88024. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88025. }
  88026. }
  88027. declare module BABYLON {
  88028. /**
  88029. * Uniform buffer objects.
  88030. *
  88031. * Handles blocks of uniform on the GPU.
  88032. *
  88033. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88034. *
  88035. * For more information, please refer to :
  88036. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88037. */
  88038. export class UniformBuffer {
  88039. private _engine;
  88040. private _buffer;
  88041. private _data;
  88042. private _bufferData;
  88043. private _dynamic?;
  88044. private _uniformLocations;
  88045. private _uniformSizes;
  88046. private _uniformLocationPointer;
  88047. private _needSync;
  88048. private _noUBO;
  88049. private _currentEffect;
  88050. /** @hidden */
  88051. _alreadyBound: boolean;
  88052. private static _MAX_UNIFORM_SIZE;
  88053. private static _tempBuffer;
  88054. /**
  88055. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88056. * This is dynamic to allow compat with webgl 1 and 2.
  88057. * You will need to pass the name of the uniform as well as the value.
  88058. */
  88059. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88060. /**
  88061. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88062. * This is dynamic to allow compat with webgl 1 and 2.
  88063. * You will need to pass the name of the uniform as well as the value.
  88064. */
  88065. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88066. /**
  88067. * Lambda to Update a single float in a uniform buffer.
  88068. * This is dynamic to allow compat with webgl 1 and 2.
  88069. * You will need to pass the name of the uniform as well as the value.
  88070. */
  88071. updateFloat: (name: string, x: number) => void;
  88072. /**
  88073. * Lambda to Update a vec2 of float in a uniform buffer.
  88074. * This is dynamic to allow compat with webgl 1 and 2.
  88075. * You will need to pass the name of the uniform as well as the value.
  88076. */
  88077. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88078. /**
  88079. * Lambda to Update a vec3 of float in a uniform buffer.
  88080. * This is dynamic to allow compat with webgl 1 and 2.
  88081. * You will need to pass the name of the uniform as well as the value.
  88082. */
  88083. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88084. /**
  88085. * Lambda to Update a vec4 of float in a uniform buffer.
  88086. * This is dynamic to allow compat with webgl 1 and 2.
  88087. * You will need to pass the name of the uniform as well as the value.
  88088. */
  88089. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88090. /**
  88091. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88092. * This is dynamic to allow compat with webgl 1 and 2.
  88093. * You will need to pass the name of the uniform as well as the value.
  88094. */
  88095. updateMatrix: (name: string, mat: Matrix) => void;
  88096. /**
  88097. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88098. * This is dynamic to allow compat with webgl 1 and 2.
  88099. * You will need to pass the name of the uniform as well as the value.
  88100. */
  88101. updateVector3: (name: string, vector: Vector3) => void;
  88102. /**
  88103. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88104. * This is dynamic to allow compat with webgl 1 and 2.
  88105. * You will need to pass the name of the uniform as well as the value.
  88106. */
  88107. updateVector4: (name: string, vector: Vector4) => void;
  88108. /**
  88109. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88110. * This is dynamic to allow compat with webgl 1 and 2.
  88111. * You will need to pass the name of the uniform as well as the value.
  88112. */
  88113. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88114. /**
  88115. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88116. * This is dynamic to allow compat with webgl 1 and 2.
  88117. * You will need to pass the name of the uniform as well as the value.
  88118. */
  88119. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88120. /**
  88121. * Instantiates a new Uniform buffer objects.
  88122. *
  88123. * Handles blocks of uniform on the GPU.
  88124. *
  88125. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88126. *
  88127. * For more information, please refer to :
  88128. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88129. * @param engine Define the engine the buffer is associated with
  88130. * @param data Define the data contained in the buffer
  88131. * @param dynamic Define if the buffer is updatable
  88132. */
  88133. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88134. /**
  88135. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88136. * or just falling back on setUniformXXX calls.
  88137. */
  88138. get useUbo(): boolean;
  88139. /**
  88140. * Indicates if the WebGL underlying uniform buffer is in sync
  88141. * with the javascript cache data.
  88142. */
  88143. get isSync(): boolean;
  88144. /**
  88145. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88146. * Also, a dynamic UniformBuffer will disable cache verification and always
  88147. * update the underlying WebGL uniform buffer to the GPU.
  88148. * @returns if Dynamic, otherwise false
  88149. */
  88150. isDynamic(): boolean;
  88151. /**
  88152. * The data cache on JS side.
  88153. * @returns the underlying data as a float array
  88154. */
  88155. getData(): Float32Array;
  88156. /**
  88157. * The underlying WebGL Uniform buffer.
  88158. * @returns the webgl buffer
  88159. */
  88160. getBuffer(): Nullable<DataBuffer>;
  88161. /**
  88162. * std140 layout specifies how to align data within an UBO structure.
  88163. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88164. * for specs.
  88165. */
  88166. private _fillAlignment;
  88167. /**
  88168. * Adds an uniform in the buffer.
  88169. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88170. * for the layout to be correct !
  88171. * @param name Name of the uniform, as used in the uniform block in the shader.
  88172. * @param size Data size, or data directly.
  88173. */
  88174. addUniform(name: string, size: number | number[]): void;
  88175. /**
  88176. * Adds a Matrix 4x4 to the uniform buffer.
  88177. * @param name Name of the uniform, as used in the uniform block in the shader.
  88178. * @param mat A 4x4 matrix.
  88179. */
  88180. addMatrix(name: string, mat: Matrix): void;
  88181. /**
  88182. * Adds a vec2 to the uniform buffer.
  88183. * @param name Name of the uniform, as used in the uniform block in the shader.
  88184. * @param x Define the x component value of the vec2
  88185. * @param y Define the y component value of the vec2
  88186. */
  88187. addFloat2(name: string, x: number, y: number): void;
  88188. /**
  88189. * Adds a vec3 to the uniform buffer.
  88190. * @param name Name of the uniform, as used in the uniform block in the shader.
  88191. * @param x Define the x component value of the vec3
  88192. * @param y Define the y component value of the vec3
  88193. * @param z Define the z component value of the vec3
  88194. */
  88195. addFloat3(name: string, x: number, y: number, z: number): void;
  88196. /**
  88197. * Adds a vec3 to the uniform buffer.
  88198. * @param name Name of the uniform, as used in the uniform block in the shader.
  88199. * @param color Define the vec3 from a Color
  88200. */
  88201. addColor3(name: string, color: Color3): void;
  88202. /**
  88203. * Adds a vec4 to the uniform buffer.
  88204. * @param name Name of the uniform, as used in the uniform block in the shader.
  88205. * @param color Define the rgb components from a Color
  88206. * @param alpha Define the a component of the vec4
  88207. */
  88208. addColor4(name: string, color: Color3, alpha: number): void;
  88209. /**
  88210. * Adds a vec3 to the uniform buffer.
  88211. * @param name Name of the uniform, as used in the uniform block in the shader.
  88212. * @param vector Define the vec3 components from a Vector
  88213. */
  88214. addVector3(name: string, vector: Vector3): void;
  88215. /**
  88216. * Adds a Matrix 3x3 to the uniform buffer.
  88217. * @param name Name of the uniform, as used in the uniform block in the shader.
  88218. */
  88219. addMatrix3x3(name: string): void;
  88220. /**
  88221. * Adds a Matrix 2x2 to the uniform buffer.
  88222. * @param name Name of the uniform, as used in the uniform block in the shader.
  88223. */
  88224. addMatrix2x2(name: string): void;
  88225. /**
  88226. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88227. */
  88228. create(): void;
  88229. /** @hidden */
  88230. _rebuild(): void;
  88231. /**
  88232. * Updates the WebGL Uniform Buffer on the GPU.
  88233. * If the `dynamic` flag is set to true, no cache comparison is done.
  88234. * Otherwise, the buffer will be updated only if the cache differs.
  88235. */
  88236. update(): void;
  88237. /**
  88238. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88239. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88240. * @param data Define the flattened data
  88241. * @param size Define the size of the data.
  88242. */
  88243. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88244. private _valueCache;
  88245. private _cacheMatrix;
  88246. private _updateMatrix3x3ForUniform;
  88247. private _updateMatrix3x3ForEffect;
  88248. private _updateMatrix2x2ForEffect;
  88249. private _updateMatrix2x2ForUniform;
  88250. private _updateFloatForEffect;
  88251. private _updateFloatForUniform;
  88252. private _updateFloat2ForEffect;
  88253. private _updateFloat2ForUniform;
  88254. private _updateFloat3ForEffect;
  88255. private _updateFloat3ForUniform;
  88256. private _updateFloat4ForEffect;
  88257. private _updateFloat4ForUniform;
  88258. private _updateMatrixForEffect;
  88259. private _updateMatrixForUniform;
  88260. private _updateVector3ForEffect;
  88261. private _updateVector3ForUniform;
  88262. private _updateVector4ForEffect;
  88263. private _updateVector4ForUniform;
  88264. private _updateColor3ForEffect;
  88265. private _updateColor3ForUniform;
  88266. private _updateColor4ForEffect;
  88267. private _updateColor4ForUniform;
  88268. /**
  88269. * Sets a sampler uniform on the effect.
  88270. * @param name Define the name of the sampler.
  88271. * @param texture Define the texture to set in the sampler
  88272. */
  88273. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88274. /**
  88275. * Directly updates the value of the uniform in the cache AND on the GPU.
  88276. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88277. * @param data Define the flattened data
  88278. */
  88279. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88280. /**
  88281. * Binds this uniform buffer to an effect.
  88282. * @param effect Define the effect to bind the buffer to
  88283. * @param name Name of the uniform block in the shader.
  88284. */
  88285. bindToEffect(effect: Effect, name: string): void;
  88286. /**
  88287. * Disposes the uniform buffer.
  88288. */
  88289. dispose(): void;
  88290. }
  88291. }
  88292. declare module BABYLON {
  88293. /**
  88294. * Enum that determines the text-wrapping mode to use.
  88295. */
  88296. export enum InspectableType {
  88297. /**
  88298. * Checkbox for booleans
  88299. */
  88300. Checkbox = 0,
  88301. /**
  88302. * Sliders for numbers
  88303. */
  88304. Slider = 1,
  88305. /**
  88306. * Vector3
  88307. */
  88308. Vector3 = 2,
  88309. /**
  88310. * Quaternions
  88311. */
  88312. Quaternion = 3,
  88313. /**
  88314. * Color3
  88315. */
  88316. Color3 = 4,
  88317. /**
  88318. * String
  88319. */
  88320. String = 5
  88321. }
  88322. /**
  88323. * Interface used to define custom inspectable properties.
  88324. * This interface is used by the inspector to display custom property grids
  88325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88326. */
  88327. export interface IInspectable {
  88328. /**
  88329. * Gets the label to display
  88330. */
  88331. label: string;
  88332. /**
  88333. * Gets the name of the property to edit
  88334. */
  88335. propertyName: string;
  88336. /**
  88337. * Gets the type of the editor to use
  88338. */
  88339. type: InspectableType;
  88340. /**
  88341. * Gets the minimum value of the property when using in "slider" mode
  88342. */
  88343. min?: number;
  88344. /**
  88345. * Gets the maximum value of the property when using in "slider" mode
  88346. */
  88347. max?: number;
  88348. /**
  88349. * Gets the setp to use when using in "slider" mode
  88350. */
  88351. step?: number;
  88352. }
  88353. }
  88354. declare module BABYLON {
  88355. /**
  88356. * Class used to provide helper for timing
  88357. */
  88358. export class TimingTools {
  88359. /**
  88360. * Polyfill for setImmediate
  88361. * @param action defines the action to execute after the current execution block
  88362. */
  88363. static SetImmediate(action: () => void): void;
  88364. }
  88365. }
  88366. declare module BABYLON {
  88367. /**
  88368. * Class used to enable instatition of objects by class name
  88369. */
  88370. export class InstantiationTools {
  88371. /**
  88372. * Use this object to register external classes like custom textures or material
  88373. * to allow the laoders to instantiate them
  88374. */
  88375. static RegisteredExternalClasses: {
  88376. [key: string]: Object;
  88377. };
  88378. /**
  88379. * Tries to instantiate a new object from a given class name
  88380. * @param className defines the class name to instantiate
  88381. * @returns the new object or null if the system was not able to do the instantiation
  88382. */
  88383. static Instantiate(className: string): any;
  88384. }
  88385. }
  88386. declare module BABYLON {
  88387. /**
  88388. * Define options used to create a depth texture
  88389. */
  88390. export class DepthTextureCreationOptions {
  88391. /** Specifies whether or not a stencil should be allocated in the texture */
  88392. generateStencil?: boolean;
  88393. /** Specifies whether or not bilinear filtering is enable on the texture */
  88394. bilinearFiltering?: boolean;
  88395. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88396. comparisonFunction?: number;
  88397. /** Specifies if the created texture is a cube texture */
  88398. isCube?: boolean;
  88399. }
  88400. }
  88401. declare module BABYLON {
  88402. interface ThinEngine {
  88403. /**
  88404. * Creates a depth stencil cube texture.
  88405. * This is only available in WebGL 2.
  88406. * @param size The size of face edge in the cube texture.
  88407. * @param options The options defining the cube texture.
  88408. * @returns The cube texture
  88409. */
  88410. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88411. /**
  88412. * Creates a cube texture
  88413. * @param rootUrl defines the url where the files to load is located
  88414. * @param scene defines the current scene
  88415. * @param files defines the list of files to load (1 per face)
  88416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88417. * @param onLoad defines an optional callback raised when the texture is loaded
  88418. * @param onError defines an optional callback raised if there is an issue to load the texture
  88419. * @param format defines the format of the data
  88420. * @param forcedExtension defines the extension to use to pick the right loader
  88421. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88422. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88423. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88424. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88425. * @returns the cube texture as an InternalTexture
  88426. */
  88427. 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;
  88428. /**
  88429. * Creates a cube texture
  88430. * @param rootUrl defines the url where the files to load is located
  88431. * @param scene defines the current scene
  88432. * @param files defines the list of files to load (1 per face)
  88433. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88434. * @param onLoad defines an optional callback raised when the texture is loaded
  88435. * @param onError defines an optional callback raised if there is an issue to load the texture
  88436. * @param format defines the format of the data
  88437. * @param forcedExtension defines the extension to use to pick the right loader
  88438. * @returns the cube texture as an InternalTexture
  88439. */
  88440. 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;
  88441. /**
  88442. * Creates a cube texture
  88443. * @param rootUrl defines the url where the files to load is located
  88444. * @param scene defines the current scene
  88445. * @param files defines the list of files to load (1 per face)
  88446. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88447. * @param onLoad defines an optional callback raised when the texture is loaded
  88448. * @param onError defines an optional callback raised if there is an issue to load the texture
  88449. * @param format defines the format of the data
  88450. * @param forcedExtension defines the extension to use to pick the right loader
  88451. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88452. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88453. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88454. * @returns the cube texture as an InternalTexture
  88455. */
  88456. 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;
  88457. /** @hidden */
  88458. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88459. /** @hidden */
  88460. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88461. /** @hidden */
  88462. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88463. /** @hidden */
  88464. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88465. /**
  88466. * @hidden
  88467. */
  88468. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88469. }
  88470. }
  88471. declare module BABYLON {
  88472. /**
  88473. * Class for creating a cube texture
  88474. */
  88475. export class CubeTexture extends BaseTexture {
  88476. private _delayedOnLoad;
  88477. /**
  88478. * Observable triggered once the texture has been loaded.
  88479. */
  88480. onLoadObservable: Observable<CubeTexture>;
  88481. /**
  88482. * The url of the texture
  88483. */
  88484. url: string;
  88485. /**
  88486. * Gets or sets the center of the bounding box associated with the cube texture.
  88487. * It must define where the camera used to render the texture was set
  88488. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88489. */
  88490. boundingBoxPosition: Vector3;
  88491. private _boundingBoxSize;
  88492. /**
  88493. * Gets or sets the size of the bounding box associated with the cube texture
  88494. * When defined, the cubemap will switch to local mode
  88495. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88496. * @example https://www.babylonjs-playground.com/#RNASML
  88497. */
  88498. set boundingBoxSize(value: Vector3);
  88499. /**
  88500. * Returns the bounding box size
  88501. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88502. */
  88503. get boundingBoxSize(): Vector3;
  88504. protected _rotationY: number;
  88505. /**
  88506. * Sets texture matrix rotation angle around Y axis in radians.
  88507. */
  88508. set rotationY(value: number);
  88509. /**
  88510. * Gets texture matrix rotation angle around Y axis radians.
  88511. */
  88512. get rotationY(): number;
  88513. /**
  88514. * Are mip maps generated for this texture or not.
  88515. */
  88516. get noMipmap(): boolean;
  88517. private _noMipmap;
  88518. private _files;
  88519. protected _forcedExtension: Nullable<string>;
  88520. private _extensions;
  88521. private _textureMatrix;
  88522. private _format;
  88523. private _createPolynomials;
  88524. /**
  88525. * Creates a cube texture from an array of image urls
  88526. * @param files defines an array of image urls
  88527. * @param scene defines the hosting scene
  88528. * @param noMipmap specifies if mip maps are not used
  88529. * @returns a cube texture
  88530. */
  88531. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88532. /**
  88533. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88534. * @param url defines the url of the prefiltered texture
  88535. * @param scene defines the scene the texture is attached to
  88536. * @param forcedExtension defines the extension of the file if different from the url
  88537. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88538. * @return the prefiltered texture
  88539. */
  88540. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88541. /**
  88542. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88543. * as prefiltered data.
  88544. * @param rootUrl defines the url of the texture or the root name of the six images
  88545. * @param null defines the scene or engine the texture is attached to
  88546. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88547. * @param noMipmap defines if mipmaps should be created or not
  88548. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88549. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88550. * @param onError defines a callback triggered in case of error during load
  88551. * @param format defines the internal format to use for the texture once loaded
  88552. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88553. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88554. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88555. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88556. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88557. * @return the cube texture
  88558. */
  88559. 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);
  88560. /**
  88561. * Get the current class name of the texture useful for serialization or dynamic coding.
  88562. * @returns "CubeTexture"
  88563. */
  88564. getClassName(): string;
  88565. /**
  88566. * Update the url (and optional buffer) of this texture if url was null during construction.
  88567. * @param url the url of the texture
  88568. * @param forcedExtension defines the extension to use
  88569. * @param onLoad callback called when the texture is loaded (defaults to null)
  88570. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88571. */
  88572. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88573. /**
  88574. * Delays loading of the cube texture
  88575. * @param forcedExtension defines the extension to use
  88576. */
  88577. delayLoad(forcedExtension?: string): void;
  88578. /**
  88579. * Returns the reflection texture matrix
  88580. * @returns the reflection texture matrix
  88581. */
  88582. getReflectionTextureMatrix(): Matrix;
  88583. /**
  88584. * Sets the reflection texture matrix
  88585. * @param value Reflection texture matrix
  88586. */
  88587. setReflectionTextureMatrix(value: Matrix): void;
  88588. /**
  88589. * Parses text to create a cube texture
  88590. * @param parsedTexture define the serialized text to read from
  88591. * @param scene defines the hosting scene
  88592. * @param rootUrl defines the root url of the cube texture
  88593. * @returns a cube texture
  88594. */
  88595. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88596. /**
  88597. * Makes a clone, or deep copy, of the cube texture
  88598. * @returns a new cube texture
  88599. */
  88600. clone(): CubeTexture;
  88601. }
  88602. }
  88603. declare module BABYLON {
  88604. /**
  88605. * Manages the defines for the Material
  88606. */
  88607. export class MaterialDefines {
  88608. /** @hidden */
  88609. protected _keys: string[];
  88610. private _isDirty;
  88611. /** @hidden */
  88612. _renderId: number;
  88613. /** @hidden */
  88614. _areLightsDirty: boolean;
  88615. /** @hidden */
  88616. _areLightsDisposed: boolean;
  88617. /** @hidden */
  88618. _areAttributesDirty: boolean;
  88619. /** @hidden */
  88620. _areTexturesDirty: boolean;
  88621. /** @hidden */
  88622. _areFresnelDirty: boolean;
  88623. /** @hidden */
  88624. _areMiscDirty: boolean;
  88625. /** @hidden */
  88626. _arePrePassDirty: boolean;
  88627. /** @hidden */
  88628. _areImageProcessingDirty: boolean;
  88629. /** @hidden */
  88630. _normals: boolean;
  88631. /** @hidden */
  88632. _uvs: boolean;
  88633. /** @hidden */
  88634. _needNormals: boolean;
  88635. /** @hidden */
  88636. _needUVs: boolean;
  88637. [id: string]: any;
  88638. /**
  88639. * Specifies if the material needs to be re-calculated
  88640. */
  88641. get isDirty(): boolean;
  88642. /**
  88643. * Marks the material to indicate that it has been re-calculated
  88644. */
  88645. markAsProcessed(): void;
  88646. /**
  88647. * Marks the material to indicate that it needs to be re-calculated
  88648. */
  88649. markAsUnprocessed(): void;
  88650. /**
  88651. * Marks the material to indicate all of its defines need to be re-calculated
  88652. */
  88653. markAllAsDirty(): void;
  88654. /**
  88655. * Marks the material to indicate that image processing needs to be re-calculated
  88656. */
  88657. markAsImageProcessingDirty(): void;
  88658. /**
  88659. * Marks the material to indicate the lights need to be re-calculated
  88660. * @param disposed Defines whether the light is dirty due to dispose or not
  88661. */
  88662. markAsLightDirty(disposed?: boolean): void;
  88663. /**
  88664. * Marks the attribute state as changed
  88665. */
  88666. markAsAttributesDirty(): void;
  88667. /**
  88668. * Marks the texture state as changed
  88669. */
  88670. markAsTexturesDirty(): void;
  88671. /**
  88672. * Marks the fresnel state as changed
  88673. */
  88674. markAsFresnelDirty(): void;
  88675. /**
  88676. * Marks the misc state as changed
  88677. */
  88678. markAsMiscDirty(): void;
  88679. /**
  88680. * Marks the prepass state as changed
  88681. */
  88682. markAsPrePassDirty(): void;
  88683. /**
  88684. * Rebuilds the material defines
  88685. */
  88686. rebuild(): void;
  88687. /**
  88688. * Specifies if two material defines are equal
  88689. * @param other - A material define instance to compare to
  88690. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88691. */
  88692. isEqual(other: MaterialDefines): boolean;
  88693. /**
  88694. * Clones this instance's defines to another instance
  88695. * @param other - material defines to clone values to
  88696. */
  88697. cloneTo(other: MaterialDefines): void;
  88698. /**
  88699. * Resets the material define values
  88700. */
  88701. reset(): void;
  88702. /**
  88703. * Converts the material define values to a string
  88704. * @returns - String of material define information
  88705. */
  88706. toString(): string;
  88707. }
  88708. }
  88709. declare module BABYLON {
  88710. /**
  88711. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88712. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88713. * 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;
  88714. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88715. */
  88716. export class ColorCurves {
  88717. private _dirty;
  88718. private _tempColor;
  88719. private _globalCurve;
  88720. private _highlightsCurve;
  88721. private _midtonesCurve;
  88722. private _shadowsCurve;
  88723. private _positiveCurve;
  88724. private _negativeCurve;
  88725. private _globalHue;
  88726. private _globalDensity;
  88727. private _globalSaturation;
  88728. private _globalExposure;
  88729. /**
  88730. * Gets the global Hue value.
  88731. * 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).
  88732. */
  88733. get globalHue(): number;
  88734. /**
  88735. * Sets the global Hue value.
  88736. * 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).
  88737. */
  88738. set globalHue(value: number);
  88739. /**
  88740. * Gets the global Density value.
  88741. * 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.
  88742. * Values less than zero provide a filter of opposite hue.
  88743. */
  88744. get globalDensity(): number;
  88745. /**
  88746. * Sets the global Density value.
  88747. * 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.
  88748. * Values less than zero provide a filter of opposite hue.
  88749. */
  88750. set globalDensity(value: number);
  88751. /**
  88752. * Gets the global Saturation value.
  88753. * 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.
  88754. */
  88755. get globalSaturation(): number;
  88756. /**
  88757. * Sets the global Saturation value.
  88758. * 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.
  88759. */
  88760. set globalSaturation(value: number);
  88761. /**
  88762. * Gets the global Exposure value.
  88763. * 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.
  88764. */
  88765. get globalExposure(): number;
  88766. /**
  88767. * Sets the global Exposure value.
  88768. * 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.
  88769. */
  88770. set globalExposure(value: number);
  88771. private _highlightsHue;
  88772. private _highlightsDensity;
  88773. private _highlightsSaturation;
  88774. private _highlightsExposure;
  88775. /**
  88776. * Gets the highlights Hue value.
  88777. * 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).
  88778. */
  88779. get highlightsHue(): number;
  88780. /**
  88781. * Sets the highlights Hue value.
  88782. * 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).
  88783. */
  88784. set highlightsHue(value: number);
  88785. /**
  88786. * Gets the highlights Density value.
  88787. * 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.
  88788. * Values less than zero provide a filter of opposite hue.
  88789. */
  88790. get highlightsDensity(): number;
  88791. /**
  88792. * Sets the highlights Density value.
  88793. * 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.
  88794. * Values less than zero provide a filter of opposite hue.
  88795. */
  88796. set highlightsDensity(value: number);
  88797. /**
  88798. * Gets the highlights Saturation value.
  88799. * 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.
  88800. */
  88801. get highlightsSaturation(): number;
  88802. /**
  88803. * Sets the highlights Saturation value.
  88804. * 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.
  88805. */
  88806. set highlightsSaturation(value: number);
  88807. /**
  88808. * Gets the highlights Exposure value.
  88809. * 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.
  88810. */
  88811. get highlightsExposure(): number;
  88812. /**
  88813. * Sets the highlights Exposure value.
  88814. * 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.
  88815. */
  88816. set highlightsExposure(value: number);
  88817. private _midtonesHue;
  88818. private _midtonesDensity;
  88819. private _midtonesSaturation;
  88820. private _midtonesExposure;
  88821. /**
  88822. * Gets the midtones Hue value.
  88823. * 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).
  88824. */
  88825. get midtonesHue(): number;
  88826. /**
  88827. * Sets the midtones Hue value.
  88828. * 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).
  88829. */
  88830. set midtonesHue(value: number);
  88831. /**
  88832. * Gets the midtones Density value.
  88833. * 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.
  88834. * Values less than zero provide a filter of opposite hue.
  88835. */
  88836. get midtonesDensity(): number;
  88837. /**
  88838. * Sets the midtones Density value.
  88839. * 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.
  88840. * Values less than zero provide a filter of opposite hue.
  88841. */
  88842. set midtonesDensity(value: number);
  88843. /**
  88844. * Gets the midtones Saturation value.
  88845. * 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.
  88846. */
  88847. get midtonesSaturation(): number;
  88848. /**
  88849. * Sets the midtones Saturation value.
  88850. * 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.
  88851. */
  88852. set midtonesSaturation(value: number);
  88853. /**
  88854. * Gets the midtones Exposure value.
  88855. * 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.
  88856. */
  88857. get midtonesExposure(): number;
  88858. /**
  88859. * Sets the midtones Exposure value.
  88860. * 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.
  88861. */
  88862. set midtonesExposure(value: number);
  88863. private _shadowsHue;
  88864. private _shadowsDensity;
  88865. private _shadowsSaturation;
  88866. private _shadowsExposure;
  88867. /**
  88868. * Gets the shadows Hue value.
  88869. * 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).
  88870. */
  88871. get shadowsHue(): number;
  88872. /**
  88873. * Sets the shadows Hue value.
  88874. * 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).
  88875. */
  88876. set shadowsHue(value: number);
  88877. /**
  88878. * Gets the shadows Density value.
  88879. * 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.
  88880. * Values less than zero provide a filter of opposite hue.
  88881. */
  88882. get shadowsDensity(): number;
  88883. /**
  88884. * Sets the shadows Density value.
  88885. * 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.
  88886. * Values less than zero provide a filter of opposite hue.
  88887. */
  88888. set shadowsDensity(value: number);
  88889. /**
  88890. * Gets the shadows Saturation value.
  88891. * 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.
  88892. */
  88893. get shadowsSaturation(): number;
  88894. /**
  88895. * Sets the shadows Saturation value.
  88896. * 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.
  88897. */
  88898. set shadowsSaturation(value: number);
  88899. /**
  88900. * Gets the shadows Exposure value.
  88901. * 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.
  88902. */
  88903. get shadowsExposure(): number;
  88904. /**
  88905. * Sets the shadows Exposure value.
  88906. * 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.
  88907. */
  88908. set shadowsExposure(value: number);
  88909. /**
  88910. * Returns the class name
  88911. * @returns The class name
  88912. */
  88913. getClassName(): string;
  88914. /**
  88915. * Binds the color curves to the shader.
  88916. * @param colorCurves The color curve to bind
  88917. * @param effect The effect to bind to
  88918. * @param positiveUniform The positive uniform shader parameter
  88919. * @param neutralUniform The neutral uniform shader parameter
  88920. * @param negativeUniform The negative uniform shader parameter
  88921. */
  88922. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88923. /**
  88924. * Prepare the list of uniforms associated with the ColorCurves effects.
  88925. * @param uniformsList The list of uniforms used in the effect
  88926. */
  88927. static PrepareUniforms(uniformsList: string[]): void;
  88928. /**
  88929. * Returns color grading data based on a hue, density, saturation and exposure value.
  88930. * @param filterHue The hue of the color filter.
  88931. * @param filterDensity The density of the color filter.
  88932. * @param saturation The saturation.
  88933. * @param exposure The exposure.
  88934. * @param result The result data container.
  88935. */
  88936. private getColorGradingDataToRef;
  88937. /**
  88938. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88939. * @param value The input slider value in range [-100,100].
  88940. * @returns Adjusted value.
  88941. */
  88942. private static applyColorGradingSliderNonlinear;
  88943. /**
  88944. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88945. * @param hue The hue (H) input.
  88946. * @param saturation The saturation (S) input.
  88947. * @param brightness The brightness (B) input.
  88948. * @result An RGBA color represented as Vector4.
  88949. */
  88950. private static fromHSBToRef;
  88951. /**
  88952. * Returns a value clamped between min and max
  88953. * @param value The value to clamp
  88954. * @param min The minimum of value
  88955. * @param max The maximum of value
  88956. * @returns The clamped value.
  88957. */
  88958. private static clamp;
  88959. /**
  88960. * Clones the current color curve instance.
  88961. * @return The cloned curves
  88962. */
  88963. clone(): ColorCurves;
  88964. /**
  88965. * Serializes the current color curve instance to a json representation.
  88966. * @return a JSON representation
  88967. */
  88968. serialize(): any;
  88969. /**
  88970. * Parses the color curve from a json representation.
  88971. * @param source the JSON source to parse
  88972. * @return The parsed curves
  88973. */
  88974. static Parse(source: any): ColorCurves;
  88975. }
  88976. }
  88977. declare module BABYLON {
  88978. /**
  88979. * Interface to follow in your material defines to integrate easily the
  88980. * Image proccessing functions.
  88981. * @hidden
  88982. */
  88983. export interface IImageProcessingConfigurationDefines {
  88984. IMAGEPROCESSING: boolean;
  88985. VIGNETTE: boolean;
  88986. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88987. VIGNETTEBLENDMODEOPAQUE: boolean;
  88988. TONEMAPPING: boolean;
  88989. TONEMAPPING_ACES: boolean;
  88990. CONTRAST: boolean;
  88991. EXPOSURE: boolean;
  88992. COLORCURVES: boolean;
  88993. COLORGRADING: boolean;
  88994. COLORGRADING3D: boolean;
  88995. SAMPLER3DGREENDEPTH: boolean;
  88996. SAMPLER3DBGRMAP: boolean;
  88997. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88998. }
  88999. /**
  89000. * @hidden
  89001. */
  89002. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89003. IMAGEPROCESSING: boolean;
  89004. VIGNETTE: boolean;
  89005. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89006. VIGNETTEBLENDMODEOPAQUE: boolean;
  89007. TONEMAPPING: boolean;
  89008. TONEMAPPING_ACES: boolean;
  89009. CONTRAST: boolean;
  89010. COLORCURVES: boolean;
  89011. COLORGRADING: boolean;
  89012. COLORGRADING3D: boolean;
  89013. SAMPLER3DGREENDEPTH: boolean;
  89014. SAMPLER3DBGRMAP: boolean;
  89015. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89016. EXPOSURE: boolean;
  89017. constructor();
  89018. }
  89019. /**
  89020. * This groups together the common properties used for image processing either in direct forward pass
  89021. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89022. * or not.
  89023. */
  89024. export class ImageProcessingConfiguration {
  89025. /**
  89026. * Default tone mapping applied in BabylonJS.
  89027. */
  89028. static readonly TONEMAPPING_STANDARD: number;
  89029. /**
  89030. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89031. * to other engines rendering to increase portability.
  89032. */
  89033. static readonly TONEMAPPING_ACES: number;
  89034. /**
  89035. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89036. */
  89037. colorCurves: Nullable<ColorCurves>;
  89038. private _colorCurvesEnabled;
  89039. /**
  89040. * Gets wether the color curves effect is enabled.
  89041. */
  89042. get colorCurvesEnabled(): boolean;
  89043. /**
  89044. * Sets wether the color curves effect is enabled.
  89045. */
  89046. set colorCurvesEnabled(value: boolean);
  89047. private _colorGradingTexture;
  89048. /**
  89049. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89050. */
  89051. get colorGradingTexture(): Nullable<BaseTexture>;
  89052. /**
  89053. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89054. */
  89055. set colorGradingTexture(value: Nullable<BaseTexture>);
  89056. private _colorGradingEnabled;
  89057. /**
  89058. * Gets wether the color grading effect is enabled.
  89059. */
  89060. get colorGradingEnabled(): boolean;
  89061. /**
  89062. * Sets wether the color grading effect is enabled.
  89063. */
  89064. set colorGradingEnabled(value: boolean);
  89065. private _colorGradingWithGreenDepth;
  89066. /**
  89067. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89068. */
  89069. get colorGradingWithGreenDepth(): boolean;
  89070. /**
  89071. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89072. */
  89073. set colorGradingWithGreenDepth(value: boolean);
  89074. private _colorGradingBGR;
  89075. /**
  89076. * Gets wether the color grading texture contains BGR values.
  89077. */
  89078. get colorGradingBGR(): boolean;
  89079. /**
  89080. * Sets wether the color grading texture contains BGR values.
  89081. */
  89082. set colorGradingBGR(value: boolean);
  89083. /** @hidden */
  89084. _exposure: number;
  89085. /**
  89086. * Gets the Exposure used in the effect.
  89087. */
  89088. get exposure(): number;
  89089. /**
  89090. * Sets the Exposure used in the effect.
  89091. */
  89092. set exposure(value: number);
  89093. private _toneMappingEnabled;
  89094. /**
  89095. * Gets wether the tone mapping effect is enabled.
  89096. */
  89097. get toneMappingEnabled(): boolean;
  89098. /**
  89099. * Sets wether the tone mapping effect is enabled.
  89100. */
  89101. set toneMappingEnabled(value: boolean);
  89102. private _toneMappingType;
  89103. /**
  89104. * Gets the type of tone mapping effect.
  89105. */
  89106. get toneMappingType(): number;
  89107. /**
  89108. * Sets the type of tone mapping effect used in BabylonJS.
  89109. */
  89110. set toneMappingType(value: number);
  89111. protected _contrast: number;
  89112. /**
  89113. * Gets the contrast used in the effect.
  89114. */
  89115. get contrast(): number;
  89116. /**
  89117. * Sets the contrast used in the effect.
  89118. */
  89119. set contrast(value: number);
  89120. /**
  89121. * Vignette stretch size.
  89122. */
  89123. vignetteStretch: number;
  89124. /**
  89125. * Vignette centre X Offset.
  89126. */
  89127. vignetteCentreX: number;
  89128. /**
  89129. * Vignette centre Y Offset.
  89130. */
  89131. vignetteCentreY: number;
  89132. /**
  89133. * Vignette weight or intensity of the vignette effect.
  89134. */
  89135. vignetteWeight: number;
  89136. /**
  89137. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89138. * if vignetteEnabled is set to true.
  89139. */
  89140. vignetteColor: Color4;
  89141. /**
  89142. * Camera field of view used by the Vignette effect.
  89143. */
  89144. vignetteCameraFov: number;
  89145. private _vignetteBlendMode;
  89146. /**
  89147. * Gets the vignette blend mode allowing different kind of effect.
  89148. */
  89149. get vignetteBlendMode(): number;
  89150. /**
  89151. * Sets the vignette blend mode allowing different kind of effect.
  89152. */
  89153. set vignetteBlendMode(value: number);
  89154. private _vignetteEnabled;
  89155. /**
  89156. * Gets wether the vignette effect is enabled.
  89157. */
  89158. get vignetteEnabled(): boolean;
  89159. /**
  89160. * Sets wether the vignette effect is enabled.
  89161. */
  89162. set vignetteEnabled(value: boolean);
  89163. private _applyByPostProcess;
  89164. /**
  89165. * Gets wether the image processing is applied through a post process or not.
  89166. */
  89167. get applyByPostProcess(): boolean;
  89168. /**
  89169. * Sets wether the image processing is applied through a post process or not.
  89170. */
  89171. set applyByPostProcess(value: boolean);
  89172. private _isEnabled;
  89173. /**
  89174. * Gets wether the image processing is enabled or not.
  89175. */
  89176. get isEnabled(): boolean;
  89177. /**
  89178. * Sets wether the image processing is enabled or not.
  89179. */
  89180. set isEnabled(value: boolean);
  89181. /**
  89182. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89183. */
  89184. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89185. /**
  89186. * Method called each time the image processing information changes requires to recompile the effect.
  89187. */
  89188. protected _updateParameters(): void;
  89189. /**
  89190. * Gets the current class name.
  89191. * @return "ImageProcessingConfiguration"
  89192. */
  89193. getClassName(): string;
  89194. /**
  89195. * Prepare the list of uniforms associated with the Image Processing effects.
  89196. * @param uniforms The list of uniforms used in the effect
  89197. * @param defines the list of defines currently in use
  89198. */
  89199. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89200. /**
  89201. * Prepare the list of samplers associated with the Image Processing effects.
  89202. * @param samplersList The list of uniforms used in the effect
  89203. * @param defines the list of defines currently in use
  89204. */
  89205. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89206. /**
  89207. * Prepare the list of defines associated to the shader.
  89208. * @param defines the list of defines to complete
  89209. * @param forPostProcess Define if we are currently in post process mode or not
  89210. */
  89211. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89212. /**
  89213. * Returns true if all the image processing information are ready.
  89214. * @returns True if ready, otherwise, false
  89215. */
  89216. isReady(): boolean;
  89217. /**
  89218. * Binds the image processing to the shader.
  89219. * @param effect The effect to bind to
  89220. * @param overrideAspectRatio Override the aspect ratio of the effect
  89221. */
  89222. bind(effect: Effect, overrideAspectRatio?: number): void;
  89223. /**
  89224. * Clones the current image processing instance.
  89225. * @return The cloned image processing
  89226. */
  89227. clone(): ImageProcessingConfiguration;
  89228. /**
  89229. * Serializes the current image processing instance to a json representation.
  89230. * @return a JSON representation
  89231. */
  89232. serialize(): any;
  89233. /**
  89234. * Parses the image processing from a json representation.
  89235. * @param source the JSON source to parse
  89236. * @return The parsed image processing
  89237. */
  89238. static Parse(source: any): ImageProcessingConfiguration;
  89239. private static _VIGNETTEMODE_MULTIPLY;
  89240. private static _VIGNETTEMODE_OPAQUE;
  89241. /**
  89242. * Used to apply the vignette as a mix with the pixel color.
  89243. */
  89244. static get VIGNETTEMODE_MULTIPLY(): number;
  89245. /**
  89246. * Used to apply the vignette as a replacement of the pixel color.
  89247. */
  89248. static get VIGNETTEMODE_OPAQUE(): number;
  89249. }
  89250. }
  89251. declare module BABYLON {
  89252. /** @hidden */
  89253. export var postprocessVertexShader: {
  89254. name: string;
  89255. shader: string;
  89256. };
  89257. }
  89258. declare module BABYLON {
  89259. /**
  89260. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89261. */
  89262. export type RenderTargetTextureSize = number | {
  89263. width: number;
  89264. height: number;
  89265. layers?: number;
  89266. };
  89267. interface ThinEngine {
  89268. /**
  89269. * Creates a new render target texture
  89270. * @param size defines the size of the texture
  89271. * @param options defines the options used to create the texture
  89272. * @returns a new render target texture stored in an InternalTexture
  89273. */
  89274. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89275. /**
  89276. * Creates a depth stencil texture.
  89277. * This is only available in WebGL 2 or with the depth texture extension available.
  89278. * @param size The size of face edge in the texture.
  89279. * @param options The options defining the texture.
  89280. * @returns The texture
  89281. */
  89282. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89283. /** @hidden */
  89284. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89285. }
  89286. }
  89287. declare module BABYLON {
  89288. /**
  89289. * Defines the kind of connection point for node based material
  89290. */
  89291. export enum NodeMaterialBlockConnectionPointTypes {
  89292. /** Float */
  89293. Float = 1,
  89294. /** Int */
  89295. Int = 2,
  89296. /** Vector2 */
  89297. Vector2 = 4,
  89298. /** Vector3 */
  89299. Vector3 = 8,
  89300. /** Vector4 */
  89301. Vector4 = 16,
  89302. /** Color3 */
  89303. Color3 = 32,
  89304. /** Color4 */
  89305. Color4 = 64,
  89306. /** Matrix */
  89307. Matrix = 128,
  89308. /** Custom object */
  89309. Object = 256,
  89310. /** Detect type based on connection */
  89311. AutoDetect = 1024,
  89312. /** Output type that will be defined by input type */
  89313. BasedOnInput = 2048
  89314. }
  89315. }
  89316. declare module BABYLON {
  89317. /**
  89318. * Enum used to define the target of a block
  89319. */
  89320. export enum NodeMaterialBlockTargets {
  89321. /** Vertex shader */
  89322. Vertex = 1,
  89323. /** Fragment shader */
  89324. Fragment = 2,
  89325. /** Neutral */
  89326. Neutral = 4,
  89327. /** Vertex and Fragment */
  89328. VertexAndFragment = 3
  89329. }
  89330. }
  89331. declare module BABYLON {
  89332. /**
  89333. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89334. */
  89335. export enum NodeMaterialBlockConnectionPointMode {
  89336. /** Value is an uniform */
  89337. Uniform = 0,
  89338. /** Value is a mesh attribute */
  89339. Attribute = 1,
  89340. /** Value is a varying between vertex and fragment shaders */
  89341. Varying = 2,
  89342. /** Mode is undefined */
  89343. Undefined = 3
  89344. }
  89345. }
  89346. declare module BABYLON {
  89347. /**
  89348. * Enum used to define system values e.g. values automatically provided by the system
  89349. */
  89350. export enum NodeMaterialSystemValues {
  89351. /** World */
  89352. World = 1,
  89353. /** View */
  89354. View = 2,
  89355. /** Projection */
  89356. Projection = 3,
  89357. /** ViewProjection */
  89358. ViewProjection = 4,
  89359. /** WorldView */
  89360. WorldView = 5,
  89361. /** WorldViewProjection */
  89362. WorldViewProjection = 6,
  89363. /** CameraPosition */
  89364. CameraPosition = 7,
  89365. /** Fog Color */
  89366. FogColor = 8,
  89367. /** Delta time */
  89368. DeltaTime = 9
  89369. }
  89370. }
  89371. declare module BABYLON {
  89372. /** Defines supported spaces */
  89373. export enum Space {
  89374. /** Local (object) space */
  89375. LOCAL = 0,
  89376. /** World space */
  89377. WORLD = 1,
  89378. /** Bone space */
  89379. BONE = 2
  89380. }
  89381. /** Defines the 3 main axes */
  89382. export class Axis {
  89383. /** X axis */
  89384. static X: Vector3;
  89385. /** Y axis */
  89386. static Y: Vector3;
  89387. /** Z axis */
  89388. static Z: Vector3;
  89389. }
  89390. }
  89391. declare module BABYLON {
  89392. /**
  89393. * Represents a camera frustum
  89394. */
  89395. export class Frustum {
  89396. /**
  89397. * Gets the planes representing the frustum
  89398. * @param transform matrix to be applied to the returned planes
  89399. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89400. */
  89401. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89402. /**
  89403. * Gets the near frustum plane transformed by the transform matrix
  89404. * @param transform transformation matrix to be applied to the resulting frustum plane
  89405. * @param frustumPlane the resuling frustum plane
  89406. */
  89407. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89408. /**
  89409. * Gets the far frustum plane transformed by the transform matrix
  89410. * @param transform transformation matrix to be applied to the resulting frustum plane
  89411. * @param frustumPlane the resuling frustum plane
  89412. */
  89413. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89414. /**
  89415. * Gets the left frustum plane transformed by the transform matrix
  89416. * @param transform transformation matrix to be applied to the resulting frustum plane
  89417. * @param frustumPlane the resuling frustum plane
  89418. */
  89419. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89420. /**
  89421. * Gets the right frustum plane transformed by the transform matrix
  89422. * @param transform transformation matrix to be applied to the resulting frustum plane
  89423. * @param frustumPlane the resuling frustum plane
  89424. */
  89425. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89426. /**
  89427. * Gets the top frustum plane transformed by the transform matrix
  89428. * @param transform transformation matrix to be applied to the resulting frustum plane
  89429. * @param frustumPlane the resuling frustum plane
  89430. */
  89431. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89432. /**
  89433. * Gets the bottom frustum plane transformed by the transform matrix
  89434. * @param transform transformation matrix to be applied to the resulting frustum plane
  89435. * @param frustumPlane the resuling frustum plane
  89436. */
  89437. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89438. /**
  89439. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89440. * @param transform transformation matrix to be applied to the resulting frustum planes
  89441. * @param frustumPlanes the resuling frustum planes
  89442. */
  89443. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89444. }
  89445. }
  89446. declare module BABYLON {
  89447. /**
  89448. * Interface for the size containing width and height
  89449. */
  89450. export interface ISize {
  89451. /**
  89452. * Width
  89453. */
  89454. width: number;
  89455. /**
  89456. * Heighht
  89457. */
  89458. height: number;
  89459. }
  89460. /**
  89461. * Size containing widht and height
  89462. */
  89463. export class Size implements ISize {
  89464. /**
  89465. * Width
  89466. */
  89467. width: number;
  89468. /**
  89469. * Height
  89470. */
  89471. height: number;
  89472. /**
  89473. * Creates a Size object from the given width and height (floats).
  89474. * @param width width of the new size
  89475. * @param height height of the new size
  89476. */
  89477. constructor(width: number, height: number);
  89478. /**
  89479. * Returns a string with the Size width and height
  89480. * @returns a string with the Size width and height
  89481. */
  89482. toString(): string;
  89483. /**
  89484. * "Size"
  89485. * @returns the string "Size"
  89486. */
  89487. getClassName(): string;
  89488. /**
  89489. * Returns the Size hash code.
  89490. * @returns a hash code for a unique width and height
  89491. */
  89492. getHashCode(): number;
  89493. /**
  89494. * Updates the current size from the given one.
  89495. * @param src the given size
  89496. */
  89497. copyFrom(src: Size): void;
  89498. /**
  89499. * Updates in place the current Size from the given floats.
  89500. * @param width width of the new size
  89501. * @param height height of the new size
  89502. * @returns the updated Size.
  89503. */
  89504. copyFromFloats(width: number, height: number): Size;
  89505. /**
  89506. * Updates in place the current Size from the given floats.
  89507. * @param width width to set
  89508. * @param height height to set
  89509. * @returns the updated Size.
  89510. */
  89511. set(width: number, height: number): Size;
  89512. /**
  89513. * Multiplies the width and height by numbers
  89514. * @param w factor to multiple the width by
  89515. * @param h factor to multiple the height by
  89516. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89517. */
  89518. multiplyByFloats(w: number, h: number): Size;
  89519. /**
  89520. * Clones the size
  89521. * @returns a new Size copied from the given one.
  89522. */
  89523. clone(): Size;
  89524. /**
  89525. * True if the current Size and the given one width and height are strictly equal.
  89526. * @param other the other size to compare against
  89527. * @returns True if the current Size and the given one width and height are strictly equal.
  89528. */
  89529. equals(other: Size): boolean;
  89530. /**
  89531. * The surface of the Size : width * height (float).
  89532. */
  89533. get surface(): number;
  89534. /**
  89535. * Create a new size of zero
  89536. * @returns a new Size set to (0.0, 0.0)
  89537. */
  89538. static Zero(): Size;
  89539. /**
  89540. * Sums the width and height of two sizes
  89541. * @param otherSize size to add to this size
  89542. * @returns a new Size set as the addition result of the current Size and the given one.
  89543. */
  89544. add(otherSize: Size): Size;
  89545. /**
  89546. * Subtracts the width and height of two
  89547. * @param otherSize size to subtract to this size
  89548. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89549. */
  89550. subtract(otherSize: Size): Size;
  89551. /**
  89552. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89553. * @param start starting size to lerp between
  89554. * @param end end size to lerp between
  89555. * @param amount amount to lerp between the start and end values
  89556. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89557. */
  89558. static Lerp(start: Size, end: Size, amount: number): Size;
  89559. }
  89560. }
  89561. declare module BABYLON {
  89562. /**
  89563. * Contains position and normal vectors for a vertex
  89564. */
  89565. export class PositionNormalVertex {
  89566. /** the position of the vertex (defaut: 0,0,0) */
  89567. position: Vector3;
  89568. /** the normal of the vertex (defaut: 0,1,0) */
  89569. normal: Vector3;
  89570. /**
  89571. * Creates a PositionNormalVertex
  89572. * @param position the position of the vertex (defaut: 0,0,0)
  89573. * @param normal the normal of the vertex (defaut: 0,1,0)
  89574. */
  89575. constructor(
  89576. /** the position of the vertex (defaut: 0,0,0) */
  89577. position?: Vector3,
  89578. /** the normal of the vertex (defaut: 0,1,0) */
  89579. normal?: Vector3);
  89580. /**
  89581. * Clones the PositionNormalVertex
  89582. * @returns the cloned PositionNormalVertex
  89583. */
  89584. clone(): PositionNormalVertex;
  89585. }
  89586. /**
  89587. * Contains position, normal and uv vectors for a vertex
  89588. */
  89589. export class PositionNormalTextureVertex {
  89590. /** the position of the vertex (defaut: 0,0,0) */
  89591. position: Vector3;
  89592. /** the normal of the vertex (defaut: 0,1,0) */
  89593. normal: Vector3;
  89594. /** the uv of the vertex (default: 0,0) */
  89595. uv: Vector2;
  89596. /**
  89597. * Creates a PositionNormalTextureVertex
  89598. * @param position the position of the vertex (defaut: 0,0,0)
  89599. * @param normal the normal of the vertex (defaut: 0,1,0)
  89600. * @param uv the uv of the vertex (default: 0,0)
  89601. */
  89602. constructor(
  89603. /** the position of the vertex (defaut: 0,0,0) */
  89604. position?: Vector3,
  89605. /** the normal of the vertex (defaut: 0,1,0) */
  89606. normal?: Vector3,
  89607. /** the uv of the vertex (default: 0,0) */
  89608. uv?: Vector2);
  89609. /**
  89610. * Clones the PositionNormalTextureVertex
  89611. * @returns the cloned PositionNormalTextureVertex
  89612. */
  89613. clone(): PositionNormalTextureVertex;
  89614. }
  89615. }
  89616. declare module BABYLON {
  89617. /**
  89618. * Enum defining the type of animations supported by InputBlock
  89619. */
  89620. export enum AnimatedInputBlockTypes {
  89621. /** No animation */
  89622. None = 0,
  89623. /** Time based animation. Will only work for floats */
  89624. Time = 1
  89625. }
  89626. }
  89627. declare module BABYLON {
  89628. /**
  89629. * Interface describing all the common properties and methods a shadow light needs to implement.
  89630. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89631. * as well as binding the different shadow properties to the effects.
  89632. */
  89633. export interface IShadowLight extends Light {
  89634. /**
  89635. * The light id in the scene (used in scene.findLighById for instance)
  89636. */
  89637. id: string;
  89638. /**
  89639. * The position the shdow will be casted from.
  89640. */
  89641. position: Vector3;
  89642. /**
  89643. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89644. */
  89645. direction: Vector3;
  89646. /**
  89647. * The transformed position. Position of the light in world space taking parenting in account.
  89648. */
  89649. transformedPosition: Vector3;
  89650. /**
  89651. * The transformed direction. Direction of the light in world space taking parenting in account.
  89652. */
  89653. transformedDirection: Vector3;
  89654. /**
  89655. * The friendly name of the light in the scene.
  89656. */
  89657. name: string;
  89658. /**
  89659. * Defines the shadow projection clipping minimum z value.
  89660. */
  89661. shadowMinZ: number;
  89662. /**
  89663. * Defines the shadow projection clipping maximum z value.
  89664. */
  89665. shadowMaxZ: number;
  89666. /**
  89667. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89668. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89669. */
  89670. computeTransformedInformation(): boolean;
  89671. /**
  89672. * Gets the scene the light belongs to.
  89673. * @returns The scene
  89674. */
  89675. getScene(): Scene;
  89676. /**
  89677. * Callback defining a custom Projection Matrix Builder.
  89678. * This can be used to override the default projection matrix computation.
  89679. */
  89680. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89681. /**
  89682. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89683. * @param matrix The materix to updated with the projection information
  89684. * @param viewMatrix The transform matrix of the light
  89685. * @param renderList The list of mesh to render in the map
  89686. * @returns The current light
  89687. */
  89688. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89689. /**
  89690. * Gets the current depth scale used in ESM.
  89691. * @returns The scale
  89692. */
  89693. getDepthScale(): number;
  89694. /**
  89695. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89696. * @returns true if a cube texture needs to be use
  89697. */
  89698. needCube(): boolean;
  89699. /**
  89700. * Detects if the projection matrix requires to be recomputed this frame.
  89701. * @returns true if it requires to be recomputed otherwise, false.
  89702. */
  89703. needProjectionMatrixCompute(): boolean;
  89704. /**
  89705. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89706. */
  89707. forceProjectionMatrixCompute(): void;
  89708. /**
  89709. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89710. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89711. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89712. */
  89713. getShadowDirection(faceIndex?: number): Vector3;
  89714. /**
  89715. * Gets the minZ used for shadow according to both the scene and the light.
  89716. * @param activeCamera The camera we are returning the min for
  89717. * @returns the depth min z
  89718. */
  89719. getDepthMinZ(activeCamera: Camera): number;
  89720. /**
  89721. * Gets the maxZ used for shadow according to both the scene and the light.
  89722. * @param activeCamera The camera we are returning the max for
  89723. * @returns the depth max z
  89724. */
  89725. getDepthMaxZ(activeCamera: Camera): number;
  89726. }
  89727. /**
  89728. * Base implementation IShadowLight
  89729. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89730. */
  89731. export abstract class ShadowLight extends Light implements IShadowLight {
  89732. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89733. protected _position: Vector3;
  89734. protected _setPosition(value: Vector3): void;
  89735. /**
  89736. * Sets the position the shadow will be casted from. Also use as the light position for both
  89737. * point and spot lights.
  89738. */
  89739. get position(): Vector3;
  89740. /**
  89741. * Sets the position the shadow will be casted from. Also use as the light position for both
  89742. * point and spot lights.
  89743. */
  89744. set position(value: Vector3);
  89745. protected _direction: Vector3;
  89746. protected _setDirection(value: Vector3): void;
  89747. /**
  89748. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89749. * Also use as the light direction on spot and directional lights.
  89750. */
  89751. get direction(): Vector3;
  89752. /**
  89753. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89754. * Also use as the light direction on spot and directional lights.
  89755. */
  89756. set direction(value: Vector3);
  89757. protected _shadowMinZ: number;
  89758. /**
  89759. * Gets the shadow projection clipping minimum z value.
  89760. */
  89761. get shadowMinZ(): number;
  89762. /**
  89763. * Sets the shadow projection clipping minimum z value.
  89764. */
  89765. set shadowMinZ(value: number);
  89766. protected _shadowMaxZ: number;
  89767. /**
  89768. * Sets the shadow projection clipping maximum z value.
  89769. */
  89770. get shadowMaxZ(): number;
  89771. /**
  89772. * Gets the shadow projection clipping maximum z value.
  89773. */
  89774. set shadowMaxZ(value: number);
  89775. /**
  89776. * Callback defining a custom Projection Matrix Builder.
  89777. * This can be used to override the default projection matrix computation.
  89778. */
  89779. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89780. /**
  89781. * The transformed position. Position of the light in world space taking parenting in account.
  89782. */
  89783. transformedPosition: Vector3;
  89784. /**
  89785. * The transformed direction. Direction of the light in world space taking parenting in account.
  89786. */
  89787. transformedDirection: Vector3;
  89788. private _needProjectionMatrixCompute;
  89789. /**
  89790. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89791. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89792. */
  89793. computeTransformedInformation(): boolean;
  89794. /**
  89795. * Return the depth scale used for the shadow map.
  89796. * @returns the depth scale.
  89797. */
  89798. getDepthScale(): number;
  89799. /**
  89800. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89801. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89802. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89803. */
  89804. getShadowDirection(faceIndex?: number): Vector3;
  89805. /**
  89806. * Returns the ShadowLight absolute position in the World.
  89807. * @returns the position vector in world space
  89808. */
  89809. getAbsolutePosition(): Vector3;
  89810. /**
  89811. * Sets the ShadowLight direction toward the passed target.
  89812. * @param target The point to target in local space
  89813. * @returns the updated ShadowLight direction
  89814. */
  89815. setDirectionToTarget(target: Vector3): Vector3;
  89816. /**
  89817. * Returns the light rotation in euler definition.
  89818. * @returns the x y z rotation in local space.
  89819. */
  89820. getRotation(): Vector3;
  89821. /**
  89822. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89823. * @returns true if a cube texture needs to be use
  89824. */
  89825. needCube(): boolean;
  89826. /**
  89827. * Detects if the projection matrix requires to be recomputed this frame.
  89828. * @returns true if it requires to be recomputed otherwise, false.
  89829. */
  89830. needProjectionMatrixCompute(): boolean;
  89831. /**
  89832. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89833. */
  89834. forceProjectionMatrixCompute(): void;
  89835. /** @hidden */
  89836. _initCache(): void;
  89837. /** @hidden */
  89838. _isSynchronized(): boolean;
  89839. /**
  89840. * Computes the world matrix of the node
  89841. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89842. * @returns the world matrix
  89843. */
  89844. computeWorldMatrix(force?: boolean): Matrix;
  89845. /**
  89846. * Gets the minZ used for shadow according to both the scene and the light.
  89847. * @param activeCamera The camera we are returning the min for
  89848. * @returns the depth min z
  89849. */
  89850. getDepthMinZ(activeCamera: Camera): number;
  89851. /**
  89852. * Gets the maxZ used for shadow according to both the scene and the light.
  89853. * @param activeCamera The camera we are returning the max for
  89854. * @returns the depth max z
  89855. */
  89856. getDepthMaxZ(activeCamera: Camera): number;
  89857. /**
  89858. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89859. * @param matrix The materix to updated with the projection information
  89860. * @param viewMatrix The transform matrix of the light
  89861. * @param renderList The list of mesh to render in the map
  89862. * @returns The current light
  89863. */
  89864. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89865. }
  89866. }
  89867. declare module BABYLON {
  89868. /** @hidden */
  89869. export var packingFunctions: {
  89870. name: string;
  89871. shader: string;
  89872. };
  89873. }
  89874. declare module BABYLON {
  89875. /** @hidden */
  89876. export var bayerDitherFunctions: {
  89877. name: string;
  89878. shader: string;
  89879. };
  89880. }
  89881. declare module BABYLON {
  89882. /** @hidden */
  89883. export var shadowMapFragmentDeclaration: {
  89884. name: string;
  89885. shader: string;
  89886. };
  89887. }
  89888. declare module BABYLON {
  89889. /** @hidden */
  89890. export var clipPlaneFragmentDeclaration: {
  89891. name: string;
  89892. shader: string;
  89893. };
  89894. }
  89895. declare module BABYLON {
  89896. /** @hidden */
  89897. export var clipPlaneFragment: {
  89898. name: string;
  89899. shader: string;
  89900. };
  89901. }
  89902. declare module BABYLON {
  89903. /** @hidden */
  89904. export var shadowMapFragment: {
  89905. name: string;
  89906. shader: string;
  89907. };
  89908. }
  89909. declare module BABYLON {
  89910. /** @hidden */
  89911. export var shadowMapPixelShader: {
  89912. name: string;
  89913. shader: string;
  89914. };
  89915. }
  89916. declare module BABYLON {
  89917. /** @hidden */
  89918. export var bonesDeclaration: {
  89919. name: string;
  89920. shader: string;
  89921. };
  89922. }
  89923. declare module BABYLON {
  89924. /** @hidden */
  89925. export var morphTargetsVertexGlobalDeclaration: {
  89926. name: string;
  89927. shader: string;
  89928. };
  89929. }
  89930. declare module BABYLON {
  89931. /** @hidden */
  89932. export var morphTargetsVertexDeclaration: {
  89933. name: string;
  89934. shader: string;
  89935. };
  89936. }
  89937. declare module BABYLON {
  89938. /** @hidden */
  89939. export var instancesDeclaration: {
  89940. name: string;
  89941. shader: string;
  89942. };
  89943. }
  89944. declare module BABYLON {
  89945. /** @hidden */
  89946. export var helperFunctions: {
  89947. name: string;
  89948. shader: string;
  89949. };
  89950. }
  89951. declare module BABYLON {
  89952. /** @hidden */
  89953. export var shadowMapVertexDeclaration: {
  89954. name: string;
  89955. shader: string;
  89956. };
  89957. }
  89958. declare module BABYLON {
  89959. /** @hidden */
  89960. export var clipPlaneVertexDeclaration: {
  89961. name: string;
  89962. shader: string;
  89963. };
  89964. }
  89965. declare module BABYLON {
  89966. /** @hidden */
  89967. export var morphTargetsVertex: {
  89968. name: string;
  89969. shader: string;
  89970. };
  89971. }
  89972. declare module BABYLON {
  89973. /** @hidden */
  89974. export var instancesVertex: {
  89975. name: string;
  89976. shader: string;
  89977. };
  89978. }
  89979. declare module BABYLON {
  89980. /** @hidden */
  89981. export var bonesVertex: {
  89982. name: string;
  89983. shader: string;
  89984. };
  89985. }
  89986. declare module BABYLON {
  89987. /** @hidden */
  89988. export var shadowMapVertexNormalBias: {
  89989. name: string;
  89990. shader: string;
  89991. };
  89992. }
  89993. declare module BABYLON {
  89994. /** @hidden */
  89995. export var shadowMapVertexMetric: {
  89996. name: string;
  89997. shader: string;
  89998. };
  89999. }
  90000. declare module BABYLON {
  90001. /** @hidden */
  90002. export var clipPlaneVertex: {
  90003. name: string;
  90004. shader: string;
  90005. };
  90006. }
  90007. declare module BABYLON {
  90008. /** @hidden */
  90009. export var shadowMapVertexShader: {
  90010. name: string;
  90011. shader: string;
  90012. };
  90013. }
  90014. declare module BABYLON {
  90015. /** @hidden */
  90016. export var depthBoxBlurPixelShader: {
  90017. name: string;
  90018. shader: string;
  90019. };
  90020. }
  90021. declare module BABYLON {
  90022. /** @hidden */
  90023. export var shadowMapFragmentSoftTransparentShadow: {
  90024. name: string;
  90025. shader: string;
  90026. };
  90027. }
  90028. declare module BABYLON {
  90029. /**
  90030. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90031. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90032. */
  90033. export class EffectFallbacks implements IEffectFallbacks {
  90034. private _defines;
  90035. private _currentRank;
  90036. private _maxRank;
  90037. private _mesh;
  90038. /**
  90039. * Removes the fallback from the bound mesh.
  90040. */
  90041. unBindMesh(): void;
  90042. /**
  90043. * Adds a fallback on the specified property.
  90044. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90045. * @param define The name of the define in the shader
  90046. */
  90047. addFallback(rank: number, define: string): void;
  90048. /**
  90049. * Sets the mesh to use CPU skinning when needing to fallback.
  90050. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90051. * @param mesh The mesh to use the fallbacks.
  90052. */
  90053. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90054. /**
  90055. * Checks to see if more fallbacks are still availible.
  90056. */
  90057. get hasMoreFallbacks(): boolean;
  90058. /**
  90059. * Removes the defines that should be removed when falling back.
  90060. * @param currentDefines defines the current define statements for the shader.
  90061. * @param effect defines the current effect we try to compile
  90062. * @returns The resulting defines with defines of the current rank removed.
  90063. */
  90064. reduce(currentDefines: string, effect: Effect): string;
  90065. }
  90066. }
  90067. declare module BABYLON {
  90068. /**
  90069. * Interface used to define Action
  90070. */
  90071. export interface IAction {
  90072. /**
  90073. * Trigger for the action
  90074. */
  90075. trigger: number;
  90076. /** Options of the trigger */
  90077. triggerOptions: any;
  90078. /**
  90079. * Gets the trigger parameters
  90080. * @returns the trigger parameters
  90081. */
  90082. getTriggerParameter(): any;
  90083. /**
  90084. * Internal only - executes current action event
  90085. * @hidden
  90086. */
  90087. _executeCurrent(evt?: ActionEvent): void;
  90088. /**
  90089. * Serialize placeholder for child classes
  90090. * @param parent of child
  90091. * @returns the serialized object
  90092. */
  90093. serialize(parent: any): any;
  90094. /**
  90095. * Internal only
  90096. * @hidden
  90097. */
  90098. _prepare(): void;
  90099. /**
  90100. * Internal only - manager for action
  90101. * @hidden
  90102. */
  90103. _actionManager: Nullable<AbstractActionManager>;
  90104. /**
  90105. * Adds action to chain of actions, may be a DoNothingAction
  90106. * @param action defines the next action to execute
  90107. * @returns The action passed in
  90108. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90109. */
  90110. then(action: IAction): IAction;
  90111. }
  90112. /**
  90113. * The action to be carried out following a trigger
  90114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90115. */
  90116. export class Action implements IAction {
  90117. /** the trigger, with or without parameters, for the action */
  90118. triggerOptions: any;
  90119. /**
  90120. * Trigger for the action
  90121. */
  90122. trigger: number;
  90123. /**
  90124. * Internal only - manager for action
  90125. * @hidden
  90126. */
  90127. _actionManager: ActionManager;
  90128. private _nextActiveAction;
  90129. private _child;
  90130. private _condition?;
  90131. private _triggerParameter;
  90132. /**
  90133. * An event triggered prior to action being executed.
  90134. */
  90135. onBeforeExecuteObservable: Observable<Action>;
  90136. /**
  90137. * Creates a new Action
  90138. * @param triggerOptions the trigger, with or without parameters, for the action
  90139. * @param condition an optional determinant of action
  90140. */
  90141. constructor(
  90142. /** the trigger, with or without parameters, for the action */
  90143. triggerOptions: any, condition?: Condition);
  90144. /**
  90145. * Internal only
  90146. * @hidden
  90147. */
  90148. _prepare(): void;
  90149. /**
  90150. * Gets the trigger parameters
  90151. * @returns the trigger parameters
  90152. */
  90153. getTriggerParameter(): any;
  90154. /**
  90155. * Internal only - executes current action event
  90156. * @hidden
  90157. */
  90158. _executeCurrent(evt?: ActionEvent): void;
  90159. /**
  90160. * Execute placeholder for child classes
  90161. * @param evt optional action event
  90162. */
  90163. execute(evt?: ActionEvent): void;
  90164. /**
  90165. * Skips to next active action
  90166. */
  90167. skipToNextActiveAction(): void;
  90168. /**
  90169. * Adds action to chain of actions, may be a DoNothingAction
  90170. * @param action defines the next action to execute
  90171. * @returns The action passed in
  90172. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90173. */
  90174. then(action: Action): Action;
  90175. /**
  90176. * Internal only
  90177. * @hidden
  90178. */
  90179. _getProperty(propertyPath: string): string;
  90180. /**
  90181. * Internal only
  90182. * @hidden
  90183. */
  90184. _getEffectiveTarget(target: any, propertyPath: string): any;
  90185. /**
  90186. * Serialize placeholder for child classes
  90187. * @param parent of child
  90188. * @returns the serialized object
  90189. */
  90190. serialize(parent: any): any;
  90191. /**
  90192. * Internal only called by serialize
  90193. * @hidden
  90194. */
  90195. protected _serialize(serializedAction: any, parent?: any): any;
  90196. /**
  90197. * Internal only
  90198. * @hidden
  90199. */
  90200. static _SerializeValueAsString: (value: any) => string;
  90201. /**
  90202. * Internal only
  90203. * @hidden
  90204. */
  90205. static _GetTargetProperty: (target: Scene | Node) => {
  90206. name: string;
  90207. targetType: string;
  90208. value: string;
  90209. };
  90210. }
  90211. }
  90212. declare module BABYLON {
  90213. /**
  90214. * A Condition applied to an Action
  90215. */
  90216. export class Condition {
  90217. /**
  90218. * Internal only - manager for action
  90219. * @hidden
  90220. */
  90221. _actionManager: ActionManager;
  90222. /**
  90223. * Internal only
  90224. * @hidden
  90225. */
  90226. _evaluationId: number;
  90227. /**
  90228. * Internal only
  90229. * @hidden
  90230. */
  90231. _currentResult: boolean;
  90232. /**
  90233. * Creates a new Condition
  90234. * @param actionManager the manager of the action the condition is applied to
  90235. */
  90236. constructor(actionManager: ActionManager);
  90237. /**
  90238. * Check if the current condition is valid
  90239. * @returns a boolean
  90240. */
  90241. isValid(): boolean;
  90242. /**
  90243. * Internal only
  90244. * @hidden
  90245. */
  90246. _getProperty(propertyPath: string): string;
  90247. /**
  90248. * Internal only
  90249. * @hidden
  90250. */
  90251. _getEffectiveTarget(target: any, propertyPath: string): any;
  90252. /**
  90253. * Serialize placeholder for child classes
  90254. * @returns the serialized object
  90255. */
  90256. serialize(): any;
  90257. /**
  90258. * Internal only
  90259. * @hidden
  90260. */
  90261. protected _serialize(serializedCondition: any): any;
  90262. }
  90263. /**
  90264. * Defines specific conditional operators as extensions of Condition
  90265. */
  90266. export class ValueCondition extends Condition {
  90267. /** path to specify the property of the target the conditional operator uses */
  90268. propertyPath: string;
  90269. /** the value compared by the conditional operator against the current value of the property */
  90270. value: any;
  90271. /** the conditional operator, default ValueCondition.IsEqual */
  90272. operator: number;
  90273. /**
  90274. * Internal only
  90275. * @hidden
  90276. */
  90277. private static _IsEqual;
  90278. /**
  90279. * Internal only
  90280. * @hidden
  90281. */
  90282. private static _IsDifferent;
  90283. /**
  90284. * Internal only
  90285. * @hidden
  90286. */
  90287. private static _IsGreater;
  90288. /**
  90289. * Internal only
  90290. * @hidden
  90291. */
  90292. private static _IsLesser;
  90293. /**
  90294. * returns the number for IsEqual
  90295. */
  90296. static get IsEqual(): number;
  90297. /**
  90298. * Returns the number for IsDifferent
  90299. */
  90300. static get IsDifferent(): number;
  90301. /**
  90302. * Returns the number for IsGreater
  90303. */
  90304. static get IsGreater(): number;
  90305. /**
  90306. * Returns the number for IsLesser
  90307. */
  90308. static get IsLesser(): number;
  90309. /**
  90310. * Internal only The action manager for the condition
  90311. * @hidden
  90312. */
  90313. _actionManager: ActionManager;
  90314. /**
  90315. * Internal only
  90316. * @hidden
  90317. */
  90318. private _target;
  90319. /**
  90320. * Internal only
  90321. * @hidden
  90322. */
  90323. private _effectiveTarget;
  90324. /**
  90325. * Internal only
  90326. * @hidden
  90327. */
  90328. private _property;
  90329. /**
  90330. * Creates a new ValueCondition
  90331. * @param actionManager manager for the action the condition applies to
  90332. * @param target for the action
  90333. * @param propertyPath path to specify the property of the target the conditional operator uses
  90334. * @param value the value compared by the conditional operator against the current value of the property
  90335. * @param operator the conditional operator, default ValueCondition.IsEqual
  90336. */
  90337. constructor(actionManager: ActionManager, target: any,
  90338. /** path to specify the property of the target the conditional operator uses */
  90339. propertyPath: string,
  90340. /** the value compared by the conditional operator against the current value of the property */
  90341. value: any,
  90342. /** the conditional operator, default ValueCondition.IsEqual */
  90343. operator?: number);
  90344. /**
  90345. * Compares the given value with the property value for the specified conditional operator
  90346. * @returns the result of the comparison
  90347. */
  90348. isValid(): boolean;
  90349. /**
  90350. * Serialize the ValueCondition into a JSON compatible object
  90351. * @returns serialization object
  90352. */
  90353. serialize(): any;
  90354. /**
  90355. * Gets the name of the conditional operator for the ValueCondition
  90356. * @param operator the conditional operator
  90357. * @returns the name
  90358. */
  90359. static GetOperatorName(operator: number): string;
  90360. }
  90361. /**
  90362. * Defines a predicate condition as an extension of Condition
  90363. */
  90364. export class PredicateCondition extends Condition {
  90365. /** defines the predicate function used to validate the condition */
  90366. predicate: () => boolean;
  90367. /**
  90368. * Internal only - manager for action
  90369. * @hidden
  90370. */
  90371. _actionManager: ActionManager;
  90372. /**
  90373. * Creates a new PredicateCondition
  90374. * @param actionManager manager for the action the condition applies to
  90375. * @param predicate defines the predicate function used to validate the condition
  90376. */
  90377. constructor(actionManager: ActionManager,
  90378. /** defines the predicate function used to validate the condition */
  90379. predicate: () => boolean);
  90380. /**
  90381. * @returns the validity of the predicate condition
  90382. */
  90383. isValid(): boolean;
  90384. }
  90385. /**
  90386. * Defines a state condition as an extension of Condition
  90387. */
  90388. export class StateCondition extends Condition {
  90389. /** Value to compare with target state */
  90390. value: string;
  90391. /**
  90392. * Internal only - manager for action
  90393. * @hidden
  90394. */
  90395. _actionManager: ActionManager;
  90396. /**
  90397. * Internal only
  90398. * @hidden
  90399. */
  90400. private _target;
  90401. /**
  90402. * Creates a new StateCondition
  90403. * @param actionManager manager for the action the condition applies to
  90404. * @param target of the condition
  90405. * @param value to compare with target state
  90406. */
  90407. constructor(actionManager: ActionManager, target: any,
  90408. /** Value to compare with target state */
  90409. value: string);
  90410. /**
  90411. * Gets a boolean indicating if the current condition is met
  90412. * @returns the validity of the state
  90413. */
  90414. isValid(): boolean;
  90415. /**
  90416. * Serialize the StateCondition into a JSON compatible object
  90417. * @returns serialization object
  90418. */
  90419. serialize(): any;
  90420. }
  90421. }
  90422. declare module BABYLON {
  90423. /**
  90424. * This defines an action responsible to toggle a boolean once triggered.
  90425. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90426. */
  90427. export class SwitchBooleanAction extends Action {
  90428. /**
  90429. * The path to the boolean property in the target object
  90430. */
  90431. propertyPath: string;
  90432. private _target;
  90433. private _effectiveTarget;
  90434. private _property;
  90435. /**
  90436. * Instantiate the action
  90437. * @param triggerOptions defines the trigger options
  90438. * @param target defines the object containing the boolean
  90439. * @param propertyPath defines the path to the boolean property in the target object
  90440. * @param condition defines the trigger related conditions
  90441. */
  90442. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90443. /** @hidden */
  90444. _prepare(): void;
  90445. /**
  90446. * Execute the action toggle the boolean value.
  90447. */
  90448. execute(): void;
  90449. /**
  90450. * Serializes the actions and its related information.
  90451. * @param parent defines the object to serialize in
  90452. * @returns the serialized object
  90453. */
  90454. serialize(parent: any): any;
  90455. }
  90456. /**
  90457. * This defines an action responsible to set a the state field of the target
  90458. * to a desired value once triggered.
  90459. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90460. */
  90461. export class SetStateAction extends Action {
  90462. /**
  90463. * The value to store in the state field.
  90464. */
  90465. value: string;
  90466. private _target;
  90467. /**
  90468. * Instantiate the action
  90469. * @param triggerOptions defines the trigger options
  90470. * @param target defines the object containing the state property
  90471. * @param value defines the value to store in the state field
  90472. * @param condition defines the trigger related conditions
  90473. */
  90474. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90475. /**
  90476. * Execute the action and store the value on the target state property.
  90477. */
  90478. execute(): void;
  90479. /**
  90480. * Serializes the actions and its related information.
  90481. * @param parent defines the object to serialize in
  90482. * @returns the serialized object
  90483. */
  90484. serialize(parent: any): any;
  90485. }
  90486. /**
  90487. * This defines an action responsible to set a property of the target
  90488. * to a desired value once triggered.
  90489. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90490. */
  90491. export class SetValueAction extends Action {
  90492. /**
  90493. * The path of the property to set in the target.
  90494. */
  90495. propertyPath: string;
  90496. /**
  90497. * The value to set in the property
  90498. */
  90499. value: any;
  90500. private _target;
  90501. private _effectiveTarget;
  90502. private _property;
  90503. /**
  90504. * Instantiate the action
  90505. * @param triggerOptions defines the trigger options
  90506. * @param target defines the object containing the property
  90507. * @param propertyPath defines the path of the property to set in the target
  90508. * @param value defines the value to set in the property
  90509. * @param condition defines the trigger related conditions
  90510. */
  90511. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90512. /** @hidden */
  90513. _prepare(): void;
  90514. /**
  90515. * Execute the action and set the targetted property to the desired value.
  90516. */
  90517. execute(): void;
  90518. /**
  90519. * Serializes the actions and its related information.
  90520. * @param parent defines the object to serialize in
  90521. * @returns the serialized object
  90522. */
  90523. serialize(parent: any): any;
  90524. }
  90525. /**
  90526. * This defines an action responsible to increment the target value
  90527. * to a desired value once triggered.
  90528. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90529. */
  90530. export class IncrementValueAction extends Action {
  90531. /**
  90532. * The path of the property to increment in the target.
  90533. */
  90534. propertyPath: string;
  90535. /**
  90536. * The value we should increment the property by.
  90537. */
  90538. value: any;
  90539. private _target;
  90540. private _effectiveTarget;
  90541. private _property;
  90542. /**
  90543. * Instantiate the action
  90544. * @param triggerOptions defines the trigger options
  90545. * @param target defines the object containing the property
  90546. * @param propertyPath defines the path of the property to increment in the target
  90547. * @param value defines the value value we should increment the property by
  90548. * @param condition defines the trigger related conditions
  90549. */
  90550. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90551. /** @hidden */
  90552. _prepare(): void;
  90553. /**
  90554. * Execute the action and increment the target of the value amount.
  90555. */
  90556. execute(): void;
  90557. /**
  90558. * Serializes the actions and its related information.
  90559. * @param parent defines the object to serialize in
  90560. * @returns the serialized object
  90561. */
  90562. serialize(parent: any): any;
  90563. }
  90564. /**
  90565. * This defines an action responsible to start an animation once triggered.
  90566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90567. */
  90568. export class PlayAnimationAction extends Action {
  90569. /**
  90570. * Where the animation should start (animation frame)
  90571. */
  90572. from: number;
  90573. /**
  90574. * Where the animation should stop (animation frame)
  90575. */
  90576. to: number;
  90577. /**
  90578. * Define if the animation should loop or stop after the first play.
  90579. */
  90580. loop?: boolean;
  90581. private _target;
  90582. /**
  90583. * Instantiate the action
  90584. * @param triggerOptions defines the trigger options
  90585. * @param target defines the target animation or animation name
  90586. * @param from defines from where the animation should start (animation frame)
  90587. * @param end defines where the animation should stop (animation frame)
  90588. * @param loop defines if the animation should loop or stop after the first play
  90589. * @param condition defines the trigger related conditions
  90590. */
  90591. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90592. /** @hidden */
  90593. _prepare(): void;
  90594. /**
  90595. * Execute the action and play the animation.
  90596. */
  90597. execute(): void;
  90598. /**
  90599. * Serializes the actions and its related information.
  90600. * @param parent defines the object to serialize in
  90601. * @returns the serialized object
  90602. */
  90603. serialize(parent: any): any;
  90604. }
  90605. /**
  90606. * This defines an action responsible to stop an animation once triggered.
  90607. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90608. */
  90609. export class StopAnimationAction extends Action {
  90610. private _target;
  90611. /**
  90612. * Instantiate the action
  90613. * @param triggerOptions defines the trigger options
  90614. * @param target defines the target animation or animation name
  90615. * @param condition defines the trigger related conditions
  90616. */
  90617. constructor(triggerOptions: any, target: any, condition?: Condition);
  90618. /** @hidden */
  90619. _prepare(): void;
  90620. /**
  90621. * Execute the action and stop the animation.
  90622. */
  90623. execute(): void;
  90624. /**
  90625. * Serializes the actions and its related information.
  90626. * @param parent defines the object to serialize in
  90627. * @returns the serialized object
  90628. */
  90629. serialize(parent: any): any;
  90630. }
  90631. /**
  90632. * This defines an action responsible that does nothing once triggered.
  90633. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90634. */
  90635. export class DoNothingAction extends Action {
  90636. /**
  90637. * Instantiate the action
  90638. * @param triggerOptions defines the trigger options
  90639. * @param condition defines the trigger related conditions
  90640. */
  90641. constructor(triggerOptions?: any, condition?: Condition);
  90642. /**
  90643. * Execute the action and do nothing.
  90644. */
  90645. execute(): void;
  90646. /**
  90647. * Serializes the actions and its related information.
  90648. * @param parent defines the object to serialize in
  90649. * @returns the serialized object
  90650. */
  90651. serialize(parent: any): any;
  90652. }
  90653. /**
  90654. * This defines an action responsible to trigger several actions once triggered.
  90655. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90656. */
  90657. export class CombineAction extends Action {
  90658. /**
  90659. * The list of aggregated animations to run.
  90660. */
  90661. children: Action[];
  90662. /**
  90663. * Instantiate the action
  90664. * @param triggerOptions defines the trigger options
  90665. * @param children defines the list of aggregated animations to run
  90666. * @param condition defines the trigger related conditions
  90667. */
  90668. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90669. /** @hidden */
  90670. _prepare(): void;
  90671. /**
  90672. * Execute the action and executes all the aggregated actions.
  90673. */
  90674. execute(evt: ActionEvent): void;
  90675. /**
  90676. * Serializes the actions and its related information.
  90677. * @param parent defines the object to serialize in
  90678. * @returns the serialized object
  90679. */
  90680. serialize(parent: any): any;
  90681. }
  90682. /**
  90683. * This defines an action responsible to run code (external event) once triggered.
  90684. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90685. */
  90686. export class ExecuteCodeAction extends Action {
  90687. /**
  90688. * The callback function to run.
  90689. */
  90690. func: (evt: ActionEvent) => void;
  90691. /**
  90692. * Instantiate the action
  90693. * @param triggerOptions defines the trigger options
  90694. * @param func defines the callback function to run
  90695. * @param condition defines the trigger related conditions
  90696. */
  90697. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90698. /**
  90699. * Execute the action and run the attached code.
  90700. */
  90701. execute(evt: ActionEvent): void;
  90702. }
  90703. /**
  90704. * This defines an action responsible to set the parent property of the target once triggered.
  90705. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90706. */
  90707. export class SetParentAction extends Action {
  90708. private _parent;
  90709. private _target;
  90710. /**
  90711. * Instantiate the action
  90712. * @param triggerOptions defines the trigger options
  90713. * @param target defines the target containing the parent property
  90714. * @param parent defines from where the animation should start (animation frame)
  90715. * @param condition defines the trigger related conditions
  90716. */
  90717. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90718. /** @hidden */
  90719. _prepare(): void;
  90720. /**
  90721. * Execute the action and set the parent property.
  90722. */
  90723. execute(): void;
  90724. /**
  90725. * Serializes the actions and its related information.
  90726. * @param parent defines the object to serialize in
  90727. * @returns the serialized object
  90728. */
  90729. serialize(parent: any): any;
  90730. }
  90731. }
  90732. declare module BABYLON {
  90733. /**
  90734. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90735. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90736. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90737. */
  90738. export class ActionManager extends AbstractActionManager {
  90739. /**
  90740. * Nothing
  90741. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90742. */
  90743. static readonly NothingTrigger: number;
  90744. /**
  90745. * On pick
  90746. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90747. */
  90748. static readonly OnPickTrigger: number;
  90749. /**
  90750. * On left pick
  90751. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90752. */
  90753. static readonly OnLeftPickTrigger: number;
  90754. /**
  90755. * On right pick
  90756. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90757. */
  90758. static readonly OnRightPickTrigger: number;
  90759. /**
  90760. * On center pick
  90761. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90762. */
  90763. static readonly OnCenterPickTrigger: number;
  90764. /**
  90765. * On pick down
  90766. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90767. */
  90768. static readonly OnPickDownTrigger: number;
  90769. /**
  90770. * On double pick
  90771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90772. */
  90773. static readonly OnDoublePickTrigger: number;
  90774. /**
  90775. * On pick up
  90776. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90777. */
  90778. static readonly OnPickUpTrigger: number;
  90779. /**
  90780. * On pick out.
  90781. * This trigger will only be raised if you also declared a OnPickDown
  90782. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90783. */
  90784. static readonly OnPickOutTrigger: number;
  90785. /**
  90786. * On long press
  90787. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90788. */
  90789. static readonly OnLongPressTrigger: number;
  90790. /**
  90791. * On pointer over
  90792. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90793. */
  90794. static readonly OnPointerOverTrigger: number;
  90795. /**
  90796. * On pointer out
  90797. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90798. */
  90799. static readonly OnPointerOutTrigger: number;
  90800. /**
  90801. * On every frame
  90802. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90803. */
  90804. static readonly OnEveryFrameTrigger: number;
  90805. /**
  90806. * On intersection enter
  90807. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90808. */
  90809. static readonly OnIntersectionEnterTrigger: number;
  90810. /**
  90811. * On intersection exit
  90812. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90813. */
  90814. static readonly OnIntersectionExitTrigger: number;
  90815. /**
  90816. * On key down
  90817. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90818. */
  90819. static readonly OnKeyDownTrigger: number;
  90820. /**
  90821. * On key up
  90822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90823. */
  90824. static readonly OnKeyUpTrigger: number;
  90825. private _scene;
  90826. /**
  90827. * Creates a new action manager
  90828. * @param scene defines the hosting scene
  90829. */
  90830. constructor(scene: Scene);
  90831. /**
  90832. * Releases all associated resources
  90833. */
  90834. dispose(): void;
  90835. /**
  90836. * Gets hosting scene
  90837. * @returns the hosting scene
  90838. */
  90839. getScene(): Scene;
  90840. /**
  90841. * Does this action manager handles actions of any of the given triggers
  90842. * @param triggers defines the triggers to be tested
  90843. * @return a boolean indicating whether one (or more) of the triggers is handled
  90844. */
  90845. hasSpecificTriggers(triggers: number[]): boolean;
  90846. /**
  90847. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90848. * speed.
  90849. * @param triggerA defines the trigger to be tested
  90850. * @param triggerB defines the trigger to be tested
  90851. * @return a boolean indicating whether one (or more) of the triggers is handled
  90852. */
  90853. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90854. /**
  90855. * Does this action manager handles actions of a given trigger
  90856. * @param trigger defines the trigger to be tested
  90857. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90858. * @return whether the trigger is handled
  90859. */
  90860. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90861. /**
  90862. * Does this action manager has pointer triggers
  90863. */
  90864. get hasPointerTriggers(): boolean;
  90865. /**
  90866. * Does this action manager has pick triggers
  90867. */
  90868. get hasPickTriggers(): boolean;
  90869. /**
  90870. * Registers an action to this action manager
  90871. * @param action defines the action to be registered
  90872. * @return the action amended (prepared) after registration
  90873. */
  90874. registerAction(action: IAction): Nullable<IAction>;
  90875. /**
  90876. * Unregisters an action to this action manager
  90877. * @param action defines the action to be unregistered
  90878. * @return a boolean indicating whether the action has been unregistered
  90879. */
  90880. unregisterAction(action: IAction): Boolean;
  90881. /**
  90882. * Process a specific trigger
  90883. * @param trigger defines the trigger to process
  90884. * @param evt defines the event details to be processed
  90885. */
  90886. processTrigger(trigger: number, evt?: IActionEvent): void;
  90887. /** @hidden */
  90888. _getEffectiveTarget(target: any, propertyPath: string): any;
  90889. /** @hidden */
  90890. _getProperty(propertyPath: string): string;
  90891. /**
  90892. * Serialize this manager to a JSON object
  90893. * @param name defines the property name to store this manager
  90894. * @returns a JSON representation of this manager
  90895. */
  90896. serialize(name: string): any;
  90897. /**
  90898. * Creates a new ActionManager from a JSON data
  90899. * @param parsedActions defines the JSON data to read from
  90900. * @param object defines the hosting mesh
  90901. * @param scene defines the hosting scene
  90902. */
  90903. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90904. /**
  90905. * Get a trigger name by index
  90906. * @param trigger defines the trigger index
  90907. * @returns a trigger name
  90908. */
  90909. static GetTriggerName(trigger: number): string;
  90910. }
  90911. }
  90912. declare module BABYLON {
  90913. /**
  90914. * Class used to represent a sprite
  90915. * @see https://doc.babylonjs.com/babylon101/sprites
  90916. */
  90917. export class Sprite implements IAnimatable {
  90918. /** defines the name */
  90919. name: string;
  90920. /** Gets or sets the current world position */
  90921. position: Vector3;
  90922. /** Gets or sets the main color */
  90923. color: Color4;
  90924. /** Gets or sets the width */
  90925. width: number;
  90926. /** Gets or sets the height */
  90927. height: number;
  90928. /** Gets or sets rotation angle */
  90929. angle: number;
  90930. /** Gets or sets the cell index in the sprite sheet */
  90931. cellIndex: number;
  90932. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90933. cellRef: string;
  90934. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90935. invertU: boolean;
  90936. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90937. invertV: boolean;
  90938. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90939. disposeWhenFinishedAnimating: boolean;
  90940. /** Gets the list of attached animations */
  90941. animations: Nullable<Array<Animation>>;
  90942. /** Gets or sets a boolean indicating if the sprite can be picked */
  90943. isPickable: boolean;
  90944. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90945. useAlphaForPicking: boolean;
  90946. /** @hidden */
  90947. _xOffset: number;
  90948. /** @hidden */
  90949. _yOffset: number;
  90950. /** @hidden */
  90951. _xSize: number;
  90952. /** @hidden */
  90953. _ySize: number;
  90954. /**
  90955. * Gets or sets the associated action manager
  90956. */
  90957. actionManager: Nullable<ActionManager>;
  90958. /**
  90959. * An event triggered when the control has been disposed
  90960. */
  90961. onDisposeObservable: Observable<Sprite>;
  90962. private _animationStarted;
  90963. private _loopAnimation;
  90964. private _fromIndex;
  90965. private _toIndex;
  90966. private _delay;
  90967. private _direction;
  90968. private _manager;
  90969. private _time;
  90970. private _onAnimationEnd;
  90971. /**
  90972. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90973. */
  90974. isVisible: boolean;
  90975. /**
  90976. * Gets or sets the sprite size
  90977. */
  90978. get size(): number;
  90979. set size(value: number);
  90980. /**
  90981. * Returns a boolean indicating if the animation is started
  90982. */
  90983. get animationStarted(): boolean;
  90984. /**
  90985. * Gets or sets the unique id of the sprite
  90986. */
  90987. uniqueId: number;
  90988. /**
  90989. * Gets the manager of this sprite
  90990. */
  90991. get manager(): ISpriteManager;
  90992. /**
  90993. * Creates a new Sprite
  90994. * @param name defines the name
  90995. * @param manager defines the manager
  90996. */
  90997. constructor(
  90998. /** defines the name */
  90999. name: string, manager: ISpriteManager);
  91000. /**
  91001. * Returns the string "Sprite"
  91002. * @returns "Sprite"
  91003. */
  91004. getClassName(): string;
  91005. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91006. get fromIndex(): number;
  91007. set fromIndex(value: number);
  91008. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91009. get toIndex(): number;
  91010. set toIndex(value: number);
  91011. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91012. get loopAnimation(): boolean;
  91013. set loopAnimation(value: boolean);
  91014. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91015. get delay(): number;
  91016. set delay(value: number);
  91017. /**
  91018. * Starts an animation
  91019. * @param from defines the initial key
  91020. * @param to defines the end key
  91021. * @param loop defines if the animation must loop
  91022. * @param delay defines the start delay (in ms)
  91023. * @param onAnimationEnd defines a callback to call when animation ends
  91024. */
  91025. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91026. /** Stops current animation (if any) */
  91027. stopAnimation(): void;
  91028. /** @hidden */
  91029. _animate(deltaTime: number): void;
  91030. /** Release associated resources */
  91031. dispose(): void;
  91032. /**
  91033. * Serializes the sprite to a JSON object
  91034. * @returns the JSON object
  91035. */
  91036. serialize(): any;
  91037. /**
  91038. * Parses a JSON object to create a new sprite
  91039. * @param parsedSprite The JSON object to parse
  91040. * @param manager defines the hosting manager
  91041. * @returns the new sprite
  91042. */
  91043. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91044. }
  91045. }
  91046. declare module BABYLON {
  91047. /**
  91048. * Information about the result of picking within a scene
  91049. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91050. */
  91051. export class PickingInfo {
  91052. /** @hidden */
  91053. _pickingUnavailable: boolean;
  91054. /**
  91055. * If the pick collided with an object
  91056. */
  91057. hit: boolean;
  91058. /**
  91059. * Distance away where the pick collided
  91060. */
  91061. distance: number;
  91062. /**
  91063. * The location of pick collision
  91064. */
  91065. pickedPoint: Nullable<Vector3>;
  91066. /**
  91067. * The mesh corresponding the the pick collision
  91068. */
  91069. pickedMesh: Nullable<AbstractMesh>;
  91070. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91071. bu: number;
  91072. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91073. bv: number;
  91074. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91075. faceId: number;
  91076. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91077. subMeshFaceId: number;
  91078. /** Id of the the submesh that was picked */
  91079. subMeshId: number;
  91080. /** If a sprite was picked, this will be the sprite the pick collided with */
  91081. pickedSprite: Nullable<Sprite>;
  91082. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91083. thinInstanceIndex: number;
  91084. /**
  91085. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91086. */
  91087. originMesh: Nullable<AbstractMesh>;
  91088. /**
  91089. * The ray that was used to perform the picking.
  91090. */
  91091. ray: Nullable<Ray>;
  91092. /**
  91093. * Gets the normal correspodning to the face the pick collided with
  91094. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91095. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91096. * @returns The normal correspodning to the face the pick collided with
  91097. */
  91098. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91099. /**
  91100. * Gets the texture coordinates of where the pick occured
  91101. * @returns the vector containing the coordnates of the texture
  91102. */
  91103. getTextureCoordinates(): Nullable<Vector2>;
  91104. }
  91105. }
  91106. declare module BABYLON {
  91107. /**
  91108. * Class representing a ray with position and direction
  91109. */
  91110. export class Ray {
  91111. /** origin point */
  91112. origin: Vector3;
  91113. /** direction */
  91114. direction: Vector3;
  91115. /** length of the ray */
  91116. length: number;
  91117. private static readonly _TmpVector3;
  91118. private _tmpRay;
  91119. /**
  91120. * Creates a new ray
  91121. * @param origin origin point
  91122. * @param direction direction
  91123. * @param length length of the ray
  91124. */
  91125. constructor(
  91126. /** origin point */
  91127. origin: Vector3,
  91128. /** direction */
  91129. direction: Vector3,
  91130. /** length of the ray */
  91131. length?: number);
  91132. /**
  91133. * Checks if the ray intersects a box
  91134. * This does not account for the ray lenght by design to improve perfs.
  91135. * @param minimum bound of the box
  91136. * @param maximum bound of the box
  91137. * @param intersectionTreshold extra extend to be added to the box in all direction
  91138. * @returns if the box was hit
  91139. */
  91140. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91141. /**
  91142. * Checks if the ray intersects a box
  91143. * This does not account for the ray lenght by design to improve perfs.
  91144. * @param box the bounding box to check
  91145. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91146. * @returns if the box was hit
  91147. */
  91148. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91149. /**
  91150. * If the ray hits a sphere
  91151. * @param sphere the bounding sphere to check
  91152. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91153. * @returns true if it hits the sphere
  91154. */
  91155. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91156. /**
  91157. * If the ray hits a triange
  91158. * @param vertex0 triangle vertex
  91159. * @param vertex1 triangle vertex
  91160. * @param vertex2 triangle vertex
  91161. * @returns intersection information if hit
  91162. */
  91163. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91164. /**
  91165. * Checks if ray intersects a plane
  91166. * @param plane the plane to check
  91167. * @returns the distance away it was hit
  91168. */
  91169. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91170. /**
  91171. * Calculate the intercept of a ray on a given axis
  91172. * @param axis to check 'x' | 'y' | 'z'
  91173. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91174. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91175. */
  91176. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91177. /**
  91178. * Checks if ray intersects a mesh
  91179. * @param mesh the mesh to check
  91180. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91181. * @returns picking info of the intersecton
  91182. */
  91183. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91184. /**
  91185. * Checks if ray intersects a mesh
  91186. * @param meshes the meshes to check
  91187. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91188. * @param results array to store result in
  91189. * @returns Array of picking infos
  91190. */
  91191. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91192. private _comparePickingInfo;
  91193. private static smallnum;
  91194. private static rayl;
  91195. /**
  91196. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91197. * @param sega the first point of the segment to test the intersection against
  91198. * @param segb the second point of the segment to test the intersection against
  91199. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91200. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91201. */
  91202. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91203. /**
  91204. * Update the ray from viewport position
  91205. * @param x position
  91206. * @param y y position
  91207. * @param viewportWidth viewport width
  91208. * @param viewportHeight viewport height
  91209. * @param world world matrix
  91210. * @param view view matrix
  91211. * @param projection projection matrix
  91212. * @returns this ray updated
  91213. */
  91214. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91215. /**
  91216. * Creates a ray with origin and direction of 0,0,0
  91217. * @returns the new ray
  91218. */
  91219. static Zero(): Ray;
  91220. /**
  91221. * Creates a new ray from screen space and viewport
  91222. * @param x position
  91223. * @param y y position
  91224. * @param viewportWidth viewport width
  91225. * @param viewportHeight viewport height
  91226. * @param world world matrix
  91227. * @param view view matrix
  91228. * @param projection projection matrix
  91229. * @returns new ray
  91230. */
  91231. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91232. /**
  91233. * 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
  91234. * transformed to the given world matrix.
  91235. * @param origin The origin point
  91236. * @param end The end point
  91237. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91238. * @returns the new ray
  91239. */
  91240. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91241. /**
  91242. * Transforms a ray by a matrix
  91243. * @param ray ray to transform
  91244. * @param matrix matrix to apply
  91245. * @returns the resulting new ray
  91246. */
  91247. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91248. /**
  91249. * Transforms a ray by a matrix
  91250. * @param ray ray to transform
  91251. * @param matrix matrix to apply
  91252. * @param result ray to store result in
  91253. */
  91254. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91255. /**
  91256. * Unproject a ray from screen space to object space
  91257. * @param sourceX defines the screen space x coordinate to use
  91258. * @param sourceY defines the screen space y coordinate to use
  91259. * @param viewportWidth defines the current width of the viewport
  91260. * @param viewportHeight defines the current height of the viewport
  91261. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91262. * @param view defines the view matrix to use
  91263. * @param projection defines the projection matrix to use
  91264. */
  91265. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91266. }
  91267. /**
  91268. * Type used to define predicate used to select faces when a mesh intersection is detected
  91269. */
  91270. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91271. interface Scene {
  91272. /** @hidden */
  91273. _tempPickingRay: Nullable<Ray>;
  91274. /** @hidden */
  91275. _cachedRayForTransform: Ray;
  91276. /** @hidden */
  91277. _pickWithRayInverseMatrix: Matrix;
  91278. /** @hidden */
  91279. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91280. /** @hidden */
  91281. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91282. /** @hidden */
  91283. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91284. }
  91285. }
  91286. declare module BABYLON {
  91287. /**
  91288. * Groups all the scene component constants in one place to ease maintenance.
  91289. * @hidden
  91290. */
  91291. export class SceneComponentConstants {
  91292. static readonly NAME_EFFECTLAYER: string;
  91293. static readonly NAME_LAYER: string;
  91294. static readonly NAME_LENSFLARESYSTEM: string;
  91295. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91296. static readonly NAME_PARTICLESYSTEM: string;
  91297. static readonly NAME_GAMEPAD: string;
  91298. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91299. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91300. static readonly NAME_PREPASSRENDERER: string;
  91301. static readonly NAME_DEPTHRENDERER: string;
  91302. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91303. static readonly NAME_SPRITE: string;
  91304. static readonly NAME_SUBSURFACE: string;
  91305. static readonly NAME_OUTLINERENDERER: string;
  91306. static readonly NAME_PROCEDURALTEXTURE: string;
  91307. static readonly NAME_SHADOWGENERATOR: string;
  91308. static readonly NAME_OCTREE: string;
  91309. static readonly NAME_PHYSICSENGINE: string;
  91310. static readonly NAME_AUDIO: string;
  91311. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91312. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91313. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91314. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91315. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91316. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91317. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91318. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91319. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91320. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91321. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91322. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91323. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91324. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91325. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91326. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91327. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91328. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91329. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91330. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91331. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91332. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91333. static readonly STEP_AFTERRENDER_AUDIO: number;
  91334. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91335. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91336. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91337. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91338. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91339. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91340. static readonly STEP_POINTERMOVE_SPRITE: number;
  91341. static readonly STEP_POINTERDOWN_SPRITE: number;
  91342. static readonly STEP_POINTERUP_SPRITE: number;
  91343. }
  91344. /**
  91345. * This represents a scene component.
  91346. *
  91347. * This is used to decouple the dependency the scene is having on the different workloads like
  91348. * layers, post processes...
  91349. */
  91350. export interface ISceneComponent {
  91351. /**
  91352. * The name of the component. Each component must have a unique name.
  91353. */
  91354. name: string;
  91355. /**
  91356. * The scene the component belongs to.
  91357. */
  91358. scene: Scene;
  91359. /**
  91360. * Register the component to one instance of a scene.
  91361. */
  91362. register(): void;
  91363. /**
  91364. * Rebuilds the elements related to this component in case of
  91365. * context lost for instance.
  91366. */
  91367. rebuild(): void;
  91368. /**
  91369. * Disposes the component and the associated ressources.
  91370. */
  91371. dispose(): void;
  91372. }
  91373. /**
  91374. * This represents a SERIALIZABLE scene component.
  91375. *
  91376. * This extends Scene Component to add Serialization methods on top.
  91377. */
  91378. export interface ISceneSerializableComponent extends ISceneComponent {
  91379. /**
  91380. * Adds all the elements from the container to the scene
  91381. * @param container the container holding the elements
  91382. */
  91383. addFromContainer(container: AbstractScene): void;
  91384. /**
  91385. * Removes all the elements in the container from the scene
  91386. * @param container contains the elements to remove
  91387. * @param dispose if the removed element should be disposed (default: false)
  91388. */
  91389. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91390. /**
  91391. * Serializes the component data to the specified json object
  91392. * @param serializationObject The object to serialize to
  91393. */
  91394. serialize(serializationObject: any): void;
  91395. }
  91396. /**
  91397. * Strong typing of a Mesh related stage step action
  91398. */
  91399. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91400. /**
  91401. * Strong typing of a Evaluate Sub Mesh related stage step action
  91402. */
  91403. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91404. /**
  91405. * Strong typing of a Active Mesh related stage step action
  91406. */
  91407. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91408. /**
  91409. * Strong typing of a Camera related stage step action
  91410. */
  91411. export type CameraStageAction = (camera: Camera) => void;
  91412. /**
  91413. * Strong typing of a Camera Frame buffer related stage step action
  91414. */
  91415. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91416. /**
  91417. * Strong typing of a Render Target related stage step action
  91418. */
  91419. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91420. /**
  91421. * Strong typing of a RenderingGroup related stage step action
  91422. */
  91423. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91424. /**
  91425. * Strong typing of a Mesh Render related stage step action
  91426. */
  91427. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91428. /**
  91429. * Strong typing of a simple stage step action
  91430. */
  91431. export type SimpleStageAction = () => void;
  91432. /**
  91433. * Strong typing of a render target action.
  91434. */
  91435. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91436. /**
  91437. * Strong typing of a pointer move action.
  91438. */
  91439. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91440. /**
  91441. * Strong typing of a pointer up/down action.
  91442. */
  91443. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91444. /**
  91445. * Representation of a stage in the scene (Basically a list of ordered steps)
  91446. * @hidden
  91447. */
  91448. export class Stage<T extends Function> extends Array<{
  91449. index: number;
  91450. component: ISceneComponent;
  91451. action: T;
  91452. }> {
  91453. /**
  91454. * Hide ctor from the rest of the world.
  91455. * @param items The items to add.
  91456. */
  91457. private constructor();
  91458. /**
  91459. * Creates a new Stage.
  91460. * @returns A new instance of a Stage
  91461. */
  91462. static Create<T extends Function>(): Stage<T>;
  91463. /**
  91464. * Registers a step in an ordered way in the targeted stage.
  91465. * @param index Defines the position to register the step in
  91466. * @param component Defines the component attached to the step
  91467. * @param action Defines the action to launch during the step
  91468. */
  91469. registerStep(index: number, component: ISceneComponent, action: T): void;
  91470. /**
  91471. * Clears all the steps from the stage.
  91472. */
  91473. clear(): void;
  91474. }
  91475. }
  91476. declare module BABYLON {
  91477. interface Scene {
  91478. /** @hidden */
  91479. _pointerOverSprite: Nullable<Sprite>;
  91480. /** @hidden */
  91481. _pickedDownSprite: Nullable<Sprite>;
  91482. /** @hidden */
  91483. _tempSpritePickingRay: Nullable<Ray>;
  91484. /**
  91485. * All of the sprite managers added to this scene
  91486. * @see https://doc.babylonjs.com/babylon101/sprites
  91487. */
  91488. spriteManagers: Array<ISpriteManager>;
  91489. /**
  91490. * An event triggered when sprites rendering is about to start
  91491. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91492. */
  91493. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91494. /**
  91495. * An event triggered when sprites rendering is done
  91496. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91497. */
  91498. onAfterSpritesRenderingObservable: Observable<Scene>;
  91499. /** @hidden */
  91500. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91501. /** Launch a ray to try to pick a sprite in the scene
  91502. * @param x position on screen
  91503. * @param y position on screen
  91504. * @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
  91505. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91506. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91507. * @returns a PickingInfo
  91508. */
  91509. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91510. /** Use the given ray to pick a sprite in the scene
  91511. * @param ray The ray (in world space) to use to pick meshes
  91512. * @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
  91513. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91514. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91515. * @returns a PickingInfo
  91516. */
  91517. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91518. /** @hidden */
  91519. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91520. /** Launch a ray to try to pick sprites in the scene
  91521. * @param x position on screen
  91522. * @param y position on screen
  91523. * @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
  91524. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91525. * @returns a PickingInfo array
  91526. */
  91527. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91528. /** Use the given ray to pick sprites in the scene
  91529. * @param ray The ray (in world space) to use to pick meshes
  91530. * @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
  91531. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91532. * @returns a PickingInfo array
  91533. */
  91534. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91535. /**
  91536. * Force the sprite under the pointer
  91537. * @param sprite defines the sprite to use
  91538. */
  91539. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91540. /**
  91541. * Gets the sprite under the pointer
  91542. * @returns a Sprite or null if no sprite is under the pointer
  91543. */
  91544. getPointerOverSprite(): Nullable<Sprite>;
  91545. }
  91546. /**
  91547. * Defines the sprite scene component responsible to manage sprites
  91548. * in a given scene.
  91549. */
  91550. export class SpriteSceneComponent implements ISceneComponent {
  91551. /**
  91552. * The component name helpfull to identify the component in the list of scene components.
  91553. */
  91554. readonly name: string;
  91555. /**
  91556. * The scene the component belongs to.
  91557. */
  91558. scene: Scene;
  91559. /** @hidden */
  91560. private _spritePredicate;
  91561. /**
  91562. * Creates a new instance of the component for the given scene
  91563. * @param scene Defines the scene to register the component in
  91564. */
  91565. constructor(scene: Scene);
  91566. /**
  91567. * Registers the component in a given scene
  91568. */
  91569. register(): void;
  91570. /**
  91571. * Rebuilds the elements related to this component in case of
  91572. * context lost for instance.
  91573. */
  91574. rebuild(): void;
  91575. /**
  91576. * Disposes the component and the associated ressources.
  91577. */
  91578. dispose(): void;
  91579. private _pickSpriteButKeepRay;
  91580. private _pointerMove;
  91581. private _pointerDown;
  91582. private _pointerUp;
  91583. }
  91584. }
  91585. declare module BABYLON {
  91586. /** @hidden */
  91587. export var fogFragmentDeclaration: {
  91588. name: string;
  91589. shader: string;
  91590. };
  91591. }
  91592. declare module BABYLON {
  91593. /** @hidden */
  91594. export var fogFragment: {
  91595. name: string;
  91596. shader: string;
  91597. };
  91598. }
  91599. declare module BABYLON {
  91600. /** @hidden */
  91601. export var imageProcessingCompatibility: {
  91602. name: string;
  91603. shader: string;
  91604. };
  91605. }
  91606. declare module BABYLON {
  91607. /** @hidden */
  91608. export var spritesPixelShader: {
  91609. name: string;
  91610. shader: string;
  91611. };
  91612. }
  91613. declare module BABYLON {
  91614. /** @hidden */
  91615. export var fogVertexDeclaration: {
  91616. name: string;
  91617. shader: string;
  91618. };
  91619. }
  91620. declare module BABYLON {
  91621. /** @hidden */
  91622. export var spritesVertexShader: {
  91623. name: string;
  91624. shader: string;
  91625. };
  91626. }
  91627. declare module BABYLON {
  91628. /**
  91629. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91630. */
  91631. export interface ISpriteManager extends IDisposable {
  91632. /**
  91633. * Gets manager's name
  91634. */
  91635. name: string;
  91636. /**
  91637. * Restricts the camera to viewing objects with the same layerMask.
  91638. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91639. */
  91640. layerMask: number;
  91641. /**
  91642. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91643. */
  91644. isPickable: boolean;
  91645. /**
  91646. * Gets the hosting scene
  91647. */
  91648. scene: Scene;
  91649. /**
  91650. * Specifies the rendering group id for this mesh (0 by default)
  91651. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91652. */
  91653. renderingGroupId: number;
  91654. /**
  91655. * Defines the list of sprites managed by the manager.
  91656. */
  91657. sprites: Array<Sprite>;
  91658. /**
  91659. * Gets or sets the spritesheet texture
  91660. */
  91661. texture: Texture;
  91662. /** Defines the default width of a cell in the spritesheet */
  91663. cellWidth: number;
  91664. /** Defines the default height of a cell in the spritesheet */
  91665. cellHeight: number;
  91666. /**
  91667. * Tests the intersection of a sprite with a specific ray.
  91668. * @param ray The ray we are sending to test the collision
  91669. * @param camera The camera space we are sending rays in
  91670. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91671. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91672. * @returns picking info or null.
  91673. */
  91674. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91675. /**
  91676. * Intersects the sprites with a ray
  91677. * @param ray defines the ray to intersect with
  91678. * @param camera defines the current active camera
  91679. * @param predicate defines a predicate used to select candidate sprites
  91680. * @returns null if no hit or a PickingInfo array
  91681. */
  91682. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91683. /**
  91684. * Renders the list of sprites on screen.
  91685. */
  91686. render(): void;
  91687. }
  91688. /**
  91689. * Class used to manage multiple sprites on the same spritesheet
  91690. * @see https://doc.babylonjs.com/babylon101/sprites
  91691. */
  91692. export class SpriteManager implements ISpriteManager {
  91693. /** defines the manager's name */
  91694. name: string;
  91695. /** Define the Url to load snippets */
  91696. static SnippetUrl: string;
  91697. /** Snippet ID if the manager was created from the snippet server */
  91698. snippetId: string;
  91699. /** Gets the list of sprites */
  91700. sprites: Sprite[];
  91701. /** Gets or sets the rendering group id (0 by default) */
  91702. renderingGroupId: number;
  91703. /** Gets or sets camera layer mask */
  91704. layerMask: number;
  91705. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91706. fogEnabled: boolean;
  91707. /** Gets or sets a boolean indicating if the sprites are pickable */
  91708. isPickable: boolean;
  91709. /** Defines the default width of a cell in the spritesheet */
  91710. cellWidth: number;
  91711. /** Defines the default height of a cell in the spritesheet */
  91712. cellHeight: number;
  91713. /** Associative array from JSON sprite data file */
  91714. private _cellData;
  91715. /** Array of sprite names from JSON sprite data file */
  91716. private _spriteMap;
  91717. /** True when packed cell data from JSON file is ready*/
  91718. private _packedAndReady;
  91719. private _textureContent;
  91720. private _useInstancing;
  91721. /**
  91722. * An event triggered when the manager is disposed.
  91723. */
  91724. onDisposeObservable: Observable<SpriteManager>;
  91725. private _onDisposeObserver;
  91726. /**
  91727. * Callback called when the manager is disposed
  91728. */
  91729. set onDispose(callback: () => void);
  91730. private _capacity;
  91731. private _fromPacked;
  91732. private _spriteTexture;
  91733. private _epsilon;
  91734. private _scene;
  91735. private _vertexData;
  91736. private _buffer;
  91737. private _vertexBuffers;
  91738. private _spriteBuffer;
  91739. private _indexBuffer;
  91740. private _effectBase;
  91741. private _effectFog;
  91742. private _vertexBufferSize;
  91743. /**
  91744. * Gets or sets the unique id of the sprite
  91745. */
  91746. uniqueId: number;
  91747. /**
  91748. * Gets the array of sprites
  91749. */
  91750. get children(): Sprite[];
  91751. /**
  91752. * Gets the hosting scene
  91753. */
  91754. get scene(): Scene;
  91755. /**
  91756. * Gets the capacity of the manager
  91757. */
  91758. get capacity(): number;
  91759. /**
  91760. * Gets or sets the spritesheet texture
  91761. */
  91762. get texture(): Texture;
  91763. set texture(value: Texture);
  91764. private _blendMode;
  91765. /**
  91766. * Blend mode use to render the particle, it can be any of
  91767. * the static Constants.ALPHA_x properties provided in this class.
  91768. * Default value is Constants.ALPHA_COMBINE
  91769. */
  91770. get blendMode(): number;
  91771. set blendMode(blendMode: number);
  91772. /** Disables writing to the depth buffer when rendering the sprites.
  91773. * It can be handy to disable depth writing when using textures without alpha channel
  91774. * and setting some specific blend modes.
  91775. */
  91776. disableDepthWrite: boolean;
  91777. /**
  91778. * Creates a new sprite manager
  91779. * @param name defines the manager's name
  91780. * @param imgUrl defines the sprite sheet url
  91781. * @param capacity defines the maximum allowed number of sprites
  91782. * @param cellSize defines the size of a sprite cell
  91783. * @param scene defines the hosting scene
  91784. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91785. * @param samplingMode defines the smapling mode to use with spritesheet
  91786. * @param fromPacked set to false; do not alter
  91787. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91788. */
  91789. constructor(
  91790. /** defines the manager's name */
  91791. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91792. /**
  91793. * Returns the string "SpriteManager"
  91794. * @returns "SpriteManager"
  91795. */
  91796. getClassName(): string;
  91797. private _makePacked;
  91798. private _appendSpriteVertex;
  91799. private _checkTextureAlpha;
  91800. /**
  91801. * Intersects the sprites with a ray
  91802. * @param ray defines the ray to intersect with
  91803. * @param camera defines the current active camera
  91804. * @param predicate defines a predicate used to select candidate sprites
  91805. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91806. * @returns null if no hit or a PickingInfo
  91807. */
  91808. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91809. /**
  91810. * Intersects the sprites with a ray
  91811. * @param ray defines the ray to intersect with
  91812. * @param camera defines the current active camera
  91813. * @param predicate defines a predicate used to select candidate sprites
  91814. * @returns null if no hit or a PickingInfo array
  91815. */
  91816. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91817. /**
  91818. * Render all child sprites
  91819. */
  91820. render(): void;
  91821. /**
  91822. * Release associated resources
  91823. */
  91824. dispose(): void;
  91825. /**
  91826. * Serializes the sprite manager to a JSON object
  91827. * @param serializeTexture defines if the texture must be serialized as well
  91828. * @returns the JSON object
  91829. */
  91830. serialize(serializeTexture?: boolean): any;
  91831. /**
  91832. * Parses a JSON object to create a new sprite manager.
  91833. * @param parsedManager The JSON object to parse
  91834. * @param scene The scene to create the sprite managerin
  91835. * @param rootUrl The root url to use to load external dependencies like texture
  91836. * @returns the new sprite manager
  91837. */
  91838. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91839. /**
  91840. * Creates a sprite manager from a snippet saved in a remote file
  91841. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91842. * @param url defines the url to load from
  91843. * @param scene defines the hosting scene
  91844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91845. * @returns a promise that will resolve to the new sprite manager
  91846. */
  91847. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91848. /**
  91849. * Creates a sprite manager from a snippet saved by the sprite editor
  91850. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91851. * @param scene defines the hosting scene
  91852. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91853. * @returns a promise that will resolve to the new sprite manager
  91854. */
  91855. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91856. }
  91857. }
  91858. declare module BABYLON {
  91859. /** Interface used by value gradients (color, factor, ...) */
  91860. export interface IValueGradient {
  91861. /**
  91862. * Gets or sets the gradient value (between 0 and 1)
  91863. */
  91864. gradient: number;
  91865. }
  91866. /** Class used to store color4 gradient */
  91867. export class ColorGradient implements IValueGradient {
  91868. /**
  91869. * Gets or sets the gradient value (between 0 and 1)
  91870. */
  91871. gradient: number;
  91872. /**
  91873. * Gets or sets first associated color
  91874. */
  91875. color1: Color4;
  91876. /**
  91877. * Gets or sets second associated color
  91878. */
  91879. color2?: Color4 | undefined;
  91880. /**
  91881. * Creates a new color4 gradient
  91882. * @param gradient gets or sets the gradient value (between 0 and 1)
  91883. * @param color1 gets or sets first associated color
  91884. * @param color2 gets or sets first second color
  91885. */
  91886. constructor(
  91887. /**
  91888. * Gets or sets the gradient value (between 0 and 1)
  91889. */
  91890. gradient: number,
  91891. /**
  91892. * Gets or sets first associated color
  91893. */
  91894. color1: Color4,
  91895. /**
  91896. * Gets or sets second associated color
  91897. */
  91898. color2?: Color4 | undefined);
  91899. /**
  91900. * Will get a color picked randomly between color1 and color2.
  91901. * If color2 is undefined then color1 will be used
  91902. * @param result defines the target Color4 to store the result in
  91903. */
  91904. getColorToRef(result: Color4): void;
  91905. }
  91906. /** Class used to store color 3 gradient */
  91907. export class Color3Gradient implements IValueGradient {
  91908. /**
  91909. * Gets or sets the gradient value (between 0 and 1)
  91910. */
  91911. gradient: number;
  91912. /**
  91913. * Gets or sets the associated color
  91914. */
  91915. color: Color3;
  91916. /**
  91917. * Creates a new color3 gradient
  91918. * @param gradient gets or sets the gradient value (between 0 and 1)
  91919. * @param color gets or sets associated color
  91920. */
  91921. constructor(
  91922. /**
  91923. * Gets or sets the gradient value (between 0 and 1)
  91924. */
  91925. gradient: number,
  91926. /**
  91927. * Gets or sets the associated color
  91928. */
  91929. color: Color3);
  91930. }
  91931. /** Class used to store factor gradient */
  91932. export class FactorGradient implements IValueGradient {
  91933. /**
  91934. * Gets or sets the gradient value (between 0 and 1)
  91935. */
  91936. gradient: number;
  91937. /**
  91938. * Gets or sets first associated factor
  91939. */
  91940. factor1: number;
  91941. /**
  91942. * Gets or sets second associated factor
  91943. */
  91944. factor2?: number | undefined;
  91945. /**
  91946. * Creates a new factor gradient
  91947. * @param gradient gets or sets the gradient value (between 0 and 1)
  91948. * @param factor1 gets or sets first associated factor
  91949. * @param factor2 gets or sets second associated factor
  91950. */
  91951. constructor(
  91952. /**
  91953. * Gets or sets the gradient value (between 0 and 1)
  91954. */
  91955. gradient: number,
  91956. /**
  91957. * Gets or sets first associated factor
  91958. */
  91959. factor1: number,
  91960. /**
  91961. * Gets or sets second associated factor
  91962. */
  91963. factor2?: number | undefined);
  91964. /**
  91965. * Will get a number picked randomly between factor1 and factor2.
  91966. * If factor2 is undefined then factor1 will be used
  91967. * @returns the picked number
  91968. */
  91969. getFactor(): number;
  91970. }
  91971. /**
  91972. * Helper used to simplify some generic gradient tasks
  91973. */
  91974. export class GradientHelper {
  91975. /**
  91976. * Gets the current gradient from an array of IValueGradient
  91977. * @param ratio defines the current ratio to get
  91978. * @param gradients defines the array of IValueGradient
  91979. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91980. */
  91981. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91982. }
  91983. }
  91984. declare module BABYLON {
  91985. interface ThinEngine {
  91986. /**
  91987. * Creates a raw texture
  91988. * @param data defines the data to store in the texture
  91989. * @param width defines the width of the texture
  91990. * @param height defines the height of the texture
  91991. * @param format defines the format of the data
  91992. * @param generateMipMaps defines if the engine should generate the mip levels
  91993. * @param invertY defines if data must be stored with Y axis inverted
  91994. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91995. * @param compression defines the compression used (null by default)
  91996. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91997. * @returns the raw texture inside an InternalTexture
  91998. */
  91999. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92000. /**
  92001. * Update a raw texture
  92002. * @param texture defines the texture to update
  92003. * @param data defines the data to store in the texture
  92004. * @param format defines the format of the data
  92005. * @param invertY defines if data must be stored with Y axis inverted
  92006. */
  92007. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92008. /**
  92009. * Update a raw texture
  92010. * @param texture defines the texture to update
  92011. * @param data defines the data to store in the texture
  92012. * @param format defines the format of the data
  92013. * @param invertY defines if data must be stored with Y axis inverted
  92014. * @param compression defines the compression used (null by default)
  92015. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92016. */
  92017. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92018. /**
  92019. * Creates a new raw cube texture
  92020. * @param data defines the array of data to use to create each face
  92021. * @param size defines the size of the textures
  92022. * @param format defines the format of the data
  92023. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92024. * @param generateMipMaps defines if the engine should generate the mip levels
  92025. * @param invertY defines if data must be stored with Y axis inverted
  92026. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92027. * @param compression defines the compression used (null by default)
  92028. * @returns the cube texture as an InternalTexture
  92029. */
  92030. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92031. /**
  92032. * Update a raw cube texture
  92033. * @param texture defines the texture to udpdate
  92034. * @param data defines the data to store
  92035. * @param format defines the data format
  92036. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92037. * @param invertY defines if data must be stored with Y axis inverted
  92038. */
  92039. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92040. /**
  92041. * Update a raw cube texture
  92042. * @param texture defines the texture to udpdate
  92043. * @param data defines the data to store
  92044. * @param format defines the data format
  92045. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92046. * @param invertY defines if data must be stored with Y axis inverted
  92047. * @param compression defines the compression used (null by default)
  92048. */
  92049. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92050. /**
  92051. * Update a raw cube texture
  92052. * @param texture defines the texture to udpdate
  92053. * @param data defines the data to store
  92054. * @param format defines the data format
  92055. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92056. * @param invertY defines if data must be stored with Y axis inverted
  92057. * @param compression defines the compression used (null by default)
  92058. * @param level defines which level of the texture to update
  92059. */
  92060. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92061. /**
  92062. * Creates a new raw cube texture from a specified url
  92063. * @param url defines the url where the data is located
  92064. * @param scene defines the current scene
  92065. * @param size defines the size of the textures
  92066. * @param format defines the format of the data
  92067. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92068. * @param noMipmap defines if the engine should avoid generating the mip levels
  92069. * @param callback defines a callback used to extract texture data from loaded data
  92070. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92071. * @param onLoad defines a callback called when texture is loaded
  92072. * @param onError defines a callback called if there is an error
  92073. * @returns the cube texture as an InternalTexture
  92074. */
  92075. 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;
  92076. /**
  92077. * Creates a new raw cube texture from a specified url
  92078. * @param url defines the url where the data is located
  92079. * @param scene defines the current scene
  92080. * @param size defines the size of the textures
  92081. * @param format defines the format of the data
  92082. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92083. * @param noMipmap defines if the engine should avoid generating the mip levels
  92084. * @param callback defines a callback used to extract texture data from loaded data
  92085. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92086. * @param onLoad defines a callback called when texture is loaded
  92087. * @param onError defines a callback called if there is an error
  92088. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92089. * @param invertY defines if data must be stored with Y axis inverted
  92090. * @returns the cube texture as an InternalTexture
  92091. */
  92092. 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;
  92093. /**
  92094. * Creates a new raw 3D texture
  92095. * @param data defines the data used to create the texture
  92096. * @param width defines the width of the texture
  92097. * @param height defines the height of the texture
  92098. * @param depth defines the depth of the texture
  92099. * @param format defines the format of the texture
  92100. * @param generateMipMaps defines if the engine must generate mip levels
  92101. * @param invertY defines if data must be stored with Y axis inverted
  92102. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92103. * @param compression defines the compressed used (can be null)
  92104. * @param textureType defines the compressed used (can be null)
  92105. * @returns a new raw 3D texture (stored in an InternalTexture)
  92106. */
  92107. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92108. /**
  92109. * Update a raw 3D texture
  92110. * @param texture defines the texture to update
  92111. * @param data defines the data to store
  92112. * @param format defines the data format
  92113. * @param invertY defines if data must be stored with Y axis inverted
  92114. */
  92115. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92116. /**
  92117. * Update a raw 3D texture
  92118. * @param texture defines the texture to update
  92119. * @param data defines the data to store
  92120. * @param format defines the data format
  92121. * @param invertY defines if data must be stored with Y axis inverted
  92122. * @param compression defines the used compression (can be null)
  92123. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92124. */
  92125. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92126. /**
  92127. * Creates a new raw 2D array texture
  92128. * @param data defines the data used to create the texture
  92129. * @param width defines the width of the texture
  92130. * @param height defines the height of the texture
  92131. * @param depth defines the number of layers of the texture
  92132. * @param format defines the format of the texture
  92133. * @param generateMipMaps defines if the engine must generate mip levels
  92134. * @param invertY defines if data must be stored with Y axis inverted
  92135. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92136. * @param compression defines the compressed used (can be null)
  92137. * @param textureType defines the compressed used (can be null)
  92138. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92139. */
  92140. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92141. /**
  92142. * Update a raw 2D array texture
  92143. * @param texture defines the texture to update
  92144. * @param data defines the data to store
  92145. * @param format defines the data format
  92146. * @param invertY defines if data must be stored with Y axis inverted
  92147. */
  92148. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92149. /**
  92150. * Update a raw 2D array texture
  92151. * @param texture defines the texture to update
  92152. * @param data defines the data to store
  92153. * @param format defines the data format
  92154. * @param invertY defines if data must be stored with Y axis inverted
  92155. * @param compression defines the used compression (can be null)
  92156. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92157. */
  92158. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92159. }
  92160. }
  92161. declare module BABYLON {
  92162. /**
  92163. * Raw texture can help creating a texture directly from an array of data.
  92164. * This can be super useful if you either get the data from an uncompressed source or
  92165. * if you wish to create your texture pixel by pixel.
  92166. */
  92167. export class RawTexture extends Texture {
  92168. /**
  92169. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92170. */
  92171. format: number;
  92172. /**
  92173. * Instantiates a new RawTexture.
  92174. * Raw texture can help creating a texture directly from an array of data.
  92175. * This can be super useful if you either get the data from an uncompressed source or
  92176. * if you wish to create your texture pixel by pixel.
  92177. * @param data define the array of data to use to create the texture
  92178. * @param width define the width of the texture
  92179. * @param height define the height of the texture
  92180. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92181. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92182. * @param generateMipMaps define whether mip maps should be generated or not
  92183. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92184. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92185. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92186. */
  92187. constructor(data: ArrayBufferView, width: number, height: number,
  92188. /**
  92189. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92190. */
  92191. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92192. /**
  92193. * Updates the texture underlying data.
  92194. * @param data Define the new data of the texture
  92195. */
  92196. update(data: ArrayBufferView): void;
  92197. /**
  92198. * Creates a luminance texture from some data.
  92199. * @param data Define the texture data
  92200. * @param width Define the width of the texture
  92201. * @param height Define the height of the texture
  92202. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92203. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92204. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92205. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92206. * @returns the luminance texture
  92207. */
  92208. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92209. /**
  92210. * Creates a luminance alpha texture from some data.
  92211. * @param data Define the texture data
  92212. * @param width Define the width of the texture
  92213. * @param height Define the height of the texture
  92214. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92215. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92216. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92217. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92218. * @returns the luminance alpha texture
  92219. */
  92220. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92221. /**
  92222. * Creates an alpha texture from some data.
  92223. * @param data Define the texture data
  92224. * @param width Define the width of the texture
  92225. * @param height Define the height of the texture
  92226. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92227. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92228. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92229. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92230. * @returns the alpha texture
  92231. */
  92232. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92233. /**
  92234. * Creates a RGB texture from some data.
  92235. * @param data Define the texture data
  92236. * @param width Define the width of the texture
  92237. * @param height Define the height of the texture
  92238. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92239. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92240. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92241. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92242. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92243. * @returns the RGB alpha texture
  92244. */
  92245. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92246. /**
  92247. * Creates a RGBA texture from some data.
  92248. * @param data Define the texture data
  92249. * @param width Define the width of the texture
  92250. * @param height Define the height of the texture
  92251. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92252. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92253. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92254. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92255. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92256. * @returns the RGBA texture
  92257. */
  92258. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92259. /**
  92260. * Creates a R texture from some data.
  92261. * @param data Define the texture data
  92262. * @param width Define the width of the texture
  92263. * @param height Define the height of the texture
  92264. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92265. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92266. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92267. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92268. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92269. * @returns the R texture
  92270. */
  92271. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92272. }
  92273. }
  92274. declare module BABYLON {
  92275. interface ThinEngine {
  92276. /**
  92277. * Update a dynamic index buffer
  92278. * @param indexBuffer defines the target index buffer
  92279. * @param indices defines the data to update
  92280. * @param offset defines the offset in the target index buffer where update should start
  92281. */
  92282. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92283. /**
  92284. * Updates a dynamic vertex buffer.
  92285. * @param vertexBuffer the vertex buffer to update
  92286. * @param data the data used to update the vertex buffer
  92287. * @param byteOffset the byte offset of the data
  92288. * @param byteLength the byte length of the data
  92289. */
  92290. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92291. }
  92292. }
  92293. declare module BABYLON {
  92294. interface AbstractScene {
  92295. /**
  92296. * The list of procedural textures added to the scene
  92297. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92298. */
  92299. proceduralTextures: Array<ProceduralTexture>;
  92300. }
  92301. /**
  92302. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92303. * in a given scene.
  92304. */
  92305. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92306. /**
  92307. * The component name helpfull to identify the component in the list of scene components.
  92308. */
  92309. readonly name: string;
  92310. /**
  92311. * The scene the component belongs to.
  92312. */
  92313. scene: Scene;
  92314. /**
  92315. * Creates a new instance of the component for the given scene
  92316. * @param scene Defines the scene to register the component in
  92317. */
  92318. constructor(scene: Scene);
  92319. /**
  92320. * Registers the component in a given scene
  92321. */
  92322. register(): void;
  92323. /**
  92324. * Rebuilds the elements related to this component in case of
  92325. * context lost for instance.
  92326. */
  92327. rebuild(): void;
  92328. /**
  92329. * Disposes the component and the associated ressources.
  92330. */
  92331. dispose(): void;
  92332. private _beforeClear;
  92333. }
  92334. }
  92335. declare module BABYLON {
  92336. interface ThinEngine {
  92337. /**
  92338. * Creates a new render target cube texture
  92339. * @param size defines the size of the texture
  92340. * @param options defines the options used to create the texture
  92341. * @returns a new render target cube texture stored in an InternalTexture
  92342. */
  92343. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92344. }
  92345. }
  92346. declare module BABYLON {
  92347. /** @hidden */
  92348. export var proceduralVertexShader: {
  92349. name: string;
  92350. shader: string;
  92351. };
  92352. }
  92353. declare module BABYLON {
  92354. /**
  92355. * 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.
  92356. * This is the base class of any Procedural texture and contains most of the shareable code.
  92357. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92358. */
  92359. export class ProceduralTexture extends Texture {
  92360. /**
  92361. * Define if the texture is enabled or not (disabled texture will not render)
  92362. */
  92363. isEnabled: boolean;
  92364. /**
  92365. * Define if the texture must be cleared before rendering (default is true)
  92366. */
  92367. autoClear: boolean;
  92368. /**
  92369. * Callback called when the texture is generated
  92370. */
  92371. onGenerated: () => void;
  92372. /**
  92373. * Event raised when the texture is generated
  92374. */
  92375. onGeneratedObservable: Observable<ProceduralTexture>;
  92376. /**
  92377. * Event raised before the texture is generated
  92378. */
  92379. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92380. /**
  92381. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92382. */
  92383. nodeMaterialSource: Nullable<NodeMaterial>;
  92384. /** @hidden */
  92385. _generateMipMaps: boolean;
  92386. /** @hidden **/
  92387. _effect: Effect;
  92388. /** @hidden */
  92389. _textures: {
  92390. [key: string]: Texture;
  92391. };
  92392. /** @hidden */
  92393. protected _fallbackTexture: Nullable<Texture>;
  92394. private _size;
  92395. private _currentRefreshId;
  92396. private _frameId;
  92397. private _refreshRate;
  92398. private _vertexBuffers;
  92399. private _indexBuffer;
  92400. private _uniforms;
  92401. private _samplers;
  92402. private _fragment;
  92403. private _floats;
  92404. private _ints;
  92405. private _floatsArrays;
  92406. private _colors3;
  92407. private _colors4;
  92408. private _vectors2;
  92409. private _vectors3;
  92410. private _matrices;
  92411. private _fallbackTextureUsed;
  92412. private _fullEngine;
  92413. private _cachedDefines;
  92414. private _contentUpdateId;
  92415. private _contentData;
  92416. /**
  92417. * Instantiates a new procedural texture.
  92418. * 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.
  92419. * This is the base class of any Procedural texture and contains most of the shareable code.
  92420. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92421. * @param name Define the name of the texture
  92422. * @param size Define the size of the texture to create
  92423. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92424. * @param scene Define the scene the texture belongs to
  92425. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92426. * @param generateMipMaps Define if the texture should creates mip maps or not
  92427. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92428. * @param textureType The FBO internal texture type
  92429. */
  92430. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92431. /**
  92432. * The effect that is created when initializing the post process.
  92433. * @returns The created effect corresponding the the postprocess.
  92434. */
  92435. getEffect(): Effect;
  92436. /**
  92437. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92438. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92439. */
  92440. getContent(): Nullable<ArrayBufferView>;
  92441. private _createIndexBuffer;
  92442. /** @hidden */
  92443. _rebuild(): void;
  92444. /**
  92445. * Resets the texture in order to recreate its associated resources.
  92446. * This can be called in case of context loss
  92447. */
  92448. reset(): void;
  92449. protected _getDefines(): string;
  92450. /**
  92451. * Is the texture ready to be used ? (rendered at least once)
  92452. * @returns true if ready, otherwise, false.
  92453. */
  92454. isReady(): boolean;
  92455. /**
  92456. * Resets the refresh counter of the texture and start bak from scratch.
  92457. * Could be useful to regenerate the texture if it is setup to render only once.
  92458. */
  92459. resetRefreshCounter(): void;
  92460. /**
  92461. * Set the fragment shader to use in order to render the texture.
  92462. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92463. */
  92464. setFragment(fragment: any): void;
  92465. /**
  92466. * Define the refresh rate of the texture or the rendering frequency.
  92467. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92468. */
  92469. get refreshRate(): number;
  92470. set refreshRate(value: number);
  92471. /** @hidden */
  92472. _shouldRender(): boolean;
  92473. /**
  92474. * Get the size the texture is rendering at.
  92475. * @returns the size (on cube texture it is always squared)
  92476. */
  92477. getRenderSize(): RenderTargetTextureSize;
  92478. /**
  92479. * Resize the texture to new value.
  92480. * @param size Define the new size the texture should have
  92481. * @param generateMipMaps Define whether the new texture should create mip maps
  92482. */
  92483. resize(size: number, generateMipMaps: boolean): void;
  92484. private _checkUniform;
  92485. /**
  92486. * Set a texture in the shader program used to render.
  92487. * @param name Define the name of the uniform samplers as defined in the shader
  92488. * @param texture Define the texture to bind to this sampler
  92489. * @return the texture itself allowing "fluent" like uniform updates
  92490. */
  92491. setTexture(name: string, texture: Texture): ProceduralTexture;
  92492. /**
  92493. * Set a float in the shader.
  92494. * @param name Define the name of the uniform as defined in the shader
  92495. * @param value Define the value to give to the uniform
  92496. * @return the texture itself allowing "fluent" like uniform updates
  92497. */
  92498. setFloat(name: string, value: number): ProceduralTexture;
  92499. /**
  92500. * Set a int in the shader.
  92501. * @param name Define the name of the uniform as defined in the shader
  92502. * @param value Define the value to give to the uniform
  92503. * @return the texture itself allowing "fluent" like uniform updates
  92504. */
  92505. setInt(name: string, value: number): ProceduralTexture;
  92506. /**
  92507. * Set an array of floats in the shader.
  92508. * @param name Define the name of the uniform as defined in the shader
  92509. * @param value Define the value to give to the uniform
  92510. * @return the texture itself allowing "fluent" like uniform updates
  92511. */
  92512. setFloats(name: string, value: number[]): ProceduralTexture;
  92513. /**
  92514. * Set a vec3 in the shader from a Color3.
  92515. * @param name Define the name of the uniform as defined in the shader
  92516. * @param value Define the value to give to the uniform
  92517. * @return the texture itself allowing "fluent" like uniform updates
  92518. */
  92519. setColor3(name: string, value: Color3): ProceduralTexture;
  92520. /**
  92521. * Set a vec4 in the shader from a Color4.
  92522. * @param name Define the name of the uniform as defined in the shader
  92523. * @param value Define the value to give to the uniform
  92524. * @return the texture itself allowing "fluent" like uniform updates
  92525. */
  92526. setColor4(name: string, value: Color4): ProceduralTexture;
  92527. /**
  92528. * Set a vec2 in the shader from a Vector2.
  92529. * @param name Define the name of the uniform as defined in the shader
  92530. * @param value Define the value to give to the uniform
  92531. * @return the texture itself allowing "fluent" like uniform updates
  92532. */
  92533. setVector2(name: string, value: Vector2): ProceduralTexture;
  92534. /**
  92535. * Set a vec3 in the shader from a Vector3.
  92536. * @param name Define the name of the uniform as defined in the shader
  92537. * @param value Define the value to give to the uniform
  92538. * @return the texture itself allowing "fluent" like uniform updates
  92539. */
  92540. setVector3(name: string, value: Vector3): ProceduralTexture;
  92541. /**
  92542. * Set a mat4 in the shader from a MAtrix.
  92543. * @param name Define the name of the uniform as defined in the shader
  92544. * @param value Define the value to give to the uniform
  92545. * @return the texture itself allowing "fluent" like uniform updates
  92546. */
  92547. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92548. /**
  92549. * Render the texture to its associated render target.
  92550. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92551. */
  92552. render(useCameraPostProcess?: boolean): void;
  92553. /**
  92554. * Clone the texture.
  92555. * @returns the cloned texture
  92556. */
  92557. clone(): ProceduralTexture;
  92558. /**
  92559. * Dispose the texture and release its asoociated resources.
  92560. */
  92561. dispose(): void;
  92562. }
  92563. }
  92564. declare module BABYLON {
  92565. /**
  92566. * This represents the base class for particle system in Babylon.
  92567. * 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.
  92568. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92569. * @example https://doc.babylonjs.com/babylon101/particles
  92570. */
  92571. export class BaseParticleSystem {
  92572. /**
  92573. * Source color is added to the destination color without alpha affecting the result
  92574. */
  92575. static BLENDMODE_ONEONE: number;
  92576. /**
  92577. * Blend current color and particle color using particle’s alpha
  92578. */
  92579. static BLENDMODE_STANDARD: number;
  92580. /**
  92581. * Add current color and particle color multiplied by particle’s alpha
  92582. */
  92583. static BLENDMODE_ADD: number;
  92584. /**
  92585. * Multiply current color with particle color
  92586. */
  92587. static BLENDMODE_MULTIPLY: number;
  92588. /**
  92589. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92590. */
  92591. static BLENDMODE_MULTIPLYADD: number;
  92592. /**
  92593. * List of animations used by the particle system.
  92594. */
  92595. animations: Animation[];
  92596. /**
  92597. * Gets or sets the unique id of the particle system
  92598. */
  92599. uniqueId: number;
  92600. /**
  92601. * The id of the Particle system.
  92602. */
  92603. id: string;
  92604. /**
  92605. * The friendly name of the Particle system.
  92606. */
  92607. name: string;
  92608. /**
  92609. * Snippet ID if the particle system was created from the snippet server
  92610. */
  92611. snippetId: string;
  92612. /**
  92613. * The rendering group used by the Particle system to chose when to render.
  92614. */
  92615. renderingGroupId: number;
  92616. /**
  92617. * The emitter represents the Mesh or position we are attaching the particle system to.
  92618. */
  92619. emitter: Nullable<AbstractMesh | Vector3>;
  92620. /**
  92621. * The maximum number of particles to emit per frame
  92622. */
  92623. emitRate: number;
  92624. /**
  92625. * If you want to launch only a few particles at once, that can be done, as well.
  92626. */
  92627. manualEmitCount: number;
  92628. /**
  92629. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92630. */
  92631. updateSpeed: number;
  92632. /**
  92633. * The amount of time the particle system is running (depends of the overall update speed).
  92634. */
  92635. targetStopDuration: number;
  92636. /**
  92637. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92638. */
  92639. disposeOnStop: boolean;
  92640. /**
  92641. * Minimum power of emitting particles.
  92642. */
  92643. minEmitPower: number;
  92644. /**
  92645. * Maximum power of emitting particles.
  92646. */
  92647. maxEmitPower: number;
  92648. /**
  92649. * Minimum life time of emitting particles.
  92650. */
  92651. minLifeTime: number;
  92652. /**
  92653. * Maximum life time of emitting particles.
  92654. */
  92655. maxLifeTime: number;
  92656. /**
  92657. * Minimum Size of emitting particles.
  92658. */
  92659. minSize: number;
  92660. /**
  92661. * Maximum Size of emitting particles.
  92662. */
  92663. maxSize: number;
  92664. /**
  92665. * Minimum scale of emitting particles on X axis.
  92666. */
  92667. minScaleX: number;
  92668. /**
  92669. * Maximum scale of emitting particles on X axis.
  92670. */
  92671. maxScaleX: number;
  92672. /**
  92673. * Minimum scale of emitting particles on Y axis.
  92674. */
  92675. minScaleY: number;
  92676. /**
  92677. * Maximum scale of emitting particles on Y axis.
  92678. */
  92679. maxScaleY: number;
  92680. /**
  92681. * Gets or sets the minimal initial rotation in radians.
  92682. */
  92683. minInitialRotation: number;
  92684. /**
  92685. * Gets or sets the maximal initial rotation in radians.
  92686. */
  92687. maxInitialRotation: number;
  92688. /**
  92689. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92690. */
  92691. minAngularSpeed: number;
  92692. /**
  92693. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92694. */
  92695. maxAngularSpeed: number;
  92696. /**
  92697. * The texture used to render each particle. (this can be a spritesheet)
  92698. */
  92699. particleTexture: Nullable<BaseTexture>;
  92700. /**
  92701. * The layer mask we are rendering the particles through.
  92702. */
  92703. layerMask: number;
  92704. /**
  92705. * This can help using your own shader to render the particle system.
  92706. * The according effect will be created
  92707. */
  92708. customShader: any;
  92709. /**
  92710. * By default particle system starts as soon as they are created. This prevents the
  92711. * automatic start to happen and let you decide when to start emitting particles.
  92712. */
  92713. preventAutoStart: boolean;
  92714. private _noiseTexture;
  92715. /**
  92716. * Gets or sets a texture used to add random noise to particle positions
  92717. */
  92718. get noiseTexture(): Nullable<ProceduralTexture>;
  92719. set noiseTexture(value: Nullable<ProceduralTexture>);
  92720. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92721. noiseStrength: Vector3;
  92722. /**
  92723. * Callback triggered when the particle animation is ending.
  92724. */
  92725. onAnimationEnd: Nullable<() => void>;
  92726. /**
  92727. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92728. */
  92729. blendMode: number;
  92730. /**
  92731. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92732. * to override the particles.
  92733. */
  92734. forceDepthWrite: boolean;
  92735. /** 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 */
  92736. preWarmCycles: number;
  92737. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92738. preWarmStepOffset: number;
  92739. /**
  92740. * 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)
  92741. */
  92742. spriteCellChangeSpeed: number;
  92743. /**
  92744. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92745. */
  92746. startSpriteCellID: number;
  92747. /**
  92748. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92749. */
  92750. endSpriteCellID: number;
  92751. /**
  92752. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92753. */
  92754. spriteCellWidth: number;
  92755. /**
  92756. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92757. */
  92758. spriteCellHeight: number;
  92759. /**
  92760. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92761. */
  92762. spriteRandomStartCell: boolean;
  92763. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92764. translationPivot: Vector2;
  92765. /** @hidden */
  92766. protected _isAnimationSheetEnabled: boolean;
  92767. /**
  92768. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92769. */
  92770. beginAnimationOnStart: boolean;
  92771. /**
  92772. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92773. */
  92774. beginAnimationFrom: number;
  92775. /**
  92776. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92777. */
  92778. beginAnimationTo: number;
  92779. /**
  92780. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92781. */
  92782. beginAnimationLoop: boolean;
  92783. /**
  92784. * Gets or sets a world offset applied to all particles
  92785. */
  92786. worldOffset: Vector3;
  92787. /**
  92788. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92789. */
  92790. get isAnimationSheetEnabled(): boolean;
  92791. set isAnimationSheetEnabled(value: boolean);
  92792. /**
  92793. * Get hosting scene
  92794. * @returns the scene
  92795. */
  92796. getScene(): Nullable<Scene>;
  92797. /**
  92798. * You can use gravity if you want to give an orientation to your particles.
  92799. */
  92800. gravity: Vector3;
  92801. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92802. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92803. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92804. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92805. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92806. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92807. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92808. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92809. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92810. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92811. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92812. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92813. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92814. /**
  92815. * Defines the delay in milliseconds before starting the system (0 by default)
  92816. */
  92817. startDelay: number;
  92818. /**
  92819. * Gets the current list of drag gradients.
  92820. * You must use addDragGradient and removeDragGradient to udpate this list
  92821. * @returns the list of drag gradients
  92822. */
  92823. getDragGradients(): Nullable<Array<FactorGradient>>;
  92824. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92825. limitVelocityDamping: number;
  92826. /**
  92827. * Gets the current list of limit velocity gradients.
  92828. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92829. * @returns the list of limit velocity gradients
  92830. */
  92831. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92832. /**
  92833. * Gets the current list of color gradients.
  92834. * You must use addColorGradient and removeColorGradient to udpate this list
  92835. * @returns the list of color gradients
  92836. */
  92837. getColorGradients(): Nullable<Array<ColorGradient>>;
  92838. /**
  92839. * Gets the current list of size gradients.
  92840. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92841. * @returns the list of size gradients
  92842. */
  92843. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92844. /**
  92845. * Gets the current list of color remap gradients.
  92846. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92847. * @returns the list of color remap gradients
  92848. */
  92849. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92850. /**
  92851. * Gets the current list of alpha remap gradients.
  92852. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92853. * @returns the list of alpha remap gradients
  92854. */
  92855. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92856. /**
  92857. * Gets the current list of life time gradients.
  92858. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92859. * @returns the list of life time gradients
  92860. */
  92861. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92862. /**
  92863. * Gets the current list of angular speed gradients.
  92864. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92865. * @returns the list of angular speed gradients
  92866. */
  92867. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92868. /**
  92869. * Gets the current list of velocity gradients.
  92870. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92871. * @returns the list of velocity gradients
  92872. */
  92873. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92874. /**
  92875. * Gets the current list of start size gradients.
  92876. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92877. * @returns the list of start size gradients
  92878. */
  92879. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92880. /**
  92881. * Gets the current list of emit rate gradients.
  92882. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92883. * @returns the list of emit rate gradients
  92884. */
  92885. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92886. /**
  92887. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92888. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92889. */
  92890. get direction1(): Vector3;
  92891. set direction1(value: Vector3);
  92892. /**
  92893. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92894. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92895. */
  92896. get direction2(): Vector3;
  92897. set direction2(value: Vector3);
  92898. /**
  92899. * 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.
  92900. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92901. */
  92902. get minEmitBox(): Vector3;
  92903. set minEmitBox(value: Vector3);
  92904. /**
  92905. * 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.
  92906. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92907. */
  92908. get maxEmitBox(): Vector3;
  92909. set maxEmitBox(value: Vector3);
  92910. /**
  92911. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92912. */
  92913. color1: Color4;
  92914. /**
  92915. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92916. */
  92917. color2: Color4;
  92918. /**
  92919. * Color the particle will have at the end of its lifetime
  92920. */
  92921. colorDead: Color4;
  92922. /**
  92923. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92924. */
  92925. textureMask: Color4;
  92926. /**
  92927. * The particle emitter type defines the emitter used by the particle system.
  92928. * It can be for example box, sphere, or cone...
  92929. */
  92930. particleEmitterType: IParticleEmitterType;
  92931. /** @hidden */
  92932. _isSubEmitter: boolean;
  92933. /**
  92934. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92935. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92936. */
  92937. billboardMode: number;
  92938. protected _isBillboardBased: boolean;
  92939. /**
  92940. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92941. */
  92942. get isBillboardBased(): boolean;
  92943. set isBillboardBased(value: boolean);
  92944. /**
  92945. * The scene the particle system belongs to.
  92946. */
  92947. protected _scene: Nullable<Scene>;
  92948. /**
  92949. * The engine the particle system belongs to.
  92950. */
  92951. protected _engine: ThinEngine;
  92952. /**
  92953. * Local cache of defines for image processing.
  92954. */
  92955. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92956. /**
  92957. * Default configuration related to image processing available in the standard Material.
  92958. */
  92959. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92960. /**
  92961. * Gets the image processing configuration used either in this material.
  92962. */
  92963. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92964. /**
  92965. * Sets the Default image processing configuration used either in the this material.
  92966. *
  92967. * If sets to null, the scene one is in use.
  92968. */
  92969. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92970. /**
  92971. * Attaches a new image processing configuration to the Standard Material.
  92972. * @param configuration
  92973. */
  92974. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92975. /** @hidden */
  92976. protected _reset(): void;
  92977. /** @hidden */
  92978. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92979. /**
  92980. * Instantiates a particle system.
  92981. * 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.
  92982. * @param name The name of the particle system
  92983. */
  92984. constructor(name: string);
  92985. /**
  92986. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92987. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92988. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92989. * @returns the emitter
  92990. */
  92991. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92992. /**
  92993. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92994. * @param radius The radius of the hemisphere to emit from
  92995. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92996. * @returns the emitter
  92997. */
  92998. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92999. /**
  93000. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93001. * @param radius The radius of the sphere to emit from
  93002. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93003. * @returns the emitter
  93004. */
  93005. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93006. /**
  93007. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93008. * @param radius The radius of the sphere to emit from
  93009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93011. * @returns the emitter
  93012. */
  93013. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93014. /**
  93015. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93016. * @param radius The radius of the emission cylinder
  93017. * @param height The height of the emission cylinder
  93018. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93019. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93020. * @returns the emitter
  93021. */
  93022. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93023. /**
  93024. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93025. * @param radius The radius of the cylinder to emit from
  93026. * @param height The height of the emission cylinder
  93027. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93028. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93029. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93030. * @returns the emitter
  93031. */
  93032. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93033. /**
  93034. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93035. * @param radius The radius of the cone to emit from
  93036. * @param angle The base angle of the cone
  93037. * @returns the emitter
  93038. */
  93039. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93040. /**
  93041. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93042. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93043. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93044. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93045. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93046. * @returns the emitter
  93047. */
  93048. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93049. }
  93050. }
  93051. declare module BABYLON {
  93052. /**
  93053. * Type of sub emitter
  93054. */
  93055. export enum SubEmitterType {
  93056. /**
  93057. * Attached to the particle over it's lifetime
  93058. */
  93059. ATTACHED = 0,
  93060. /**
  93061. * Created when the particle dies
  93062. */
  93063. END = 1
  93064. }
  93065. /**
  93066. * Sub emitter class used to emit particles from an existing particle
  93067. */
  93068. export class SubEmitter {
  93069. /**
  93070. * the particle system to be used by the sub emitter
  93071. */
  93072. particleSystem: ParticleSystem;
  93073. /**
  93074. * Type of the submitter (Default: END)
  93075. */
  93076. type: SubEmitterType;
  93077. /**
  93078. * 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)
  93079. * Note: This only is supported when using an emitter of type Mesh
  93080. */
  93081. inheritDirection: boolean;
  93082. /**
  93083. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93084. */
  93085. inheritedVelocityAmount: number;
  93086. /**
  93087. * Creates a sub emitter
  93088. * @param particleSystem the particle system to be used by the sub emitter
  93089. */
  93090. constructor(
  93091. /**
  93092. * the particle system to be used by the sub emitter
  93093. */
  93094. particleSystem: ParticleSystem);
  93095. /**
  93096. * Clones the sub emitter
  93097. * @returns the cloned sub emitter
  93098. */
  93099. clone(): SubEmitter;
  93100. /**
  93101. * Serialize current object to a JSON object
  93102. * @returns the serialized object
  93103. */
  93104. serialize(): any;
  93105. /** @hidden */
  93106. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93107. /**
  93108. * Creates a new SubEmitter from a serialized JSON version
  93109. * @param serializationObject defines the JSON object to read from
  93110. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93111. * @param rootUrl defines the rootUrl for data loading
  93112. * @returns a new SubEmitter
  93113. */
  93114. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93115. /** Release associated resources */
  93116. dispose(): void;
  93117. }
  93118. }
  93119. declare module BABYLON {
  93120. /** @hidden */
  93121. export var imageProcessingDeclaration: {
  93122. name: string;
  93123. shader: string;
  93124. };
  93125. }
  93126. declare module BABYLON {
  93127. /** @hidden */
  93128. export var imageProcessingFunctions: {
  93129. name: string;
  93130. shader: string;
  93131. };
  93132. }
  93133. declare module BABYLON {
  93134. /** @hidden */
  93135. export var particlesPixelShader: {
  93136. name: string;
  93137. shader: string;
  93138. };
  93139. }
  93140. declare module BABYLON {
  93141. /** @hidden */
  93142. export var particlesVertexShader: {
  93143. name: string;
  93144. shader: string;
  93145. };
  93146. }
  93147. declare module BABYLON {
  93148. /**
  93149. * Interface used to define entities containing multiple clip planes
  93150. */
  93151. export interface IClipPlanesHolder {
  93152. /**
  93153. * Gets or sets the active clipplane 1
  93154. */
  93155. clipPlane: Nullable<Plane>;
  93156. /**
  93157. * Gets or sets the active clipplane 2
  93158. */
  93159. clipPlane2: Nullable<Plane>;
  93160. /**
  93161. * Gets or sets the active clipplane 3
  93162. */
  93163. clipPlane3: Nullable<Plane>;
  93164. /**
  93165. * Gets or sets the active clipplane 4
  93166. */
  93167. clipPlane4: Nullable<Plane>;
  93168. /**
  93169. * Gets or sets the active clipplane 5
  93170. */
  93171. clipPlane5: Nullable<Plane>;
  93172. /**
  93173. * Gets or sets the active clipplane 6
  93174. */
  93175. clipPlane6: Nullable<Plane>;
  93176. }
  93177. }
  93178. declare module BABYLON {
  93179. /**
  93180. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93181. *
  93182. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93183. *
  93184. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93185. */
  93186. export class ThinMaterialHelper {
  93187. /**
  93188. * Binds the clip plane information from the holder to the effect.
  93189. * @param effect The effect we are binding the data to
  93190. * @param holder The entity containing the clip plane information
  93191. */
  93192. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93193. }
  93194. }
  93195. declare module BABYLON {
  93196. interface ThinEngine {
  93197. /**
  93198. * Sets alpha constants used by some alpha blending modes
  93199. * @param r defines the red component
  93200. * @param g defines the green component
  93201. * @param b defines the blue component
  93202. * @param a defines the alpha component
  93203. */
  93204. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93205. /**
  93206. * Sets the current alpha mode
  93207. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93208. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93209. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93210. */
  93211. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93212. /**
  93213. * Gets the current alpha mode
  93214. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93215. * @returns the current alpha mode
  93216. */
  93217. getAlphaMode(): number;
  93218. /**
  93219. * Sets the current alpha equation
  93220. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93221. */
  93222. setAlphaEquation(equation: number): void;
  93223. /**
  93224. * Gets the current alpha equation.
  93225. * @returns the current alpha equation
  93226. */
  93227. getAlphaEquation(): number;
  93228. }
  93229. }
  93230. declare module BABYLON {
  93231. /**
  93232. * This represents a particle system in Babylon.
  93233. * 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.
  93234. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93235. * @example https://doc.babylonjs.com/babylon101/particles
  93236. */
  93237. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93238. /**
  93239. * Billboard mode will only apply to Y axis
  93240. */
  93241. static readonly BILLBOARDMODE_Y: number;
  93242. /**
  93243. * Billboard mode will apply to all axes
  93244. */
  93245. static readonly BILLBOARDMODE_ALL: number;
  93246. /**
  93247. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93248. */
  93249. static readonly BILLBOARDMODE_STRETCHED: number;
  93250. /**
  93251. * This function can be defined to provide custom update for active particles.
  93252. * This function will be called instead of regular update (age, position, color, etc.).
  93253. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93254. */
  93255. updateFunction: (particles: Particle[]) => void;
  93256. private _emitterWorldMatrix;
  93257. /**
  93258. * This function can be defined to specify initial direction for every new particle.
  93259. * It by default use the emitterType defined function
  93260. */
  93261. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93262. /**
  93263. * This function can be defined to specify initial position for every new particle.
  93264. * It by default use the emitterType defined function
  93265. */
  93266. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93267. /**
  93268. * @hidden
  93269. */
  93270. _inheritedVelocityOffset: Vector3;
  93271. /**
  93272. * An event triggered when the system is disposed
  93273. */
  93274. onDisposeObservable: Observable<IParticleSystem>;
  93275. /**
  93276. * An event triggered when the system is stopped
  93277. */
  93278. onStoppedObservable: Observable<IParticleSystem>;
  93279. private _onDisposeObserver;
  93280. /**
  93281. * Sets a callback that will be triggered when the system is disposed
  93282. */
  93283. set onDispose(callback: () => void);
  93284. private _particles;
  93285. private _epsilon;
  93286. private _capacity;
  93287. private _stockParticles;
  93288. private _newPartsExcess;
  93289. private _vertexData;
  93290. private _vertexBuffer;
  93291. private _vertexBuffers;
  93292. private _spriteBuffer;
  93293. private _indexBuffer;
  93294. private _effect;
  93295. private _customEffect;
  93296. private _cachedDefines;
  93297. private _scaledColorStep;
  93298. private _colorDiff;
  93299. private _scaledDirection;
  93300. private _scaledGravity;
  93301. private _currentRenderId;
  93302. private _alive;
  93303. private _useInstancing;
  93304. private _started;
  93305. private _stopped;
  93306. private _actualFrame;
  93307. private _scaledUpdateSpeed;
  93308. private _vertexBufferSize;
  93309. /** @hidden */
  93310. _currentEmitRateGradient: Nullable<FactorGradient>;
  93311. /** @hidden */
  93312. _currentEmitRate1: number;
  93313. /** @hidden */
  93314. _currentEmitRate2: number;
  93315. /** @hidden */
  93316. _currentStartSizeGradient: Nullable<FactorGradient>;
  93317. /** @hidden */
  93318. _currentStartSize1: number;
  93319. /** @hidden */
  93320. _currentStartSize2: number;
  93321. private readonly _rawTextureWidth;
  93322. private _rampGradientsTexture;
  93323. private _useRampGradients;
  93324. /** Gets or sets a matrix to use to compute projection */
  93325. defaultProjectionMatrix: Matrix;
  93326. /** Gets or sets a matrix to use to compute view */
  93327. defaultViewMatrix: Matrix;
  93328. /** Gets or sets a boolean indicating that ramp gradients must be used
  93329. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93330. */
  93331. get useRampGradients(): boolean;
  93332. set useRampGradients(value: boolean);
  93333. /**
  93334. * 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.
  93335. * 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: [])
  93336. */
  93337. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93338. private _subEmitters;
  93339. /**
  93340. * @hidden
  93341. * If the particle systems emitter should be disposed when the particle system is disposed
  93342. */
  93343. _disposeEmitterOnDispose: boolean;
  93344. /**
  93345. * The current active Sub-systems, this property is used by the root particle system only.
  93346. */
  93347. activeSubSystems: Array<ParticleSystem>;
  93348. /**
  93349. * Specifies if the particles are updated in emitter local space or world space
  93350. */
  93351. isLocal: boolean;
  93352. private _rootParticleSystem;
  93353. /**
  93354. * Gets the current list of active particles
  93355. */
  93356. get particles(): Particle[];
  93357. /**
  93358. * Gets the number of particles active at the same time.
  93359. * @returns The number of active particles.
  93360. */
  93361. getActiveCount(): number;
  93362. /**
  93363. * Returns the string "ParticleSystem"
  93364. * @returns a string containing the class name
  93365. */
  93366. getClassName(): string;
  93367. /**
  93368. * Gets a boolean indicating that the system is stopping
  93369. * @returns true if the system is currently stopping
  93370. */
  93371. isStopping(): boolean;
  93372. /**
  93373. * Gets the custom effect used to render the particles
  93374. * @param blendMode Blend mode for which the effect should be retrieved
  93375. * @returns The effect
  93376. */
  93377. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93378. /**
  93379. * Sets the custom effect used to render the particles
  93380. * @param effect The effect to set
  93381. * @param blendMode Blend mode for which the effect should be set
  93382. */
  93383. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93384. /** @hidden */
  93385. private _onBeforeDrawParticlesObservable;
  93386. /**
  93387. * Observable that will be called just before the particles are drawn
  93388. */
  93389. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93390. /**
  93391. * Gets the name of the particle vertex shader
  93392. */
  93393. get vertexShaderName(): string;
  93394. /**
  93395. * Instantiates a particle system.
  93396. * 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.
  93397. * @param name The name of the particle system
  93398. * @param capacity The max number of particles alive at the same time
  93399. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93400. * @param customEffect a custom effect used to change the way particles are rendered by default
  93401. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93402. * @param epsilon Offset used to render the particles
  93403. */
  93404. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93405. private _addFactorGradient;
  93406. private _removeFactorGradient;
  93407. /**
  93408. * Adds a new life time gradient
  93409. * @param gradient defines the gradient to use (between 0 and 1)
  93410. * @param factor defines the life time factor to affect to the specified gradient
  93411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93412. * @returns the current particle system
  93413. */
  93414. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93415. /**
  93416. * Remove a specific life time gradient
  93417. * @param gradient defines the gradient to remove
  93418. * @returns the current particle system
  93419. */
  93420. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93421. /**
  93422. * Adds a new size gradient
  93423. * @param gradient defines the gradient to use (between 0 and 1)
  93424. * @param factor defines the size factor to affect to the specified gradient
  93425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93426. * @returns the current particle system
  93427. */
  93428. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93429. /**
  93430. * Remove a specific size gradient
  93431. * @param gradient defines the gradient to remove
  93432. * @returns the current particle system
  93433. */
  93434. removeSizeGradient(gradient: number): IParticleSystem;
  93435. /**
  93436. * Adds a new color remap gradient
  93437. * @param gradient defines the gradient to use (between 0 and 1)
  93438. * @param min defines the color remap minimal range
  93439. * @param max defines the color remap maximal range
  93440. * @returns the current particle system
  93441. */
  93442. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93443. /**
  93444. * Remove a specific color remap gradient
  93445. * @param gradient defines the gradient to remove
  93446. * @returns the current particle system
  93447. */
  93448. removeColorRemapGradient(gradient: number): IParticleSystem;
  93449. /**
  93450. * Adds a new alpha remap gradient
  93451. * @param gradient defines the gradient to use (between 0 and 1)
  93452. * @param min defines the alpha remap minimal range
  93453. * @param max defines the alpha remap maximal range
  93454. * @returns the current particle system
  93455. */
  93456. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93457. /**
  93458. * Remove a specific alpha remap gradient
  93459. * @param gradient defines the gradient to remove
  93460. * @returns the current particle system
  93461. */
  93462. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93463. /**
  93464. * Adds a new angular speed gradient
  93465. * @param gradient defines the gradient to use (between 0 and 1)
  93466. * @param factor defines the angular speed to affect to the specified gradient
  93467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93468. * @returns the current particle system
  93469. */
  93470. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93471. /**
  93472. * Remove a specific angular speed gradient
  93473. * @param gradient defines the gradient to remove
  93474. * @returns the current particle system
  93475. */
  93476. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93477. /**
  93478. * Adds a new velocity gradient
  93479. * @param gradient defines the gradient to use (between 0 and 1)
  93480. * @param factor defines the velocity to affect to the specified gradient
  93481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93482. * @returns the current particle system
  93483. */
  93484. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93485. /**
  93486. * Remove a specific velocity gradient
  93487. * @param gradient defines the gradient to remove
  93488. * @returns the current particle system
  93489. */
  93490. removeVelocityGradient(gradient: number): IParticleSystem;
  93491. /**
  93492. * Adds a new limit velocity gradient
  93493. * @param gradient defines the gradient to use (between 0 and 1)
  93494. * @param factor defines the limit velocity value to affect to the specified gradient
  93495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93496. * @returns the current particle system
  93497. */
  93498. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93499. /**
  93500. * Remove a specific limit velocity gradient
  93501. * @param gradient defines the gradient to remove
  93502. * @returns the current particle system
  93503. */
  93504. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93505. /**
  93506. * Adds a new drag gradient
  93507. * @param gradient defines the gradient to use (between 0 and 1)
  93508. * @param factor defines the drag value to affect to the specified gradient
  93509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93510. * @returns the current particle system
  93511. */
  93512. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93513. /**
  93514. * Remove a specific drag gradient
  93515. * @param gradient defines the gradient to remove
  93516. * @returns the current particle system
  93517. */
  93518. removeDragGradient(gradient: number): IParticleSystem;
  93519. /**
  93520. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93521. * @param gradient defines the gradient to use (between 0 and 1)
  93522. * @param factor defines the emit rate value to affect to the specified gradient
  93523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93524. * @returns the current particle system
  93525. */
  93526. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93527. /**
  93528. * Remove a specific emit rate gradient
  93529. * @param gradient defines the gradient to remove
  93530. * @returns the current particle system
  93531. */
  93532. removeEmitRateGradient(gradient: number): IParticleSystem;
  93533. /**
  93534. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93535. * @param gradient defines the gradient to use (between 0 and 1)
  93536. * @param factor defines the start size value to affect to the specified gradient
  93537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93538. * @returns the current particle system
  93539. */
  93540. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93541. /**
  93542. * Remove a specific start size gradient
  93543. * @param gradient defines the gradient to remove
  93544. * @returns the current particle system
  93545. */
  93546. removeStartSizeGradient(gradient: number): IParticleSystem;
  93547. private _createRampGradientTexture;
  93548. /**
  93549. * Gets the current list of ramp gradients.
  93550. * You must use addRampGradient and removeRampGradient to udpate this list
  93551. * @returns the list of ramp gradients
  93552. */
  93553. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93554. /** Force the system to rebuild all gradients that need to be resync */
  93555. forceRefreshGradients(): void;
  93556. private _syncRampGradientTexture;
  93557. /**
  93558. * Adds a new ramp gradient used to remap particle colors
  93559. * @param gradient defines the gradient to use (between 0 and 1)
  93560. * @param color defines the color to affect to the specified gradient
  93561. * @returns the current particle system
  93562. */
  93563. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93564. /**
  93565. * Remove a specific ramp gradient
  93566. * @param gradient defines the gradient to remove
  93567. * @returns the current particle system
  93568. */
  93569. removeRampGradient(gradient: number): ParticleSystem;
  93570. /**
  93571. * Adds a new color gradient
  93572. * @param gradient defines the gradient to use (between 0 and 1)
  93573. * @param color1 defines the color to affect to the specified gradient
  93574. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93575. * @returns this particle system
  93576. */
  93577. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93578. /**
  93579. * Remove a specific color gradient
  93580. * @param gradient defines the gradient to remove
  93581. * @returns this particle system
  93582. */
  93583. removeColorGradient(gradient: number): IParticleSystem;
  93584. private _fetchR;
  93585. protected _reset(): void;
  93586. private _resetEffect;
  93587. private _createVertexBuffers;
  93588. private _createIndexBuffer;
  93589. /**
  93590. * Gets the maximum number of particles active at the same time.
  93591. * @returns The max number of active particles.
  93592. */
  93593. getCapacity(): number;
  93594. /**
  93595. * Gets whether there are still active particles in the system.
  93596. * @returns True if it is alive, otherwise false.
  93597. */
  93598. isAlive(): boolean;
  93599. /**
  93600. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93601. * @returns True if it has been started, otherwise false.
  93602. */
  93603. isStarted(): boolean;
  93604. private _prepareSubEmitterInternalArray;
  93605. /**
  93606. * Starts the particle system and begins to emit
  93607. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93608. */
  93609. start(delay?: number): void;
  93610. /**
  93611. * Stops the particle system.
  93612. * @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.
  93613. */
  93614. stop(stopSubEmitters?: boolean): void;
  93615. /**
  93616. * Remove all active particles
  93617. */
  93618. reset(): void;
  93619. /**
  93620. * @hidden (for internal use only)
  93621. */
  93622. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93623. /**
  93624. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93625. * Its lifetime will start back at 0.
  93626. */
  93627. recycleParticle: (particle: Particle) => void;
  93628. private _stopSubEmitters;
  93629. private _createParticle;
  93630. private _removeFromRoot;
  93631. private _emitFromParticle;
  93632. private _update;
  93633. /** @hidden */
  93634. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93635. /** @hidden */
  93636. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93637. /**
  93638. * Fill the defines array according to the current settings of the particle system
  93639. * @param defines Array to be updated
  93640. * @param blendMode blend mode to take into account when updating the array
  93641. */
  93642. fillDefines(defines: Array<string>, blendMode: number): void;
  93643. /**
  93644. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93645. * @param uniforms Uniforms array to fill
  93646. * @param attributes Attributes array to fill
  93647. * @param samplers Samplers array to fill
  93648. */
  93649. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93650. /** @hidden */
  93651. private _getEffect;
  93652. /**
  93653. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93654. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93655. */
  93656. animate(preWarmOnly?: boolean): void;
  93657. private _appendParticleVertices;
  93658. /**
  93659. * Rebuilds the particle system.
  93660. */
  93661. rebuild(): void;
  93662. /**
  93663. * Is this system ready to be used/rendered
  93664. * @return true if the system is ready
  93665. */
  93666. isReady(): boolean;
  93667. private _render;
  93668. /**
  93669. * Renders the particle system in its current state.
  93670. * @returns the current number of particles
  93671. */
  93672. render(): number;
  93673. /**
  93674. * Disposes the particle system and free the associated resources
  93675. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93676. */
  93677. dispose(disposeTexture?: boolean): void;
  93678. /**
  93679. * Clones the particle system.
  93680. * @param name The name of the cloned object
  93681. * @param newEmitter The new emitter to use
  93682. * @returns the cloned particle system
  93683. */
  93684. clone(name: string, newEmitter: any): ParticleSystem;
  93685. /**
  93686. * Serializes the particle system to a JSON object
  93687. * @param serializeTexture defines if the texture must be serialized as well
  93688. * @returns the JSON object
  93689. */
  93690. serialize(serializeTexture?: boolean): any;
  93691. /** @hidden */
  93692. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93693. /** @hidden */
  93694. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93695. /**
  93696. * Parses a JSON object to create a particle system.
  93697. * @param parsedParticleSystem The JSON object to parse
  93698. * @param sceneOrEngine The scene or the engine to create the particle system in
  93699. * @param rootUrl The root url to use to load external dependencies like texture
  93700. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93701. * @returns the Parsed particle system
  93702. */
  93703. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93704. }
  93705. }
  93706. declare module BABYLON {
  93707. /**
  93708. * A particle represents one of the element emitted by a particle system.
  93709. * This is mainly define by its coordinates, direction, velocity and age.
  93710. */
  93711. export class Particle {
  93712. /**
  93713. * The particle system the particle belongs to.
  93714. */
  93715. particleSystem: ParticleSystem;
  93716. private static _Count;
  93717. /**
  93718. * Unique ID of the particle
  93719. */
  93720. id: number;
  93721. /**
  93722. * The world position of the particle in the scene.
  93723. */
  93724. position: Vector3;
  93725. /**
  93726. * The world direction of the particle in the scene.
  93727. */
  93728. direction: Vector3;
  93729. /**
  93730. * The color of the particle.
  93731. */
  93732. color: Color4;
  93733. /**
  93734. * The color change of the particle per step.
  93735. */
  93736. colorStep: Color4;
  93737. /**
  93738. * Defines how long will the life of the particle be.
  93739. */
  93740. lifeTime: number;
  93741. /**
  93742. * The current age of the particle.
  93743. */
  93744. age: number;
  93745. /**
  93746. * The current size of the particle.
  93747. */
  93748. size: number;
  93749. /**
  93750. * The current scale of the particle.
  93751. */
  93752. scale: Vector2;
  93753. /**
  93754. * The current angle of the particle.
  93755. */
  93756. angle: number;
  93757. /**
  93758. * Defines how fast is the angle changing.
  93759. */
  93760. angularSpeed: number;
  93761. /**
  93762. * Defines the cell index used by the particle to be rendered from a sprite.
  93763. */
  93764. cellIndex: number;
  93765. /**
  93766. * The information required to support color remapping
  93767. */
  93768. remapData: Vector4;
  93769. /** @hidden */
  93770. _randomCellOffset?: number;
  93771. /** @hidden */
  93772. _initialDirection: Nullable<Vector3>;
  93773. /** @hidden */
  93774. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93775. /** @hidden */
  93776. _initialStartSpriteCellID: number;
  93777. /** @hidden */
  93778. _initialEndSpriteCellID: number;
  93779. /** @hidden */
  93780. _currentColorGradient: Nullable<ColorGradient>;
  93781. /** @hidden */
  93782. _currentColor1: Color4;
  93783. /** @hidden */
  93784. _currentColor2: Color4;
  93785. /** @hidden */
  93786. _currentSizeGradient: Nullable<FactorGradient>;
  93787. /** @hidden */
  93788. _currentSize1: number;
  93789. /** @hidden */
  93790. _currentSize2: number;
  93791. /** @hidden */
  93792. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93793. /** @hidden */
  93794. _currentAngularSpeed1: number;
  93795. /** @hidden */
  93796. _currentAngularSpeed2: number;
  93797. /** @hidden */
  93798. _currentVelocityGradient: Nullable<FactorGradient>;
  93799. /** @hidden */
  93800. _currentVelocity1: number;
  93801. /** @hidden */
  93802. _currentVelocity2: number;
  93803. /** @hidden */
  93804. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93805. /** @hidden */
  93806. _currentLimitVelocity1: number;
  93807. /** @hidden */
  93808. _currentLimitVelocity2: number;
  93809. /** @hidden */
  93810. _currentDragGradient: Nullable<FactorGradient>;
  93811. /** @hidden */
  93812. _currentDrag1: number;
  93813. /** @hidden */
  93814. _currentDrag2: number;
  93815. /** @hidden */
  93816. _randomNoiseCoordinates1: Vector3;
  93817. /** @hidden */
  93818. _randomNoiseCoordinates2: Vector3;
  93819. /** @hidden */
  93820. _localPosition?: Vector3;
  93821. /**
  93822. * Creates a new instance Particle
  93823. * @param particleSystem the particle system the particle belongs to
  93824. */
  93825. constructor(
  93826. /**
  93827. * The particle system the particle belongs to.
  93828. */
  93829. particleSystem: ParticleSystem);
  93830. private updateCellInfoFromSystem;
  93831. /**
  93832. * Defines how the sprite cell index is updated for the particle
  93833. */
  93834. updateCellIndex(): void;
  93835. /** @hidden */
  93836. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93837. /** @hidden */
  93838. _inheritParticleInfoToSubEmitters(): void;
  93839. /** @hidden */
  93840. _reset(): void;
  93841. /**
  93842. * Copy the properties of particle to another one.
  93843. * @param other the particle to copy the information to.
  93844. */
  93845. copyTo(other: Particle): void;
  93846. }
  93847. }
  93848. declare module BABYLON {
  93849. /**
  93850. * Particle emitter represents a volume emitting particles.
  93851. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93852. */
  93853. export interface IParticleEmitterType {
  93854. /**
  93855. * Called by the particle System when the direction is computed for the created particle.
  93856. * @param worldMatrix is the world matrix of the particle system
  93857. * @param directionToUpdate is the direction vector to update with the result
  93858. * @param particle is the particle we are computed the direction for
  93859. * @param isLocal defines if the direction should be set in local space
  93860. */
  93861. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93862. /**
  93863. * Called by the particle System when the position is computed for the created particle.
  93864. * @param worldMatrix is the world matrix of the particle system
  93865. * @param positionToUpdate is the position vector to update with the result
  93866. * @param particle is the particle we are computed the position for
  93867. * @param isLocal defines if the position should be set in local space
  93868. */
  93869. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93870. /**
  93871. * Clones the current emitter and returns a copy of it
  93872. * @returns the new emitter
  93873. */
  93874. clone(): IParticleEmitterType;
  93875. /**
  93876. * Called by the GPUParticleSystem to setup the update shader
  93877. * @param effect defines the update shader
  93878. */
  93879. applyToShader(effect: Effect): void;
  93880. /**
  93881. * Returns a string to use to update the GPU particles update shader
  93882. * @returns the effect defines string
  93883. */
  93884. getEffectDefines(): string;
  93885. /**
  93886. * Returns a string representing the class name
  93887. * @returns a string containing the class name
  93888. */
  93889. getClassName(): string;
  93890. /**
  93891. * Serializes the particle system to a JSON object.
  93892. * @returns the JSON object
  93893. */
  93894. serialize(): any;
  93895. /**
  93896. * Parse properties from a JSON object
  93897. * @param serializationObject defines the JSON object
  93898. * @param scene defines the hosting scene
  93899. */
  93900. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93901. }
  93902. }
  93903. declare module BABYLON {
  93904. /**
  93905. * Particle emitter emitting particles from the inside of a box.
  93906. * It emits the particles randomly between 2 given directions.
  93907. */
  93908. export class BoxParticleEmitter implements IParticleEmitterType {
  93909. /**
  93910. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93911. */
  93912. direction1: Vector3;
  93913. /**
  93914. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93915. */
  93916. direction2: Vector3;
  93917. /**
  93918. * 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.
  93919. */
  93920. minEmitBox: Vector3;
  93921. /**
  93922. * 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.
  93923. */
  93924. maxEmitBox: Vector3;
  93925. /**
  93926. * Creates a new instance BoxParticleEmitter
  93927. */
  93928. constructor();
  93929. /**
  93930. * Called by the particle System when the direction is computed for the created particle.
  93931. * @param worldMatrix is the world matrix of the particle system
  93932. * @param directionToUpdate is the direction vector to update with the result
  93933. * @param particle is the particle we are computed the direction for
  93934. * @param isLocal defines if the direction should be set in local space
  93935. */
  93936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93937. /**
  93938. * Called by the particle System when the position is computed for the created particle.
  93939. * @param worldMatrix is the world matrix of the particle system
  93940. * @param positionToUpdate is the position vector to update with the result
  93941. * @param particle is the particle we are computed the position for
  93942. * @param isLocal defines if the position should be set in local space
  93943. */
  93944. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93945. /**
  93946. * Clones the current emitter and returns a copy of it
  93947. * @returns the new emitter
  93948. */
  93949. clone(): BoxParticleEmitter;
  93950. /**
  93951. * Called by the GPUParticleSystem to setup the update shader
  93952. * @param effect defines the update shader
  93953. */
  93954. applyToShader(effect: Effect): void;
  93955. /**
  93956. * Returns a string to use to update the GPU particles update shader
  93957. * @returns a string containng the defines string
  93958. */
  93959. getEffectDefines(): string;
  93960. /**
  93961. * Returns the string "BoxParticleEmitter"
  93962. * @returns a string containing the class name
  93963. */
  93964. getClassName(): string;
  93965. /**
  93966. * Serializes the particle system to a JSON object.
  93967. * @returns the JSON object
  93968. */
  93969. serialize(): any;
  93970. /**
  93971. * Parse properties from a JSON object
  93972. * @param serializationObject defines the JSON object
  93973. */
  93974. parse(serializationObject: any): void;
  93975. }
  93976. }
  93977. declare module BABYLON {
  93978. /**
  93979. * Particle emitter emitting particles from the inside of a cone.
  93980. * It emits the particles alongside the cone volume from the base to the particle.
  93981. * The emission direction might be randomized.
  93982. */
  93983. export class ConeParticleEmitter implements IParticleEmitterType {
  93984. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93985. directionRandomizer: number;
  93986. private _radius;
  93987. private _angle;
  93988. private _height;
  93989. /**
  93990. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93991. */
  93992. radiusRange: number;
  93993. /**
  93994. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93995. */
  93996. heightRange: number;
  93997. /**
  93998. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93999. */
  94000. emitFromSpawnPointOnly: boolean;
  94001. /**
  94002. * Gets or sets the radius of the emission cone
  94003. */
  94004. get radius(): number;
  94005. set radius(value: number);
  94006. /**
  94007. * Gets or sets the angle of the emission cone
  94008. */
  94009. get angle(): number;
  94010. set angle(value: number);
  94011. private _buildHeight;
  94012. /**
  94013. * Creates a new instance ConeParticleEmitter
  94014. * @param radius the radius of the emission cone (1 by default)
  94015. * @param angle the cone base angle (PI by default)
  94016. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94017. */
  94018. constructor(radius?: number, angle?: number,
  94019. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94020. directionRandomizer?: number);
  94021. /**
  94022. * Called by the particle System when the direction is computed for the created particle.
  94023. * @param worldMatrix is the world matrix of the particle system
  94024. * @param directionToUpdate is the direction vector to update with the result
  94025. * @param particle is the particle we are computed the direction for
  94026. * @param isLocal defines if the direction should be set in local space
  94027. */
  94028. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94029. /**
  94030. * Called by the particle System when the position is computed for the created particle.
  94031. * @param worldMatrix is the world matrix of the particle system
  94032. * @param positionToUpdate is the position vector to update with the result
  94033. * @param particle is the particle we are computed the position for
  94034. * @param isLocal defines if the position should be set in local space
  94035. */
  94036. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94037. /**
  94038. * Clones the current emitter and returns a copy of it
  94039. * @returns the new emitter
  94040. */
  94041. clone(): ConeParticleEmitter;
  94042. /**
  94043. * Called by the GPUParticleSystem to setup the update shader
  94044. * @param effect defines the update shader
  94045. */
  94046. applyToShader(effect: Effect): void;
  94047. /**
  94048. * Returns a string to use to update the GPU particles update shader
  94049. * @returns a string containng the defines string
  94050. */
  94051. getEffectDefines(): string;
  94052. /**
  94053. * Returns the string "ConeParticleEmitter"
  94054. * @returns a string containing the class name
  94055. */
  94056. getClassName(): string;
  94057. /**
  94058. * Serializes the particle system to a JSON object.
  94059. * @returns the JSON object
  94060. */
  94061. serialize(): any;
  94062. /**
  94063. * Parse properties from a JSON object
  94064. * @param serializationObject defines the JSON object
  94065. */
  94066. parse(serializationObject: any): void;
  94067. }
  94068. }
  94069. declare module BABYLON {
  94070. /**
  94071. * Particle emitter emitting particles from the inside of a cylinder.
  94072. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94073. */
  94074. export class CylinderParticleEmitter implements IParticleEmitterType {
  94075. /**
  94076. * The radius of the emission cylinder.
  94077. */
  94078. radius: number;
  94079. /**
  94080. * The height of the emission cylinder.
  94081. */
  94082. height: number;
  94083. /**
  94084. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94085. */
  94086. radiusRange: number;
  94087. /**
  94088. * How much to randomize the particle direction [0-1].
  94089. */
  94090. directionRandomizer: number;
  94091. /**
  94092. * Creates a new instance CylinderParticleEmitter
  94093. * @param radius the radius of the emission cylinder (1 by default)
  94094. * @param height the height of the emission cylinder (1 by default)
  94095. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94096. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94097. */
  94098. constructor(
  94099. /**
  94100. * The radius of the emission cylinder.
  94101. */
  94102. radius?: number,
  94103. /**
  94104. * The height of the emission cylinder.
  94105. */
  94106. height?: number,
  94107. /**
  94108. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94109. */
  94110. radiusRange?: number,
  94111. /**
  94112. * How much to randomize the particle direction [0-1].
  94113. */
  94114. directionRandomizer?: number);
  94115. /**
  94116. * Called by the particle System when the direction is computed for the created particle.
  94117. * @param worldMatrix is the world matrix of the particle system
  94118. * @param directionToUpdate is the direction vector to update with the result
  94119. * @param particle is the particle we are computed the direction for
  94120. * @param isLocal defines if the direction should be set in local space
  94121. */
  94122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94123. /**
  94124. * Called by the particle System when the position is computed for the created particle.
  94125. * @param worldMatrix is the world matrix of the particle system
  94126. * @param positionToUpdate is the position vector to update with the result
  94127. * @param particle is the particle we are computed the position for
  94128. * @param isLocal defines if the position should be set in local space
  94129. */
  94130. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94131. /**
  94132. * Clones the current emitter and returns a copy of it
  94133. * @returns the new emitter
  94134. */
  94135. clone(): CylinderParticleEmitter;
  94136. /**
  94137. * Called by the GPUParticleSystem to setup the update shader
  94138. * @param effect defines the update shader
  94139. */
  94140. applyToShader(effect: Effect): void;
  94141. /**
  94142. * Returns a string to use to update the GPU particles update shader
  94143. * @returns a string containng the defines string
  94144. */
  94145. getEffectDefines(): string;
  94146. /**
  94147. * Returns the string "CylinderParticleEmitter"
  94148. * @returns a string containing the class name
  94149. */
  94150. getClassName(): string;
  94151. /**
  94152. * Serializes the particle system to a JSON object.
  94153. * @returns the JSON object
  94154. */
  94155. serialize(): any;
  94156. /**
  94157. * Parse properties from a JSON object
  94158. * @param serializationObject defines the JSON object
  94159. */
  94160. parse(serializationObject: any): void;
  94161. }
  94162. /**
  94163. * Particle emitter emitting particles from the inside of a cylinder.
  94164. * It emits the particles randomly between two vectors.
  94165. */
  94166. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94167. /**
  94168. * The min limit of the emission direction.
  94169. */
  94170. direction1: Vector3;
  94171. /**
  94172. * The max limit of the emission direction.
  94173. */
  94174. direction2: Vector3;
  94175. /**
  94176. * Creates a new instance CylinderDirectedParticleEmitter
  94177. * @param radius the radius of the emission cylinder (1 by default)
  94178. * @param height the height of the emission cylinder (1 by default)
  94179. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94180. * @param direction1 the min limit of the emission direction (up vector by default)
  94181. * @param direction2 the max limit of the emission direction (up vector by default)
  94182. */
  94183. constructor(radius?: number, height?: number, radiusRange?: number,
  94184. /**
  94185. * The min limit of the emission direction.
  94186. */
  94187. direction1?: Vector3,
  94188. /**
  94189. * The max limit of the emission direction.
  94190. */
  94191. direction2?: Vector3);
  94192. /**
  94193. * Called by the particle System when the direction is computed for the created particle.
  94194. * @param worldMatrix is the world matrix of the particle system
  94195. * @param directionToUpdate is the direction vector to update with the result
  94196. * @param particle is the particle we are computed the direction for
  94197. */
  94198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94199. /**
  94200. * Clones the current emitter and returns a copy of it
  94201. * @returns the new emitter
  94202. */
  94203. clone(): CylinderDirectedParticleEmitter;
  94204. /**
  94205. * Called by the GPUParticleSystem to setup the update shader
  94206. * @param effect defines the update shader
  94207. */
  94208. applyToShader(effect: Effect): void;
  94209. /**
  94210. * Returns a string to use to update the GPU particles update shader
  94211. * @returns a string containng the defines string
  94212. */
  94213. getEffectDefines(): string;
  94214. /**
  94215. * Returns the string "CylinderDirectedParticleEmitter"
  94216. * @returns a string containing the class name
  94217. */
  94218. getClassName(): string;
  94219. /**
  94220. * Serializes the particle system to a JSON object.
  94221. * @returns the JSON object
  94222. */
  94223. serialize(): any;
  94224. /**
  94225. * Parse properties from a JSON object
  94226. * @param serializationObject defines the JSON object
  94227. */
  94228. parse(serializationObject: any): void;
  94229. }
  94230. }
  94231. declare module BABYLON {
  94232. /**
  94233. * Particle emitter emitting particles from the inside of a hemisphere.
  94234. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94235. */
  94236. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94237. /**
  94238. * The radius of the emission hemisphere.
  94239. */
  94240. radius: number;
  94241. /**
  94242. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94243. */
  94244. radiusRange: number;
  94245. /**
  94246. * How much to randomize the particle direction [0-1].
  94247. */
  94248. directionRandomizer: number;
  94249. /**
  94250. * Creates a new instance HemisphericParticleEmitter
  94251. * @param radius the radius of the emission hemisphere (1 by default)
  94252. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94253. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94254. */
  94255. constructor(
  94256. /**
  94257. * The radius of the emission hemisphere.
  94258. */
  94259. radius?: number,
  94260. /**
  94261. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94262. */
  94263. radiusRange?: number,
  94264. /**
  94265. * How much to randomize the particle direction [0-1].
  94266. */
  94267. directionRandomizer?: number);
  94268. /**
  94269. * Called by the particle System when the direction is computed for the created particle.
  94270. * @param worldMatrix is the world matrix of the particle system
  94271. * @param directionToUpdate is the direction vector to update with the result
  94272. * @param particle is the particle we are computed the direction for
  94273. * @param isLocal defines if the direction should be set in local space
  94274. */
  94275. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94276. /**
  94277. * Called by the particle System when the position is computed for the created particle.
  94278. * @param worldMatrix is the world matrix of the particle system
  94279. * @param positionToUpdate is the position vector to update with the result
  94280. * @param particle is the particle we are computed the position for
  94281. * @param isLocal defines if the position should be set in local space
  94282. */
  94283. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94284. /**
  94285. * Clones the current emitter and returns a copy of it
  94286. * @returns the new emitter
  94287. */
  94288. clone(): HemisphericParticleEmitter;
  94289. /**
  94290. * Called by the GPUParticleSystem to setup the update shader
  94291. * @param effect defines the update shader
  94292. */
  94293. applyToShader(effect: Effect): void;
  94294. /**
  94295. * Returns a string to use to update the GPU particles update shader
  94296. * @returns a string containng the defines string
  94297. */
  94298. getEffectDefines(): string;
  94299. /**
  94300. * Returns the string "HemisphericParticleEmitter"
  94301. * @returns a string containing the class name
  94302. */
  94303. getClassName(): string;
  94304. /**
  94305. * Serializes the particle system to a JSON object.
  94306. * @returns the JSON object
  94307. */
  94308. serialize(): any;
  94309. /**
  94310. * Parse properties from a JSON object
  94311. * @param serializationObject defines the JSON object
  94312. */
  94313. parse(serializationObject: any): void;
  94314. }
  94315. }
  94316. declare module BABYLON {
  94317. /**
  94318. * Particle emitter emitting particles from a point.
  94319. * It emits the particles randomly between 2 given directions.
  94320. */
  94321. export class PointParticleEmitter implements IParticleEmitterType {
  94322. /**
  94323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94324. */
  94325. direction1: Vector3;
  94326. /**
  94327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94328. */
  94329. direction2: Vector3;
  94330. /**
  94331. * Creates a new instance PointParticleEmitter
  94332. */
  94333. constructor();
  94334. /**
  94335. * Called by the particle System when the direction is computed for the created particle.
  94336. * @param worldMatrix is the world matrix of the particle system
  94337. * @param directionToUpdate is the direction vector to update with the result
  94338. * @param particle is the particle we are computed the direction for
  94339. * @param isLocal defines if the direction should be set in local space
  94340. */
  94341. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94342. /**
  94343. * Called by the particle System when the position is computed for the created particle.
  94344. * @param worldMatrix is the world matrix of the particle system
  94345. * @param positionToUpdate is the position vector to update with the result
  94346. * @param particle is the particle we are computed the position for
  94347. * @param isLocal defines if the position should be set in local space
  94348. */
  94349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94350. /**
  94351. * Clones the current emitter and returns a copy of it
  94352. * @returns the new emitter
  94353. */
  94354. clone(): PointParticleEmitter;
  94355. /**
  94356. * Called by the GPUParticleSystem to setup the update shader
  94357. * @param effect defines the update shader
  94358. */
  94359. applyToShader(effect: Effect): void;
  94360. /**
  94361. * Returns a string to use to update the GPU particles update shader
  94362. * @returns a string containng the defines string
  94363. */
  94364. getEffectDefines(): string;
  94365. /**
  94366. * Returns the string "PointParticleEmitter"
  94367. * @returns a string containing the class name
  94368. */
  94369. getClassName(): string;
  94370. /**
  94371. * Serializes the particle system to a JSON object.
  94372. * @returns the JSON object
  94373. */
  94374. serialize(): any;
  94375. /**
  94376. * Parse properties from a JSON object
  94377. * @param serializationObject defines the JSON object
  94378. */
  94379. parse(serializationObject: any): void;
  94380. }
  94381. }
  94382. declare module BABYLON {
  94383. /**
  94384. * Particle emitter emitting particles from the inside of a sphere.
  94385. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94386. */
  94387. export class SphereParticleEmitter implements IParticleEmitterType {
  94388. /**
  94389. * The radius of the emission sphere.
  94390. */
  94391. radius: number;
  94392. /**
  94393. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94394. */
  94395. radiusRange: number;
  94396. /**
  94397. * How much to randomize the particle direction [0-1].
  94398. */
  94399. directionRandomizer: number;
  94400. /**
  94401. * Creates a new instance SphereParticleEmitter
  94402. * @param radius the radius of the emission sphere (1 by default)
  94403. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94404. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94405. */
  94406. constructor(
  94407. /**
  94408. * The radius of the emission sphere.
  94409. */
  94410. radius?: number,
  94411. /**
  94412. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94413. */
  94414. radiusRange?: number,
  94415. /**
  94416. * How much to randomize the particle direction [0-1].
  94417. */
  94418. directionRandomizer?: number);
  94419. /**
  94420. * Called by the particle System when the direction is computed for the created particle.
  94421. * @param worldMatrix is the world matrix of the particle system
  94422. * @param directionToUpdate is the direction vector to update with the result
  94423. * @param particle is the particle we are computed the direction for
  94424. * @param isLocal defines if the direction should be set in local space
  94425. */
  94426. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94427. /**
  94428. * Called by the particle System when the position is computed for the created particle.
  94429. * @param worldMatrix is the world matrix of the particle system
  94430. * @param positionToUpdate is the position vector to update with the result
  94431. * @param particle is the particle we are computed the position for
  94432. * @param isLocal defines if the position should be set in local space
  94433. */
  94434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94435. /**
  94436. * Clones the current emitter and returns a copy of it
  94437. * @returns the new emitter
  94438. */
  94439. clone(): SphereParticleEmitter;
  94440. /**
  94441. * Called by the GPUParticleSystem to setup the update shader
  94442. * @param effect defines the update shader
  94443. */
  94444. applyToShader(effect: Effect): void;
  94445. /**
  94446. * Returns a string to use to update the GPU particles update shader
  94447. * @returns a string containng the defines string
  94448. */
  94449. getEffectDefines(): string;
  94450. /**
  94451. * Returns the string "SphereParticleEmitter"
  94452. * @returns a string containing the class name
  94453. */
  94454. getClassName(): string;
  94455. /**
  94456. * Serializes the particle system to a JSON object.
  94457. * @returns the JSON object
  94458. */
  94459. serialize(): any;
  94460. /**
  94461. * Parse properties from a JSON object
  94462. * @param serializationObject defines the JSON object
  94463. */
  94464. parse(serializationObject: any): void;
  94465. }
  94466. /**
  94467. * Particle emitter emitting particles from the inside of a sphere.
  94468. * It emits the particles randomly between two vectors.
  94469. */
  94470. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94471. /**
  94472. * The min limit of the emission direction.
  94473. */
  94474. direction1: Vector3;
  94475. /**
  94476. * The max limit of the emission direction.
  94477. */
  94478. direction2: Vector3;
  94479. /**
  94480. * Creates a new instance SphereDirectedParticleEmitter
  94481. * @param radius the radius of the emission sphere (1 by default)
  94482. * @param direction1 the min limit of the emission direction (up vector by default)
  94483. * @param direction2 the max limit of the emission direction (up vector by default)
  94484. */
  94485. constructor(radius?: number,
  94486. /**
  94487. * The min limit of the emission direction.
  94488. */
  94489. direction1?: Vector3,
  94490. /**
  94491. * The max limit of the emission direction.
  94492. */
  94493. direction2?: Vector3);
  94494. /**
  94495. * Called by the particle System when the direction is computed for the created particle.
  94496. * @param worldMatrix is the world matrix of the particle system
  94497. * @param directionToUpdate is the direction vector to update with the result
  94498. * @param particle is the particle we are computed the direction for
  94499. */
  94500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94501. /**
  94502. * Clones the current emitter and returns a copy of it
  94503. * @returns the new emitter
  94504. */
  94505. clone(): SphereDirectedParticleEmitter;
  94506. /**
  94507. * Called by the GPUParticleSystem to setup the update shader
  94508. * @param effect defines the update shader
  94509. */
  94510. applyToShader(effect: Effect): void;
  94511. /**
  94512. * Returns a string to use to update the GPU particles update shader
  94513. * @returns a string containng the defines string
  94514. */
  94515. getEffectDefines(): string;
  94516. /**
  94517. * Returns the string "SphereDirectedParticleEmitter"
  94518. * @returns a string containing the class name
  94519. */
  94520. getClassName(): string;
  94521. /**
  94522. * Serializes the particle system to a JSON object.
  94523. * @returns the JSON object
  94524. */
  94525. serialize(): any;
  94526. /**
  94527. * Parse properties from a JSON object
  94528. * @param serializationObject defines the JSON object
  94529. */
  94530. parse(serializationObject: any): void;
  94531. }
  94532. }
  94533. declare module BABYLON {
  94534. /**
  94535. * Particle emitter emitting particles from a custom list of positions.
  94536. */
  94537. export class CustomParticleEmitter implements IParticleEmitterType {
  94538. /**
  94539. * Gets or sets the position generator that will create the inital position of each particle.
  94540. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94541. */
  94542. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94543. /**
  94544. * Gets or sets the destination generator that will create the final destination of each particle.
  94545. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94546. */
  94547. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94548. /**
  94549. * Creates a new instance CustomParticleEmitter
  94550. */
  94551. constructor();
  94552. /**
  94553. * Called by the particle System when the direction is computed for the created particle.
  94554. * @param worldMatrix is the world matrix of the particle system
  94555. * @param directionToUpdate is the direction vector to update with the result
  94556. * @param particle is the particle we are computed the direction for
  94557. * @param isLocal defines if the direction should be set in local space
  94558. */
  94559. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94560. /**
  94561. * Called by the particle System when the position is computed for the created particle.
  94562. * @param worldMatrix is the world matrix of the particle system
  94563. * @param positionToUpdate is the position vector to update with the result
  94564. * @param particle is the particle we are computed the position for
  94565. * @param isLocal defines if the position should be set in local space
  94566. */
  94567. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94568. /**
  94569. * Clones the current emitter and returns a copy of it
  94570. * @returns the new emitter
  94571. */
  94572. clone(): CustomParticleEmitter;
  94573. /**
  94574. * Called by the GPUParticleSystem to setup the update shader
  94575. * @param effect defines the update shader
  94576. */
  94577. applyToShader(effect: Effect): void;
  94578. /**
  94579. * Returns a string to use to update the GPU particles update shader
  94580. * @returns a string containng the defines string
  94581. */
  94582. getEffectDefines(): string;
  94583. /**
  94584. * Returns the string "PointParticleEmitter"
  94585. * @returns a string containing the class name
  94586. */
  94587. getClassName(): string;
  94588. /**
  94589. * Serializes the particle system to a JSON object.
  94590. * @returns the JSON object
  94591. */
  94592. serialize(): any;
  94593. /**
  94594. * Parse properties from a JSON object
  94595. * @param serializationObject defines the JSON object
  94596. */
  94597. parse(serializationObject: any): void;
  94598. }
  94599. }
  94600. declare module BABYLON {
  94601. /**
  94602. * Particle emitter emitting particles from the inside of a box.
  94603. * It emits the particles randomly between 2 given directions.
  94604. */
  94605. export class MeshParticleEmitter implements IParticleEmitterType {
  94606. private _indices;
  94607. private _positions;
  94608. private _normals;
  94609. private _storedNormal;
  94610. private _mesh;
  94611. /**
  94612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94613. */
  94614. direction1: Vector3;
  94615. /**
  94616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94617. */
  94618. direction2: Vector3;
  94619. /**
  94620. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94621. */
  94622. useMeshNormalsForDirection: boolean;
  94623. /** Defines the mesh to use as source */
  94624. get mesh(): Nullable<AbstractMesh>;
  94625. set mesh(value: Nullable<AbstractMesh>);
  94626. /**
  94627. * Creates a new instance MeshParticleEmitter
  94628. * @param mesh defines the mesh to use as source
  94629. */
  94630. constructor(mesh?: Nullable<AbstractMesh>);
  94631. /**
  94632. * Called by the particle System when the direction is computed for the created particle.
  94633. * @param worldMatrix is the world matrix of the particle system
  94634. * @param directionToUpdate is the direction vector to update with the result
  94635. * @param particle is the particle we are computed the direction for
  94636. * @param isLocal defines if the direction should be set in local space
  94637. */
  94638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94639. /**
  94640. * Called by the particle System when the position is computed for the created particle.
  94641. * @param worldMatrix is the world matrix of the particle system
  94642. * @param positionToUpdate is the position vector to update with the result
  94643. * @param particle is the particle we are computed the position for
  94644. * @param isLocal defines if the position should be set in local space
  94645. */
  94646. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94647. /**
  94648. * Clones the current emitter and returns a copy of it
  94649. * @returns the new emitter
  94650. */
  94651. clone(): MeshParticleEmitter;
  94652. /**
  94653. * Called by the GPUParticleSystem to setup the update shader
  94654. * @param effect defines the update shader
  94655. */
  94656. applyToShader(effect: Effect): void;
  94657. /**
  94658. * Returns a string to use to update the GPU particles update shader
  94659. * @returns a string containng the defines string
  94660. */
  94661. getEffectDefines(): string;
  94662. /**
  94663. * Returns the string "BoxParticleEmitter"
  94664. * @returns a string containing the class name
  94665. */
  94666. getClassName(): string;
  94667. /**
  94668. * Serializes the particle system to a JSON object.
  94669. * @returns the JSON object
  94670. */
  94671. serialize(): any;
  94672. /**
  94673. * Parse properties from a JSON object
  94674. * @param serializationObject defines the JSON object
  94675. * @param scene defines the hosting scene
  94676. */
  94677. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94678. }
  94679. }
  94680. declare module BABYLON {
  94681. /**
  94682. * Interface representing a particle system in Babylon.js.
  94683. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94684. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94685. */
  94686. export interface IParticleSystem {
  94687. /**
  94688. * List of animations used by the particle system.
  94689. */
  94690. animations: Animation[];
  94691. /**
  94692. * The id of the Particle system.
  94693. */
  94694. id: string;
  94695. /**
  94696. * The name of the Particle system.
  94697. */
  94698. name: string;
  94699. /**
  94700. * The emitter represents the Mesh or position we are attaching the particle system to.
  94701. */
  94702. emitter: Nullable<AbstractMesh | Vector3>;
  94703. /**
  94704. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94705. */
  94706. isBillboardBased: boolean;
  94707. /**
  94708. * The rendering group used by the Particle system to chose when to render.
  94709. */
  94710. renderingGroupId: number;
  94711. /**
  94712. * The layer mask we are rendering the particles through.
  94713. */
  94714. layerMask: number;
  94715. /**
  94716. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94717. */
  94718. updateSpeed: number;
  94719. /**
  94720. * The amount of time the particle system is running (depends of the overall update speed).
  94721. */
  94722. targetStopDuration: number;
  94723. /**
  94724. * The texture used to render each particle. (this can be a spritesheet)
  94725. */
  94726. particleTexture: Nullable<BaseTexture>;
  94727. /**
  94728. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94729. */
  94730. blendMode: number;
  94731. /**
  94732. * Minimum life time of emitting particles.
  94733. */
  94734. minLifeTime: number;
  94735. /**
  94736. * Maximum life time of emitting particles.
  94737. */
  94738. maxLifeTime: number;
  94739. /**
  94740. * Minimum Size of emitting particles.
  94741. */
  94742. minSize: number;
  94743. /**
  94744. * Maximum Size of emitting particles.
  94745. */
  94746. maxSize: number;
  94747. /**
  94748. * Minimum scale of emitting particles on X axis.
  94749. */
  94750. minScaleX: number;
  94751. /**
  94752. * Maximum scale of emitting particles on X axis.
  94753. */
  94754. maxScaleX: number;
  94755. /**
  94756. * Minimum scale of emitting particles on Y axis.
  94757. */
  94758. minScaleY: number;
  94759. /**
  94760. * Maximum scale of emitting particles on Y axis.
  94761. */
  94762. maxScaleY: number;
  94763. /**
  94764. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94765. */
  94766. color1: Color4;
  94767. /**
  94768. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94769. */
  94770. color2: Color4;
  94771. /**
  94772. * Color the particle will have at the end of its lifetime.
  94773. */
  94774. colorDead: Color4;
  94775. /**
  94776. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94777. */
  94778. emitRate: number;
  94779. /**
  94780. * You can use gravity if you want to give an orientation to your particles.
  94781. */
  94782. gravity: Vector3;
  94783. /**
  94784. * Minimum power of emitting particles.
  94785. */
  94786. minEmitPower: number;
  94787. /**
  94788. * Maximum power of emitting particles.
  94789. */
  94790. maxEmitPower: number;
  94791. /**
  94792. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94793. */
  94794. minAngularSpeed: number;
  94795. /**
  94796. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94797. */
  94798. maxAngularSpeed: number;
  94799. /**
  94800. * Gets or sets the minimal initial rotation in radians.
  94801. */
  94802. minInitialRotation: number;
  94803. /**
  94804. * Gets or sets the maximal initial rotation in radians.
  94805. */
  94806. maxInitialRotation: number;
  94807. /**
  94808. * The particle emitter type defines the emitter used by the particle system.
  94809. * It can be for example box, sphere, or cone...
  94810. */
  94811. particleEmitterType: Nullable<IParticleEmitterType>;
  94812. /**
  94813. * Defines the delay in milliseconds before starting the system (0 by default)
  94814. */
  94815. startDelay: number;
  94816. /**
  94817. * 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
  94818. */
  94819. preWarmCycles: number;
  94820. /**
  94821. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94822. */
  94823. preWarmStepOffset: number;
  94824. /**
  94825. * 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)
  94826. */
  94827. spriteCellChangeSpeed: number;
  94828. /**
  94829. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94830. */
  94831. startSpriteCellID: number;
  94832. /**
  94833. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94834. */
  94835. endSpriteCellID: number;
  94836. /**
  94837. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94838. */
  94839. spriteCellWidth: number;
  94840. /**
  94841. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94842. */
  94843. spriteCellHeight: number;
  94844. /**
  94845. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94846. */
  94847. spriteRandomStartCell: boolean;
  94848. /**
  94849. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94850. */
  94851. isAnimationSheetEnabled: boolean;
  94852. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94853. translationPivot: Vector2;
  94854. /**
  94855. * Gets or sets a texture used to add random noise to particle positions
  94856. */
  94857. noiseTexture: Nullable<BaseTexture>;
  94858. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94859. noiseStrength: Vector3;
  94860. /**
  94861. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94862. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94863. */
  94864. billboardMode: number;
  94865. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94866. limitVelocityDamping: number;
  94867. /**
  94868. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94869. */
  94870. beginAnimationOnStart: boolean;
  94871. /**
  94872. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94873. */
  94874. beginAnimationFrom: number;
  94875. /**
  94876. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94877. */
  94878. beginAnimationTo: number;
  94879. /**
  94880. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94881. */
  94882. beginAnimationLoop: boolean;
  94883. /**
  94884. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94885. */
  94886. disposeOnStop: boolean;
  94887. /**
  94888. * Specifies if the particles are updated in emitter local space or world space
  94889. */
  94890. isLocal: boolean;
  94891. /** Snippet ID if the particle system was created from the snippet server */
  94892. snippetId: string;
  94893. /** Gets or sets a matrix to use to compute projection */
  94894. defaultProjectionMatrix: Matrix;
  94895. /**
  94896. * Gets the maximum number of particles active at the same time.
  94897. * @returns The max number of active particles.
  94898. */
  94899. getCapacity(): number;
  94900. /**
  94901. * Gets the number of particles active at the same time.
  94902. * @returns The number of active particles.
  94903. */
  94904. getActiveCount(): number;
  94905. /**
  94906. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94907. * @returns True if it has been started, otherwise false.
  94908. */
  94909. isStarted(): boolean;
  94910. /**
  94911. * Animates the particle system for this frame.
  94912. */
  94913. animate(): void;
  94914. /**
  94915. * Renders the particle system in its current state.
  94916. * @returns the current number of particles
  94917. */
  94918. render(): number;
  94919. /**
  94920. * Dispose the particle system and frees its associated resources.
  94921. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94922. */
  94923. dispose(disposeTexture?: boolean): void;
  94924. /**
  94925. * An event triggered when the system is disposed
  94926. */
  94927. onDisposeObservable: Observable<IParticleSystem>;
  94928. /**
  94929. * An event triggered when the system is stopped
  94930. */
  94931. onStoppedObservable: Observable<IParticleSystem>;
  94932. /**
  94933. * Clones the particle system.
  94934. * @param name The name of the cloned object
  94935. * @param newEmitter The new emitter to use
  94936. * @returns the cloned particle system
  94937. */
  94938. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94939. /**
  94940. * Serializes the particle system to a JSON object
  94941. * @param serializeTexture defines if the texture must be serialized as well
  94942. * @returns the JSON object
  94943. */
  94944. serialize(serializeTexture: boolean): any;
  94945. /**
  94946. * Rebuild the particle system
  94947. */
  94948. rebuild(): void;
  94949. /** Force the system to rebuild all gradients that need to be resync */
  94950. forceRefreshGradients(): void;
  94951. /**
  94952. * Starts the particle system and begins to emit
  94953. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94954. */
  94955. start(delay?: number): void;
  94956. /**
  94957. * Stops the particle system.
  94958. */
  94959. stop(): void;
  94960. /**
  94961. * Remove all active particles
  94962. */
  94963. reset(): void;
  94964. /**
  94965. * Gets a boolean indicating that the system is stopping
  94966. * @returns true if the system is currently stopping
  94967. */
  94968. isStopping(): boolean;
  94969. /**
  94970. * Is this system ready to be used/rendered
  94971. * @return true if the system is ready
  94972. */
  94973. isReady(): boolean;
  94974. /**
  94975. * Returns the string "ParticleSystem"
  94976. * @returns a string containing the class name
  94977. */
  94978. getClassName(): string;
  94979. /**
  94980. * Gets the custom effect used to render the particles
  94981. * @param blendMode Blend mode for which the effect should be retrieved
  94982. * @returns The effect
  94983. */
  94984. getCustomEffect(blendMode: number): Nullable<Effect>;
  94985. /**
  94986. * Sets the custom effect used to render the particles
  94987. * @param effect The effect to set
  94988. * @param blendMode Blend mode for which the effect should be set
  94989. */
  94990. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94991. /**
  94992. * Fill the defines array according to the current settings of the particle system
  94993. * @param defines Array to be updated
  94994. * @param blendMode blend mode to take into account when updating the array
  94995. */
  94996. fillDefines(defines: Array<string>, blendMode: number): void;
  94997. /**
  94998. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94999. * @param uniforms Uniforms array to fill
  95000. * @param attributes Attributes array to fill
  95001. * @param samplers Samplers array to fill
  95002. */
  95003. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95004. /**
  95005. * Observable that will be called just before the particles are drawn
  95006. */
  95007. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95008. /**
  95009. * Gets the name of the particle vertex shader
  95010. */
  95011. vertexShaderName: string;
  95012. /**
  95013. * Adds a new color gradient
  95014. * @param gradient defines the gradient to use (between 0 and 1)
  95015. * @param color1 defines the color to affect to the specified gradient
  95016. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95017. * @returns the current particle system
  95018. */
  95019. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95020. /**
  95021. * Remove a specific color gradient
  95022. * @param gradient defines the gradient to remove
  95023. * @returns the current particle system
  95024. */
  95025. removeColorGradient(gradient: number): IParticleSystem;
  95026. /**
  95027. * Adds a new size gradient
  95028. * @param gradient defines the gradient to use (between 0 and 1)
  95029. * @param factor defines the size factor to affect to the specified gradient
  95030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95031. * @returns the current particle system
  95032. */
  95033. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95034. /**
  95035. * Remove a specific size gradient
  95036. * @param gradient defines the gradient to remove
  95037. * @returns the current particle system
  95038. */
  95039. removeSizeGradient(gradient: number): IParticleSystem;
  95040. /**
  95041. * Gets the current list of color gradients.
  95042. * You must use addColorGradient and removeColorGradient to udpate this list
  95043. * @returns the list of color gradients
  95044. */
  95045. getColorGradients(): Nullable<Array<ColorGradient>>;
  95046. /**
  95047. * Gets the current list of size gradients.
  95048. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95049. * @returns the list of size gradients
  95050. */
  95051. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95052. /**
  95053. * Gets the current list of angular speed gradients.
  95054. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95055. * @returns the list of angular speed gradients
  95056. */
  95057. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95058. /**
  95059. * Adds a new angular speed gradient
  95060. * @param gradient defines the gradient to use (between 0 and 1)
  95061. * @param factor defines the angular speed to affect to the specified gradient
  95062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95063. * @returns the current particle system
  95064. */
  95065. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95066. /**
  95067. * Remove a specific angular speed gradient
  95068. * @param gradient defines the gradient to remove
  95069. * @returns the current particle system
  95070. */
  95071. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95072. /**
  95073. * Gets the current list of velocity gradients.
  95074. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95075. * @returns the list of velocity gradients
  95076. */
  95077. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95078. /**
  95079. * Adds a new velocity gradient
  95080. * @param gradient defines the gradient to use (between 0 and 1)
  95081. * @param factor defines the velocity to affect to the specified gradient
  95082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95083. * @returns the current particle system
  95084. */
  95085. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95086. /**
  95087. * Remove a specific velocity gradient
  95088. * @param gradient defines the gradient to remove
  95089. * @returns the current particle system
  95090. */
  95091. removeVelocityGradient(gradient: number): IParticleSystem;
  95092. /**
  95093. * Gets the current list of limit velocity gradients.
  95094. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95095. * @returns the list of limit velocity gradients
  95096. */
  95097. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95098. /**
  95099. * Adds a new limit velocity gradient
  95100. * @param gradient defines the gradient to use (between 0 and 1)
  95101. * @param factor defines the limit velocity to affect to the specified gradient
  95102. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95103. * @returns the current particle system
  95104. */
  95105. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95106. /**
  95107. * Remove a specific limit velocity gradient
  95108. * @param gradient defines the gradient to remove
  95109. * @returns the current particle system
  95110. */
  95111. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95112. /**
  95113. * Adds a new drag gradient
  95114. * @param gradient defines the gradient to use (between 0 and 1)
  95115. * @param factor defines the drag to affect to the specified gradient
  95116. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95117. * @returns the current particle system
  95118. */
  95119. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95120. /**
  95121. * Remove a specific drag gradient
  95122. * @param gradient defines the gradient to remove
  95123. * @returns the current particle system
  95124. */
  95125. removeDragGradient(gradient: number): IParticleSystem;
  95126. /**
  95127. * Gets the current list of drag gradients.
  95128. * You must use addDragGradient and removeDragGradient to udpate this list
  95129. * @returns the list of drag gradients
  95130. */
  95131. getDragGradients(): Nullable<Array<FactorGradient>>;
  95132. /**
  95133. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95134. * @param gradient defines the gradient to use (between 0 and 1)
  95135. * @param factor defines the emit rate to affect to the specified gradient
  95136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95137. * @returns the current particle system
  95138. */
  95139. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95140. /**
  95141. * Remove a specific emit rate gradient
  95142. * @param gradient defines the gradient to remove
  95143. * @returns the current particle system
  95144. */
  95145. removeEmitRateGradient(gradient: number): IParticleSystem;
  95146. /**
  95147. * Gets the current list of emit rate gradients.
  95148. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95149. * @returns the list of emit rate gradients
  95150. */
  95151. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95152. /**
  95153. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95154. * @param gradient defines the gradient to use (between 0 and 1)
  95155. * @param factor defines the start size to affect to the specified gradient
  95156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95157. * @returns the current particle system
  95158. */
  95159. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95160. /**
  95161. * Remove a specific start size gradient
  95162. * @param gradient defines the gradient to remove
  95163. * @returns the current particle system
  95164. */
  95165. removeStartSizeGradient(gradient: number): IParticleSystem;
  95166. /**
  95167. * Gets the current list of start size gradients.
  95168. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95169. * @returns the list of start size gradients
  95170. */
  95171. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95172. /**
  95173. * Adds a new life time gradient
  95174. * @param gradient defines the gradient to use (between 0 and 1)
  95175. * @param factor defines the life time factor to affect to the specified gradient
  95176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95177. * @returns the current particle system
  95178. */
  95179. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95180. /**
  95181. * Remove a specific life time gradient
  95182. * @param gradient defines the gradient to remove
  95183. * @returns the current particle system
  95184. */
  95185. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95186. /**
  95187. * Gets the current list of life time gradients.
  95188. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95189. * @returns the list of life time gradients
  95190. */
  95191. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95192. /**
  95193. * Gets the current list of color gradients.
  95194. * You must use addColorGradient and removeColorGradient to udpate this list
  95195. * @returns the list of color gradients
  95196. */
  95197. getColorGradients(): Nullable<Array<ColorGradient>>;
  95198. /**
  95199. * Adds a new ramp gradient used to remap particle colors
  95200. * @param gradient defines the gradient to use (between 0 and 1)
  95201. * @param color defines the color to affect to the specified gradient
  95202. * @returns the current particle system
  95203. */
  95204. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95205. /**
  95206. * Gets the current list of ramp gradients.
  95207. * You must use addRampGradient and removeRampGradient to udpate this list
  95208. * @returns the list of ramp gradients
  95209. */
  95210. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95211. /** Gets or sets a boolean indicating that ramp gradients must be used
  95212. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95213. */
  95214. useRampGradients: boolean;
  95215. /**
  95216. * Adds a new color remap gradient
  95217. * @param gradient defines the gradient to use (between 0 and 1)
  95218. * @param min defines the color remap minimal range
  95219. * @param max defines the color remap maximal range
  95220. * @returns the current particle system
  95221. */
  95222. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95223. /**
  95224. * Gets the current list of color remap gradients.
  95225. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95226. * @returns the list of color remap gradients
  95227. */
  95228. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95229. /**
  95230. * Adds a new alpha remap gradient
  95231. * @param gradient defines the gradient to use (between 0 and 1)
  95232. * @param min defines the alpha remap minimal range
  95233. * @param max defines the alpha remap maximal range
  95234. * @returns the current particle system
  95235. */
  95236. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95237. /**
  95238. * Gets the current list of alpha remap gradients.
  95239. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95240. * @returns the list of alpha remap gradients
  95241. */
  95242. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95243. /**
  95244. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95245. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95246. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95247. * @returns the emitter
  95248. */
  95249. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95250. /**
  95251. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95252. * @param radius The radius of the hemisphere to emit from
  95253. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95254. * @returns the emitter
  95255. */
  95256. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95257. /**
  95258. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95259. * @param radius The radius of the sphere to emit from
  95260. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95261. * @returns the emitter
  95262. */
  95263. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95264. /**
  95265. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95266. * @param radius The radius of the sphere to emit from
  95267. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95268. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95269. * @returns the emitter
  95270. */
  95271. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95272. /**
  95273. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95274. * @param radius The radius of the emission cylinder
  95275. * @param height The height of the emission cylinder
  95276. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95277. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95278. * @returns the emitter
  95279. */
  95280. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95281. /**
  95282. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95283. * @param radius The radius of the cylinder to emit from
  95284. * @param height The height of the emission cylinder
  95285. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95288. * @returns the emitter
  95289. */
  95290. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95291. /**
  95292. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95293. * @param radius The radius of the cone to emit from
  95294. * @param angle The base angle of the cone
  95295. * @returns the emitter
  95296. */
  95297. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95298. /**
  95299. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95300. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95301. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95302. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95303. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95304. * @returns the emitter
  95305. */
  95306. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95307. /**
  95308. * Get hosting scene
  95309. * @returns the scene
  95310. */
  95311. getScene(): Nullable<Scene>;
  95312. }
  95313. }
  95314. declare module BABYLON {
  95315. /**
  95316. * 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.
  95317. * @see https://doc.babylonjs.com/how_to/transformnode
  95318. */
  95319. export class TransformNode extends Node {
  95320. /**
  95321. * Object will not rotate to face the camera
  95322. */
  95323. static BILLBOARDMODE_NONE: number;
  95324. /**
  95325. * Object will rotate to face the camera but only on the x axis
  95326. */
  95327. static BILLBOARDMODE_X: number;
  95328. /**
  95329. * Object will rotate to face the camera but only on the y axis
  95330. */
  95331. static BILLBOARDMODE_Y: number;
  95332. /**
  95333. * Object will rotate to face the camera but only on the z axis
  95334. */
  95335. static BILLBOARDMODE_Z: number;
  95336. /**
  95337. * Object will rotate to face the camera
  95338. */
  95339. static BILLBOARDMODE_ALL: number;
  95340. /**
  95341. * Object will rotate to face the camera's position instead of orientation
  95342. */
  95343. static BILLBOARDMODE_USE_POSITION: number;
  95344. private static _TmpRotation;
  95345. private static _TmpScaling;
  95346. private static _TmpTranslation;
  95347. private _forward;
  95348. private _forwardInverted;
  95349. private _up;
  95350. private _right;
  95351. private _rightInverted;
  95352. private _position;
  95353. private _rotation;
  95354. private _rotationQuaternion;
  95355. protected _scaling: Vector3;
  95356. protected _isDirty: boolean;
  95357. private _transformToBoneReferal;
  95358. private _isAbsoluteSynced;
  95359. private _billboardMode;
  95360. /**
  95361. * Gets or sets the billboard mode. Default is 0.
  95362. *
  95363. * | Value | Type | Description |
  95364. * | --- | --- | --- |
  95365. * | 0 | BILLBOARDMODE_NONE | |
  95366. * | 1 | BILLBOARDMODE_X | |
  95367. * | 2 | BILLBOARDMODE_Y | |
  95368. * | 4 | BILLBOARDMODE_Z | |
  95369. * | 7 | BILLBOARDMODE_ALL | |
  95370. *
  95371. */
  95372. get billboardMode(): number;
  95373. set billboardMode(value: number);
  95374. private _preserveParentRotationForBillboard;
  95375. /**
  95376. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95377. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95378. */
  95379. get preserveParentRotationForBillboard(): boolean;
  95380. set preserveParentRotationForBillboard(value: boolean);
  95381. /**
  95382. * 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
  95383. */
  95384. scalingDeterminant: number;
  95385. private _infiniteDistance;
  95386. /**
  95387. * Gets or sets the distance of the object to max, often used by skybox
  95388. */
  95389. get infiniteDistance(): boolean;
  95390. set infiniteDistance(value: boolean);
  95391. /**
  95392. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95393. * By default the system will update normals to compensate
  95394. */
  95395. ignoreNonUniformScaling: boolean;
  95396. /**
  95397. * 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
  95398. */
  95399. reIntegrateRotationIntoRotationQuaternion: boolean;
  95400. /** @hidden */
  95401. _poseMatrix: Nullable<Matrix>;
  95402. /** @hidden */
  95403. _localMatrix: Matrix;
  95404. private _usePivotMatrix;
  95405. private _absolutePosition;
  95406. private _absoluteScaling;
  95407. private _absoluteRotationQuaternion;
  95408. private _pivotMatrix;
  95409. private _pivotMatrixInverse;
  95410. /** @hidden */
  95411. _postMultiplyPivotMatrix: boolean;
  95412. protected _isWorldMatrixFrozen: boolean;
  95413. /** @hidden */
  95414. _indexInSceneTransformNodesArray: number;
  95415. /**
  95416. * An event triggered after the world matrix is updated
  95417. */
  95418. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95419. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95420. /**
  95421. * Gets a string identifying the name of the class
  95422. * @returns "TransformNode" string
  95423. */
  95424. getClassName(): string;
  95425. /**
  95426. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95427. */
  95428. get position(): Vector3;
  95429. set position(newPosition: Vector3);
  95430. /**
  95431. * 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)).
  95432. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95433. */
  95434. get rotation(): Vector3;
  95435. set rotation(newRotation: Vector3);
  95436. /**
  95437. * 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)).
  95438. */
  95439. get scaling(): Vector3;
  95440. set scaling(newScaling: Vector3);
  95441. /**
  95442. * 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).
  95443. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95444. */
  95445. get rotationQuaternion(): Nullable<Quaternion>;
  95446. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95447. /**
  95448. * The forward direction of that transform in world space.
  95449. */
  95450. get forward(): Vector3;
  95451. /**
  95452. * The up direction of that transform in world space.
  95453. */
  95454. get up(): Vector3;
  95455. /**
  95456. * The right direction of that transform in world space.
  95457. */
  95458. get right(): Vector3;
  95459. /**
  95460. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95461. * @param matrix the matrix to copy the pose from
  95462. * @returns this TransformNode.
  95463. */
  95464. updatePoseMatrix(matrix: Matrix): TransformNode;
  95465. /**
  95466. * Returns the mesh Pose matrix.
  95467. * @returns the pose matrix
  95468. */
  95469. getPoseMatrix(): Matrix;
  95470. /** @hidden */
  95471. _isSynchronized(): boolean;
  95472. /** @hidden */
  95473. _initCache(): void;
  95474. /**
  95475. * Flag the transform node as dirty (Forcing it to update everything)
  95476. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95477. * @returns this transform node
  95478. */
  95479. markAsDirty(property: string): TransformNode;
  95480. /**
  95481. * Returns the current mesh absolute position.
  95482. * Returns a Vector3.
  95483. */
  95484. get absolutePosition(): Vector3;
  95485. /**
  95486. * Returns the current mesh absolute scaling.
  95487. * Returns a Vector3.
  95488. */
  95489. get absoluteScaling(): Vector3;
  95490. /**
  95491. * Returns the current mesh absolute rotation.
  95492. * Returns a Quaternion.
  95493. */
  95494. get absoluteRotationQuaternion(): Quaternion;
  95495. /**
  95496. * Sets a new matrix to apply before all other transformation
  95497. * @param matrix defines the transform matrix
  95498. * @returns the current TransformNode
  95499. */
  95500. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95501. /**
  95502. * Sets a new pivot matrix to the current node
  95503. * @param matrix defines the new pivot matrix to use
  95504. * @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
  95505. * @returns the current TransformNode
  95506. */
  95507. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95508. /**
  95509. * Returns the mesh pivot matrix.
  95510. * Default : Identity.
  95511. * @returns the matrix
  95512. */
  95513. getPivotMatrix(): Matrix;
  95514. /**
  95515. * Instantiate (when possible) or clone that node with its hierarchy
  95516. * @param newParent defines the new parent to use for the instance (or clone)
  95517. * @param options defines options to configure how copy is done
  95518. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95519. * @returns an instance (or a clone) of the current node with its hiearchy
  95520. */
  95521. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95522. doNotInstantiate: boolean;
  95523. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95524. /**
  95525. * Prevents the World matrix to be computed any longer
  95526. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95527. * @returns the TransformNode.
  95528. */
  95529. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95530. /**
  95531. * Allows back the World matrix computation.
  95532. * @returns the TransformNode.
  95533. */
  95534. unfreezeWorldMatrix(): this;
  95535. /**
  95536. * True if the World matrix has been frozen.
  95537. */
  95538. get isWorldMatrixFrozen(): boolean;
  95539. /**
  95540. * Retuns the mesh absolute position in the World.
  95541. * @returns a Vector3.
  95542. */
  95543. getAbsolutePosition(): Vector3;
  95544. /**
  95545. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95546. * @param absolutePosition the absolute position to set
  95547. * @returns the TransformNode.
  95548. */
  95549. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95550. /**
  95551. * Sets the mesh position in its local space.
  95552. * @param vector3 the position to set in localspace
  95553. * @returns the TransformNode.
  95554. */
  95555. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95556. /**
  95557. * Returns the mesh position in the local space from the current World matrix values.
  95558. * @returns a new Vector3.
  95559. */
  95560. getPositionExpressedInLocalSpace(): Vector3;
  95561. /**
  95562. * Translates the mesh along the passed Vector3 in its local space.
  95563. * @param vector3 the distance to translate in localspace
  95564. * @returns the TransformNode.
  95565. */
  95566. locallyTranslate(vector3: Vector3): TransformNode;
  95567. private static _lookAtVectorCache;
  95568. /**
  95569. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95570. * @param targetPoint the position (must be in same space as current mesh) to look at
  95571. * @param yawCor optional yaw (y-axis) correction in radians
  95572. * @param pitchCor optional pitch (x-axis) correction in radians
  95573. * @param rollCor optional roll (z-axis) correction in radians
  95574. * @param space the choosen space of the target
  95575. * @returns the TransformNode.
  95576. */
  95577. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95578. /**
  95579. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95580. * This Vector3 is expressed in the World space.
  95581. * @param localAxis axis to rotate
  95582. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95583. */
  95584. getDirection(localAxis: Vector3): Vector3;
  95585. /**
  95586. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95587. * localAxis is expressed in the mesh local space.
  95588. * result is computed in the Wordl space from the mesh World matrix.
  95589. * @param localAxis axis to rotate
  95590. * @param result the resulting transformnode
  95591. * @returns this TransformNode.
  95592. */
  95593. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95594. /**
  95595. * Sets this transform node rotation to the given local axis.
  95596. * @param localAxis the axis in local space
  95597. * @param yawCor optional yaw (y-axis) correction in radians
  95598. * @param pitchCor optional pitch (x-axis) correction in radians
  95599. * @param rollCor optional roll (z-axis) correction in radians
  95600. * @returns this TransformNode
  95601. */
  95602. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95603. /**
  95604. * Sets a new pivot point to the current node
  95605. * @param point defines the new pivot point to use
  95606. * @param space defines if the point is in world or local space (local by default)
  95607. * @returns the current TransformNode
  95608. */
  95609. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95610. /**
  95611. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95612. * @returns the pivot point
  95613. */
  95614. getPivotPoint(): Vector3;
  95615. /**
  95616. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95617. * @param result the vector3 to store the result
  95618. * @returns this TransformNode.
  95619. */
  95620. getPivotPointToRef(result: Vector3): TransformNode;
  95621. /**
  95622. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95623. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95624. */
  95625. getAbsolutePivotPoint(): Vector3;
  95626. /**
  95627. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95628. * @param result vector3 to store the result
  95629. * @returns this TransformNode.
  95630. */
  95631. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95632. /**
  95633. * Defines the passed node as the parent of the current node.
  95634. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95635. * @see https://doc.babylonjs.com/how_to/parenting
  95636. * @param node the node ot set as the parent
  95637. * @returns this TransformNode.
  95638. */
  95639. setParent(node: Nullable<Node>): TransformNode;
  95640. private _nonUniformScaling;
  95641. /**
  95642. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95643. */
  95644. get nonUniformScaling(): boolean;
  95645. /** @hidden */
  95646. _updateNonUniformScalingState(value: boolean): boolean;
  95647. /**
  95648. * Attach the current TransformNode to another TransformNode associated with a bone
  95649. * @param bone Bone affecting the TransformNode
  95650. * @param affectedTransformNode TransformNode associated with the bone
  95651. * @returns this object
  95652. */
  95653. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95654. /**
  95655. * Detach the transform node if its associated with a bone
  95656. * @returns this object
  95657. */
  95658. detachFromBone(): TransformNode;
  95659. private static _rotationAxisCache;
  95660. /**
  95661. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95662. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95663. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95664. * The passed axis is also normalized.
  95665. * @param axis the axis to rotate around
  95666. * @param amount the amount to rotate in radians
  95667. * @param space Space to rotate in (Default: local)
  95668. * @returns the TransformNode.
  95669. */
  95670. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95671. /**
  95672. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95673. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95674. * The passed axis is also normalized. .
  95675. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95676. * @param point the point to rotate around
  95677. * @param axis the axis to rotate around
  95678. * @param amount the amount to rotate in radians
  95679. * @returns the TransformNode
  95680. */
  95681. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95682. /**
  95683. * Translates the mesh along the axis vector for the passed distance in the given space.
  95684. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95685. * @param axis the axis to translate in
  95686. * @param distance the distance to translate
  95687. * @param space Space to rotate in (Default: local)
  95688. * @returns the TransformNode.
  95689. */
  95690. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95691. /**
  95692. * Adds a rotation step to the mesh current rotation.
  95693. * x, y, z are Euler angles expressed in radians.
  95694. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95695. * This means this rotation is made in the mesh local space only.
  95696. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95697. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95698. * ```javascript
  95699. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95700. * ```
  95701. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95702. * 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.
  95703. * @param x Rotation to add
  95704. * @param y Rotation to add
  95705. * @param z Rotation to add
  95706. * @returns the TransformNode.
  95707. */
  95708. addRotation(x: number, y: number, z: number): TransformNode;
  95709. /**
  95710. * @hidden
  95711. */
  95712. protected _getEffectiveParent(): Nullable<Node>;
  95713. /**
  95714. * Computes the world matrix of the node
  95715. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95716. * @returns the world matrix
  95717. */
  95718. computeWorldMatrix(force?: boolean): Matrix;
  95719. /**
  95720. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95721. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95722. */
  95723. resetLocalMatrix(independentOfChildren?: boolean): void;
  95724. protected _afterComputeWorldMatrix(): void;
  95725. /**
  95726. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95727. * @param func callback function to add
  95728. *
  95729. * @returns the TransformNode.
  95730. */
  95731. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95732. /**
  95733. * Removes a registered callback function.
  95734. * @param func callback function to remove
  95735. * @returns the TransformNode.
  95736. */
  95737. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95738. /**
  95739. * Gets the position of the current mesh in camera space
  95740. * @param camera defines the camera to use
  95741. * @returns a position
  95742. */
  95743. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95744. /**
  95745. * Returns the distance from the mesh to the active camera
  95746. * @param camera defines the camera to use
  95747. * @returns the distance
  95748. */
  95749. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95750. /**
  95751. * Clone the current transform node
  95752. * @param name Name of the new clone
  95753. * @param newParent New parent for the clone
  95754. * @param doNotCloneChildren Do not clone children hierarchy
  95755. * @returns the new transform node
  95756. */
  95757. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95758. /**
  95759. * Serializes the objects information.
  95760. * @param currentSerializationObject defines the object to serialize in
  95761. * @returns the serialized object
  95762. */
  95763. serialize(currentSerializationObject?: any): any;
  95764. /**
  95765. * Returns a new TransformNode object parsed from the source provided.
  95766. * @param parsedTransformNode is the source.
  95767. * @param scene the scne the object belongs to
  95768. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95769. * @returns a new TransformNode object parsed from the source provided.
  95770. */
  95771. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95772. /**
  95773. * Get all child-transformNodes of this node
  95774. * @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
  95775. * @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
  95776. * @returns an array of TransformNode
  95777. */
  95778. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95779. /**
  95780. * Releases resources associated with this transform node.
  95781. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95782. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95783. */
  95784. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95785. /**
  95786. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95787. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95788. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95789. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95790. * @returns the current mesh
  95791. */
  95792. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95793. private _syncAbsoluteScalingAndRotation;
  95794. }
  95795. }
  95796. declare module BABYLON {
  95797. /**
  95798. * Class used to override all child animations of a given target
  95799. */
  95800. export class AnimationPropertiesOverride {
  95801. /**
  95802. * Gets or sets a value indicating if animation blending must be used
  95803. */
  95804. enableBlending: boolean;
  95805. /**
  95806. * Gets or sets the blending speed to use when enableBlending is true
  95807. */
  95808. blendingSpeed: number;
  95809. /**
  95810. * Gets or sets the default loop mode to use
  95811. */
  95812. loopMode: number;
  95813. }
  95814. }
  95815. declare module BABYLON {
  95816. /**
  95817. * Class used to store bone information
  95818. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95819. */
  95820. export class Bone extends Node {
  95821. /**
  95822. * defines the bone name
  95823. */
  95824. name: string;
  95825. private static _tmpVecs;
  95826. private static _tmpQuat;
  95827. private static _tmpMats;
  95828. /**
  95829. * Gets the list of child bones
  95830. */
  95831. children: Bone[];
  95832. /** Gets the animations associated with this bone */
  95833. animations: Animation[];
  95834. /**
  95835. * Gets or sets bone length
  95836. */
  95837. length: number;
  95838. /**
  95839. * @hidden Internal only
  95840. * Set this value to map this bone to a different index in the transform matrices
  95841. * Set this value to -1 to exclude the bone from the transform matrices
  95842. */
  95843. _index: Nullable<number>;
  95844. private _skeleton;
  95845. private _localMatrix;
  95846. private _restPose;
  95847. private _bindPose;
  95848. private _baseMatrix;
  95849. private _absoluteTransform;
  95850. private _invertedAbsoluteTransform;
  95851. private _parent;
  95852. private _scalingDeterminant;
  95853. private _worldTransform;
  95854. private _localScaling;
  95855. private _localRotation;
  95856. private _localPosition;
  95857. private _needToDecompose;
  95858. private _needToCompose;
  95859. /** @hidden */
  95860. _linkedTransformNode: Nullable<TransformNode>;
  95861. /** @hidden */
  95862. _waitingTransformNodeId: Nullable<string>;
  95863. /** @hidden */
  95864. get _matrix(): Matrix;
  95865. /** @hidden */
  95866. set _matrix(value: Matrix);
  95867. /**
  95868. * Create a new bone
  95869. * @param name defines the bone name
  95870. * @param skeleton defines the parent skeleton
  95871. * @param parentBone defines the parent (can be null if the bone is the root)
  95872. * @param localMatrix defines the local matrix
  95873. * @param restPose defines the rest pose matrix
  95874. * @param baseMatrix defines the base matrix
  95875. * @param index defines index of the bone in the hiearchy
  95876. */
  95877. constructor(
  95878. /**
  95879. * defines the bone name
  95880. */
  95881. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95882. /**
  95883. * Gets the current object class name.
  95884. * @return the class name
  95885. */
  95886. getClassName(): string;
  95887. /**
  95888. * Gets the parent skeleton
  95889. * @returns a skeleton
  95890. */
  95891. getSkeleton(): Skeleton;
  95892. /**
  95893. * Gets parent bone
  95894. * @returns a bone or null if the bone is the root of the bone hierarchy
  95895. */
  95896. getParent(): Nullable<Bone>;
  95897. /**
  95898. * Returns an array containing the root bones
  95899. * @returns an array containing the root bones
  95900. */
  95901. getChildren(): Array<Bone>;
  95902. /**
  95903. * Gets the node index in matrix array generated for rendering
  95904. * @returns the node index
  95905. */
  95906. getIndex(): number;
  95907. /**
  95908. * Sets the parent bone
  95909. * @param parent defines the parent (can be null if the bone is the root)
  95910. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95911. */
  95912. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95913. /**
  95914. * Gets the local matrix
  95915. * @returns a matrix
  95916. */
  95917. getLocalMatrix(): Matrix;
  95918. /**
  95919. * Gets the base matrix (initial matrix which remains unchanged)
  95920. * @returns a matrix
  95921. */
  95922. getBaseMatrix(): Matrix;
  95923. /**
  95924. * Gets the rest pose matrix
  95925. * @returns a matrix
  95926. */
  95927. getRestPose(): Matrix;
  95928. /**
  95929. * Sets the rest pose matrix
  95930. * @param matrix the local-space rest pose to set for this bone
  95931. */
  95932. setRestPose(matrix: Matrix): void;
  95933. /**
  95934. * Gets the bind pose matrix
  95935. * @returns the bind pose matrix
  95936. */
  95937. getBindPose(): Matrix;
  95938. /**
  95939. * Sets the bind pose matrix
  95940. * @param matrix the local-space bind pose to set for this bone
  95941. */
  95942. setBindPose(matrix: Matrix): void;
  95943. /**
  95944. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95945. */
  95946. getWorldMatrix(): Matrix;
  95947. /**
  95948. * Sets the local matrix to rest pose matrix
  95949. */
  95950. returnToRest(): void;
  95951. /**
  95952. * Gets the inverse of the absolute transform matrix.
  95953. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95954. * @returns a matrix
  95955. */
  95956. getInvertedAbsoluteTransform(): Matrix;
  95957. /**
  95958. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95959. * @returns a matrix
  95960. */
  95961. getAbsoluteTransform(): Matrix;
  95962. /**
  95963. * Links with the given transform node.
  95964. * The local matrix of this bone is copied from the transform node every frame.
  95965. * @param transformNode defines the transform node to link to
  95966. */
  95967. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95968. /**
  95969. * Gets the node used to drive the bone's transformation
  95970. * @returns a transform node or null
  95971. */
  95972. getTransformNode(): Nullable<TransformNode>;
  95973. /** Gets or sets current position (in local space) */
  95974. get position(): Vector3;
  95975. set position(newPosition: Vector3);
  95976. /** Gets or sets current rotation (in local space) */
  95977. get rotation(): Vector3;
  95978. set rotation(newRotation: Vector3);
  95979. /** Gets or sets current rotation quaternion (in local space) */
  95980. get rotationQuaternion(): Quaternion;
  95981. set rotationQuaternion(newRotation: Quaternion);
  95982. /** Gets or sets current scaling (in local space) */
  95983. get scaling(): Vector3;
  95984. set scaling(newScaling: Vector3);
  95985. /**
  95986. * Gets the animation properties override
  95987. */
  95988. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95989. private _decompose;
  95990. private _compose;
  95991. /**
  95992. * Update the base and local matrices
  95993. * @param matrix defines the new base or local matrix
  95994. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95995. * @param updateLocalMatrix defines if the local matrix should be updated
  95996. */
  95997. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95998. /** @hidden */
  95999. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96000. /**
  96001. * Flag the bone as dirty (Forcing it to update everything)
  96002. */
  96003. markAsDirty(): void;
  96004. /** @hidden */
  96005. _markAsDirtyAndCompose(): void;
  96006. private _markAsDirtyAndDecompose;
  96007. /**
  96008. * Translate the bone in local or world space
  96009. * @param vec The amount to translate the bone
  96010. * @param space The space that the translation is in
  96011. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96012. */
  96013. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96014. /**
  96015. * Set the postion of the bone in local or world space
  96016. * @param position The position to set the bone
  96017. * @param space The space that the position is in
  96018. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96019. */
  96020. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96021. /**
  96022. * Set the absolute position of the bone (world space)
  96023. * @param position The position to set the bone
  96024. * @param mesh The mesh that this bone is attached to
  96025. */
  96026. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96027. /**
  96028. * Scale the bone on the x, y and z axes (in local space)
  96029. * @param x The amount to scale the bone on the x axis
  96030. * @param y The amount to scale the bone on the y axis
  96031. * @param z The amount to scale the bone on the z axis
  96032. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96033. */
  96034. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96035. /**
  96036. * Set the bone scaling in local space
  96037. * @param scale defines the scaling vector
  96038. */
  96039. setScale(scale: Vector3): void;
  96040. /**
  96041. * Gets the current scaling in local space
  96042. * @returns the current scaling vector
  96043. */
  96044. getScale(): Vector3;
  96045. /**
  96046. * Gets the current scaling in local space and stores it in a target vector
  96047. * @param result defines the target vector
  96048. */
  96049. getScaleToRef(result: Vector3): void;
  96050. /**
  96051. * Set the yaw, pitch, and roll of the bone in local or world space
  96052. * @param yaw The rotation of the bone on the y axis
  96053. * @param pitch The rotation of the bone on the x axis
  96054. * @param roll The rotation of the bone on the z axis
  96055. * @param space The space that the axes of rotation are in
  96056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96057. */
  96058. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96059. /**
  96060. * Add a rotation to the bone on an axis in local or world space
  96061. * @param axis The axis to rotate the bone on
  96062. * @param amount The amount to rotate the bone
  96063. * @param space The space that the axis is in
  96064. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96065. */
  96066. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96067. /**
  96068. * Set the rotation of the bone to a particular axis angle in local or world space
  96069. * @param axis The axis to rotate the bone on
  96070. * @param angle The angle that the bone should be rotated to
  96071. * @param space The space that the axis is in
  96072. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96073. */
  96074. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96075. /**
  96076. * Set the euler rotation of the bone in local or world space
  96077. * @param rotation The euler rotation that the bone should be set to
  96078. * @param space The space that the rotation is in
  96079. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96080. */
  96081. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96082. /**
  96083. * Set the quaternion rotation of the bone in local or world space
  96084. * @param quat The quaternion rotation that the bone should be set to
  96085. * @param space The space that the rotation is in
  96086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96087. */
  96088. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96089. /**
  96090. * Set the rotation matrix of the bone in local or world space
  96091. * @param rotMat The rotation matrix that the bone should be set to
  96092. * @param space The space that the rotation is in
  96093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96094. */
  96095. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96096. private _rotateWithMatrix;
  96097. private _getNegativeRotationToRef;
  96098. /**
  96099. * Get the position of the bone in local or world space
  96100. * @param space The space that the returned position is in
  96101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96102. * @returns The position of the bone
  96103. */
  96104. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96105. /**
  96106. * Copy the position of the bone to a vector3 in local or world space
  96107. * @param space The space that the returned position is in
  96108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96109. * @param result The vector3 to copy the position to
  96110. */
  96111. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96112. /**
  96113. * Get the absolute position of the bone (world space)
  96114. * @param mesh The mesh that this bone is attached to
  96115. * @returns The absolute position of the bone
  96116. */
  96117. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96118. /**
  96119. * Copy the absolute position of the bone (world space) to the result param
  96120. * @param mesh The mesh that this bone is attached to
  96121. * @param result The vector3 to copy the absolute position to
  96122. */
  96123. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96124. /**
  96125. * Compute the absolute transforms of this bone and its children
  96126. */
  96127. computeAbsoluteTransforms(): void;
  96128. /**
  96129. * Get the world direction from an axis that is in the local space of the bone
  96130. * @param localAxis The local direction that is used to compute the world direction
  96131. * @param mesh The mesh that this bone is attached to
  96132. * @returns The world direction
  96133. */
  96134. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96135. /**
  96136. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96137. * @param localAxis The local direction that is used to compute the world direction
  96138. * @param mesh The mesh that this bone is attached to
  96139. * @param result The vector3 that the world direction will be copied to
  96140. */
  96141. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96142. /**
  96143. * Get the euler rotation of the bone in local or world space
  96144. * @param space The space that the rotation should be in
  96145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96146. * @returns The euler rotation
  96147. */
  96148. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96149. /**
  96150. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96151. * @param space The space that the rotation should be in
  96152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96153. * @param result The vector3 that the rotation should be copied to
  96154. */
  96155. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96156. /**
  96157. * Get the quaternion rotation of the bone in either local or world space
  96158. * @param space The space that the rotation should be in
  96159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96160. * @returns The quaternion rotation
  96161. */
  96162. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96163. /**
  96164. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96165. * @param space The space that the rotation should be in
  96166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96167. * @param result The quaternion that the rotation should be copied to
  96168. */
  96169. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96170. /**
  96171. * Get the rotation matrix of the bone in local or world space
  96172. * @param space The space that the rotation should be in
  96173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96174. * @returns The rotation matrix
  96175. */
  96176. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96177. /**
  96178. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96179. * @param space The space that the rotation should be in
  96180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96181. * @param result The quaternion that the rotation should be copied to
  96182. */
  96183. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96184. /**
  96185. * Get the world position of a point that is in the local space of the bone
  96186. * @param position The local position
  96187. * @param mesh The mesh that this bone is attached to
  96188. * @returns The world position
  96189. */
  96190. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96191. /**
  96192. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96193. * @param position The local position
  96194. * @param mesh The mesh that this bone is attached to
  96195. * @param result The vector3 that the world position should be copied to
  96196. */
  96197. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96198. /**
  96199. * Get the local position of a point that is in world space
  96200. * @param position The world position
  96201. * @param mesh The mesh that this bone is attached to
  96202. * @returns The local position
  96203. */
  96204. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96205. /**
  96206. * Get the local position of a point that is in world space and copy it to the result param
  96207. * @param position The world position
  96208. * @param mesh The mesh that this bone is attached to
  96209. * @param result The vector3 that the local position should be copied to
  96210. */
  96211. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96212. /**
  96213. * Set the current local matrix as the restPose for this bone.
  96214. */
  96215. setCurrentPoseAsRest(): void;
  96216. }
  96217. }
  96218. declare module BABYLON {
  96219. /**
  96220. * Defines a runtime animation
  96221. */
  96222. export class RuntimeAnimation {
  96223. private _events;
  96224. /**
  96225. * The current frame of the runtime animation
  96226. */
  96227. private _currentFrame;
  96228. /**
  96229. * The animation used by the runtime animation
  96230. */
  96231. private _animation;
  96232. /**
  96233. * The target of the runtime animation
  96234. */
  96235. private _target;
  96236. /**
  96237. * The initiating animatable
  96238. */
  96239. private _host;
  96240. /**
  96241. * The original value of the runtime animation
  96242. */
  96243. private _originalValue;
  96244. /**
  96245. * The original blend value of the runtime animation
  96246. */
  96247. private _originalBlendValue;
  96248. /**
  96249. * The offsets cache of the runtime animation
  96250. */
  96251. private _offsetsCache;
  96252. /**
  96253. * The high limits cache of the runtime animation
  96254. */
  96255. private _highLimitsCache;
  96256. /**
  96257. * Specifies if the runtime animation has been stopped
  96258. */
  96259. private _stopped;
  96260. /**
  96261. * The blending factor of the runtime animation
  96262. */
  96263. private _blendingFactor;
  96264. /**
  96265. * The BabylonJS scene
  96266. */
  96267. private _scene;
  96268. /**
  96269. * The current value of the runtime animation
  96270. */
  96271. private _currentValue;
  96272. /** @hidden */
  96273. _animationState: _IAnimationState;
  96274. /**
  96275. * The active target of the runtime animation
  96276. */
  96277. private _activeTargets;
  96278. private _currentActiveTarget;
  96279. private _directTarget;
  96280. /**
  96281. * The target path of the runtime animation
  96282. */
  96283. private _targetPath;
  96284. /**
  96285. * The weight of the runtime animation
  96286. */
  96287. private _weight;
  96288. /**
  96289. * The ratio offset of the runtime animation
  96290. */
  96291. private _ratioOffset;
  96292. /**
  96293. * The previous delay of the runtime animation
  96294. */
  96295. private _previousDelay;
  96296. /**
  96297. * The previous ratio of the runtime animation
  96298. */
  96299. private _previousRatio;
  96300. private _enableBlending;
  96301. private _keys;
  96302. private _minFrame;
  96303. private _maxFrame;
  96304. private _minValue;
  96305. private _maxValue;
  96306. private _targetIsArray;
  96307. /**
  96308. * Gets the current frame of the runtime animation
  96309. */
  96310. get currentFrame(): number;
  96311. /**
  96312. * Gets the weight of the runtime animation
  96313. */
  96314. get weight(): number;
  96315. /**
  96316. * Gets the current value of the runtime animation
  96317. */
  96318. get currentValue(): any;
  96319. /**
  96320. * Gets the target path of the runtime animation
  96321. */
  96322. get targetPath(): string;
  96323. /**
  96324. * Gets the actual target of the runtime animation
  96325. */
  96326. get target(): any;
  96327. /**
  96328. * Gets the additive state of the runtime animation
  96329. */
  96330. get isAdditive(): boolean;
  96331. /** @hidden */
  96332. _onLoop: () => void;
  96333. /**
  96334. * Create a new RuntimeAnimation object
  96335. * @param target defines the target of the animation
  96336. * @param animation defines the source animation object
  96337. * @param scene defines the hosting scene
  96338. * @param host defines the initiating Animatable
  96339. */
  96340. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96341. private _preparePath;
  96342. /**
  96343. * Gets the animation from the runtime animation
  96344. */
  96345. get animation(): Animation;
  96346. /**
  96347. * Resets the runtime animation to the beginning
  96348. * @param restoreOriginal defines whether to restore the target property to the original value
  96349. */
  96350. reset(restoreOriginal?: boolean): void;
  96351. /**
  96352. * Specifies if the runtime animation is stopped
  96353. * @returns Boolean specifying if the runtime animation is stopped
  96354. */
  96355. isStopped(): boolean;
  96356. /**
  96357. * Disposes of the runtime animation
  96358. */
  96359. dispose(): void;
  96360. /**
  96361. * Apply the interpolated value to the target
  96362. * @param currentValue defines the value computed by the animation
  96363. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96364. */
  96365. setValue(currentValue: any, weight: number): void;
  96366. private _getOriginalValues;
  96367. private _setValue;
  96368. /**
  96369. * Gets the loop pmode of the runtime animation
  96370. * @returns Loop Mode
  96371. */
  96372. private _getCorrectLoopMode;
  96373. /**
  96374. * Move the current animation to a given frame
  96375. * @param frame defines the frame to move to
  96376. */
  96377. goToFrame(frame: number): void;
  96378. /**
  96379. * @hidden Internal use only
  96380. */
  96381. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96382. /**
  96383. * Execute the current animation
  96384. * @param delay defines the delay to add to the current frame
  96385. * @param from defines the lower bound of the animation range
  96386. * @param to defines the upper bound of the animation range
  96387. * @param loop defines if the current animation must loop
  96388. * @param speedRatio defines the current speed ratio
  96389. * @param weight defines the weight of the animation (default is -1 so no weight)
  96390. * @param onLoop optional callback called when animation loops
  96391. * @returns a boolean indicating if the animation is running
  96392. */
  96393. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96394. }
  96395. }
  96396. declare module BABYLON {
  96397. /**
  96398. * Class used to store an actual running animation
  96399. */
  96400. export class Animatable {
  96401. /** defines the target object */
  96402. target: any;
  96403. /** defines the starting frame number (default is 0) */
  96404. fromFrame: number;
  96405. /** defines the ending frame number (default is 100) */
  96406. toFrame: number;
  96407. /** defines if the animation must loop (default is false) */
  96408. loopAnimation: boolean;
  96409. /** defines a callback to call when animation ends if it is not looping */
  96410. onAnimationEnd?: (() => void) | null | undefined;
  96411. /** defines a callback to call when animation loops */
  96412. onAnimationLoop?: (() => void) | null | undefined;
  96413. /** defines whether the animation should be evaluated additively */
  96414. isAdditive: boolean;
  96415. private _localDelayOffset;
  96416. private _pausedDelay;
  96417. private _runtimeAnimations;
  96418. private _paused;
  96419. private _scene;
  96420. private _speedRatio;
  96421. private _weight;
  96422. private _syncRoot;
  96423. /**
  96424. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96425. * This will only apply for non looping animation (default is true)
  96426. */
  96427. disposeOnEnd: boolean;
  96428. /**
  96429. * Gets a boolean indicating if the animation has started
  96430. */
  96431. animationStarted: boolean;
  96432. /**
  96433. * Observer raised when the animation ends
  96434. */
  96435. onAnimationEndObservable: Observable<Animatable>;
  96436. /**
  96437. * Observer raised when the animation loops
  96438. */
  96439. onAnimationLoopObservable: Observable<Animatable>;
  96440. /**
  96441. * Gets the root Animatable used to synchronize and normalize animations
  96442. */
  96443. get syncRoot(): Nullable<Animatable>;
  96444. /**
  96445. * Gets the current frame of the first RuntimeAnimation
  96446. * Used to synchronize Animatables
  96447. */
  96448. get masterFrame(): number;
  96449. /**
  96450. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96451. */
  96452. get weight(): number;
  96453. set weight(value: number);
  96454. /**
  96455. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96456. */
  96457. get speedRatio(): number;
  96458. set speedRatio(value: number);
  96459. /**
  96460. * Creates a new Animatable
  96461. * @param scene defines the hosting scene
  96462. * @param target defines the target object
  96463. * @param fromFrame defines the starting frame number (default is 0)
  96464. * @param toFrame defines the ending frame number (default is 100)
  96465. * @param loopAnimation defines if the animation must loop (default is false)
  96466. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96467. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96468. * @param animations defines a group of animation to add to the new Animatable
  96469. * @param onAnimationLoop defines a callback to call when animation loops
  96470. * @param isAdditive defines whether the animation should be evaluated additively
  96471. */
  96472. constructor(scene: Scene,
  96473. /** defines the target object */
  96474. target: any,
  96475. /** defines the starting frame number (default is 0) */
  96476. fromFrame?: number,
  96477. /** defines the ending frame number (default is 100) */
  96478. toFrame?: number,
  96479. /** defines if the animation must loop (default is false) */
  96480. loopAnimation?: boolean, speedRatio?: number,
  96481. /** defines a callback to call when animation ends if it is not looping */
  96482. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96483. /** defines a callback to call when animation loops */
  96484. onAnimationLoop?: (() => void) | null | undefined,
  96485. /** defines whether the animation should be evaluated additively */
  96486. isAdditive?: boolean);
  96487. /**
  96488. * Synchronize and normalize current Animatable with a source Animatable
  96489. * This is useful when using animation weights and when animations are not of the same length
  96490. * @param root defines the root Animatable to synchronize with
  96491. * @returns the current Animatable
  96492. */
  96493. syncWith(root: Animatable): Animatable;
  96494. /**
  96495. * Gets the list of runtime animations
  96496. * @returns an array of RuntimeAnimation
  96497. */
  96498. getAnimations(): RuntimeAnimation[];
  96499. /**
  96500. * Adds more animations to the current animatable
  96501. * @param target defines the target of the animations
  96502. * @param animations defines the new animations to add
  96503. */
  96504. appendAnimations(target: any, animations: Animation[]): void;
  96505. /**
  96506. * Gets the source animation for a specific property
  96507. * @param property defines the propertyu to look for
  96508. * @returns null or the source animation for the given property
  96509. */
  96510. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96511. /**
  96512. * Gets the runtime animation for a specific property
  96513. * @param property defines the propertyu to look for
  96514. * @returns null or the runtime animation for the given property
  96515. */
  96516. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96517. /**
  96518. * Resets the animatable to its original state
  96519. */
  96520. reset(): void;
  96521. /**
  96522. * Allows the animatable to blend with current running animations
  96523. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96524. * @param blendingSpeed defines the blending speed to use
  96525. */
  96526. enableBlending(blendingSpeed: number): void;
  96527. /**
  96528. * Disable animation blending
  96529. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96530. */
  96531. disableBlending(): void;
  96532. /**
  96533. * Jump directly to a given frame
  96534. * @param frame defines the frame to jump to
  96535. */
  96536. goToFrame(frame: number): void;
  96537. /**
  96538. * Pause the animation
  96539. */
  96540. pause(): void;
  96541. /**
  96542. * Restart the animation
  96543. */
  96544. restart(): void;
  96545. private _raiseOnAnimationEnd;
  96546. /**
  96547. * Stop and delete the current animation
  96548. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96549. * @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)
  96550. */
  96551. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96552. /**
  96553. * Wait asynchronously for the animation to end
  96554. * @returns a promise which will be fullfilled when the animation ends
  96555. */
  96556. waitAsync(): Promise<Animatable>;
  96557. /** @hidden */
  96558. _animate(delay: number): boolean;
  96559. }
  96560. interface Scene {
  96561. /** @hidden */
  96562. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96563. /** @hidden */
  96564. _processLateAnimationBindingsForMatrices(holder: {
  96565. totalWeight: number;
  96566. totalAdditiveWeight: number;
  96567. animations: RuntimeAnimation[];
  96568. additiveAnimations: RuntimeAnimation[];
  96569. originalValue: Matrix;
  96570. }): any;
  96571. /** @hidden */
  96572. _processLateAnimationBindingsForQuaternions(holder: {
  96573. totalWeight: number;
  96574. totalAdditiveWeight: number;
  96575. animations: RuntimeAnimation[];
  96576. additiveAnimations: RuntimeAnimation[];
  96577. originalValue: Quaternion;
  96578. }, refQuaternion: Quaternion): Quaternion;
  96579. /** @hidden */
  96580. _processLateAnimationBindings(): void;
  96581. /**
  96582. * Will start the animation sequence of a given target
  96583. * @param target defines the target
  96584. * @param from defines from which frame should animation start
  96585. * @param to defines until which frame should animation run.
  96586. * @param weight defines the weight to apply to the animation (1.0 by default)
  96587. * @param loop defines if the animation loops
  96588. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96589. * @param onAnimationEnd defines the function to be executed when the animation ends
  96590. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96591. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96592. * @param onAnimationLoop defines the callback to call when an animation loops
  96593. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96594. * @returns the animatable object created for this animation
  96595. */
  96596. 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;
  96597. /**
  96598. * Will start the animation sequence of a given target
  96599. * @param target defines the target
  96600. * @param from defines from which frame should animation start
  96601. * @param to defines until which frame should animation run.
  96602. * @param loop defines if the animation loops
  96603. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96604. * @param onAnimationEnd defines the function to be executed when the animation ends
  96605. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96606. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96607. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96608. * @param onAnimationLoop defines the callback to call when an animation loops
  96609. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96610. * @returns the animatable object created for this animation
  96611. */
  96612. 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;
  96613. /**
  96614. * Will start the animation sequence of a given target and its hierarchy
  96615. * @param target defines the target
  96616. * @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.
  96617. * @param from defines from which frame should animation start
  96618. * @param to defines until which frame should animation run.
  96619. * @param loop defines if the animation loops
  96620. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96621. * @param onAnimationEnd defines the function to be executed when the animation ends
  96622. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96623. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96624. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96625. * @param onAnimationLoop defines the callback to call when an animation loops
  96626. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96627. * @returns the list of created animatables
  96628. */
  96629. 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[];
  96630. /**
  96631. * Begin a new animation on a given node
  96632. * @param target defines the target where the animation will take place
  96633. * @param animations defines the list of animations to start
  96634. * @param from defines the initial value
  96635. * @param to defines the final value
  96636. * @param loop defines if you want animation to loop (off by default)
  96637. * @param speedRatio defines the speed ratio to apply to all animations
  96638. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96639. * @param onAnimationLoop defines the callback to call when an animation loops
  96640. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96641. * @returns the list of created animatables
  96642. */
  96643. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96644. /**
  96645. * Begin a new animation on a given node and its hierarchy
  96646. * @param target defines the root node where the animation will take place
  96647. * @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.
  96648. * @param animations defines the list of animations to start
  96649. * @param from defines the initial value
  96650. * @param to defines the final value
  96651. * @param loop defines if you want animation to loop (off by default)
  96652. * @param speedRatio defines the speed ratio to apply to all animations
  96653. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96654. * @param onAnimationLoop defines the callback to call when an animation loops
  96655. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96656. * @returns the list of animatables created for all nodes
  96657. */
  96658. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96659. /**
  96660. * Gets the animatable associated with a specific target
  96661. * @param target defines the target of the animatable
  96662. * @returns the required animatable if found
  96663. */
  96664. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96665. /**
  96666. * Gets all animatables associated with a given target
  96667. * @param target defines the target to look animatables for
  96668. * @returns an array of Animatables
  96669. */
  96670. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96671. /**
  96672. * Stops and removes all animations that have been applied to the scene
  96673. */
  96674. stopAllAnimations(): void;
  96675. /**
  96676. * Gets the current delta time used by animation engine
  96677. */
  96678. deltaTime: number;
  96679. }
  96680. interface Bone {
  96681. /**
  96682. * Copy an animation range from another bone
  96683. * @param source defines the source bone
  96684. * @param rangeName defines the range name to copy
  96685. * @param frameOffset defines the frame offset
  96686. * @param rescaleAsRequired defines if rescaling must be applied if required
  96687. * @param skelDimensionsRatio defines the scaling ratio
  96688. * @returns true if operation was successful
  96689. */
  96690. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96691. }
  96692. }
  96693. declare module BABYLON {
  96694. /**
  96695. * Class used to handle skinning animations
  96696. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96697. */
  96698. export class Skeleton implements IAnimatable {
  96699. /** defines the skeleton name */
  96700. name: string;
  96701. /** defines the skeleton Id */
  96702. id: string;
  96703. /**
  96704. * Defines the list of child bones
  96705. */
  96706. bones: Bone[];
  96707. /**
  96708. * Defines an estimate of the dimension of the skeleton at rest
  96709. */
  96710. dimensionsAtRest: Vector3;
  96711. /**
  96712. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96713. */
  96714. needInitialSkinMatrix: boolean;
  96715. /**
  96716. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96717. */
  96718. overrideMesh: Nullable<AbstractMesh>;
  96719. /**
  96720. * Gets the list of animations attached to this skeleton
  96721. */
  96722. animations: Array<Animation>;
  96723. private _scene;
  96724. private _isDirty;
  96725. private _transformMatrices;
  96726. private _transformMatrixTexture;
  96727. private _meshesWithPoseMatrix;
  96728. private _animatables;
  96729. private _identity;
  96730. private _synchronizedWithMesh;
  96731. private _ranges;
  96732. private _lastAbsoluteTransformsUpdateId;
  96733. private _canUseTextureForBones;
  96734. private _uniqueId;
  96735. /** @hidden */
  96736. _numBonesWithLinkedTransformNode: number;
  96737. /** @hidden */
  96738. _hasWaitingData: Nullable<boolean>;
  96739. /** @hidden */
  96740. _waitingOverrideMeshId: Nullable<string>;
  96741. /**
  96742. * Specifies if the skeleton should be serialized
  96743. */
  96744. doNotSerialize: boolean;
  96745. private _useTextureToStoreBoneMatrices;
  96746. /**
  96747. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96748. * Please note that this option is not available if the hardware does not support it
  96749. */
  96750. get useTextureToStoreBoneMatrices(): boolean;
  96751. set useTextureToStoreBoneMatrices(value: boolean);
  96752. private _animationPropertiesOverride;
  96753. /**
  96754. * Gets or sets the animation properties override
  96755. */
  96756. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96757. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96758. /**
  96759. * List of inspectable custom properties (used by the Inspector)
  96760. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96761. */
  96762. inspectableCustomProperties: IInspectable[];
  96763. /**
  96764. * An observable triggered before computing the skeleton's matrices
  96765. */
  96766. onBeforeComputeObservable: Observable<Skeleton>;
  96767. /**
  96768. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96769. */
  96770. get isUsingTextureForMatrices(): boolean;
  96771. /**
  96772. * Gets the unique ID of this skeleton
  96773. */
  96774. get uniqueId(): number;
  96775. /**
  96776. * Creates a new skeleton
  96777. * @param name defines the skeleton name
  96778. * @param id defines the skeleton Id
  96779. * @param scene defines the hosting scene
  96780. */
  96781. constructor(
  96782. /** defines the skeleton name */
  96783. name: string,
  96784. /** defines the skeleton Id */
  96785. id: string, scene: Scene);
  96786. /**
  96787. * Gets the current object class name.
  96788. * @return the class name
  96789. */
  96790. getClassName(): string;
  96791. /**
  96792. * Returns an array containing the root bones
  96793. * @returns an array containing the root bones
  96794. */
  96795. getChildren(): Array<Bone>;
  96796. /**
  96797. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96798. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96799. * @returns a Float32Array containing matrices data
  96800. */
  96801. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96802. /**
  96803. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96804. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96805. * @returns a raw texture containing the data
  96806. */
  96807. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96808. /**
  96809. * Gets the current hosting scene
  96810. * @returns a scene object
  96811. */
  96812. getScene(): Scene;
  96813. /**
  96814. * Gets a string representing the current skeleton data
  96815. * @param fullDetails defines a boolean indicating if we want a verbose version
  96816. * @returns a string representing the current skeleton data
  96817. */
  96818. toString(fullDetails?: boolean): string;
  96819. /**
  96820. * Get bone's index searching by name
  96821. * @param name defines bone's name to search for
  96822. * @return the indice of the bone. Returns -1 if not found
  96823. */
  96824. getBoneIndexByName(name: string): number;
  96825. /**
  96826. * Creater a new animation range
  96827. * @param name defines the name of the range
  96828. * @param from defines the start key
  96829. * @param to defines the end key
  96830. */
  96831. createAnimationRange(name: string, from: number, to: number): void;
  96832. /**
  96833. * Delete a specific animation range
  96834. * @param name defines the name of the range
  96835. * @param deleteFrames defines if frames must be removed as well
  96836. */
  96837. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96838. /**
  96839. * Gets a specific animation range
  96840. * @param name defines the name of the range to look for
  96841. * @returns the requested animation range or null if not found
  96842. */
  96843. getAnimationRange(name: string): Nullable<AnimationRange>;
  96844. /**
  96845. * Gets the list of all animation ranges defined on this skeleton
  96846. * @returns an array
  96847. */
  96848. getAnimationRanges(): Nullable<AnimationRange>[];
  96849. /**
  96850. * Copy animation range from a source skeleton.
  96851. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96852. * @param source defines the source skeleton
  96853. * @param name defines the name of the range to copy
  96854. * @param rescaleAsRequired defines if rescaling must be applied if required
  96855. * @returns true if operation was successful
  96856. */
  96857. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96858. /**
  96859. * Forces the skeleton to go to rest pose
  96860. */
  96861. returnToRest(): void;
  96862. private _getHighestAnimationFrame;
  96863. /**
  96864. * Begin a specific animation range
  96865. * @param name defines the name of the range to start
  96866. * @param loop defines if looping must be turned on (false by default)
  96867. * @param speedRatio defines the speed ratio to apply (1 by default)
  96868. * @param onAnimationEnd defines a callback which will be called when animation will end
  96869. * @returns a new animatable
  96870. */
  96871. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96872. /**
  96873. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96874. * @param skeleton defines the Skeleton containing the animation range to convert
  96875. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96876. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96877. * @returns the original skeleton
  96878. */
  96879. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96880. /** @hidden */
  96881. _markAsDirty(): void;
  96882. /** @hidden */
  96883. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96884. /** @hidden */
  96885. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96886. private _computeTransformMatrices;
  96887. /**
  96888. * Build all resources required to render a skeleton
  96889. */
  96890. prepare(): void;
  96891. /**
  96892. * Gets the list of animatables currently running for this skeleton
  96893. * @returns an array of animatables
  96894. */
  96895. getAnimatables(): IAnimatable[];
  96896. /**
  96897. * Clone the current skeleton
  96898. * @param name defines the name of the new skeleton
  96899. * @param id defines the id of the new skeleton
  96900. * @returns the new skeleton
  96901. */
  96902. clone(name: string, id?: string): Skeleton;
  96903. /**
  96904. * Enable animation blending for this skeleton
  96905. * @param blendingSpeed defines the blending speed to apply
  96906. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96907. */
  96908. enableBlending(blendingSpeed?: number): void;
  96909. /**
  96910. * Releases all resources associated with the current skeleton
  96911. */
  96912. dispose(): void;
  96913. /**
  96914. * Serialize the skeleton in a JSON object
  96915. * @returns a JSON object
  96916. */
  96917. serialize(): any;
  96918. /**
  96919. * Creates a new skeleton from serialized data
  96920. * @param parsedSkeleton defines the serialized data
  96921. * @param scene defines the hosting scene
  96922. * @returns a new skeleton
  96923. */
  96924. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96925. /**
  96926. * Compute all node absolute transforms
  96927. * @param forceUpdate defines if computation must be done even if cache is up to date
  96928. */
  96929. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96930. /**
  96931. * Gets the root pose matrix
  96932. * @returns a matrix
  96933. */
  96934. getPoseMatrix(): Nullable<Matrix>;
  96935. /**
  96936. * Sorts bones per internal index
  96937. */
  96938. sortBones(): void;
  96939. private _sortBones;
  96940. /**
  96941. * Set the current local matrix as the restPose for all bones in the skeleton.
  96942. */
  96943. setCurrentPoseAsRest(): void;
  96944. }
  96945. }
  96946. declare module BABYLON {
  96947. /**
  96948. * Creates an instance based on a source mesh.
  96949. */
  96950. export class InstancedMesh extends AbstractMesh {
  96951. private _sourceMesh;
  96952. private _currentLOD;
  96953. /** @hidden */
  96954. _indexInSourceMeshInstanceArray: number;
  96955. constructor(name: string, source: Mesh);
  96956. /**
  96957. * Returns the string "InstancedMesh".
  96958. */
  96959. getClassName(): string;
  96960. /** Gets the list of lights affecting that mesh */
  96961. get lightSources(): Light[];
  96962. _resyncLightSources(): void;
  96963. _resyncLightSource(light: Light): void;
  96964. _removeLightSource(light: Light, dispose: boolean): void;
  96965. /**
  96966. * If the source mesh receives shadows
  96967. */
  96968. get receiveShadows(): boolean;
  96969. /**
  96970. * The material of the source mesh
  96971. */
  96972. get material(): Nullable<Material>;
  96973. /**
  96974. * Visibility of the source mesh
  96975. */
  96976. get visibility(): number;
  96977. /**
  96978. * Skeleton of the source mesh
  96979. */
  96980. get skeleton(): Nullable<Skeleton>;
  96981. /**
  96982. * Rendering ground id of the source mesh
  96983. */
  96984. get renderingGroupId(): number;
  96985. set renderingGroupId(value: number);
  96986. /**
  96987. * Returns the total number of vertices (integer).
  96988. */
  96989. getTotalVertices(): number;
  96990. /**
  96991. * Returns a positive integer : the total number of indices in this mesh geometry.
  96992. * @returns the numner of indices or zero if the mesh has no geometry.
  96993. */
  96994. getTotalIndices(): number;
  96995. /**
  96996. * The source mesh of the instance
  96997. */
  96998. get sourceMesh(): Mesh;
  96999. /**
  97000. * Creates a new InstancedMesh object from the mesh model.
  97001. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97002. * @param name defines the name of the new instance
  97003. * @returns a new InstancedMesh
  97004. */
  97005. createInstance(name: string): InstancedMesh;
  97006. /**
  97007. * Is this node ready to be used/rendered
  97008. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97009. * @return {boolean} is it ready
  97010. */
  97011. isReady(completeCheck?: boolean): boolean;
  97012. /**
  97013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97014. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97015. * @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.
  97016. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97017. */
  97018. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97019. /**
  97020. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97021. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97022. * The `data` are either a numeric array either a Float32Array.
  97023. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97024. * 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).
  97025. * Note that a new underlying VertexBuffer object is created each call.
  97026. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97027. *
  97028. * Possible `kind` values :
  97029. * - VertexBuffer.PositionKind
  97030. * - VertexBuffer.UVKind
  97031. * - VertexBuffer.UV2Kind
  97032. * - VertexBuffer.UV3Kind
  97033. * - VertexBuffer.UV4Kind
  97034. * - VertexBuffer.UV5Kind
  97035. * - VertexBuffer.UV6Kind
  97036. * - VertexBuffer.ColorKind
  97037. * - VertexBuffer.MatricesIndicesKind
  97038. * - VertexBuffer.MatricesIndicesExtraKind
  97039. * - VertexBuffer.MatricesWeightsKind
  97040. * - VertexBuffer.MatricesWeightsExtraKind
  97041. *
  97042. * Returns the Mesh.
  97043. */
  97044. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97045. /**
  97046. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97047. * If the mesh has no geometry, it is simply returned as it is.
  97048. * The `data` are either a numeric array either a Float32Array.
  97049. * No new underlying VertexBuffer object is created.
  97050. * 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.
  97051. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97052. *
  97053. * Possible `kind` values :
  97054. * - VertexBuffer.PositionKind
  97055. * - VertexBuffer.UVKind
  97056. * - VertexBuffer.UV2Kind
  97057. * - VertexBuffer.UV3Kind
  97058. * - VertexBuffer.UV4Kind
  97059. * - VertexBuffer.UV5Kind
  97060. * - VertexBuffer.UV6Kind
  97061. * - VertexBuffer.ColorKind
  97062. * - VertexBuffer.MatricesIndicesKind
  97063. * - VertexBuffer.MatricesIndicesExtraKind
  97064. * - VertexBuffer.MatricesWeightsKind
  97065. * - VertexBuffer.MatricesWeightsExtraKind
  97066. *
  97067. * Returns the Mesh.
  97068. */
  97069. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97070. /**
  97071. * Sets the mesh indices.
  97072. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97073. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97074. * This method creates a new index buffer each call.
  97075. * Returns the Mesh.
  97076. */
  97077. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97078. /**
  97079. * Boolean : True if the mesh owns the requested kind of data.
  97080. */
  97081. isVerticesDataPresent(kind: string): boolean;
  97082. /**
  97083. * Returns an array of indices (IndicesArray).
  97084. */
  97085. getIndices(): Nullable<IndicesArray>;
  97086. get _positions(): Nullable<Vector3[]>;
  97087. /**
  97088. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97089. * This means the mesh underlying bounding box and sphere are recomputed.
  97090. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97091. * @returns the current mesh
  97092. */
  97093. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97094. /** @hidden */
  97095. _preActivate(): InstancedMesh;
  97096. /** @hidden */
  97097. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97098. /** @hidden */
  97099. _postActivate(): void;
  97100. getWorldMatrix(): Matrix;
  97101. get isAnInstance(): boolean;
  97102. /**
  97103. * Returns the current associated LOD AbstractMesh.
  97104. */
  97105. getLOD(camera: Camera): AbstractMesh;
  97106. /** @hidden */
  97107. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97108. /** @hidden */
  97109. _syncSubMeshes(): InstancedMesh;
  97110. /** @hidden */
  97111. _generatePointsArray(): boolean;
  97112. /** @hidden */
  97113. _updateBoundingInfo(): AbstractMesh;
  97114. /**
  97115. * Creates a new InstancedMesh from the current mesh.
  97116. * - name (string) : the cloned mesh name
  97117. * - newParent (optional Node) : the optional Node to parent the clone to.
  97118. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97119. *
  97120. * Returns the clone.
  97121. */
  97122. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97123. /**
  97124. * Disposes the InstancedMesh.
  97125. * Returns nothing.
  97126. */
  97127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97128. }
  97129. interface Mesh {
  97130. /**
  97131. * Register a custom buffer that will be instanced
  97132. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97133. * @param kind defines the buffer kind
  97134. * @param stride defines the stride in floats
  97135. */
  97136. registerInstancedBuffer(kind: string, stride: number): void;
  97137. /**
  97138. * true to use the edge renderer for all instances of this mesh
  97139. */
  97140. edgesShareWithInstances: boolean;
  97141. /** @hidden */
  97142. _userInstancedBuffersStorage: {
  97143. data: {
  97144. [key: string]: Float32Array;
  97145. };
  97146. sizes: {
  97147. [key: string]: number;
  97148. };
  97149. vertexBuffers: {
  97150. [key: string]: Nullable<VertexBuffer>;
  97151. };
  97152. strides: {
  97153. [key: string]: number;
  97154. };
  97155. };
  97156. }
  97157. interface AbstractMesh {
  97158. /**
  97159. * Object used to store instanced buffers defined by user
  97160. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97161. */
  97162. instancedBuffers: {
  97163. [key: string]: any;
  97164. };
  97165. }
  97166. }
  97167. declare module BABYLON {
  97168. /**
  97169. * Defines the options associated with the creation of a shader material.
  97170. */
  97171. export interface IShaderMaterialOptions {
  97172. /**
  97173. * Does the material work in alpha blend mode
  97174. */
  97175. needAlphaBlending: boolean;
  97176. /**
  97177. * Does the material work in alpha test mode
  97178. */
  97179. needAlphaTesting: boolean;
  97180. /**
  97181. * The list of attribute names used in the shader
  97182. */
  97183. attributes: string[];
  97184. /**
  97185. * The list of unifrom names used in the shader
  97186. */
  97187. uniforms: string[];
  97188. /**
  97189. * The list of UBO names used in the shader
  97190. */
  97191. uniformBuffers: string[];
  97192. /**
  97193. * The list of sampler names used in the shader
  97194. */
  97195. samplers: string[];
  97196. /**
  97197. * The list of defines used in the shader
  97198. */
  97199. defines: string[];
  97200. }
  97201. /**
  97202. * 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.
  97203. *
  97204. * This returned material effects how the mesh will look based on the code in the shaders.
  97205. *
  97206. * @see https://doc.babylonjs.com/how_to/shader_material
  97207. */
  97208. export class ShaderMaterial extends Material {
  97209. private _shaderPath;
  97210. private _options;
  97211. private _textures;
  97212. private _textureArrays;
  97213. private _floats;
  97214. private _ints;
  97215. private _floatsArrays;
  97216. private _colors3;
  97217. private _colors3Arrays;
  97218. private _colors4;
  97219. private _colors4Arrays;
  97220. private _vectors2;
  97221. private _vectors3;
  97222. private _vectors4;
  97223. private _matrices;
  97224. private _matrixArrays;
  97225. private _matrices3x3;
  97226. private _matrices2x2;
  97227. private _vectors2Arrays;
  97228. private _vectors3Arrays;
  97229. private _vectors4Arrays;
  97230. private _cachedWorldViewMatrix;
  97231. private _cachedWorldViewProjectionMatrix;
  97232. private _renderId;
  97233. private _multiview;
  97234. private _cachedDefines;
  97235. /** Define the Url to load snippets */
  97236. static SnippetUrl: string;
  97237. /** Snippet ID if the material was created from the snippet server */
  97238. snippetId: string;
  97239. /**
  97240. * Instantiate a new shader material.
  97241. * 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.
  97242. * This returned material effects how the mesh will look based on the code in the shaders.
  97243. * @see https://doc.babylonjs.com/how_to/shader_material
  97244. * @param name Define the name of the material in the scene
  97245. * @param scene Define the scene the material belongs to
  97246. * @param shaderPath Defines the route to the shader code in one of three ways:
  97247. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97248. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97249. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97250. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97251. * @param options Define the options used to create the shader
  97252. */
  97253. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97254. /**
  97255. * Gets the shader path used to define the shader code
  97256. * It can be modified to trigger a new compilation
  97257. */
  97258. get shaderPath(): any;
  97259. /**
  97260. * Sets the shader path used to define the shader code
  97261. * It can be modified to trigger a new compilation
  97262. */
  97263. set shaderPath(shaderPath: any);
  97264. /**
  97265. * Gets the options used to compile the shader.
  97266. * They can be modified to trigger a new compilation
  97267. */
  97268. get options(): IShaderMaterialOptions;
  97269. /**
  97270. * Gets the current class name of the material e.g. "ShaderMaterial"
  97271. * Mainly use in serialization.
  97272. * @returns the class name
  97273. */
  97274. getClassName(): string;
  97275. /**
  97276. * Specifies if the material will require alpha blending
  97277. * @returns a boolean specifying if alpha blending is needed
  97278. */
  97279. needAlphaBlending(): boolean;
  97280. /**
  97281. * Specifies if this material should be rendered in alpha test mode
  97282. * @returns a boolean specifying if an alpha test is needed.
  97283. */
  97284. needAlphaTesting(): boolean;
  97285. private _checkUniform;
  97286. /**
  97287. * Set a texture in the shader.
  97288. * @param name Define the name of the uniform samplers as defined in the shader
  97289. * @param texture Define the texture to bind to this sampler
  97290. * @return the material itself allowing "fluent" like uniform updates
  97291. */
  97292. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97293. /**
  97294. * Set a texture array in the shader.
  97295. * @param name Define the name of the uniform sampler array as defined in the shader
  97296. * @param textures Define the list of textures to bind to this sampler
  97297. * @return the material itself allowing "fluent" like uniform updates
  97298. */
  97299. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97300. /**
  97301. * Set a float in the shader.
  97302. * @param name Define the name of the uniform as defined in the shader
  97303. * @param value Define the value to give to the uniform
  97304. * @return the material itself allowing "fluent" like uniform updates
  97305. */
  97306. setFloat(name: string, value: number): ShaderMaterial;
  97307. /**
  97308. * Set a int in the shader.
  97309. * @param name Define the name of the uniform as defined in the shader
  97310. * @param value Define the value to give to the uniform
  97311. * @return the material itself allowing "fluent" like uniform updates
  97312. */
  97313. setInt(name: string, value: number): ShaderMaterial;
  97314. /**
  97315. * Set an array of floats in the shader.
  97316. * @param name Define the name of the uniform as defined in the shader
  97317. * @param value Define the value to give to the uniform
  97318. * @return the material itself allowing "fluent" like uniform updates
  97319. */
  97320. setFloats(name: string, value: number[]): ShaderMaterial;
  97321. /**
  97322. * Set a vec3 in the shader from a Color3.
  97323. * @param name Define the name of the uniform as defined in the shader
  97324. * @param value Define the value to give to the uniform
  97325. * @return the material itself allowing "fluent" like uniform updates
  97326. */
  97327. setColor3(name: string, value: Color3): ShaderMaterial;
  97328. /**
  97329. * Set a vec3 array in the shader from a Color3 array.
  97330. * @param name Define the name of the uniform as defined in the shader
  97331. * @param value Define the value to give to the uniform
  97332. * @return the material itself allowing "fluent" like uniform updates
  97333. */
  97334. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97335. /**
  97336. * Set a vec4 in the shader from a Color4.
  97337. * @param name Define the name of the uniform as defined in the shader
  97338. * @param value Define the value to give to the uniform
  97339. * @return the material itself allowing "fluent" like uniform updates
  97340. */
  97341. setColor4(name: string, value: Color4): ShaderMaterial;
  97342. /**
  97343. * Set a vec4 array in the shader from a Color4 array.
  97344. * @param name Define the name of the uniform as defined in the shader
  97345. * @param value Define the value to give to the uniform
  97346. * @return the material itself allowing "fluent" like uniform updates
  97347. */
  97348. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97349. /**
  97350. * Set a vec2 in the shader from a Vector2.
  97351. * @param name Define the name of the uniform as defined in the shader
  97352. * @param value Define the value to give to the uniform
  97353. * @return the material itself allowing "fluent" like uniform updates
  97354. */
  97355. setVector2(name: string, value: Vector2): ShaderMaterial;
  97356. /**
  97357. * Set a vec3 in the shader from a Vector3.
  97358. * @param name Define the name of the uniform as defined in the shader
  97359. * @param value Define the value to give to the uniform
  97360. * @return the material itself allowing "fluent" like uniform updates
  97361. */
  97362. setVector3(name: string, value: Vector3): ShaderMaterial;
  97363. /**
  97364. * Set a vec4 in the shader from a Vector4.
  97365. * @param name Define the name of the uniform as defined in the shader
  97366. * @param value Define the value to give to the uniform
  97367. * @return the material itself allowing "fluent" like uniform updates
  97368. */
  97369. setVector4(name: string, value: Vector4): ShaderMaterial;
  97370. /**
  97371. * Set a mat4 in the shader from a Matrix.
  97372. * @param name Define the name of the uniform as defined in the shader
  97373. * @param value Define the value to give to the uniform
  97374. * @return the material itself allowing "fluent" like uniform updates
  97375. */
  97376. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97377. /**
  97378. * Set a float32Array in the shader from a matrix array.
  97379. * @param name Define the name of the uniform as defined in the shader
  97380. * @param value Define the value to give to the uniform
  97381. * @return the material itself allowing "fluent" like uniform updates
  97382. */
  97383. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97384. /**
  97385. * Set a mat3 in the shader from a Float32Array.
  97386. * @param name Define the name of the uniform as defined in the shader
  97387. * @param value Define the value to give to the uniform
  97388. * @return the material itself allowing "fluent" like uniform updates
  97389. */
  97390. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97391. /**
  97392. * Set a mat2 in the shader from a Float32Array.
  97393. * @param name Define the name of the uniform as defined in the shader
  97394. * @param value Define the value to give to the uniform
  97395. * @return the material itself allowing "fluent" like uniform updates
  97396. */
  97397. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97398. /**
  97399. * Set a vec2 array in the shader from a number array.
  97400. * @param name Define the name of the uniform as defined in the shader
  97401. * @param value Define the value to give to the uniform
  97402. * @return the material itself allowing "fluent" like uniform updates
  97403. */
  97404. setArray2(name: string, value: number[]): ShaderMaterial;
  97405. /**
  97406. * Set a vec3 array in the shader from a number array.
  97407. * @param name Define the name of the uniform as defined in the shader
  97408. * @param value Define the value to give to the uniform
  97409. * @return the material itself allowing "fluent" like uniform updates
  97410. */
  97411. setArray3(name: string, value: number[]): ShaderMaterial;
  97412. /**
  97413. * Set a vec4 array in the shader from a number array.
  97414. * @param name Define the name of the uniform as defined in the shader
  97415. * @param value Define the value to give to the uniform
  97416. * @return the material itself allowing "fluent" like uniform updates
  97417. */
  97418. setArray4(name: string, value: number[]): ShaderMaterial;
  97419. private _checkCache;
  97420. /**
  97421. * Specifies that the submesh is ready to be used
  97422. * @param mesh defines the mesh to check
  97423. * @param subMesh defines which submesh to check
  97424. * @param useInstances specifies that instances should be used
  97425. * @returns a boolean indicating that the submesh is ready or not
  97426. */
  97427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97428. /**
  97429. * Checks if the material is ready to render the requested mesh
  97430. * @param mesh Define the mesh to render
  97431. * @param useInstances Define whether or not the material is used with instances
  97432. * @returns true if ready, otherwise false
  97433. */
  97434. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97435. /**
  97436. * Binds the world matrix to the material
  97437. * @param world defines the world transformation matrix
  97438. * @param effectOverride - If provided, use this effect instead of internal effect
  97439. */
  97440. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97441. /**
  97442. * Binds the submesh to this material by preparing the effect and shader to draw
  97443. * @param world defines the world transformation matrix
  97444. * @param mesh defines the mesh containing the submesh
  97445. * @param subMesh defines the submesh to bind the material to
  97446. */
  97447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97448. /**
  97449. * Binds the material to the mesh
  97450. * @param world defines the world transformation matrix
  97451. * @param mesh defines the mesh to bind the material to
  97452. * @param effectOverride - If provided, use this effect instead of internal effect
  97453. */
  97454. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97455. protected _afterBind(mesh?: Mesh): void;
  97456. /**
  97457. * Gets the active textures from the material
  97458. * @returns an array of textures
  97459. */
  97460. getActiveTextures(): BaseTexture[];
  97461. /**
  97462. * Specifies if the material uses a texture
  97463. * @param texture defines the texture to check against the material
  97464. * @returns a boolean specifying if the material uses the texture
  97465. */
  97466. hasTexture(texture: BaseTexture): boolean;
  97467. /**
  97468. * Makes a duplicate of the material, and gives it a new name
  97469. * @param name defines the new name for the duplicated material
  97470. * @returns the cloned material
  97471. */
  97472. clone(name: string): ShaderMaterial;
  97473. /**
  97474. * Disposes the material
  97475. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97476. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97477. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97478. */
  97479. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97480. /**
  97481. * Serializes this material in a JSON representation
  97482. * @returns the serialized material object
  97483. */
  97484. serialize(): any;
  97485. /**
  97486. * Creates a shader material from parsed shader material data
  97487. * @param source defines the JSON represnetation of the material
  97488. * @param scene defines the hosting scene
  97489. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97490. * @returns a new material
  97491. */
  97492. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97493. /**
  97494. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97495. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97496. * @param url defines the url to load from
  97497. * @param scene defines the hosting scene
  97498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97499. * @returns a promise that will resolve to the new ShaderMaterial
  97500. */
  97501. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97502. /**
  97503. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97504. * @param snippetId defines the snippet to load
  97505. * @param scene defines the hosting scene
  97506. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97507. * @returns a promise that will resolve to the new ShaderMaterial
  97508. */
  97509. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97510. }
  97511. }
  97512. declare module BABYLON {
  97513. /** @hidden */
  97514. export var colorPixelShader: {
  97515. name: string;
  97516. shader: string;
  97517. };
  97518. }
  97519. declare module BABYLON {
  97520. /** @hidden */
  97521. export var colorVertexShader: {
  97522. name: string;
  97523. shader: string;
  97524. };
  97525. }
  97526. declare module BABYLON {
  97527. /**
  97528. * Line mesh
  97529. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97530. */
  97531. export class LinesMesh extends Mesh {
  97532. /**
  97533. * If vertex color should be applied to the mesh
  97534. */
  97535. readonly useVertexColor?: boolean | undefined;
  97536. /**
  97537. * If vertex alpha should be applied to the mesh
  97538. */
  97539. readonly useVertexAlpha?: boolean | undefined;
  97540. /**
  97541. * Color of the line (Default: White)
  97542. */
  97543. color: Color3;
  97544. /**
  97545. * Alpha of the line (Default: 1)
  97546. */
  97547. alpha: number;
  97548. /**
  97549. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97550. * This margin is expressed in world space coordinates, so its value may vary.
  97551. * Default value is 0.1
  97552. */
  97553. intersectionThreshold: number;
  97554. private _colorShader;
  97555. private color4;
  97556. /**
  97557. * Creates a new LinesMesh
  97558. * @param name defines the name
  97559. * @param scene defines the hosting scene
  97560. * @param parent defines the parent mesh if any
  97561. * @param source defines the optional source LinesMesh used to clone data from
  97562. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97563. * When false, achieved by calling a clone(), also passing False.
  97564. * This will make creation of children, recursive.
  97565. * @param useVertexColor defines if this LinesMesh supports vertex color
  97566. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97567. */
  97568. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97569. /**
  97570. * If vertex color should be applied to the mesh
  97571. */
  97572. useVertexColor?: boolean | undefined,
  97573. /**
  97574. * If vertex alpha should be applied to the mesh
  97575. */
  97576. useVertexAlpha?: boolean | undefined);
  97577. private _addClipPlaneDefine;
  97578. private _removeClipPlaneDefine;
  97579. isReady(): boolean;
  97580. /**
  97581. * Returns the string "LineMesh"
  97582. */
  97583. getClassName(): string;
  97584. /**
  97585. * @hidden
  97586. */
  97587. get material(): Material;
  97588. /**
  97589. * @hidden
  97590. */
  97591. set material(value: Material);
  97592. /**
  97593. * @hidden
  97594. */
  97595. get checkCollisions(): boolean;
  97596. /** @hidden */
  97597. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97598. /** @hidden */
  97599. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97600. /**
  97601. * Disposes of the line mesh
  97602. * @param doNotRecurse If children should be disposed
  97603. */
  97604. dispose(doNotRecurse?: boolean): void;
  97605. /**
  97606. * Returns a new LineMesh object cloned from the current one.
  97607. */
  97608. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97609. /**
  97610. * Creates a new InstancedLinesMesh object from the mesh model.
  97611. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97612. * @param name defines the name of the new instance
  97613. * @returns a new InstancedLinesMesh
  97614. */
  97615. createInstance(name: string): InstancedLinesMesh;
  97616. }
  97617. /**
  97618. * Creates an instance based on a source LinesMesh
  97619. */
  97620. export class InstancedLinesMesh extends InstancedMesh {
  97621. /**
  97622. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97623. * This margin is expressed in world space coordinates, so its value may vary.
  97624. * Initilized with the intersectionThreshold value of the source LinesMesh
  97625. */
  97626. intersectionThreshold: number;
  97627. constructor(name: string, source: LinesMesh);
  97628. /**
  97629. * Returns the string "InstancedLinesMesh".
  97630. */
  97631. getClassName(): string;
  97632. }
  97633. }
  97634. declare module BABYLON {
  97635. /** @hidden */
  97636. export var linePixelShader: {
  97637. name: string;
  97638. shader: string;
  97639. };
  97640. }
  97641. declare module BABYLON {
  97642. /** @hidden */
  97643. export var lineVertexShader: {
  97644. name: string;
  97645. shader: string;
  97646. };
  97647. }
  97648. declare module BABYLON {
  97649. interface Scene {
  97650. /** @hidden */
  97651. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97652. }
  97653. interface AbstractMesh {
  97654. /**
  97655. * Gets the edgesRenderer associated with the mesh
  97656. */
  97657. edgesRenderer: Nullable<EdgesRenderer>;
  97658. }
  97659. interface LinesMesh {
  97660. /**
  97661. * Enables the edge rendering mode on the mesh.
  97662. * This mode makes the mesh edges visible
  97663. * @param epsilon defines the maximal distance between two angles to detect a face
  97664. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97665. * @returns the currentAbstractMesh
  97666. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97667. */
  97668. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97669. }
  97670. interface InstancedLinesMesh {
  97671. /**
  97672. * Enables the edge rendering mode on the mesh.
  97673. * This mode makes the mesh edges visible
  97674. * @param epsilon defines the maximal distance between two angles to detect a face
  97675. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97676. * @returns the current InstancedLinesMesh
  97677. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97678. */
  97679. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97680. }
  97681. /**
  97682. * Defines the minimum contract an Edges renderer should follow.
  97683. */
  97684. export interface IEdgesRenderer extends IDisposable {
  97685. /**
  97686. * Gets or sets a boolean indicating if the edgesRenderer is active
  97687. */
  97688. isEnabled: boolean;
  97689. /**
  97690. * Renders the edges of the attached mesh,
  97691. */
  97692. render(): void;
  97693. /**
  97694. * Checks wether or not the edges renderer is ready to render.
  97695. * @return true if ready, otherwise false.
  97696. */
  97697. isReady(): boolean;
  97698. /**
  97699. * List of instances to render in case the source mesh has instances
  97700. */
  97701. customInstances: SmartArray<Matrix>;
  97702. }
  97703. /**
  97704. * Defines the additional options of the edges renderer
  97705. */
  97706. export interface IEdgesRendererOptions {
  97707. /**
  97708. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97709. * If not defined, the default value is true
  97710. */
  97711. useAlternateEdgeFinder?: boolean;
  97712. /**
  97713. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97714. * If not defined, the default value is true.
  97715. * 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)
  97716. * This option is used only if useAlternateEdgeFinder = true
  97717. */
  97718. useFastVertexMerger?: boolean;
  97719. /**
  97720. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97721. * The default value is 1e-6
  97722. * This option is used only if useAlternateEdgeFinder = true
  97723. */
  97724. epsilonVertexMerge?: number;
  97725. /**
  97726. * 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
  97727. * 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.
  97728. * This option is used only if useAlternateEdgeFinder = true
  97729. */
  97730. applyTessellation?: boolean;
  97731. /**
  97732. * 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
  97733. * The default value is 1e-6
  97734. * This option is used only if useAlternateEdgeFinder = true
  97735. */
  97736. epsilonVertexAligned?: number;
  97737. }
  97738. /**
  97739. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97740. */
  97741. export class EdgesRenderer implements IEdgesRenderer {
  97742. /**
  97743. * Define the size of the edges with an orthographic camera
  97744. */
  97745. edgesWidthScalerForOrthographic: number;
  97746. /**
  97747. * Define the size of the edges with a perspective camera
  97748. */
  97749. edgesWidthScalerForPerspective: number;
  97750. protected _source: AbstractMesh;
  97751. protected _linesPositions: number[];
  97752. protected _linesNormals: number[];
  97753. protected _linesIndices: number[];
  97754. protected _epsilon: number;
  97755. protected _indicesCount: number;
  97756. protected _lineShader: ShaderMaterial;
  97757. protected _ib: DataBuffer;
  97758. protected _buffers: {
  97759. [key: string]: Nullable<VertexBuffer>;
  97760. };
  97761. protected _buffersForInstances: {
  97762. [key: string]: Nullable<VertexBuffer>;
  97763. };
  97764. protected _checkVerticesInsteadOfIndices: boolean;
  97765. protected _options: Nullable<IEdgesRendererOptions>;
  97766. private _meshRebuildObserver;
  97767. private _meshDisposeObserver;
  97768. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97769. isEnabled: boolean;
  97770. /**
  97771. * List of instances to render in case the source mesh has instances
  97772. */
  97773. customInstances: SmartArray<Matrix>;
  97774. private static GetShader;
  97775. /**
  97776. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97777. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97778. * @param source Mesh used to create edges
  97779. * @param epsilon sum of angles in adjacency to check for edge
  97780. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97781. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97782. * @param options The options to apply when generating the edges
  97783. */
  97784. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97785. protected _prepareRessources(): void;
  97786. /** @hidden */
  97787. _rebuild(): void;
  97788. /**
  97789. * Releases the required resources for the edges renderer
  97790. */
  97791. dispose(): void;
  97792. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97793. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97794. /**
  97795. * Checks if the pair of p0 and p1 is en edge
  97796. * @param faceIndex
  97797. * @param edge
  97798. * @param faceNormals
  97799. * @param p0
  97800. * @param p1
  97801. * @private
  97802. */
  97803. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97804. /**
  97805. * push line into the position, normal and index buffer
  97806. * @protected
  97807. */
  97808. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97809. /**
  97810. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97811. */
  97812. private _tessellateTriangle;
  97813. private _generateEdgesLinesAlternate;
  97814. /**
  97815. * Generates lines edges from adjacencjes
  97816. * @private
  97817. */
  97818. _generateEdgesLines(): void;
  97819. /**
  97820. * Checks wether or not the edges renderer is ready to render.
  97821. * @return true if ready, otherwise false.
  97822. */
  97823. isReady(): boolean;
  97824. /**
  97825. * Renders the edges of the attached mesh,
  97826. */
  97827. render(): void;
  97828. }
  97829. /**
  97830. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97831. */
  97832. export class LineEdgesRenderer extends EdgesRenderer {
  97833. /**
  97834. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97835. * @param source LineMesh used to generate edges
  97836. * @param epsilon not important (specified angle for edge detection)
  97837. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97838. */
  97839. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97840. /**
  97841. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97842. */
  97843. _generateEdgesLines(): void;
  97844. }
  97845. }
  97846. declare module BABYLON {
  97847. /**
  97848. * This represents the object necessary to create a rendering group.
  97849. * This is exclusively used and created by the rendering manager.
  97850. * To modify the behavior, you use the available helpers in your scene or meshes.
  97851. * @hidden
  97852. */
  97853. export class RenderingGroup {
  97854. index: number;
  97855. private static _zeroVector;
  97856. private _scene;
  97857. private _opaqueSubMeshes;
  97858. private _transparentSubMeshes;
  97859. private _alphaTestSubMeshes;
  97860. private _depthOnlySubMeshes;
  97861. private _particleSystems;
  97862. private _spriteManagers;
  97863. private _opaqueSortCompareFn;
  97864. private _alphaTestSortCompareFn;
  97865. private _transparentSortCompareFn;
  97866. private _renderOpaque;
  97867. private _renderAlphaTest;
  97868. private _renderTransparent;
  97869. /** @hidden */
  97870. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97871. onBeforeTransparentRendering: () => void;
  97872. /**
  97873. * Set the opaque sort comparison function.
  97874. * If null the sub meshes will be render in the order they were created
  97875. */
  97876. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97877. /**
  97878. * Set the alpha test sort comparison function.
  97879. * If null the sub meshes will be render in the order they were created
  97880. */
  97881. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97882. /**
  97883. * Set the transparent sort comparison function.
  97884. * If null the sub meshes will be render in the order they were created
  97885. */
  97886. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97887. /**
  97888. * Creates a new rendering group.
  97889. * @param index The rendering group index
  97890. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97891. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97892. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97893. */
  97894. 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>);
  97895. /**
  97896. * Render all the sub meshes contained in the group.
  97897. * @param customRenderFunction Used to override the default render behaviour of the group.
  97898. * @returns true if rendered some submeshes.
  97899. */
  97900. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97901. /**
  97902. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97903. * @param subMeshes The submeshes to render
  97904. */
  97905. private renderOpaqueSorted;
  97906. /**
  97907. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97908. * @param subMeshes The submeshes to render
  97909. */
  97910. private renderAlphaTestSorted;
  97911. /**
  97912. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97913. * @param subMeshes The submeshes to render
  97914. */
  97915. private renderTransparentSorted;
  97916. /**
  97917. * Renders the submeshes in a specified order.
  97918. * @param subMeshes The submeshes to sort before render
  97919. * @param sortCompareFn The comparison function use to sort
  97920. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97921. * @param transparent Specifies to activate blending if true
  97922. */
  97923. private static renderSorted;
  97924. /**
  97925. * Renders the submeshes in the order they were dispatched (no sort applied).
  97926. * @param subMeshes The submeshes to render
  97927. */
  97928. private static renderUnsorted;
  97929. /**
  97930. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97931. * are rendered back to front if in the same alpha index.
  97932. *
  97933. * @param a The first submesh
  97934. * @param b The second submesh
  97935. * @returns The result of the comparison
  97936. */
  97937. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97938. /**
  97939. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97940. * are rendered back to front.
  97941. *
  97942. * @param a The first submesh
  97943. * @param b The second submesh
  97944. * @returns The result of the comparison
  97945. */
  97946. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97947. /**
  97948. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97949. * are rendered front to back (prevent overdraw).
  97950. *
  97951. * @param a The first submesh
  97952. * @param b The second submesh
  97953. * @returns The result of the comparison
  97954. */
  97955. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97956. /**
  97957. * Resets the different lists of submeshes to prepare a new frame.
  97958. */
  97959. prepare(): void;
  97960. dispose(): void;
  97961. /**
  97962. * Inserts the submesh in its correct queue depending on its material.
  97963. * @param subMesh The submesh to dispatch
  97964. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97965. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97966. */
  97967. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97968. dispatchSprites(spriteManager: ISpriteManager): void;
  97969. dispatchParticles(particleSystem: IParticleSystem): void;
  97970. private _renderParticles;
  97971. private _renderSprites;
  97972. }
  97973. }
  97974. declare module BABYLON {
  97975. /**
  97976. * Interface describing the different options available in the rendering manager
  97977. * regarding Auto Clear between groups.
  97978. */
  97979. export interface IRenderingManagerAutoClearSetup {
  97980. /**
  97981. * Defines whether or not autoclear is enable.
  97982. */
  97983. autoClear: boolean;
  97984. /**
  97985. * Defines whether or not to autoclear the depth buffer.
  97986. */
  97987. depth: boolean;
  97988. /**
  97989. * Defines whether or not to autoclear the stencil buffer.
  97990. */
  97991. stencil: boolean;
  97992. }
  97993. /**
  97994. * This class is used by the onRenderingGroupObservable
  97995. */
  97996. export class RenderingGroupInfo {
  97997. /**
  97998. * The Scene that being rendered
  97999. */
  98000. scene: Scene;
  98001. /**
  98002. * The camera currently used for the rendering pass
  98003. */
  98004. camera: Nullable<Camera>;
  98005. /**
  98006. * The ID of the renderingGroup being processed
  98007. */
  98008. renderingGroupId: number;
  98009. }
  98010. /**
  98011. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98012. * It is enable to manage the different groups as well as the different necessary sort functions.
  98013. * This should not be used directly aside of the few static configurations
  98014. */
  98015. export class RenderingManager {
  98016. /**
  98017. * The max id used for rendering groups (not included)
  98018. */
  98019. static MAX_RENDERINGGROUPS: number;
  98020. /**
  98021. * The min id used for rendering groups (included)
  98022. */
  98023. static MIN_RENDERINGGROUPS: number;
  98024. /**
  98025. * Used to globally prevent autoclearing scenes.
  98026. */
  98027. static AUTOCLEAR: boolean;
  98028. /**
  98029. * @hidden
  98030. */
  98031. _useSceneAutoClearSetup: boolean;
  98032. private _scene;
  98033. private _renderingGroups;
  98034. private _depthStencilBufferAlreadyCleaned;
  98035. private _autoClearDepthStencil;
  98036. private _customOpaqueSortCompareFn;
  98037. private _customAlphaTestSortCompareFn;
  98038. private _customTransparentSortCompareFn;
  98039. private _renderingGroupInfo;
  98040. /**
  98041. * Instantiates a new rendering group for a particular scene
  98042. * @param scene Defines the scene the groups belongs to
  98043. */
  98044. constructor(scene: Scene);
  98045. private _clearDepthStencilBuffer;
  98046. /**
  98047. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98048. * @hidden
  98049. */
  98050. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98051. /**
  98052. * Resets the different information of the group to prepare a new frame
  98053. * @hidden
  98054. */
  98055. reset(): void;
  98056. /**
  98057. * Dispose and release the group and its associated resources.
  98058. * @hidden
  98059. */
  98060. dispose(): void;
  98061. /**
  98062. * Clear the info related to rendering groups preventing retention points during dispose.
  98063. */
  98064. freeRenderingGroups(): void;
  98065. private _prepareRenderingGroup;
  98066. /**
  98067. * Add a sprite manager to the rendering manager in order to render it this frame.
  98068. * @param spriteManager Define the sprite manager to render
  98069. */
  98070. dispatchSprites(spriteManager: ISpriteManager): void;
  98071. /**
  98072. * Add a particle system to the rendering manager in order to render it this frame.
  98073. * @param particleSystem Define the particle system to render
  98074. */
  98075. dispatchParticles(particleSystem: IParticleSystem): void;
  98076. /**
  98077. * Add a submesh to the manager in order to render it this frame
  98078. * @param subMesh The submesh to dispatch
  98079. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98080. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98081. */
  98082. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98083. /**
  98084. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98085. * This allowed control for front to back rendering or reversly depending of the special needs.
  98086. *
  98087. * @param renderingGroupId The rendering group id corresponding to its index
  98088. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98089. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98090. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98091. */
  98092. 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;
  98093. /**
  98094. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98095. *
  98096. * @param renderingGroupId The rendering group id corresponding to its index
  98097. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98098. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98099. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98100. */
  98101. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98102. /**
  98103. * Gets the current auto clear configuration for one rendering group of the rendering
  98104. * manager.
  98105. * @param index the rendering group index to get the information for
  98106. * @returns The auto clear setup for the requested rendering group
  98107. */
  98108. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98109. }
  98110. }
  98111. declare module BABYLON {
  98112. /**
  98113. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98114. */
  98115. export interface ICustomShaderOptions {
  98116. /**
  98117. * Gets or sets the custom shader name to use
  98118. */
  98119. shaderName: string;
  98120. /**
  98121. * The list of attribute names used in the shader
  98122. */
  98123. attributes?: string[];
  98124. /**
  98125. * The list of unifrom names used in the shader
  98126. */
  98127. uniforms?: string[];
  98128. /**
  98129. * The list of sampler names used in the shader
  98130. */
  98131. samplers?: string[];
  98132. /**
  98133. * The list of defines used in the shader
  98134. */
  98135. defines?: string[];
  98136. }
  98137. /**
  98138. * Interface to implement to create a shadow generator compatible with BJS.
  98139. */
  98140. export interface IShadowGenerator {
  98141. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98142. id: string;
  98143. /**
  98144. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98145. * @returns The render target texture if present otherwise, null
  98146. */
  98147. getShadowMap(): Nullable<RenderTargetTexture>;
  98148. /**
  98149. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98150. * @param subMesh The submesh we want to render in the shadow map
  98151. * @param useInstances Defines wether will draw in the map using instances
  98152. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98153. * @returns true if ready otherwise, false
  98154. */
  98155. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98156. /**
  98157. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98158. * @param defines Defines of the material we want to update
  98159. * @param lightIndex Index of the light in the enabled light list of the material
  98160. */
  98161. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98162. /**
  98163. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98164. * defined in the generator but impacting the effect).
  98165. * It implies the unifroms available on the materials are the standard BJS ones.
  98166. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98167. * @param effect The effect we are binfing the information for
  98168. */
  98169. bindShadowLight(lightIndex: string, effect: Effect): void;
  98170. /**
  98171. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98172. * (eq to shadow prjection matrix * light transform matrix)
  98173. * @returns The transform matrix used to create the shadow map
  98174. */
  98175. getTransformMatrix(): Matrix;
  98176. /**
  98177. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98178. * Cube and 2D textures for instance.
  98179. */
  98180. recreateShadowMap(): void;
  98181. /**
  98182. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98183. * @param onCompiled Callback triggered at the and of the effects compilation
  98184. * @param options Sets of optional options forcing the compilation with different modes
  98185. */
  98186. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98187. useInstances: boolean;
  98188. }>): void;
  98189. /**
  98190. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98191. * @param options Sets of optional options forcing the compilation with different modes
  98192. * @returns A promise that resolves when the compilation completes
  98193. */
  98194. forceCompilationAsync(options?: Partial<{
  98195. useInstances: boolean;
  98196. }>): Promise<void>;
  98197. /**
  98198. * Serializes the shadow generator setup to a json object.
  98199. * @returns The serialized JSON object
  98200. */
  98201. serialize(): any;
  98202. /**
  98203. * Disposes the Shadow map and related Textures and effects.
  98204. */
  98205. dispose(): void;
  98206. }
  98207. /**
  98208. * Default implementation IShadowGenerator.
  98209. * This is the main object responsible of generating shadows in the framework.
  98210. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98211. */
  98212. export class ShadowGenerator implements IShadowGenerator {
  98213. /**
  98214. * Name of the shadow generator class
  98215. */
  98216. static CLASSNAME: string;
  98217. /**
  98218. * Shadow generator mode None: no filtering applied.
  98219. */
  98220. static readonly FILTER_NONE: number;
  98221. /**
  98222. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98223. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98224. */
  98225. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98226. /**
  98227. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98228. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98229. */
  98230. static readonly FILTER_POISSONSAMPLING: number;
  98231. /**
  98232. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98233. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98234. */
  98235. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98236. /**
  98237. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98238. * edge artifacts on steep falloff.
  98239. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98240. */
  98241. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98242. /**
  98243. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98244. * edge artifacts on steep falloff.
  98245. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98246. */
  98247. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98248. /**
  98249. * Shadow generator mode PCF: Percentage Closer Filtering
  98250. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98251. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98252. */
  98253. static readonly FILTER_PCF: number;
  98254. /**
  98255. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98256. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98257. * Contact Hardening
  98258. */
  98259. static readonly FILTER_PCSS: number;
  98260. /**
  98261. * Reserved for PCF and PCSS
  98262. * Highest Quality.
  98263. *
  98264. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98265. *
  98266. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98267. */
  98268. static readonly QUALITY_HIGH: number;
  98269. /**
  98270. * Reserved for PCF and PCSS
  98271. * Good tradeoff for quality/perf cross devices
  98272. *
  98273. * Execute PCF on a 3*3 kernel.
  98274. *
  98275. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98276. */
  98277. static readonly QUALITY_MEDIUM: number;
  98278. /**
  98279. * Reserved for PCF and PCSS
  98280. * The lowest quality but the fastest.
  98281. *
  98282. * Execute PCF on a 1*1 kernel.
  98283. *
  98284. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98285. */
  98286. static readonly QUALITY_LOW: number;
  98287. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98288. id: string;
  98289. /** Gets or sets the custom shader name to use */
  98290. customShaderOptions: ICustomShaderOptions;
  98291. /**
  98292. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98293. */
  98294. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98295. /**
  98296. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98297. */
  98298. onAfterShadowMapRenderObservable: Observable<Effect>;
  98299. /**
  98300. * Observable triggered before a mesh is rendered in the shadow map.
  98301. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98302. */
  98303. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98304. /**
  98305. * Observable triggered after a mesh is rendered in the shadow map.
  98306. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98307. */
  98308. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98309. protected _bias: number;
  98310. /**
  98311. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98312. */
  98313. get bias(): number;
  98314. /**
  98315. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98316. */
  98317. set bias(bias: number);
  98318. protected _normalBias: number;
  98319. /**
  98320. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98321. */
  98322. get normalBias(): number;
  98323. /**
  98324. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98325. */
  98326. set normalBias(normalBias: number);
  98327. protected _blurBoxOffset: number;
  98328. /**
  98329. * Gets the blur box offset: offset applied during the blur pass.
  98330. * Only useful if useKernelBlur = false
  98331. */
  98332. get blurBoxOffset(): number;
  98333. /**
  98334. * Sets the blur box offset: offset applied during the blur pass.
  98335. * Only useful if useKernelBlur = false
  98336. */
  98337. set blurBoxOffset(value: number);
  98338. protected _blurScale: number;
  98339. /**
  98340. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98341. * 2 means half of the size.
  98342. */
  98343. get blurScale(): number;
  98344. /**
  98345. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98346. * 2 means half of the size.
  98347. */
  98348. set blurScale(value: number);
  98349. protected _blurKernel: number;
  98350. /**
  98351. * Gets the blur kernel: kernel size of the blur pass.
  98352. * Only useful if useKernelBlur = true
  98353. */
  98354. get blurKernel(): number;
  98355. /**
  98356. * Sets the blur kernel: kernel size of the blur pass.
  98357. * Only useful if useKernelBlur = true
  98358. */
  98359. set blurKernel(value: number);
  98360. protected _useKernelBlur: boolean;
  98361. /**
  98362. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98363. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98364. */
  98365. get useKernelBlur(): boolean;
  98366. /**
  98367. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98368. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98369. */
  98370. set useKernelBlur(value: boolean);
  98371. protected _depthScale: number;
  98372. /**
  98373. * Gets the depth scale used in ESM mode.
  98374. */
  98375. get depthScale(): number;
  98376. /**
  98377. * Sets the depth scale used in ESM mode.
  98378. * This can override the scale stored on the light.
  98379. */
  98380. set depthScale(value: number);
  98381. protected _validateFilter(filter: number): number;
  98382. protected _filter: number;
  98383. /**
  98384. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98385. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98386. */
  98387. get filter(): number;
  98388. /**
  98389. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98390. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98391. */
  98392. set filter(value: number);
  98393. /**
  98394. * Gets if the current filter is set to Poisson Sampling.
  98395. */
  98396. get usePoissonSampling(): boolean;
  98397. /**
  98398. * Sets the current filter to Poisson Sampling.
  98399. */
  98400. set usePoissonSampling(value: boolean);
  98401. /**
  98402. * Gets if the current filter is set to ESM.
  98403. */
  98404. get useExponentialShadowMap(): boolean;
  98405. /**
  98406. * Sets the current filter is to ESM.
  98407. */
  98408. set useExponentialShadowMap(value: boolean);
  98409. /**
  98410. * Gets if the current filter is set to filtered ESM.
  98411. */
  98412. get useBlurExponentialShadowMap(): boolean;
  98413. /**
  98414. * Gets if the current filter is set to filtered ESM.
  98415. */
  98416. set useBlurExponentialShadowMap(value: boolean);
  98417. /**
  98418. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98419. * exponential to prevent steep falloff artifacts).
  98420. */
  98421. get useCloseExponentialShadowMap(): boolean;
  98422. /**
  98423. * Sets the current filter to "close ESM" (using the inverse of the
  98424. * exponential to prevent steep falloff artifacts).
  98425. */
  98426. set useCloseExponentialShadowMap(value: boolean);
  98427. /**
  98428. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98429. * exponential to prevent steep falloff artifacts).
  98430. */
  98431. get useBlurCloseExponentialShadowMap(): boolean;
  98432. /**
  98433. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98434. * exponential to prevent steep falloff artifacts).
  98435. */
  98436. set useBlurCloseExponentialShadowMap(value: boolean);
  98437. /**
  98438. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98439. */
  98440. get usePercentageCloserFiltering(): boolean;
  98441. /**
  98442. * Sets the current filter to "PCF" (percentage closer filtering).
  98443. */
  98444. set usePercentageCloserFiltering(value: boolean);
  98445. protected _filteringQuality: number;
  98446. /**
  98447. * Gets the PCF or PCSS Quality.
  98448. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98449. */
  98450. get filteringQuality(): number;
  98451. /**
  98452. * Sets the PCF or PCSS Quality.
  98453. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98454. */
  98455. set filteringQuality(filteringQuality: number);
  98456. /**
  98457. * Gets if the current filter is set to "PCSS" (contact hardening).
  98458. */
  98459. get useContactHardeningShadow(): boolean;
  98460. /**
  98461. * Sets the current filter to "PCSS" (contact hardening).
  98462. */
  98463. set useContactHardeningShadow(value: boolean);
  98464. protected _contactHardeningLightSizeUVRatio: number;
  98465. /**
  98466. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98467. * Using a ratio helps keeping shape stability independently of the map size.
  98468. *
  98469. * It does not account for the light projection as it was having too much
  98470. * instability during the light setup or during light position changes.
  98471. *
  98472. * Only valid if useContactHardeningShadow is true.
  98473. */
  98474. get contactHardeningLightSizeUVRatio(): number;
  98475. /**
  98476. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98477. * Using a ratio helps keeping shape stability independently of the map size.
  98478. *
  98479. * It does not account for the light projection as it was having too much
  98480. * instability during the light setup or during light position changes.
  98481. *
  98482. * Only valid if useContactHardeningShadow is true.
  98483. */
  98484. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98485. protected _darkness: number;
  98486. /** Gets or sets the actual darkness of a shadow */
  98487. get darkness(): number;
  98488. set darkness(value: number);
  98489. /**
  98490. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98491. * 0 means strongest and 1 would means no shadow.
  98492. * @returns the darkness.
  98493. */
  98494. getDarkness(): number;
  98495. /**
  98496. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98497. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98498. * @returns the shadow generator allowing fluent coding.
  98499. */
  98500. setDarkness(darkness: number): ShadowGenerator;
  98501. protected _transparencyShadow: boolean;
  98502. /** Gets or sets the ability to have transparent shadow */
  98503. get transparencyShadow(): boolean;
  98504. set transparencyShadow(value: boolean);
  98505. /**
  98506. * Sets the ability to have transparent shadow (boolean).
  98507. * @param transparent True if transparent else False
  98508. * @returns the shadow generator allowing fluent coding
  98509. */
  98510. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98511. /**
  98512. * Enables or disables shadows with varying strength based on the transparency
  98513. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98514. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98515. * mesh.visibility * alphaTexture.a
  98516. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98517. */
  98518. enableSoftTransparentShadow: boolean;
  98519. protected _shadowMap: Nullable<RenderTargetTexture>;
  98520. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98521. /**
  98522. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98523. * @returns The render target texture if present otherwise, null
  98524. */
  98525. getShadowMap(): Nullable<RenderTargetTexture>;
  98526. /**
  98527. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98528. * @returns The render target texture if the shadow map is present otherwise, null
  98529. */
  98530. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98531. /**
  98532. * Gets the class name of that object
  98533. * @returns "ShadowGenerator"
  98534. */
  98535. getClassName(): string;
  98536. /**
  98537. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98538. * @param mesh Mesh to add
  98539. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98540. * @returns the Shadow Generator itself
  98541. */
  98542. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98543. /**
  98544. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98545. * @param mesh Mesh to remove
  98546. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98547. * @returns the Shadow Generator itself
  98548. */
  98549. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98550. /**
  98551. * Controls the extent to which the shadows fade out at the edge of the frustum
  98552. */
  98553. frustumEdgeFalloff: number;
  98554. protected _light: IShadowLight;
  98555. /**
  98556. * Returns the associated light object.
  98557. * @returns the light generating the shadow
  98558. */
  98559. getLight(): IShadowLight;
  98560. /**
  98561. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98562. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98563. * It might on the other hand introduce peter panning.
  98564. */
  98565. forceBackFacesOnly: boolean;
  98566. protected _scene: Scene;
  98567. protected _lightDirection: Vector3;
  98568. protected _effect: Effect;
  98569. protected _viewMatrix: Matrix;
  98570. protected _projectionMatrix: Matrix;
  98571. protected _transformMatrix: Matrix;
  98572. protected _cachedPosition: Vector3;
  98573. protected _cachedDirection: Vector3;
  98574. protected _cachedDefines: string;
  98575. protected _currentRenderID: number;
  98576. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98577. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98578. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98579. protected _blurPostProcesses: PostProcess[];
  98580. protected _mapSize: number;
  98581. protected _currentFaceIndex: number;
  98582. protected _currentFaceIndexCache: number;
  98583. protected _textureType: number;
  98584. protected _defaultTextureMatrix: Matrix;
  98585. protected _storedUniqueId: Nullable<number>;
  98586. /** @hidden */
  98587. static _SceneComponentInitialization: (scene: Scene) => void;
  98588. /**
  98589. * Creates a ShadowGenerator object.
  98590. * A ShadowGenerator is the required tool to use the shadows.
  98591. * Each light casting shadows needs to use its own ShadowGenerator.
  98592. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98593. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98594. * @param light The light object generating the shadows.
  98595. * @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.
  98596. */
  98597. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98598. protected _initializeGenerator(): void;
  98599. protected _createTargetRenderTexture(): void;
  98600. protected _initializeShadowMap(): void;
  98601. protected _initializeBlurRTTAndPostProcesses(): void;
  98602. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98603. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98604. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98605. protected _applyFilterValues(): void;
  98606. /**
  98607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98608. * @param onCompiled Callback triggered at the and of the effects compilation
  98609. * @param options Sets of optional options forcing the compilation with different modes
  98610. */
  98611. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98612. useInstances: boolean;
  98613. }>): void;
  98614. /**
  98615. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98616. * @param options Sets of optional options forcing the compilation with different modes
  98617. * @returns A promise that resolves when the compilation completes
  98618. */
  98619. forceCompilationAsync(options?: Partial<{
  98620. useInstances: boolean;
  98621. }>): Promise<void>;
  98622. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98623. private _prepareShadowDefines;
  98624. /**
  98625. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98626. * @param subMesh The submesh we want to render in the shadow map
  98627. * @param useInstances Defines wether will draw in the map using instances
  98628. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98629. * @returns true if ready otherwise, false
  98630. */
  98631. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98632. /**
  98633. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98634. * @param defines Defines of the material we want to update
  98635. * @param lightIndex Index of the light in the enabled light list of the material
  98636. */
  98637. prepareDefines(defines: any, lightIndex: number): void;
  98638. /**
  98639. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98640. * defined in the generator but impacting the effect).
  98641. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98642. * @param effect The effect we are binfing the information for
  98643. */
  98644. bindShadowLight(lightIndex: string, effect: Effect): void;
  98645. /**
  98646. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98647. * (eq to shadow prjection matrix * light transform matrix)
  98648. * @returns The transform matrix used to create the shadow map
  98649. */
  98650. getTransformMatrix(): Matrix;
  98651. /**
  98652. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98653. * Cube and 2D textures for instance.
  98654. */
  98655. recreateShadowMap(): void;
  98656. protected _disposeBlurPostProcesses(): void;
  98657. protected _disposeRTTandPostProcesses(): void;
  98658. /**
  98659. * Disposes the ShadowGenerator.
  98660. * Returns nothing.
  98661. */
  98662. dispose(): void;
  98663. /**
  98664. * Serializes the shadow generator setup to a json object.
  98665. * @returns The serialized JSON object
  98666. */
  98667. serialize(): any;
  98668. /**
  98669. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98670. * @param parsedShadowGenerator The JSON object to parse
  98671. * @param scene The scene to create the shadow map for
  98672. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98673. * @returns The parsed shadow generator
  98674. */
  98675. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98676. }
  98677. }
  98678. declare module BABYLON {
  98679. /**
  98680. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98681. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98682. * 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.
  98683. */
  98684. export abstract class Light extends Node {
  98685. /**
  98686. * Falloff Default: light is falling off following the material specification:
  98687. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98688. */
  98689. static readonly FALLOFF_DEFAULT: number;
  98690. /**
  98691. * Falloff Physical: light is falling off following the inverse squared distance law.
  98692. */
  98693. static readonly FALLOFF_PHYSICAL: number;
  98694. /**
  98695. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98696. * to enhance interoperability with other engines.
  98697. */
  98698. static readonly FALLOFF_GLTF: number;
  98699. /**
  98700. * Falloff Standard: light is falling off like in the standard material
  98701. * to enhance interoperability with other materials.
  98702. */
  98703. static readonly FALLOFF_STANDARD: number;
  98704. /**
  98705. * If every light affecting the material is in this lightmapMode,
  98706. * material.lightmapTexture adds or multiplies
  98707. * (depends on material.useLightmapAsShadowmap)
  98708. * after every other light calculations.
  98709. */
  98710. static readonly LIGHTMAP_DEFAULT: number;
  98711. /**
  98712. * material.lightmapTexture as only diffuse lighting from this light
  98713. * adds only specular lighting from this light
  98714. * adds dynamic shadows
  98715. */
  98716. static readonly LIGHTMAP_SPECULAR: number;
  98717. /**
  98718. * material.lightmapTexture as only lighting
  98719. * no light calculation from this light
  98720. * only adds dynamic shadows from this light
  98721. */
  98722. static readonly LIGHTMAP_SHADOWSONLY: number;
  98723. /**
  98724. * Each light type uses the default quantity according to its type:
  98725. * point/spot lights use luminous intensity
  98726. * directional lights use illuminance
  98727. */
  98728. static readonly INTENSITYMODE_AUTOMATIC: number;
  98729. /**
  98730. * lumen (lm)
  98731. */
  98732. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98733. /**
  98734. * candela (lm/sr)
  98735. */
  98736. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98737. /**
  98738. * lux (lm/m^2)
  98739. */
  98740. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98741. /**
  98742. * nit (cd/m^2)
  98743. */
  98744. static readonly INTENSITYMODE_LUMINANCE: number;
  98745. /**
  98746. * Light type const id of the point light.
  98747. */
  98748. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98749. /**
  98750. * Light type const id of the directional light.
  98751. */
  98752. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98753. /**
  98754. * Light type const id of the spot light.
  98755. */
  98756. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98757. /**
  98758. * Light type const id of the hemispheric light.
  98759. */
  98760. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98761. /**
  98762. * Diffuse gives the basic color to an object.
  98763. */
  98764. diffuse: Color3;
  98765. /**
  98766. * Specular produces a highlight color on an object.
  98767. * Note: This is note affecting PBR materials.
  98768. */
  98769. specular: Color3;
  98770. /**
  98771. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98772. * falling off base on range or angle.
  98773. * This can be set to any values in Light.FALLOFF_x.
  98774. *
  98775. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98776. * other types of materials.
  98777. */
  98778. falloffType: number;
  98779. /**
  98780. * Strength of the light.
  98781. * Note: By default it is define in the framework own unit.
  98782. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98783. */
  98784. intensity: number;
  98785. private _range;
  98786. protected _inverseSquaredRange: number;
  98787. /**
  98788. * Defines how far from the source the light is impacting in scene units.
  98789. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98790. */
  98791. get range(): number;
  98792. /**
  98793. * Defines how far from the source the light is impacting in scene units.
  98794. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98795. */
  98796. set range(value: number);
  98797. /**
  98798. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98799. * of light.
  98800. */
  98801. private _photometricScale;
  98802. private _intensityMode;
  98803. /**
  98804. * Gets the photometric scale used to interpret the intensity.
  98805. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98806. */
  98807. get intensityMode(): number;
  98808. /**
  98809. * Sets the photometric scale used to interpret the intensity.
  98810. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98811. */
  98812. set intensityMode(value: number);
  98813. private _radius;
  98814. /**
  98815. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98816. */
  98817. get radius(): number;
  98818. /**
  98819. * sets the light radius used by PBR Materials to simulate soft area lights.
  98820. */
  98821. set radius(value: number);
  98822. private _renderPriority;
  98823. /**
  98824. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98825. * exceeding the number allowed of the materials.
  98826. */
  98827. renderPriority: number;
  98828. private _shadowEnabled;
  98829. /**
  98830. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98831. * the current shadow generator.
  98832. */
  98833. get shadowEnabled(): boolean;
  98834. /**
  98835. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98836. * the current shadow generator.
  98837. */
  98838. set shadowEnabled(value: boolean);
  98839. private _includedOnlyMeshes;
  98840. /**
  98841. * Gets the only meshes impacted by this light.
  98842. */
  98843. get includedOnlyMeshes(): AbstractMesh[];
  98844. /**
  98845. * Sets the only meshes impacted by this light.
  98846. */
  98847. set includedOnlyMeshes(value: AbstractMesh[]);
  98848. private _excludedMeshes;
  98849. /**
  98850. * Gets the meshes not impacted by this light.
  98851. */
  98852. get excludedMeshes(): AbstractMesh[];
  98853. /**
  98854. * Sets the meshes not impacted by this light.
  98855. */
  98856. set excludedMeshes(value: AbstractMesh[]);
  98857. private _excludeWithLayerMask;
  98858. /**
  98859. * Gets the layer id use to find what meshes are not impacted by the light.
  98860. * Inactive if 0
  98861. */
  98862. get excludeWithLayerMask(): number;
  98863. /**
  98864. * Sets the layer id use to find what meshes are not impacted by the light.
  98865. * Inactive if 0
  98866. */
  98867. set excludeWithLayerMask(value: number);
  98868. private _includeOnlyWithLayerMask;
  98869. /**
  98870. * Gets the layer id use to find what meshes are impacted by the light.
  98871. * Inactive if 0
  98872. */
  98873. get includeOnlyWithLayerMask(): number;
  98874. /**
  98875. * Sets the layer id use to find what meshes are impacted by the light.
  98876. * Inactive if 0
  98877. */
  98878. set includeOnlyWithLayerMask(value: number);
  98879. private _lightmapMode;
  98880. /**
  98881. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98882. */
  98883. get lightmapMode(): number;
  98884. /**
  98885. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98886. */
  98887. set lightmapMode(value: number);
  98888. /**
  98889. * Shadow generator associted to the light.
  98890. * @hidden Internal use only.
  98891. */
  98892. _shadowGenerator: Nullable<IShadowGenerator>;
  98893. /**
  98894. * @hidden Internal use only.
  98895. */
  98896. _excludedMeshesIds: string[];
  98897. /**
  98898. * @hidden Internal use only.
  98899. */
  98900. _includedOnlyMeshesIds: string[];
  98901. /**
  98902. * The current light unifom buffer.
  98903. * @hidden Internal use only.
  98904. */
  98905. _uniformBuffer: UniformBuffer;
  98906. /** @hidden */
  98907. _renderId: number;
  98908. /**
  98909. * Creates a Light object in the scene.
  98910. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98911. * @param name The firendly name of the light
  98912. * @param scene The scene the light belongs too
  98913. */
  98914. constructor(name: string, scene: Scene);
  98915. protected abstract _buildUniformLayout(): void;
  98916. /**
  98917. * Sets the passed Effect "effect" with the Light information.
  98918. * @param effect The effect to update
  98919. * @param lightIndex The index of the light in the effect to update
  98920. * @returns The light
  98921. */
  98922. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98923. /**
  98924. * Sets the passed Effect "effect" with the Light textures.
  98925. * @param effect The effect to update
  98926. * @param lightIndex The index of the light in the effect to update
  98927. * @returns The light
  98928. */
  98929. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98930. /**
  98931. * Binds the lights information from the scene to the effect for the given mesh.
  98932. * @param lightIndex Light index
  98933. * @param scene The scene where the light belongs to
  98934. * @param effect The effect we are binding the data to
  98935. * @param useSpecular Defines if specular is supported
  98936. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98937. */
  98938. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98939. /**
  98940. * Sets the passed Effect "effect" with the Light information.
  98941. * @param effect The effect to update
  98942. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98943. * @returns The light
  98944. */
  98945. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98946. /**
  98947. * Returns the string "Light".
  98948. * @returns the class name
  98949. */
  98950. getClassName(): string;
  98951. /** @hidden */
  98952. readonly _isLight: boolean;
  98953. /**
  98954. * Converts the light information to a readable string for debug purpose.
  98955. * @param fullDetails Supports for multiple levels of logging within scene loading
  98956. * @returns the human readable light info
  98957. */
  98958. toString(fullDetails?: boolean): string;
  98959. /** @hidden */
  98960. protected _syncParentEnabledState(): void;
  98961. /**
  98962. * Set the enabled state of this node.
  98963. * @param value - the new enabled state
  98964. */
  98965. setEnabled(value: boolean): void;
  98966. /**
  98967. * Returns the Light associated shadow generator if any.
  98968. * @return the associated shadow generator.
  98969. */
  98970. getShadowGenerator(): Nullable<IShadowGenerator>;
  98971. /**
  98972. * Returns a Vector3, the absolute light position in the World.
  98973. * @returns the world space position of the light
  98974. */
  98975. getAbsolutePosition(): Vector3;
  98976. /**
  98977. * Specifies if the light will affect the passed mesh.
  98978. * @param mesh The mesh to test against the light
  98979. * @return true the mesh is affected otherwise, false.
  98980. */
  98981. canAffectMesh(mesh: AbstractMesh): boolean;
  98982. /**
  98983. * Sort function to order lights for rendering.
  98984. * @param a First Light object to compare to second.
  98985. * @param b Second Light object to compare first.
  98986. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98987. */
  98988. static CompareLightsPriority(a: Light, b: Light): number;
  98989. /**
  98990. * Releases resources associated with this node.
  98991. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98992. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98993. */
  98994. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98995. /**
  98996. * Returns the light type ID (integer).
  98997. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98998. */
  98999. getTypeID(): number;
  99000. /**
  99001. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99002. * @returns the scaled intensity in intensity mode unit
  99003. */
  99004. getScaledIntensity(): number;
  99005. /**
  99006. * Returns a new Light object, named "name", from the current one.
  99007. * @param name The name of the cloned light
  99008. * @param newParent The parent of this light, if it has one
  99009. * @returns the new created light
  99010. */
  99011. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99012. /**
  99013. * Serializes the current light into a Serialization object.
  99014. * @returns the serialized object.
  99015. */
  99016. serialize(): any;
  99017. /**
  99018. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99019. * This new light is named "name" and added to the passed scene.
  99020. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99021. * @param name The friendly name of the light
  99022. * @param scene The scene the new light will belong to
  99023. * @returns the constructor function
  99024. */
  99025. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99026. /**
  99027. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99028. * @param parsedLight The JSON representation of the light
  99029. * @param scene The scene to create the parsed light in
  99030. * @returns the created light after parsing
  99031. */
  99032. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99033. private _hookArrayForExcluded;
  99034. private _hookArrayForIncludedOnly;
  99035. private _resyncMeshes;
  99036. /**
  99037. * Forces the meshes to update their light related information in their rendering used effects
  99038. * @hidden Internal Use Only
  99039. */
  99040. _markMeshesAsLightDirty(): void;
  99041. /**
  99042. * Recomputes the cached photometric scale if needed.
  99043. */
  99044. private _computePhotometricScale;
  99045. /**
  99046. * Returns the Photometric Scale according to the light type and intensity mode.
  99047. */
  99048. private _getPhotometricScale;
  99049. /**
  99050. * Reorder the light in the scene according to their defined priority.
  99051. * @hidden Internal Use Only
  99052. */
  99053. _reorderLightsInScene(): void;
  99054. /**
  99055. * Prepares the list of defines specific to the light type.
  99056. * @param defines the list of defines
  99057. * @param lightIndex defines the index of the light for the effect
  99058. */
  99059. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99060. }
  99061. }
  99062. declare module BABYLON {
  99063. /**
  99064. * Configuration needed for prepass-capable materials
  99065. */
  99066. export class PrePassConfiguration {
  99067. /**
  99068. * Previous world matrices of meshes carrying this material
  99069. * Used for computing velocity
  99070. */
  99071. previousWorldMatrices: {
  99072. [index: number]: Matrix;
  99073. };
  99074. /**
  99075. * Previous view project matrix
  99076. * Used for computing velocity
  99077. */
  99078. previousViewProjection: Matrix;
  99079. /**
  99080. * Previous bones of meshes carrying this material
  99081. * Used for computing velocity
  99082. */
  99083. previousBones: {
  99084. [index: number]: Float32Array;
  99085. };
  99086. /**
  99087. * Add the required uniforms to the current list.
  99088. * @param uniforms defines the current uniform list.
  99089. */
  99090. static AddUniforms(uniforms: string[]): void;
  99091. /**
  99092. * Add the required samplers to the current list.
  99093. * @param samplers defines the current sampler list.
  99094. */
  99095. static AddSamplers(samplers: string[]): void;
  99096. /**
  99097. * Binds the material data.
  99098. * @param effect defines the effect to update
  99099. * @param scene defines the scene the material belongs to.
  99100. * @param mesh The mesh
  99101. * @param world World matrix of this mesh
  99102. * @param isFrozen Is the material frozen
  99103. */
  99104. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99105. }
  99106. }
  99107. declare module BABYLON {
  99108. /**
  99109. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99110. * This is the base of the follow, arc rotate cameras and Free camera
  99111. * @see https://doc.babylonjs.com/features/cameras
  99112. */
  99113. export class TargetCamera extends Camera {
  99114. private static _RigCamTransformMatrix;
  99115. private static _TargetTransformMatrix;
  99116. private static _TargetFocalPoint;
  99117. private _tmpUpVector;
  99118. private _tmpTargetVector;
  99119. /**
  99120. * Define the current direction the camera is moving to
  99121. */
  99122. cameraDirection: Vector3;
  99123. /**
  99124. * Define the current rotation the camera is rotating to
  99125. */
  99126. cameraRotation: Vector2;
  99127. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99128. ignoreParentScaling: boolean;
  99129. /**
  99130. * When set, the up vector of the camera will be updated by the rotation of the camera
  99131. */
  99132. updateUpVectorFromRotation: boolean;
  99133. private _tmpQuaternion;
  99134. /**
  99135. * Define the current rotation of the camera
  99136. */
  99137. rotation: Vector3;
  99138. /**
  99139. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99140. */
  99141. rotationQuaternion: Quaternion;
  99142. /**
  99143. * Define the current speed of the camera
  99144. */
  99145. speed: number;
  99146. /**
  99147. * Add constraint to the camera to prevent it to move freely in all directions and
  99148. * around all axis.
  99149. */
  99150. noRotationConstraint: boolean;
  99151. /**
  99152. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99153. * panning
  99154. */
  99155. invertRotation: boolean;
  99156. /**
  99157. * Speed multiplier for inverse camera panning
  99158. */
  99159. inverseRotationSpeed: number;
  99160. /**
  99161. * Define the current target of the camera as an object or a position.
  99162. */
  99163. lockedTarget: any;
  99164. /** @hidden */
  99165. _currentTarget: Vector3;
  99166. /** @hidden */
  99167. _initialFocalDistance: number;
  99168. /** @hidden */
  99169. _viewMatrix: Matrix;
  99170. /** @hidden */
  99171. _camMatrix: Matrix;
  99172. /** @hidden */
  99173. _cameraTransformMatrix: Matrix;
  99174. /** @hidden */
  99175. _cameraRotationMatrix: Matrix;
  99176. /** @hidden */
  99177. _referencePoint: Vector3;
  99178. /** @hidden */
  99179. _transformedReferencePoint: Vector3;
  99180. /** @hidden */
  99181. _reset: () => void;
  99182. private _defaultUp;
  99183. /**
  99184. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99185. * This is the base of the follow, arc rotate cameras and Free camera
  99186. * @see https://doc.babylonjs.com/features/cameras
  99187. * @param name Defines the name of the camera in the scene
  99188. * @param position Defines the start position of the camera in the scene
  99189. * @param scene Defines the scene the camera belongs to
  99190. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99191. */
  99192. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99193. /**
  99194. * Gets the position in front of the camera at a given distance.
  99195. * @param distance The distance from the camera we want the position to be
  99196. * @returns the position
  99197. */
  99198. getFrontPosition(distance: number): Vector3;
  99199. /** @hidden */
  99200. _getLockedTargetPosition(): Nullable<Vector3>;
  99201. private _storedPosition;
  99202. private _storedRotation;
  99203. private _storedRotationQuaternion;
  99204. /**
  99205. * Store current camera state of the camera (fov, position, rotation, etc..)
  99206. * @returns the camera
  99207. */
  99208. storeState(): Camera;
  99209. /**
  99210. * Restored camera state. You must call storeState() first
  99211. * @returns whether it was successful or not
  99212. * @hidden
  99213. */
  99214. _restoreStateValues(): boolean;
  99215. /** @hidden */
  99216. _initCache(): void;
  99217. /** @hidden */
  99218. _updateCache(ignoreParentClass?: boolean): void;
  99219. /** @hidden */
  99220. _isSynchronizedViewMatrix(): boolean;
  99221. /** @hidden */
  99222. _computeLocalCameraSpeed(): number;
  99223. /**
  99224. * Defines the target the camera should look at.
  99225. * @param target Defines the new target as a Vector or a mesh
  99226. */
  99227. setTarget(target: Vector3): void;
  99228. /**
  99229. * Defines the target point of the camera.
  99230. * The camera looks towards it form the radius distance.
  99231. */
  99232. get target(): Vector3;
  99233. set target(value: Vector3);
  99234. /**
  99235. * Return the current target position of the camera. This value is expressed in local space.
  99236. * @returns the target position
  99237. */
  99238. getTarget(): Vector3;
  99239. /** @hidden */
  99240. _decideIfNeedsToMove(): boolean;
  99241. /** @hidden */
  99242. _updatePosition(): void;
  99243. /** @hidden */
  99244. _checkInputs(): void;
  99245. protected _updateCameraRotationMatrix(): void;
  99246. /**
  99247. * 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)
  99248. * @returns the current camera
  99249. */
  99250. private _rotateUpVectorWithCameraRotationMatrix;
  99251. private _cachedRotationZ;
  99252. private _cachedQuaternionRotationZ;
  99253. /** @hidden */
  99254. _getViewMatrix(): Matrix;
  99255. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99256. /**
  99257. * @hidden
  99258. */
  99259. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99260. /**
  99261. * @hidden
  99262. */
  99263. _updateRigCameras(): void;
  99264. private _getRigCamPositionAndTarget;
  99265. /**
  99266. * Gets the current object class name.
  99267. * @return the class name
  99268. */
  99269. getClassName(): string;
  99270. }
  99271. }
  99272. declare module BABYLON {
  99273. /**
  99274. * Gather the list of keyboard event types as constants.
  99275. */
  99276. export class KeyboardEventTypes {
  99277. /**
  99278. * The keydown event is fired when a key becomes active (pressed).
  99279. */
  99280. static readonly KEYDOWN: number;
  99281. /**
  99282. * The keyup event is fired when a key has been released.
  99283. */
  99284. static readonly KEYUP: number;
  99285. }
  99286. /**
  99287. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99288. */
  99289. export class KeyboardInfo {
  99290. /**
  99291. * Defines the type of event (KeyboardEventTypes)
  99292. */
  99293. type: number;
  99294. /**
  99295. * Defines the related dom event
  99296. */
  99297. event: KeyboardEvent;
  99298. /**
  99299. * Instantiates a new keyboard info.
  99300. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99301. * @param type Defines the type of event (KeyboardEventTypes)
  99302. * @param event Defines the related dom event
  99303. */
  99304. constructor(
  99305. /**
  99306. * Defines the type of event (KeyboardEventTypes)
  99307. */
  99308. type: number,
  99309. /**
  99310. * Defines the related dom event
  99311. */
  99312. event: KeyboardEvent);
  99313. }
  99314. /**
  99315. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99316. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99317. */
  99318. export class KeyboardInfoPre extends KeyboardInfo {
  99319. /**
  99320. * Defines the type of event (KeyboardEventTypes)
  99321. */
  99322. type: number;
  99323. /**
  99324. * Defines the related dom event
  99325. */
  99326. event: KeyboardEvent;
  99327. /**
  99328. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99329. */
  99330. skipOnPointerObservable: boolean;
  99331. /**
  99332. * Instantiates a new keyboard pre info.
  99333. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99334. * @param type Defines the type of event (KeyboardEventTypes)
  99335. * @param event Defines the related dom event
  99336. */
  99337. constructor(
  99338. /**
  99339. * Defines the type of event (KeyboardEventTypes)
  99340. */
  99341. type: number,
  99342. /**
  99343. * Defines the related dom event
  99344. */
  99345. event: KeyboardEvent);
  99346. }
  99347. }
  99348. declare module BABYLON {
  99349. /**
  99350. * Manage the keyboard inputs to control the movement of a free camera.
  99351. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99352. */
  99353. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99354. /**
  99355. * Defines the camera the input is attached to.
  99356. */
  99357. camera: FreeCamera;
  99358. /**
  99359. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99360. */
  99361. keysUp: number[];
  99362. /**
  99363. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99364. */
  99365. keysUpward: number[];
  99366. /**
  99367. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99368. */
  99369. keysDown: number[];
  99370. /**
  99371. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99372. */
  99373. keysDownward: number[];
  99374. /**
  99375. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99376. */
  99377. keysLeft: number[];
  99378. /**
  99379. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99380. */
  99381. keysRight: number[];
  99382. private _keys;
  99383. private _onCanvasBlurObserver;
  99384. private _onKeyboardObserver;
  99385. private _engine;
  99386. private _scene;
  99387. /**
  99388. * Attach the input controls to a specific dom element to get the input from.
  99389. * @param element Defines the element the controls should be listened from
  99390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99391. */
  99392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99393. /**
  99394. * Detach the current controls from the specified dom element.
  99395. * @param element Defines the element to stop listening the inputs from
  99396. */
  99397. detachControl(element: Nullable<HTMLElement>): void;
  99398. /**
  99399. * Update the current camera state depending on the inputs that have been used this frame.
  99400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99401. */
  99402. checkInputs(): void;
  99403. /**
  99404. * Gets the class name of the current intput.
  99405. * @returns the class name
  99406. */
  99407. getClassName(): string;
  99408. /** @hidden */
  99409. _onLostFocus(): void;
  99410. /**
  99411. * Get the friendly name associated with the input class.
  99412. * @returns the input friendly name
  99413. */
  99414. getSimpleName(): string;
  99415. }
  99416. }
  99417. declare module BABYLON {
  99418. /**
  99419. * Gather the list of pointer event types as constants.
  99420. */
  99421. export class PointerEventTypes {
  99422. /**
  99423. * 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.
  99424. */
  99425. static readonly POINTERDOWN: number;
  99426. /**
  99427. * The pointerup event is fired when a pointer is no longer active.
  99428. */
  99429. static readonly POINTERUP: number;
  99430. /**
  99431. * The pointermove event is fired when a pointer changes coordinates.
  99432. */
  99433. static readonly POINTERMOVE: number;
  99434. /**
  99435. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99436. */
  99437. static readonly POINTERWHEEL: number;
  99438. /**
  99439. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99440. */
  99441. static readonly POINTERPICK: number;
  99442. /**
  99443. * The pointertap event is fired when a the object has been touched and released without drag.
  99444. */
  99445. static readonly POINTERTAP: number;
  99446. /**
  99447. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99448. */
  99449. static readonly POINTERDOUBLETAP: number;
  99450. }
  99451. /**
  99452. * Base class of pointer info types.
  99453. */
  99454. export class PointerInfoBase {
  99455. /**
  99456. * Defines the type of event (PointerEventTypes)
  99457. */
  99458. type: number;
  99459. /**
  99460. * Defines the related dom event
  99461. */
  99462. event: PointerEvent | MouseWheelEvent;
  99463. /**
  99464. * Instantiates the base class of pointers info.
  99465. * @param type Defines the type of event (PointerEventTypes)
  99466. * @param event Defines the related dom event
  99467. */
  99468. constructor(
  99469. /**
  99470. * Defines the type of event (PointerEventTypes)
  99471. */
  99472. type: number,
  99473. /**
  99474. * Defines the related dom event
  99475. */
  99476. event: PointerEvent | MouseWheelEvent);
  99477. }
  99478. /**
  99479. * This class is used to store pointer related info for the onPrePointerObservable event.
  99480. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99481. */
  99482. export class PointerInfoPre extends PointerInfoBase {
  99483. /**
  99484. * Ray from a pointer if availible (eg. 6dof controller)
  99485. */
  99486. ray: Nullable<Ray>;
  99487. /**
  99488. * Defines the local position of the pointer on the canvas.
  99489. */
  99490. localPosition: Vector2;
  99491. /**
  99492. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99493. */
  99494. skipOnPointerObservable: boolean;
  99495. /**
  99496. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99497. * @param type Defines the type of event (PointerEventTypes)
  99498. * @param event Defines the related dom event
  99499. * @param localX Defines the local x coordinates of the pointer when the event occured
  99500. * @param localY Defines the local y coordinates of the pointer when the event occured
  99501. */
  99502. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99503. }
  99504. /**
  99505. * This type contains all the data related to a pointer event in Babylon.js.
  99506. * 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.
  99507. */
  99508. export class PointerInfo extends PointerInfoBase {
  99509. /**
  99510. * Defines the picking info associated to the info (if any)\
  99511. */
  99512. pickInfo: Nullable<PickingInfo>;
  99513. /**
  99514. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99515. * @param type Defines the type of event (PointerEventTypes)
  99516. * @param event Defines the related dom event
  99517. * @param pickInfo Defines the picking info associated to the info (if any)\
  99518. */
  99519. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99520. /**
  99521. * Defines the picking info associated to the info (if any)\
  99522. */
  99523. pickInfo: Nullable<PickingInfo>);
  99524. }
  99525. /**
  99526. * Data relating to a touch event on the screen.
  99527. */
  99528. export interface PointerTouch {
  99529. /**
  99530. * X coordinate of touch.
  99531. */
  99532. x: number;
  99533. /**
  99534. * Y coordinate of touch.
  99535. */
  99536. y: number;
  99537. /**
  99538. * Id of touch. Unique for each finger.
  99539. */
  99540. pointerId: number;
  99541. /**
  99542. * Event type passed from DOM.
  99543. */
  99544. type: any;
  99545. }
  99546. }
  99547. declare module BABYLON {
  99548. /**
  99549. * Manage the mouse inputs to control the movement of a free camera.
  99550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99551. */
  99552. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99553. /**
  99554. * Define if touch is enabled in the mouse input
  99555. */
  99556. touchEnabled: boolean;
  99557. /**
  99558. * Defines the camera the input is attached to.
  99559. */
  99560. camera: FreeCamera;
  99561. /**
  99562. * Defines the buttons associated with the input to handle camera move.
  99563. */
  99564. buttons: number[];
  99565. /**
  99566. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99567. */
  99568. angularSensibility: number;
  99569. private _pointerInput;
  99570. private _onMouseMove;
  99571. private _observer;
  99572. private previousPosition;
  99573. /**
  99574. * Observable for when a pointer move event occurs containing the move offset
  99575. */
  99576. onPointerMovedObservable: Observable<{
  99577. offsetX: number;
  99578. offsetY: number;
  99579. }>;
  99580. /**
  99581. * @hidden
  99582. * If the camera should be rotated automatically based on pointer movement
  99583. */
  99584. _allowCameraRotation: boolean;
  99585. /**
  99586. * Manage the mouse inputs to control the movement of a free camera.
  99587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99588. * @param touchEnabled Defines if touch is enabled or not
  99589. */
  99590. constructor(
  99591. /**
  99592. * Define if touch is enabled in the mouse input
  99593. */
  99594. touchEnabled?: boolean);
  99595. /**
  99596. * Attach the input controls to a specific dom element to get the input from.
  99597. * @param element Defines the element the controls should be listened from
  99598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99599. */
  99600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99601. /**
  99602. * Called on JS contextmenu event.
  99603. * Override this method to provide functionality.
  99604. */
  99605. protected onContextMenu(evt: PointerEvent): void;
  99606. /**
  99607. * Detach the current controls from the specified dom element.
  99608. * @param element Defines the element to stop listening the inputs from
  99609. */
  99610. detachControl(element: Nullable<HTMLElement>): void;
  99611. /**
  99612. * Gets the class name of the current intput.
  99613. * @returns the class name
  99614. */
  99615. getClassName(): string;
  99616. /**
  99617. * Get the friendly name associated with the input class.
  99618. * @returns the input friendly name
  99619. */
  99620. getSimpleName(): string;
  99621. }
  99622. }
  99623. declare module BABYLON {
  99624. /**
  99625. * Manage the touch inputs to control the movement of a free camera.
  99626. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99627. */
  99628. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99629. /**
  99630. * Define if mouse events can be treated as touch events
  99631. */
  99632. allowMouse: boolean;
  99633. /**
  99634. * Defines the camera the input is attached to.
  99635. */
  99636. camera: FreeCamera;
  99637. /**
  99638. * Defines the touch sensibility for rotation.
  99639. * The higher the faster.
  99640. */
  99641. touchAngularSensibility: number;
  99642. /**
  99643. * Defines the touch sensibility for move.
  99644. * The higher the faster.
  99645. */
  99646. touchMoveSensibility: number;
  99647. private _offsetX;
  99648. private _offsetY;
  99649. private _pointerPressed;
  99650. private _pointerInput;
  99651. private _observer;
  99652. private _onLostFocus;
  99653. /**
  99654. * Manage the touch inputs to control the movement of a free camera.
  99655. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99656. * @param allowMouse Defines if mouse events can be treated as touch events
  99657. */
  99658. constructor(
  99659. /**
  99660. * Define if mouse events can be treated as touch events
  99661. */
  99662. allowMouse?: boolean);
  99663. /**
  99664. * Attach the input controls to a specific dom element to get the input from.
  99665. * @param element Defines the element the controls should be listened from
  99666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99667. */
  99668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99669. /**
  99670. * Detach the current controls from the specified dom element.
  99671. * @param element Defines the element to stop listening the inputs from
  99672. */
  99673. detachControl(element: Nullable<HTMLElement>): void;
  99674. /**
  99675. * Update the current camera state depending on the inputs that have been used this frame.
  99676. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99677. */
  99678. checkInputs(): void;
  99679. /**
  99680. * Gets the class name of the current intput.
  99681. * @returns the class name
  99682. */
  99683. getClassName(): string;
  99684. /**
  99685. * Get the friendly name associated with the input class.
  99686. * @returns the input friendly name
  99687. */
  99688. getSimpleName(): string;
  99689. }
  99690. }
  99691. declare module BABYLON {
  99692. /**
  99693. * Default Inputs manager for the FreeCamera.
  99694. * It groups all the default supported inputs for ease of use.
  99695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99696. */
  99697. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99698. /**
  99699. * @hidden
  99700. */
  99701. _mouseInput: Nullable<FreeCameraMouseInput>;
  99702. /**
  99703. * Instantiates a new FreeCameraInputsManager.
  99704. * @param camera Defines the camera the inputs belong to
  99705. */
  99706. constructor(camera: FreeCamera);
  99707. /**
  99708. * Add keyboard input support to the input manager.
  99709. * @returns the current input manager
  99710. */
  99711. addKeyboard(): FreeCameraInputsManager;
  99712. /**
  99713. * Add mouse input support to the input manager.
  99714. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99715. * @returns the current input manager
  99716. */
  99717. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99718. /**
  99719. * Removes the mouse input support from the manager
  99720. * @returns the current input manager
  99721. */
  99722. removeMouse(): FreeCameraInputsManager;
  99723. /**
  99724. * Add touch input support to the input manager.
  99725. * @returns the current input manager
  99726. */
  99727. addTouch(): FreeCameraInputsManager;
  99728. /**
  99729. * Remove all attached input methods from a camera
  99730. */
  99731. clear(): void;
  99732. }
  99733. }
  99734. declare module BABYLON {
  99735. /**
  99736. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99737. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99738. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99739. */
  99740. export class FreeCamera extends TargetCamera {
  99741. /**
  99742. * Define the collision ellipsoid of the camera.
  99743. * This is helpful to simulate a camera body like the player body around the camera
  99744. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99745. */
  99746. ellipsoid: Vector3;
  99747. /**
  99748. * Define an offset for the position of the ellipsoid around the camera.
  99749. * This can be helpful to determine the center of the body near the gravity center of the body
  99750. * instead of its head.
  99751. */
  99752. ellipsoidOffset: Vector3;
  99753. /**
  99754. * Enable or disable collisions of the camera with the rest of the scene objects.
  99755. */
  99756. checkCollisions: boolean;
  99757. /**
  99758. * Enable or disable gravity on the camera.
  99759. */
  99760. applyGravity: boolean;
  99761. /**
  99762. * Define the input manager associated to the camera.
  99763. */
  99764. inputs: FreeCameraInputsManager;
  99765. /**
  99766. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99767. * Higher values reduce sensitivity.
  99768. */
  99769. get angularSensibility(): number;
  99770. /**
  99771. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99772. * Higher values reduce sensitivity.
  99773. */
  99774. set angularSensibility(value: number);
  99775. /**
  99776. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99777. */
  99778. get keysUp(): number[];
  99779. set keysUp(value: number[]);
  99780. /**
  99781. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99782. */
  99783. get keysUpward(): number[];
  99784. set keysUpward(value: number[]);
  99785. /**
  99786. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99787. */
  99788. get keysDown(): number[];
  99789. set keysDown(value: number[]);
  99790. /**
  99791. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99792. */
  99793. get keysDownward(): number[];
  99794. set keysDownward(value: number[]);
  99795. /**
  99796. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99797. */
  99798. get keysLeft(): number[];
  99799. set keysLeft(value: number[]);
  99800. /**
  99801. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99802. */
  99803. get keysRight(): number[];
  99804. set keysRight(value: number[]);
  99805. /**
  99806. * Event raised when the camera collide with a mesh in the scene.
  99807. */
  99808. onCollide: (collidedMesh: AbstractMesh) => void;
  99809. private _collider;
  99810. private _needMoveForGravity;
  99811. private _oldPosition;
  99812. private _diffPosition;
  99813. private _newPosition;
  99814. /** @hidden */
  99815. _localDirection: Vector3;
  99816. /** @hidden */
  99817. _transformedDirection: Vector3;
  99818. /**
  99819. * Instantiates a Free Camera.
  99820. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99821. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99822. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99823. * @param name Define the name of the camera in the scene
  99824. * @param position Define the start position of the camera in the scene
  99825. * @param scene Define the scene the camera belongs to
  99826. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99827. */
  99828. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99829. /**
  99830. * Attached controls to the current camera.
  99831. * @param element Defines the element the controls should be listened from
  99832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99833. */
  99834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99835. /**
  99836. * Detach the current controls from the camera.
  99837. * The camera will stop reacting to inputs.
  99838. * @param element Defines the element to stop listening the inputs from
  99839. */
  99840. detachControl(element: HTMLElement): void;
  99841. private _collisionMask;
  99842. /**
  99843. * Define a collision mask to limit the list of object the camera can collide with
  99844. */
  99845. get collisionMask(): number;
  99846. set collisionMask(mask: number);
  99847. /** @hidden */
  99848. _collideWithWorld(displacement: Vector3): void;
  99849. private _onCollisionPositionChange;
  99850. /** @hidden */
  99851. _checkInputs(): void;
  99852. /** @hidden */
  99853. _decideIfNeedsToMove(): boolean;
  99854. /** @hidden */
  99855. _updatePosition(): void;
  99856. /**
  99857. * Destroy the camera and release the current resources hold by it.
  99858. */
  99859. dispose(): void;
  99860. /**
  99861. * Gets the current object class name.
  99862. * @return the class name
  99863. */
  99864. getClassName(): string;
  99865. }
  99866. }
  99867. declare module BABYLON {
  99868. /**
  99869. * Represents a gamepad control stick position
  99870. */
  99871. export class StickValues {
  99872. /**
  99873. * The x component of the control stick
  99874. */
  99875. x: number;
  99876. /**
  99877. * The y component of the control stick
  99878. */
  99879. y: number;
  99880. /**
  99881. * Initializes the gamepad x and y control stick values
  99882. * @param x The x component of the gamepad control stick value
  99883. * @param y The y component of the gamepad control stick value
  99884. */
  99885. constructor(
  99886. /**
  99887. * The x component of the control stick
  99888. */
  99889. x: number,
  99890. /**
  99891. * The y component of the control stick
  99892. */
  99893. y: number);
  99894. }
  99895. /**
  99896. * An interface which manages callbacks for gamepad button changes
  99897. */
  99898. export interface GamepadButtonChanges {
  99899. /**
  99900. * Called when a gamepad has been changed
  99901. */
  99902. changed: boolean;
  99903. /**
  99904. * Called when a gamepad press event has been triggered
  99905. */
  99906. pressChanged: boolean;
  99907. /**
  99908. * Called when a touch event has been triggered
  99909. */
  99910. touchChanged: boolean;
  99911. /**
  99912. * Called when a value has changed
  99913. */
  99914. valueChanged: boolean;
  99915. }
  99916. /**
  99917. * Represents a gamepad
  99918. */
  99919. export class Gamepad {
  99920. /**
  99921. * The id of the gamepad
  99922. */
  99923. id: string;
  99924. /**
  99925. * The index of the gamepad
  99926. */
  99927. index: number;
  99928. /**
  99929. * The browser gamepad
  99930. */
  99931. browserGamepad: any;
  99932. /**
  99933. * Specifies what type of gamepad this represents
  99934. */
  99935. type: number;
  99936. private _leftStick;
  99937. private _rightStick;
  99938. /** @hidden */
  99939. _isConnected: boolean;
  99940. private _leftStickAxisX;
  99941. private _leftStickAxisY;
  99942. private _rightStickAxisX;
  99943. private _rightStickAxisY;
  99944. /**
  99945. * Triggered when the left control stick has been changed
  99946. */
  99947. private _onleftstickchanged;
  99948. /**
  99949. * Triggered when the right control stick has been changed
  99950. */
  99951. private _onrightstickchanged;
  99952. /**
  99953. * Represents a gamepad controller
  99954. */
  99955. static GAMEPAD: number;
  99956. /**
  99957. * Represents a generic controller
  99958. */
  99959. static GENERIC: number;
  99960. /**
  99961. * Represents an XBox controller
  99962. */
  99963. static XBOX: number;
  99964. /**
  99965. * Represents a pose-enabled controller
  99966. */
  99967. static POSE_ENABLED: number;
  99968. /**
  99969. * Represents an Dual Shock controller
  99970. */
  99971. static DUALSHOCK: number;
  99972. /**
  99973. * Specifies whether the left control stick should be Y-inverted
  99974. */
  99975. protected _invertLeftStickY: boolean;
  99976. /**
  99977. * Specifies if the gamepad has been connected
  99978. */
  99979. get isConnected(): boolean;
  99980. /**
  99981. * Initializes the gamepad
  99982. * @param id The id of the gamepad
  99983. * @param index The index of the gamepad
  99984. * @param browserGamepad The browser gamepad
  99985. * @param leftStickX The x component of the left joystick
  99986. * @param leftStickY The y component of the left joystick
  99987. * @param rightStickX The x component of the right joystick
  99988. * @param rightStickY The y component of the right joystick
  99989. */
  99990. constructor(
  99991. /**
  99992. * The id of the gamepad
  99993. */
  99994. id: string,
  99995. /**
  99996. * The index of the gamepad
  99997. */
  99998. index: number,
  99999. /**
  100000. * The browser gamepad
  100001. */
  100002. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100003. /**
  100004. * Callback triggered when the left joystick has changed
  100005. * @param callback
  100006. */
  100007. onleftstickchanged(callback: (values: StickValues) => void): void;
  100008. /**
  100009. * Callback triggered when the right joystick has changed
  100010. * @param callback
  100011. */
  100012. onrightstickchanged(callback: (values: StickValues) => void): void;
  100013. /**
  100014. * Gets the left joystick
  100015. */
  100016. get leftStick(): StickValues;
  100017. /**
  100018. * Sets the left joystick values
  100019. */
  100020. set leftStick(newValues: StickValues);
  100021. /**
  100022. * Gets the right joystick
  100023. */
  100024. get rightStick(): StickValues;
  100025. /**
  100026. * Sets the right joystick value
  100027. */
  100028. set rightStick(newValues: StickValues);
  100029. /**
  100030. * Updates the gamepad joystick positions
  100031. */
  100032. update(): void;
  100033. /**
  100034. * Disposes the gamepad
  100035. */
  100036. dispose(): void;
  100037. }
  100038. /**
  100039. * Represents a generic gamepad
  100040. */
  100041. export class GenericPad extends Gamepad {
  100042. private _buttons;
  100043. private _onbuttondown;
  100044. private _onbuttonup;
  100045. /**
  100046. * Observable triggered when a button has been pressed
  100047. */
  100048. onButtonDownObservable: Observable<number>;
  100049. /**
  100050. * Observable triggered when a button has been released
  100051. */
  100052. onButtonUpObservable: Observable<number>;
  100053. /**
  100054. * Callback triggered when a button has been pressed
  100055. * @param callback Called when a button has been pressed
  100056. */
  100057. onbuttondown(callback: (buttonPressed: number) => void): void;
  100058. /**
  100059. * Callback triggered when a button has been released
  100060. * @param callback Called when a button has been released
  100061. */
  100062. onbuttonup(callback: (buttonReleased: number) => void): void;
  100063. /**
  100064. * Initializes the generic gamepad
  100065. * @param id The id of the generic gamepad
  100066. * @param index The index of the generic gamepad
  100067. * @param browserGamepad The browser gamepad
  100068. */
  100069. constructor(id: string, index: number, browserGamepad: any);
  100070. private _setButtonValue;
  100071. /**
  100072. * Updates the generic gamepad
  100073. */
  100074. update(): void;
  100075. /**
  100076. * Disposes the generic gamepad
  100077. */
  100078. dispose(): void;
  100079. }
  100080. }
  100081. declare module BABYLON {
  100082. /**
  100083. * Defines the types of pose enabled controllers that are supported
  100084. */
  100085. export enum PoseEnabledControllerType {
  100086. /**
  100087. * HTC Vive
  100088. */
  100089. VIVE = 0,
  100090. /**
  100091. * Oculus Rift
  100092. */
  100093. OCULUS = 1,
  100094. /**
  100095. * Windows mixed reality
  100096. */
  100097. WINDOWS = 2,
  100098. /**
  100099. * Samsung gear VR
  100100. */
  100101. GEAR_VR = 3,
  100102. /**
  100103. * Google Daydream
  100104. */
  100105. DAYDREAM = 4,
  100106. /**
  100107. * Generic
  100108. */
  100109. GENERIC = 5
  100110. }
  100111. /**
  100112. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100113. */
  100114. export interface MutableGamepadButton {
  100115. /**
  100116. * Value of the button/trigger
  100117. */
  100118. value: number;
  100119. /**
  100120. * If the button/trigger is currently touched
  100121. */
  100122. touched: boolean;
  100123. /**
  100124. * If the button/trigger is currently pressed
  100125. */
  100126. pressed: boolean;
  100127. }
  100128. /**
  100129. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100130. * @hidden
  100131. */
  100132. export interface ExtendedGamepadButton extends GamepadButton {
  100133. /**
  100134. * If the button/trigger is currently pressed
  100135. */
  100136. readonly pressed: boolean;
  100137. /**
  100138. * If the button/trigger is currently touched
  100139. */
  100140. readonly touched: boolean;
  100141. /**
  100142. * Value of the button/trigger
  100143. */
  100144. readonly value: number;
  100145. }
  100146. /** @hidden */
  100147. export interface _GamePadFactory {
  100148. /**
  100149. * Returns whether or not the current gamepad can be created for this type of controller.
  100150. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100151. * @returns true if it can be created, otherwise false
  100152. */
  100153. canCreate(gamepadInfo: any): boolean;
  100154. /**
  100155. * Creates a new instance of the Gamepad.
  100156. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100157. * @returns the new gamepad instance
  100158. */
  100159. create(gamepadInfo: any): Gamepad;
  100160. }
  100161. /**
  100162. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100163. */
  100164. export class PoseEnabledControllerHelper {
  100165. /** @hidden */
  100166. static _ControllerFactories: _GamePadFactory[];
  100167. /** @hidden */
  100168. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100169. /**
  100170. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100171. * @param vrGamepad the gamepad to initialized
  100172. * @returns a vr controller of the type the gamepad identified as
  100173. */
  100174. static InitiateController(vrGamepad: any): Gamepad;
  100175. }
  100176. /**
  100177. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100178. */
  100179. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100180. /**
  100181. * If the controller is used in a webXR session
  100182. */
  100183. isXR: boolean;
  100184. private _deviceRoomPosition;
  100185. private _deviceRoomRotationQuaternion;
  100186. /**
  100187. * The device position in babylon space
  100188. */
  100189. devicePosition: Vector3;
  100190. /**
  100191. * The device rotation in babylon space
  100192. */
  100193. deviceRotationQuaternion: Quaternion;
  100194. /**
  100195. * The scale factor of the device in babylon space
  100196. */
  100197. deviceScaleFactor: number;
  100198. /**
  100199. * (Likely devicePosition should be used instead) The device position in its room space
  100200. */
  100201. position: Vector3;
  100202. /**
  100203. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100204. */
  100205. rotationQuaternion: Quaternion;
  100206. /**
  100207. * The type of controller (Eg. Windows mixed reality)
  100208. */
  100209. controllerType: PoseEnabledControllerType;
  100210. protected _calculatedPosition: Vector3;
  100211. private _calculatedRotation;
  100212. /**
  100213. * The raw pose from the device
  100214. */
  100215. rawPose: DevicePose;
  100216. private _trackPosition;
  100217. private _maxRotationDistFromHeadset;
  100218. private _draggedRoomRotation;
  100219. /**
  100220. * @hidden
  100221. */
  100222. _disableTrackPosition(fixedPosition: Vector3): void;
  100223. /**
  100224. * Internal, the mesh attached to the controller
  100225. * @hidden
  100226. */
  100227. _mesh: Nullable<AbstractMesh>;
  100228. private _poseControlledCamera;
  100229. private _leftHandSystemQuaternion;
  100230. /**
  100231. * Internal, matrix used to convert room space to babylon space
  100232. * @hidden
  100233. */
  100234. _deviceToWorld: Matrix;
  100235. /**
  100236. * Node to be used when casting a ray from the controller
  100237. * @hidden
  100238. */
  100239. _pointingPoseNode: Nullable<TransformNode>;
  100240. /**
  100241. * Name of the child mesh that can be used to cast a ray from the controller
  100242. */
  100243. static readonly POINTING_POSE: string;
  100244. /**
  100245. * Creates a new PoseEnabledController from a gamepad
  100246. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100247. */
  100248. constructor(browserGamepad: any);
  100249. private _workingMatrix;
  100250. /**
  100251. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100252. */
  100253. update(): void;
  100254. /**
  100255. * Updates only the pose device and mesh without doing any button event checking
  100256. */
  100257. protected _updatePoseAndMesh(): void;
  100258. /**
  100259. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100260. * @param poseData raw pose fromthe device
  100261. */
  100262. updateFromDevice(poseData: DevicePose): void;
  100263. /**
  100264. * @hidden
  100265. */
  100266. _meshAttachedObservable: Observable<AbstractMesh>;
  100267. /**
  100268. * Attaches a mesh to the controller
  100269. * @param mesh the mesh to be attached
  100270. */
  100271. attachToMesh(mesh: AbstractMesh): void;
  100272. /**
  100273. * Attaches the controllers mesh to a camera
  100274. * @param camera the camera the mesh should be attached to
  100275. */
  100276. attachToPoseControlledCamera(camera: TargetCamera): void;
  100277. /**
  100278. * Disposes of the controller
  100279. */
  100280. dispose(): void;
  100281. /**
  100282. * The mesh that is attached to the controller
  100283. */
  100284. get mesh(): Nullable<AbstractMesh>;
  100285. /**
  100286. * Gets the ray of the controller in the direction the controller is pointing
  100287. * @param length the length the resulting ray should be
  100288. * @returns a ray in the direction the controller is pointing
  100289. */
  100290. getForwardRay(length?: number): Ray;
  100291. }
  100292. }
  100293. declare module BABYLON {
  100294. /**
  100295. * Defines the WebVRController object that represents controllers tracked in 3D space
  100296. */
  100297. export abstract class WebVRController extends PoseEnabledController {
  100298. /**
  100299. * Internal, the default controller model for the controller
  100300. */
  100301. protected _defaultModel: Nullable<AbstractMesh>;
  100302. /**
  100303. * Fired when the trigger state has changed
  100304. */
  100305. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100306. /**
  100307. * Fired when the main button state has changed
  100308. */
  100309. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100310. /**
  100311. * Fired when the secondary button state has changed
  100312. */
  100313. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100314. /**
  100315. * Fired when the pad state has changed
  100316. */
  100317. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100318. /**
  100319. * Fired when controllers stick values have changed
  100320. */
  100321. onPadValuesChangedObservable: Observable<StickValues>;
  100322. /**
  100323. * Array of button availible on the controller
  100324. */
  100325. protected _buttons: Array<MutableGamepadButton>;
  100326. private _onButtonStateChange;
  100327. /**
  100328. * Fired when a controller button's state has changed
  100329. * @param callback the callback containing the button that was modified
  100330. */
  100331. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100332. /**
  100333. * X and Y axis corresponding to the controllers joystick
  100334. */
  100335. pad: StickValues;
  100336. /**
  100337. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100338. */
  100339. hand: string;
  100340. /**
  100341. * The default controller model for the controller
  100342. */
  100343. get defaultModel(): Nullable<AbstractMesh>;
  100344. /**
  100345. * Creates a new WebVRController from a gamepad
  100346. * @param vrGamepad the gamepad that the WebVRController should be created from
  100347. */
  100348. constructor(vrGamepad: any);
  100349. /**
  100350. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100351. */
  100352. update(): void;
  100353. /**
  100354. * Function to be called when a button is modified
  100355. */
  100356. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100357. /**
  100358. * Loads a mesh and attaches it to the controller
  100359. * @param scene the scene the mesh should be added to
  100360. * @param meshLoaded callback for when the mesh has been loaded
  100361. */
  100362. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100363. private _setButtonValue;
  100364. private _changes;
  100365. private _checkChanges;
  100366. /**
  100367. * Disposes of th webVRCOntroller
  100368. */
  100369. dispose(): void;
  100370. }
  100371. }
  100372. declare module BABYLON {
  100373. /**
  100374. * The HemisphericLight simulates the ambient environment light,
  100375. * so the passed direction is the light reflection direction, not the incoming direction.
  100376. */
  100377. export class HemisphericLight extends Light {
  100378. /**
  100379. * The groundColor is the light in the opposite direction to the one specified during creation.
  100380. * 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.
  100381. */
  100382. groundColor: Color3;
  100383. /**
  100384. * The light reflection direction, not the incoming direction.
  100385. */
  100386. direction: Vector3;
  100387. /**
  100388. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100389. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100390. * The HemisphericLight can't cast shadows.
  100391. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100392. * @param name The friendly name of the light
  100393. * @param direction The direction of the light reflection
  100394. * @param scene The scene the light belongs to
  100395. */
  100396. constructor(name: string, direction: Vector3, scene: Scene);
  100397. protected _buildUniformLayout(): void;
  100398. /**
  100399. * Returns the string "HemisphericLight".
  100400. * @return The class name
  100401. */
  100402. getClassName(): string;
  100403. /**
  100404. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100405. * Returns the updated direction.
  100406. * @param target The target the direction should point to
  100407. * @return The computed direction
  100408. */
  100409. setDirectionToTarget(target: Vector3): Vector3;
  100410. /**
  100411. * Returns the shadow generator associated to the light.
  100412. * @returns Always null for hemispheric lights because it does not support shadows.
  100413. */
  100414. getShadowGenerator(): Nullable<IShadowGenerator>;
  100415. /**
  100416. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100417. * @param effect The effect to update
  100418. * @param lightIndex The index of the light in the effect to update
  100419. * @returns The hemispheric light
  100420. */
  100421. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100422. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100423. /**
  100424. * Computes the world matrix of the node
  100425. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100426. * @param useWasUpdatedFlag defines a reserved property
  100427. * @returns the world matrix
  100428. */
  100429. computeWorldMatrix(): Matrix;
  100430. /**
  100431. * Returns the integer 3.
  100432. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100433. */
  100434. getTypeID(): number;
  100435. /**
  100436. * Prepares the list of defines specific to the light type.
  100437. * @param defines the list of defines
  100438. * @param lightIndex defines the index of the light for the effect
  100439. */
  100440. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100441. }
  100442. }
  100443. declare module BABYLON {
  100444. /** @hidden */
  100445. export var vrMultiviewToSingleviewPixelShader: {
  100446. name: string;
  100447. shader: string;
  100448. };
  100449. }
  100450. declare module BABYLON {
  100451. /**
  100452. * Renders to multiple views with a single draw call
  100453. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100454. */
  100455. export class MultiviewRenderTarget extends RenderTargetTexture {
  100456. /**
  100457. * Creates a multiview render target
  100458. * @param scene scene used with the render target
  100459. * @param size the size of the render target (used for each view)
  100460. */
  100461. constructor(scene: Scene, size?: number | {
  100462. width: number;
  100463. height: number;
  100464. } | {
  100465. ratio: number;
  100466. });
  100467. /**
  100468. * @hidden
  100469. * @param faceIndex the face index, if its a cube texture
  100470. */
  100471. _bindFrameBuffer(faceIndex?: number): void;
  100472. /**
  100473. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100474. * @returns the view count
  100475. */
  100476. getViewCount(): number;
  100477. }
  100478. }
  100479. declare module BABYLON {
  100480. interface Engine {
  100481. /**
  100482. * Creates a new multiview render target
  100483. * @param width defines the width of the texture
  100484. * @param height defines the height of the texture
  100485. * @returns the created multiview texture
  100486. */
  100487. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100488. /**
  100489. * Binds a multiview framebuffer to be drawn to
  100490. * @param multiviewTexture texture to bind
  100491. */
  100492. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100493. }
  100494. interface Camera {
  100495. /**
  100496. * @hidden
  100497. * 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)
  100498. */
  100499. _useMultiviewToSingleView: boolean;
  100500. /**
  100501. * @hidden
  100502. * 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)
  100503. */
  100504. _multiviewTexture: Nullable<RenderTargetTexture>;
  100505. /**
  100506. * @hidden
  100507. * ensures the multiview texture of the camera exists and has the specified width/height
  100508. * @param width height to set on the multiview texture
  100509. * @param height width to set on the multiview texture
  100510. */
  100511. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100512. }
  100513. interface Scene {
  100514. /** @hidden */
  100515. _transformMatrixR: Matrix;
  100516. /** @hidden */
  100517. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100518. /** @hidden */
  100519. _createMultiviewUbo(): void;
  100520. /** @hidden */
  100521. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100522. /** @hidden */
  100523. _renderMultiviewToSingleView(camera: Camera): void;
  100524. }
  100525. }
  100526. declare module BABYLON {
  100527. /**
  100528. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100529. * This will not be used for webXR as it supports displaying texture arrays directly
  100530. */
  100531. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100532. /**
  100533. * Gets a string identifying the name of the class
  100534. * @returns "VRMultiviewToSingleviewPostProcess" string
  100535. */
  100536. getClassName(): string;
  100537. /**
  100538. * Initializes a VRMultiviewToSingleview
  100539. * @param name name of the post process
  100540. * @param camera camera to be applied to
  100541. * @param scaleFactor scaling factor to the size of the output texture
  100542. */
  100543. constructor(name: string, camera: Camera, scaleFactor: number);
  100544. }
  100545. }
  100546. declare module BABYLON {
  100547. /**
  100548. * Interface used to define additional presentation attributes
  100549. */
  100550. export interface IVRPresentationAttributes {
  100551. /**
  100552. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100553. */
  100554. highRefreshRate: boolean;
  100555. /**
  100556. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100557. */
  100558. foveationLevel: number;
  100559. }
  100560. interface Engine {
  100561. /** @hidden */
  100562. _vrDisplay: any;
  100563. /** @hidden */
  100564. _vrSupported: boolean;
  100565. /** @hidden */
  100566. _oldSize: Size;
  100567. /** @hidden */
  100568. _oldHardwareScaleFactor: number;
  100569. /** @hidden */
  100570. _vrExclusivePointerMode: boolean;
  100571. /** @hidden */
  100572. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100573. /** @hidden */
  100574. _onVRDisplayPointerRestricted: () => void;
  100575. /** @hidden */
  100576. _onVRDisplayPointerUnrestricted: () => void;
  100577. /** @hidden */
  100578. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100579. /** @hidden */
  100580. _onVrDisplayDisconnect: Nullable<() => void>;
  100581. /** @hidden */
  100582. _onVrDisplayPresentChange: Nullable<() => void>;
  100583. /**
  100584. * Observable signaled when VR display mode changes
  100585. */
  100586. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100587. /**
  100588. * Observable signaled when VR request present is complete
  100589. */
  100590. onVRRequestPresentComplete: Observable<boolean>;
  100591. /**
  100592. * Observable signaled when VR request present starts
  100593. */
  100594. onVRRequestPresentStart: Observable<Engine>;
  100595. /**
  100596. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100597. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100598. */
  100599. isInVRExclusivePointerMode: boolean;
  100600. /**
  100601. * Gets a boolean indicating if a webVR device was detected
  100602. * @returns true if a webVR device was detected
  100603. */
  100604. isVRDevicePresent(): boolean;
  100605. /**
  100606. * Gets the current webVR device
  100607. * @returns the current webVR device (or null)
  100608. */
  100609. getVRDevice(): any;
  100610. /**
  100611. * Initializes a webVR display and starts listening to display change events
  100612. * The onVRDisplayChangedObservable will be notified upon these changes
  100613. * @returns A promise containing a VRDisplay and if vr is supported
  100614. */
  100615. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100616. /** @hidden */
  100617. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100618. /**
  100619. * Gets or sets the presentation attributes used to configure VR rendering
  100620. */
  100621. vrPresentationAttributes?: IVRPresentationAttributes;
  100622. /**
  100623. * Call this function to switch to webVR mode
  100624. * Will do nothing if webVR is not supported or if there is no webVR device
  100625. * @param options the webvr options provided to the camera. mainly used for multiview
  100626. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100627. */
  100628. enableVR(options: WebVROptions): void;
  100629. /** @hidden */
  100630. _onVRFullScreenTriggered(): void;
  100631. }
  100632. }
  100633. declare module BABYLON {
  100634. /**
  100635. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100636. * IMPORTANT!! The data is right-hand data.
  100637. * @export
  100638. * @interface DevicePose
  100639. */
  100640. export interface DevicePose {
  100641. /**
  100642. * The position of the device, values in array are [x,y,z].
  100643. */
  100644. readonly position: Nullable<Float32Array>;
  100645. /**
  100646. * The linearVelocity of the device, values in array are [x,y,z].
  100647. */
  100648. readonly linearVelocity: Nullable<Float32Array>;
  100649. /**
  100650. * The linearAcceleration of the device, values in array are [x,y,z].
  100651. */
  100652. readonly linearAcceleration: Nullable<Float32Array>;
  100653. /**
  100654. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100655. */
  100656. readonly orientation: Nullable<Float32Array>;
  100657. /**
  100658. * The angularVelocity of the device, values in array are [x,y,z].
  100659. */
  100660. readonly angularVelocity: Nullable<Float32Array>;
  100661. /**
  100662. * The angularAcceleration of the device, values in array are [x,y,z].
  100663. */
  100664. readonly angularAcceleration: Nullable<Float32Array>;
  100665. }
  100666. /**
  100667. * Interface representing a pose controlled object in Babylon.
  100668. * A pose controlled object has both regular pose values as well as pose values
  100669. * from an external device such as a VR head mounted display
  100670. */
  100671. export interface PoseControlled {
  100672. /**
  100673. * The position of the object in babylon space.
  100674. */
  100675. position: Vector3;
  100676. /**
  100677. * The rotation quaternion of the object in babylon space.
  100678. */
  100679. rotationQuaternion: Quaternion;
  100680. /**
  100681. * The position of the device in babylon space.
  100682. */
  100683. devicePosition?: Vector3;
  100684. /**
  100685. * The rotation quaternion of the device in babylon space.
  100686. */
  100687. deviceRotationQuaternion: Quaternion;
  100688. /**
  100689. * The raw pose coming from the device.
  100690. */
  100691. rawPose: Nullable<DevicePose>;
  100692. /**
  100693. * The scale of the device to be used when translating from device space to babylon space.
  100694. */
  100695. deviceScaleFactor: number;
  100696. /**
  100697. * Updates the poseControlled values based on the input device pose.
  100698. * @param poseData the pose data to update the object with
  100699. */
  100700. updateFromDevice(poseData: DevicePose): void;
  100701. }
  100702. /**
  100703. * Set of options to customize the webVRCamera
  100704. */
  100705. export interface WebVROptions {
  100706. /**
  100707. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100708. */
  100709. trackPosition?: boolean;
  100710. /**
  100711. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100712. */
  100713. positionScale?: number;
  100714. /**
  100715. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100716. */
  100717. displayName?: string;
  100718. /**
  100719. * Should the native controller meshes be initialized. (default: true)
  100720. */
  100721. controllerMeshes?: boolean;
  100722. /**
  100723. * Creating a default HemiLight only on controllers. (default: true)
  100724. */
  100725. defaultLightingOnControllers?: boolean;
  100726. /**
  100727. * If you don't want to use the default VR button of the helper. (default: false)
  100728. */
  100729. useCustomVRButton?: boolean;
  100730. /**
  100731. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100732. */
  100733. customVRButton?: HTMLButtonElement;
  100734. /**
  100735. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100736. */
  100737. rayLength?: number;
  100738. /**
  100739. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100740. */
  100741. defaultHeight?: number;
  100742. /**
  100743. * If multiview should be used if availible (default: false)
  100744. */
  100745. useMultiview?: boolean;
  100746. }
  100747. /**
  100748. * This represents a WebVR camera.
  100749. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100750. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100751. */
  100752. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100753. private webVROptions;
  100754. /**
  100755. * @hidden
  100756. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100757. */
  100758. _vrDevice: any;
  100759. /**
  100760. * The rawPose of the vrDevice.
  100761. */
  100762. rawPose: Nullable<DevicePose>;
  100763. private _onVREnabled;
  100764. private _specsVersion;
  100765. private _attached;
  100766. private _frameData;
  100767. protected _descendants: Array<Node>;
  100768. private _deviceRoomPosition;
  100769. /** @hidden */
  100770. _deviceRoomRotationQuaternion: Quaternion;
  100771. private _standingMatrix;
  100772. /**
  100773. * Represents device position in babylon space.
  100774. */
  100775. devicePosition: Vector3;
  100776. /**
  100777. * Represents device rotation in babylon space.
  100778. */
  100779. deviceRotationQuaternion: Quaternion;
  100780. /**
  100781. * The scale of the device to be used when translating from device space to babylon space.
  100782. */
  100783. deviceScaleFactor: number;
  100784. private _deviceToWorld;
  100785. private _worldToDevice;
  100786. /**
  100787. * References to the webVR controllers for the vrDevice.
  100788. */
  100789. controllers: Array<WebVRController>;
  100790. /**
  100791. * Emits an event when a controller is attached.
  100792. */
  100793. onControllersAttachedObservable: Observable<WebVRController[]>;
  100794. /**
  100795. * Emits an event when a controller's mesh has been loaded;
  100796. */
  100797. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100798. /**
  100799. * Emits an event when the HMD's pose has been updated.
  100800. */
  100801. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100802. private _poseSet;
  100803. /**
  100804. * If the rig cameras be used as parent instead of this camera.
  100805. */
  100806. rigParenting: boolean;
  100807. private _lightOnControllers;
  100808. private _defaultHeight?;
  100809. /**
  100810. * Instantiates a WebVRFreeCamera.
  100811. * @param name The name of the WebVRFreeCamera
  100812. * @param position The starting anchor position for the camera
  100813. * @param scene The scene the camera belongs to
  100814. * @param webVROptions a set of customizable options for the webVRCamera
  100815. */
  100816. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100817. /**
  100818. * Gets the device distance from the ground in meters.
  100819. * @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.
  100820. */
  100821. deviceDistanceToRoomGround(): number;
  100822. /**
  100823. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100824. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100825. */
  100826. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100827. /**
  100828. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100829. * @returns A promise with a boolean set to if the standing matrix is supported.
  100830. */
  100831. useStandingMatrixAsync(): Promise<boolean>;
  100832. /**
  100833. * Disposes the camera
  100834. */
  100835. dispose(): void;
  100836. /**
  100837. * Gets a vrController by name.
  100838. * @param name The name of the controller to retreive
  100839. * @returns the controller matching the name specified or null if not found
  100840. */
  100841. getControllerByName(name: string): Nullable<WebVRController>;
  100842. private _leftController;
  100843. /**
  100844. * The controller corresponding to the users left hand.
  100845. */
  100846. get leftController(): Nullable<WebVRController>;
  100847. private _rightController;
  100848. /**
  100849. * The controller corresponding to the users right hand.
  100850. */
  100851. get rightController(): Nullable<WebVRController>;
  100852. /**
  100853. * Casts a ray forward from the vrCamera's gaze.
  100854. * @param length Length of the ray (default: 100)
  100855. * @returns the ray corresponding to the gaze
  100856. */
  100857. getForwardRay(length?: number): Ray;
  100858. /**
  100859. * @hidden
  100860. * Updates the camera based on device's frame data
  100861. */
  100862. _checkInputs(): void;
  100863. /**
  100864. * Updates the poseControlled values based on the input device pose.
  100865. * @param poseData Pose coming from the device
  100866. */
  100867. updateFromDevice(poseData: DevicePose): void;
  100868. private _htmlElementAttached;
  100869. private _detachIfAttached;
  100870. /**
  100871. * WebVR's attach control will start broadcasting frames to the device.
  100872. * Note that in certain browsers (chrome for example) this function must be called
  100873. * within a user-interaction callback. Example:
  100874. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100875. *
  100876. * @param element html element to attach the vrDevice to
  100877. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100878. */
  100879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100880. /**
  100881. * Detaches the camera from the html element and disables VR
  100882. *
  100883. * @param element html element to detach from
  100884. */
  100885. detachControl(element: HTMLElement): void;
  100886. /**
  100887. * @returns the name of this class
  100888. */
  100889. getClassName(): string;
  100890. /**
  100891. * Calls resetPose on the vrDisplay
  100892. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100893. */
  100894. resetToCurrentRotation(): void;
  100895. /**
  100896. * @hidden
  100897. * Updates the rig cameras (left and right eye)
  100898. */
  100899. _updateRigCameras(): void;
  100900. private _workingVector;
  100901. private _oneVector;
  100902. private _workingMatrix;
  100903. private updateCacheCalled;
  100904. private _correctPositionIfNotTrackPosition;
  100905. /**
  100906. * @hidden
  100907. * Updates the cached values of the camera
  100908. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100909. */
  100910. _updateCache(ignoreParentClass?: boolean): void;
  100911. /**
  100912. * @hidden
  100913. * Get current device position in babylon world
  100914. */
  100915. _computeDevicePosition(): void;
  100916. /**
  100917. * Updates the current device position and rotation in the babylon world
  100918. */
  100919. update(): void;
  100920. /**
  100921. * @hidden
  100922. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100923. * @returns an identity matrix
  100924. */
  100925. _getViewMatrix(): Matrix;
  100926. private _tmpMatrix;
  100927. /**
  100928. * This function is called by the two RIG cameras.
  100929. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100930. * @hidden
  100931. */
  100932. _getWebVRViewMatrix(): Matrix;
  100933. /** @hidden */
  100934. _getWebVRProjectionMatrix(): Matrix;
  100935. private _onGamepadConnectedObserver;
  100936. private _onGamepadDisconnectedObserver;
  100937. private _updateCacheWhenTrackingDisabledObserver;
  100938. /**
  100939. * Initializes the controllers and their meshes
  100940. */
  100941. initControllers(): void;
  100942. }
  100943. }
  100944. declare module BABYLON {
  100945. /**
  100946. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100947. *
  100948. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100949. *
  100950. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100951. */
  100952. export class MaterialHelper {
  100953. /**
  100954. * Bind the current view position to an effect.
  100955. * @param effect The effect to be bound
  100956. * @param scene The scene the eyes position is used from
  100957. * @param variableName name of the shader variable that will hold the eye position
  100958. */
  100959. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100960. /**
  100961. * Helps preparing the defines values about the UVs in used in the effect.
  100962. * UVs are shared as much as we can accross channels in the shaders.
  100963. * @param texture The texture we are preparing the UVs for
  100964. * @param defines The defines to update
  100965. * @param key The channel key "diffuse", "specular"... used in the shader
  100966. */
  100967. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100968. /**
  100969. * Binds a texture matrix value to its corrsponding uniform
  100970. * @param texture The texture to bind the matrix for
  100971. * @param uniformBuffer The uniform buffer receivin the data
  100972. * @param key The channel key "diffuse", "specular"... used in the shader
  100973. */
  100974. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100975. /**
  100976. * Gets the current status of the fog (should it be enabled?)
  100977. * @param mesh defines the mesh to evaluate for fog support
  100978. * @param scene defines the hosting scene
  100979. * @returns true if fog must be enabled
  100980. */
  100981. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100982. /**
  100983. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100984. * @param mesh defines the current mesh
  100985. * @param scene defines the current scene
  100986. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100987. * @param pointsCloud defines if point cloud rendering has to be turned on
  100988. * @param fogEnabled defines if fog has to be turned on
  100989. * @param alphaTest defines if alpha testing has to be turned on
  100990. * @param defines defines the current list of defines
  100991. */
  100992. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100993. /**
  100994. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100995. * @param scene defines the current scene
  100996. * @param engine defines the current engine
  100997. * @param defines specifies the list of active defines
  100998. * @param useInstances defines if instances have to be turned on
  100999. * @param useClipPlane defines if clip plane have to be turned on
  101000. * @param useInstances defines if instances have to be turned on
  101001. * @param useThinInstances defines if thin instances have to be turned on
  101002. */
  101003. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101004. /**
  101005. * Prepares the defines for bones
  101006. * @param mesh The mesh containing the geometry data we will draw
  101007. * @param defines The defines to update
  101008. */
  101009. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101010. /**
  101011. * Prepares the defines for morph targets
  101012. * @param mesh The mesh containing the geometry data we will draw
  101013. * @param defines The defines to update
  101014. */
  101015. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101016. /**
  101017. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101018. * @param mesh The mesh containing the geometry data we will draw
  101019. * @param defines The defines to update
  101020. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101021. * @param useBones Precise whether bones should be used or not (override mesh info)
  101022. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101023. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101024. * @returns false if defines are considered not dirty and have not been checked
  101025. */
  101026. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101027. /**
  101028. * Prepares the defines related to multiview
  101029. * @param scene The scene we are intending to draw
  101030. * @param defines The defines to update
  101031. */
  101032. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101033. /**
  101034. * Prepares the defines related to the prepass
  101035. * @param scene The scene we are intending to draw
  101036. * @param defines The defines to update
  101037. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101038. */
  101039. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101040. /**
  101041. * Prepares the defines related to the light information passed in parameter
  101042. * @param scene The scene we are intending to draw
  101043. * @param mesh The mesh the effect is compiling for
  101044. * @param light The light the effect is compiling for
  101045. * @param lightIndex The index of the light
  101046. * @param defines The defines to update
  101047. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101048. * @param state Defines the current state regarding what is needed (normals, etc...)
  101049. */
  101050. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101051. needNormals: boolean;
  101052. needRebuild: boolean;
  101053. shadowEnabled: boolean;
  101054. specularEnabled: boolean;
  101055. lightmapMode: boolean;
  101056. }): void;
  101057. /**
  101058. * Prepares the defines related to the light information passed in parameter
  101059. * @param scene The scene we are intending to draw
  101060. * @param mesh The mesh the effect is compiling for
  101061. * @param defines The defines to update
  101062. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101063. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101064. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101065. * @returns true if normals will be required for the rest of the effect
  101066. */
  101067. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101068. /**
  101069. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101070. * @param lightIndex defines the light index
  101071. * @param uniformsList The uniform list
  101072. * @param samplersList The sampler list
  101073. * @param projectedLightTexture defines if projected texture must be used
  101074. * @param uniformBuffersList defines an optional list of uniform buffers
  101075. */
  101076. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101077. /**
  101078. * Prepares the uniforms and samplers list to be used in the effect
  101079. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101080. * @param samplersList The sampler list
  101081. * @param defines The defines helping in the list generation
  101082. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101083. */
  101084. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101085. /**
  101086. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101087. * @param defines The defines to update while falling back
  101088. * @param fallbacks The authorized effect fallbacks
  101089. * @param maxSimultaneousLights The maximum number of lights allowed
  101090. * @param rank the current rank of the Effect
  101091. * @returns The newly affected rank
  101092. */
  101093. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101094. private static _TmpMorphInfluencers;
  101095. /**
  101096. * Prepares the list of attributes required for morph targets according to the effect defines.
  101097. * @param attribs The current list of supported attribs
  101098. * @param mesh The mesh to prepare the morph targets attributes for
  101099. * @param influencers The number of influencers
  101100. */
  101101. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101102. /**
  101103. * Prepares the list of attributes required for morph targets according to the effect defines.
  101104. * @param attribs The current list of supported attribs
  101105. * @param mesh The mesh to prepare the morph targets attributes for
  101106. * @param defines The current Defines of the effect
  101107. */
  101108. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101109. /**
  101110. * Prepares the list of attributes required for bones according to the effect defines.
  101111. * @param attribs The current list of supported attribs
  101112. * @param mesh The mesh to prepare the bones attributes for
  101113. * @param defines The current Defines of the effect
  101114. * @param fallbacks The current efffect fallback strategy
  101115. */
  101116. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101117. /**
  101118. * Check and prepare the list of attributes required for instances according to the effect defines.
  101119. * @param attribs The current list of supported attribs
  101120. * @param defines The current MaterialDefines of the effect
  101121. */
  101122. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101123. /**
  101124. * Add the list of attributes required for instances to the attribs array.
  101125. * @param attribs The current list of supported attribs
  101126. */
  101127. static PushAttributesForInstances(attribs: string[]): void;
  101128. /**
  101129. * Binds the light information to the effect.
  101130. * @param light The light containing the generator
  101131. * @param effect The effect we are binding the data to
  101132. * @param lightIndex The light index in the effect used to render
  101133. */
  101134. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101135. /**
  101136. * Binds the lights information from the scene to the effect for the given mesh.
  101137. * @param light Light to bind
  101138. * @param lightIndex Light index
  101139. * @param scene The scene where the light belongs to
  101140. * @param effect The effect we are binding the data to
  101141. * @param useSpecular Defines if specular is supported
  101142. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101143. */
  101144. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101145. /**
  101146. * Binds the lights information from the scene to the effect for the given mesh.
  101147. * @param scene The scene the lights belongs to
  101148. * @param mesh The mesh we are binding the information to render
  101149. * @param effect The effect we are binding the data to
  101150. * @param defines The generated defines for the effect
  101151. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101152. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101153. */
  101154. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101155. private static _tempFogColor;
  101156. /**
  101157. * Binds the fog information from the scene to the effect for the given mesh.
  101158. * @param scene The scene the lights belongs to
  101159. * @param mesh The mesh we are binding the information to render
  101160. * @param effect The effect we are binding the data to
  101161. * @param linearSpace Defines if the fog effect is applied in linear space
  101162. */
  101163. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101164. /**
  101165. * Binds the bones information from the mesh to the effect.
  101166. * @param mesh The mesh we are binding the information to render
  101167. * @param effect The effect we are binding the data to
  101168. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101169. */
  101170. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101171. private static _CopyBonesTransformationMatrices;
  101172. /**
  101173. * Binds the morph targets information from the mesh to the effect.
  101174. * @param abstractMesh The mesh we are binding the information to render
  101175. * @param effect The effect we are binding the data to
  101176. */
  101177. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101178. /**
  101179. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101180. * @param defines The generated defines used in the effect
  101181. * @param effect The effect we are binding the data to
  101182. * @param scene The scene we are willing to render with logarithmic scale for
  101183. */
  101184. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101185. /**
  101186. * Binds the clip plane information from the scene to the effect.
  101187. * @param scene The scene the clip plane information are extracted from
  101188. * @param effect The effect we are binding the data to
  101189. */
  101190. static BindClipPlane(effect: Effect, scene: Scene): void;
  101191. }
  101192. }
  101193. declare module BABYLON {
  101194. /**
  101195. * Block used to expose an input value
  101196. */
  101197. export class InputBlock extends NodeMaterialBlock {
  101198. private _mode;
  101199. private _associatedVariableName;
  101200. private _storedValue;
  101201. private _valueCallback;
  101202. private _type;
  101203. private _animationType;
  101204. /** Gets or set a value used to limit the range of float values */
  101205. min: number;
  101206. /** Gets or set a value used to limit the range of float values */
  101207. max: number;
  101208. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101209. isBoolean: boolean;
  101210. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101211. matrixMode: number;
  101212. /** @hidden */
  101213. _systemValue: Nullable<NodeMaterialSystemValues>;
  101214. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101215. isConstant: boolean;
  101216. /** Gets or sets the group to use to display this block in the Inspector */
  101217. groupInInspector: string;
  101218. /** Gets an observable raised when the value is changed */
  101219. onValueChangedObservable: Observable<InputBlock>;
  101220. /**
  101221. * Gets or sets the connection point type (default is float)
  101222. */
  101223. get type(): NodeMaterialBlockConnectionPointTypes;
  101224. /**
  101225. * Creates a new InputBlock
  101226. * @param name defines the block name
  101227. * @param target defines the target of that block (Vertex by default)
  101228. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101229. */
  101230. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101231. /**
  101232. * Validates if a name is a reserve word.
  101233. * @param newName the new name to be given to the node.
  101234. * @returns false if the name is a reserve word, else true.
  101235. */
  101236. validateBlockName(newName: string): boolean;
  101237. /**
  101238. * Gets the output component
  101239. */
  101240. get output(): NodeMaterialConnectionPoint;
  101241. /**
  101242. * Set the source of this connection point to a vertex attribute
  101243. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101244. * @returns the current connection point
  101245. */
  101246. setAsAttribute(attributeName?: string): InputBlock;
  101247. /**
  101248. * Set the source of this connection point to a system value
  101249. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101250. * @returns the current connection point
  101251. */
  101252. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101253. /**
  101254. * Gets or sets the value of that point.
  101255. * Please note that this value will be ignored if valueCallback is defined
  101256. */
  101257. get value(): any;
  101258. set value(value: any);
  101259. /**
  101260. * Gets or sets a callback used to get the value of that point.
  101261. * Please note that setting this value will force the connection point to ignore the value property
  101262. */
  101263. get valueCallback(): () => any;
  101264. set valueCallback(value: () => any);
  101265. /**
  101266. * Gets or sets the associated variable name in the shader
  101267. */
  101268. get associatedVariableName(): string;
  101269. set associatedVariableName(value: string);
  101270. /** Gets or sets the type of animation applied to the input */
  101271. get animationType(): AnimatedInputBlockTypes;
  101272. set animationType(value: AnimatedInputBlockTypes);
  101273. /**
  101274. * Gets a boolean indicating that this connection point not defined yet
  101275. */
  101276. get isUndefined(): boolean;
  101277. /**
  101278. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101279. * In this case the connection point name must be the name of the uniform to use.
  101280. * Can only be set on inputs
  101281. */
  101282. get isUniform(): boolean;
  101283. set isUniform(value: boolean);
  101284. /**
  101285. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101286. * In this case the connection point name must be the name of the attribute to use
  101287. * Can only be set on inputs
  101288. */
  101289. get isAttribute(): boolean;
  101290. set isAttribute(value: boolean);
  101291. /**
  101292. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101293. * Can only be set on exit points
  101294. */
  101295. get isVarying(): boolean;
  101296. set isVarying(value: boolean);
  101297. /**
  101298. * Gets a boolean indicating that the current connection point is a system value
  101299. */
  101300. get isSystemValue(): boolean;
  101301. /**
  101302. * Gets or sets the current well known value or null if not defined as a system value
  101303. */
  101304. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101305. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101306. /**
  101307. * Gets the current class name
  101308. * @returns the class name
  101309. */
  101310. getClassName(): string;
  101311. /**
  101312. * Animate the input if animationType !== None
  101313. * @param scene defines the rendering scene
  101314. */
  101315. animate(scene: Scene): void;
  101316. private _emitDefine;
  101317. initialize(state: NodeMaterialBuildState): void;
  101318. /**
  101319. * Set the input block to its default value (based on its type)
  101320. */
  101321. setDefaultValue(): void;
  101322. private _emitConstant;
  101323. /** @hidden */
  101324. get _noContextSwitch(): boolean;
  101325. private _emit;
  101326. /** @hidden */
  101327. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101328. /** @hidden */
  101329. _transmit(effect: Effect, scene: Scene): void;
  101330. protected _buildBlock(state: NodeMaterialBuildState): void;
  101331. protected _dumpPropertiesCode(): string;
  101332. dispose(): void;
  101333. serialize(): any;
  101334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101335. }
  101336. }
  101337. declare module BABYLON {
  101338. /**
  101339. * Enum used to define the compatibility state between two connection points
  101340. */
  101341. export enum NodeMaterialConnectionPointCompatibilityStates {
  101342. /** Points are compatibles */
  101343. Compatible = 0,
  101344. /** Points are incompatible because of their types */
  101345. TypeIncompatible = 1,
  101346. /** Points are incompatible because of their targets (vertex vs fragment) */
  101347. TargetIncompatible = 2
  101348. }
  101349. /**
  101350. * Defines the direction of a connection point
  101351. */
  101352. export enum NodeMaterialConnectionPointDirection {
  101353. /** Input */
  101354. Input = 0,
  101355. /** Output */
  101356. Output = 1
  101357. }
  101358. /**
  101359. * Defines a connection point for a block
  101360. */
  101361. export class NodeMaterialConnectionPoint {
  101362. /** @hidden */
  101363. _ownerBlock: NodeMaterialBlock;
  101364. /** @hidden */
  101365. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101366. private _endpoints;
  101367. private _associatedVariableName;
  101368. private _direction;
  101369. /** @hidden */
  101370. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101371. /** @hidden */
  101372. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101373. private _type;
  101374. /** @hidden */
  101375. _enforceAssociatedVariableName: boolean;
  101376. /** Gets the direction of the point */
  101377. get direction(): NodeMaterialConnectionPointDirection;
  101378. /** Indicates that this connection point needs dual validation before being connected to another point */
  101379. needDualDirectionValidation: boolean;
  101380. /**
  101381. * Gets or sets the additional types supported by this connection point
  101382. */
  101383. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101384. /**
  101385. * Gets or sets the additional types excluded by this connection point
  101386. */
  101387. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101388. /**
  101389. * Observable triggered when this point is connected
  101390. */
  101391. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101392. /**
  101393. * Gets or sets the associated variable name in the shader
  101394. */
  101395. get associatedVariableName(): string;
  101396. set associatedVariableName(value: string);
  101397. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101398. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101399. /**
  101400. * Gets or sets the connection point type (default is float)
  101401. */
  101402. get type(): NodeMaterialBlockConnectionPointTypes;
  101403. set type(value: NodeMaterialBlockConnectionPointTypes);
  101404. /**
  101405. * Gets or sets the connection point name
  101406. */
  101407. name: string;
  101408. /**
  101409. * Gets or sets the connection point name
  101410. */
  101411. displayName: string;
  101412. /**
  101413. * Gets or sets a boolean indicating that this connection point can be omitted
  101414. */
  101415. isOptional: boolean;
  101416. /**
  101417. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101418. */
  101419. isExposedOnFrame: boolean;
  101420. /**
  101421. * Gets or sets number indicating the position that the port is exposed to on a frame
  101422. */
  101423. exposedPortPosition: number;
  101424. /**
  101425. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101426. */
  101427. define: string;
  101428. /** @hidden */
  101429. _prioritizeVertex: boolean;
  101430. private _target;
  101431. /** Gets or sets the target of that connection point */
  101432. get target(): NodeMaterialBlockTargets;
  101433. set target(value: NodeMaterialBlockTargets);
  101434. /**
  101435. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101436. */
  101437. get isConnected(): boolean;
  101438. /**
  101439. * Gets a boolean indicating that the current point is connected to an input block
  101440. */
  101441. get isConnectedToInputBlock(): boolean;
  101442. /**
  101443. * Gets a the connected input block (if any)
  101444. */
  101445. get connectInputBlock(): Nullable<InputBlock>;
  101446. /** Get the other side of the connection (if any) */
  101447. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101448. /** Get the block that owns this connection point */
  101449. get ownerBlock(): NodeMaterialBlock;
  101450. /** Get the block connected on the other side of this connection (if any) */
  101451. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101452. /** Get the block connected on the endpoints of this connection (if any) */
  101453. get connectedBlocks(): Array<NodeMaterialBlock>;
  101454. /** Gets the list of connected endpoints */
  101455. get endpoints(): NodeMaterialConnectionPoint[];
  101456. /** Gets a boolean indicating if that output point is connected to at least one input */
  101457. get hasEndpoints(): boolean;
  101458. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101459. get isConnectedInVertexShader(): boolean;
  101460. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101461. get isConnectedInFragmentShader(): boolean;
  101462. /**
  101463. * Creates a block suitable to be used as an input for this input point.
  101464. * If null is returned, a block based on the point type will be created.
  101465. * @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
  101466. */
  101467. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101468. /**
  101469. * Creates a new connection point
  101470. * @param name defines the connection point name
  101471. * @param ownerBlock defines the block hosting this connection point
  101472. * @param direction defines the direction of the connection point
  101473. */
  101474. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101475. /**
  101476. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101477. * @returns the class name
  101478. */
  101479. getClassName(): string;
  101480. /**
  101481. * Gets a boolean indicating if the current point can be connected to another point
  101482. * @param connectionPoint defines the other connection point
  101483. * @returns a boolean
  101484. */
  101485. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101486. /**
  101487. * Gets a number indicating if the current point can be connected to another point
  101488. * @param connectionPoint defines the other connection point
  101489. * @returns a number defining the compatibility state
  101490. */
  101491. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101492. /**
  101493. * Connect this point to another connection point
  101494. * @param connectionPoint defines the other connection point
  101495. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101496. * @returns the current connection point
  101497. */
  101498. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101499. /**
  101500. * Disconnect this point from one of his endpoint
  101501. * @param endpoint defines the other connection point
  101502. * @returns the current connection point
  101503. */
  101504. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101505. /**
  101506. * Serializes this point in a JSON representation
  101507. * @param isInput defines if the connection point is an input (default is true)
  101508. * @returns the serialized point object
  101509. */
  101510. serialize(isInput?: boolean): any;
  101511. /**
  101512. * Release resources
  101513. */
  101514. dispose(): void;
  101515. }
  101516. }
  101517. declare module BABYLON {
  101518. /**
  101519. * Enum used to define the material modes
  101520. */
  101521. export enum NodeMaterialModes {
  101522. /** Regular material */
  101523. Material = 0,
  101524. /** For post process */
  101525. PostProcess = 1,
  101526. /** For particle system */
  101527. Particle = 2,
  101528. /** For procedural texture */
  101529. ProceduralTexture = 3
  101530. }
  101531. }
  101532. declare module BABYLON {
  101533. /**
  101534. * Block used to read a texture from a sampler
  101535. */
  101536. export class TextureBlock extends NodeMaterialBlock {
  101537. private _defineName;
  101538. private _linearDefineName;
  101539. private _gammaDefineName;
  101540. private _tempTextureRead;
  101541. private _samplerName;
  101542. private _transformedUVName;
  101543. private _textureTransformName;
  101544. private _textureInfoName;
  101545. private _mainUVName;
  101546. private _mainUVDefineName;
  101547. private _fragmentOnly;
  101548. /**
  101549. * Gets or sets the texture associated with the node
  101550. */
  101551. texture: Nullable<Texture>;
  101552. /**
  101553. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101554. */
  101555. convertToGammaSpace: boolean;
  101556. /**
  101557. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101558. */
  101559. convertToLinearSpace: boolean;
  101560. /**
  101561. * Create a new TextureBlock
  101562. * @param name defines the block name
  101563. */
  101564. constructor(name: string, fragmentOnly?: boolean);
  101565. /**
  101566. * Gets the current class name
  101567. * @returns the class name
  101568. */
  101569. getClassName(): string;
  101570. /**
  101571. * Gets the uv input component
  101572. */
  101573. get uv(): NodeMaterialConnectionPoint;
  101574. /**
  101575. * Gets the rgba output component
  101576. */
  101577. get rgba(): NodeMaterialConnectionPoint;
  101578. /**
  101579. * Gets the rgb output component
  101580. */
  101581. get rgb(): NodeMaterialConnectionPoint;
  101582. /**
  101583. * Gets the r output component
  101584. */
  101585. get r(): NodeMaterialConnectionPoint;
  101586. /**
  101587. * Gets the g output component
  101588. */
  101589. get g(): NodeMaterialConnectionPoint;
  101590. /**
  101591. * Gets the b output component
  101592. */
  101593. get b(): NodeMaterialConnectionPoint;
  101594. /**
  101595. * Gets the a output component
  101596. */
  101597. get a(): NodeMaterialConnectionPoint;
  101598. get target(): NodeMaterialBlockTargets;
  101599. autoConfigure(material: NodeMaterial): void;
  101600. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101602. isReady(): boolean;
  101603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101604. private get _isMixed();
  101605. private _injectVertexCode;
  101606. private _writeTextureRead;
  101607. private _writeOutput;
  101608. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101609. protected _dumpPropertiesCode(): string;
  101610. serialize(): any;
  101611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101612. }
  101613. }
  101614. declare module BABYLON {
  101615. /** @hidden */
  101616. export var reflectionFunction: {
  101617. name: string;
  101618. shader: string;
  101619. };
  101620. }
  101621. declare module BABYLON {
  101622. /**
  101623. * Base block used to read a reflection texture from a sampler
  101624. */
  101625. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101626. /** @hidden */
  101627. _define3DName: string;
  101628. /** @hidden */
  101629. _defineCubicName: string;
  101630. /** @hidden */
  101631. _defineExplicitName: string;
  101632. /** @hidden */
  101633. _defineProjectionName: string;
  101634. /** @hidden */
  101635. _defineLocalCubicName: string;
  101636. /** @hidden */
  101637. _defineSphericalName: string;
  101638. /** @hidden */
  101639. _definePlanarName: string;
  101640. /** @hidden */
  101641. _defineEquirectangularName: string;
  101642. /** @hidden */
  101643. _defineMirroredEquirectangularFixedName: string;
  101644. /** @hidden */
  101645. _defineEquirectangularFixedName: string;
  101646. /** @hidden */
  101647. _defineSkyboxName: string;
  101648. /** @hidden */
  101649. _defineOppositeZ: string;
  101650. /** @hidden */
  101651. _cubeSamplerName: string;
  101652. /** @hidden */
  101653. _2DSamplerName: string;
  101654. protected _positionUVWName: string;
  101655. protected _directionWName: string;
  101656. protected _reflectionVectorName: string;
  101657. /** @hidden */
  101658. _reflectionCoordsName: string;
  101659. /** @hidden */
  101660. _reflectionMatrixName: string;
  101661. protected _reflectionColorName: string;
  101662. /**
  101663. * Gets or sets the texture associated with the node
  101664. */
  101665. texture: Nullable<BaseTexture>;
  101666. /**
  101667. * Create a new ReflectionTextureBaseBlock
  101668. * @param name defines the block name
  101669. */
  101670. constructor(name: string);
  101671. /**
  101672. * Gets the current class name
  101673. * @returns the class name
  101674. */
  101675. getClassName(): string;
  101676. /**
  101677. * Gets the world position input component
  101678. */
  101679. abstract get position(): NodeMaterialConnectionPoint;
  101680. /**
  101681. * Gets the world position input component
  101682. */
  101683. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101684. /**
  101685. * Gets the world normal input component
  101686. */
  101687. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101688. /**
  101689. * Gets the world input component
  101690. */
  101691. abstract get world(): NodeMaterialConnectionPoint;
  101692. /**
  101693. * Gets the camera (or eye) position component
  101694. */
  101695. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101696. /**
  101697. * Gets the view input component
  101698. */
  101699. abstract get view(): NodeMaterialConnectionPoint;
  101700. protected _getTexture(): Nullable<BaseTexture>;
  101701. autoConfigure(material: NodeMaterial): void;
  101702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101703. isReady(): boolean;
  101704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101705. /**
  101706. * Gets the code to inject in the vertex shader
  101707. * @param state current state of the node material building
  101708. * @returns the shader code
  101709. */
  101710. handleVertexSide(state: NodeMaterialBuildState): string;
  101711. /**
  101712. * Handles the inits for the fragment code path
  101713. * @param state node material build state
  101714. */
  101715. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101716. /**
  101717. * Generates the reflection coords code for the fragment code path
  101718. * @param worldNormalVarName name of the world normal variable
  101719. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101720. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101721. * @returns the shader code
  101722. */
  101723. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101724. /**
  101725. * Generates the reflection color code for the fragment code path
  101726. * @param lodVarName name of the lod variable
  101727. * @param swizzleLookupTexture swizzle to use for the final color variable
  101728. * @returns the shader code
  101729. */
  101730. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101731. /**
  101732. * Generates the code corresponding to the connected output points
  101733. * @param state node material build state
  101734. * @param varName name of the variable to output
  101735. * @returns the shader code
  101736. */
  101737. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101738. protected _buildBlock(state: NodeMaterialBuildState): this;
  101739. protected _dumpPropertiesCode(): string;
  101740. serialize(): any;
  101741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101742. }
  101743. }
  101744. declare module BABYLON {
  101745. /**
  101746. * Defines a connection point to be used for points with a custom object type
  101747. */
  101748. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101749. private _blockType;
  101750. private _blockName;
  101751. private _nameForCheking?;
  101752. /**
  101753. * Creates a new connection point
  101754. * @param name defines the connection point name
  101755. * @param ownerBlock defines the block hosting this connection point
  101756. * @param direction defines the direction of the connection point
  101757. */
  101758. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101759. /**
  101760. * Gets a number indicating if the current point can be connected to another point
  101761. * @param connectionPoint defines the other connection point
  101762. * @returns a number defining the compatibility state
  101763. */
  101764. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101765. /**
  101766. * Creates a block suitable to be used as an input for this input point.
  101767. * If null is returned, a block based on the point type will be created.
  101768. * @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
  101769. */
  101770. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101771. }
  101772. }
  101773. declare module BABYLON {
  101774. /**
  101775. * Enum defining the type of properties that can be edited in the property pages in the NME
  101776. */
  101777. export enum PropertyTypeForEdition {
  101778. /** property is a boolean */
  101779. Boolean = 0,
  101780. /** property is a float */
  101781. Float = 1,
  101782. /** property is a Vector2 */
  101783. Vector2 = 2,
  101784. /** property is a list of values */
  101785. List = 3
  101786. }
  101787. /**
  101788. * Interface that defines an option in a variable of type list
  101789. */
  101790. export interface IEditablePropertyListOption {
  101791. /** label of the option */
  101792. "label": string;
  101793. /** value of the option */
  101794. "value": number;
  101795. }
  101796. /**
  101797. * Interface that defines the options available for an editable property
  101798. */
  101799. export interface IEditablePropertyOption {
  101800. /** min value */
  101801. "min"?: number;
  101802. /** max value */
  101803. "max"?: number;
  101804. /** notifiers: indicates which actions to take when the property is changed */
  101805. "notifiers"?: {
  101806. /** the material should be rebuilt */
  101807. "rebuild"?: boolean;
  101808. /** the preview should be updated */
  101809. "update"?: boolean;
  101810. };
  101811. /** list of the options for a variable of type list */
  101812. "options"?: IEditablePropertyListOption[];
  101813. }
  101814. /**
  101815. * Interface that describes an editable property
  101816. */
  101817. export interface IPropertyDescriptionForEdition {
  101818. /** name of the property */
  101819. "propertyName": string;
  101820. /** display name of the property */
  101821. "displayName": string;
  101822. /** type of the property */
  101823. "type": PropertyTypeForEdition;
  101824. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101825. "groupName": string;
  101826. /** options for the property */
  101827. "options": IEditablePropertyOption;
  101828. }
  101829. /**
  101830. * Decorator that flags a property in a node material block as being editable
  101831. */
  101832. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101833. }
  101834. declare module BABYLON {
  101835. /**
  101836. * Block used to implement the refraction part of the sub surface module of the PBR material
  101837. */
  101838. export class RefractionBlock extends NodeMaterialBlock {
  101839. /** @hidden */
  101840. _define3DName: string;
  101841. /** @hidden */
  101842. _refractionMatrixName: string;
  101843. /** @hidden */
  101844. _defineLODRefractionAlpha: string;
  101845. /** @hidden */
  101846. _defineLinearSpecularRefraction: string;
  101847. /** @hidden */
  101848. _defineOppositeZ: string;
  101849. /** @hidden */
  101850. _cubeSamplerName: string;
  101851. /** @hidden */
  101852. _2DSamplerName: string;
  101853. /** @hidden */
  101854. _vRefractionMicrosurfaceInfosName: string;
  101855. /** @hidden */
  101856. _vRefractionInfosName: string;
  101857. private _scene;
  101858. /**
  101859. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101860. * Materials half opaque for instance using refraction could benefit from this control.
  101861. */
  101862. linkRefractionWithTransparency: boolean;
  101863. /**
  101864. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101865. */
  101866. invertRefractionY: boolean;
  101867. /**
  101868. * Gets or sets the texture associated with the node
  101869. */
  101870. texture: Nullable<BaseTexture>;
  101871. /**
  101872. * Create a new RefractionBlock
  101873. * @param name defines the block name
  101874. */
  101875. constructor(name: string);
  101876. /**
  101877. * Gets the current class name
  101878. * @returns the class name
  101879. */
  101880. getClassName(): string;
  101881. /**
  101882. * Gets the intensity input component
  101883. */
  101884. get intensity(): NodeMaterialConnectionPoint;
  101885. /**
  101886. * Gets the index of refraction input component
  101887. */
  101888. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101889. /**
  101890. * Gets the tint at distance input component
  101891. */
  101892. get tintAtDistance(): NodeMaterialConnectionPoint;
  101893. /**
  101894. * Gets the view input component
  101895. */
  101896. get view(): NodeMaterialConnectionPoint;
  101897. /**
  101898. * Gets the refraction object output component
  101899. */
  101900. get refraction(): NodeMaterialConnectionPoint;
  101901. /**
  101902. * Returns true if the block has a texture
  101903. */
  101904. get hasTexture(): boolean;
  101905. protected _getTexture(): Nullable<BaseTexture>;
  101906. autoConfigure(material: NodeMaterial): void;
  101907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101908. isReady(): boolean;
  101909. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101910. /**
  101911. * Gets the main code of the block (fragment side)
  101912. * @param state current state of the node material building
  101913. * @returns the shader code
  101914. */
  101915. getCode(state: NodeMaterialBuildState): string;
  101916. protected _buildBlock(state: NodeMaterialBuildState): this;
  101917. protected _dumpPropertiesCode(): string;
  101918. serialize(): any;
  101919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101920. }
  101921. }
  101922. declare module BABYLON {
  101923. /**
  101924. * Base block used as input for post process
  101925. */
  101926. export class CurrentScreenBlock extends NodeMaterialBlock {
  101927. private _samplerName;
  101928. private _linearDefineName;
  101929. private _gammaDefineName;
  101930. private _mainUVName;
  101931. private _tempTextureRead;
  101932. /**
  101933. * Gets or sets the texture associated with the node
  101934. */
  101935. texture: Nullable<BaseTexture>;
  101936. /**
  101937. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101938. */
  101939. convertToGammaSpace: boolean;
  101940. /**
  101941. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101942. */
  101943. convertToLinearSpace: boolean;
  101944. /**
  101945. * Create a new CurrentScreenBlock
  101946. * @param name defines the block name
  101947. */
  101948. constructor(name: string);
  101949. /**
  101950. * Gets the current class name
  101951. * @returns the class name
  101952. */
  101953. getClassName(): string;
  101954. /**
  101955. * Gets the uv input component
  101956. */
  101957. get uv(): NodeMaterialConnectionPoint;
  101958. /**
  101959. * Gets the rgba output component
  101960. */
  101961. get rgba(): NodeMaterialConnectionPoint;
  101962. /**
  101963. * Gets the rgb output component
  101964. */
  101965. get rgb(): NodeMaterialConnectionPoint;
  101966. /**
  101967. * Gets the r output component
  101968. */
  101969. get r(): NodeMaterialConnectionPoint;
  101970. /**
  101971. * Gets the g output component
  101972. */
  101973. get g(): NodeMaterialConnectionPoint;
  101974. /**
  101975. * Gets the b output component
  101976. */
  101977. get b(): NodeMaterialConnectionPoint;
  101978. /**
  101979. * Gets the a output component
  101980. */
  101981. get a(): NodeMaterialConnectionPoint;
  101982. /**
  101983. * Initialize the block and prepare the context for build
  101984. * @param state defines the state that will be used for the build
  101985. */
  101986. initialize(state: NodeMaterialBuildState): void;
  101987. get target(): NodeMaterialBlockTargets;
  101988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101989. isReady(): boolean;
  101990. private _injectVertexCode;
  101991. private _writeTextureRead;
  101992. private _writeOutput;
  101993. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101994. serialize(): any;
  101995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101996. }
  101997. }
  101998. declare module BABYLON {
  101999. /**
  102000. * Base block used for the particle texture
  102001. */
  102002. export class ParticleTextureBlock extends NodeMaterialBlock {
  102003. private _samplerName;
  102004. private _linearDefineName;
  102005. private _gammaDefineName;
  102006. private _tempTextureRead;
  102007. /**
  102008. * Gets or sets the texture associated with the node
  102009. */
  102010. texture: Nullable<BaseTexture>;
  102011. /**
  102012. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102013. */
  102014. convertToGammaSpace: boolean;
  102015. /**
  102016. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102017. */
  102018. convertToLinearSpace: boolean;
  102019. /**
  102020. * Create a new ParticleTextureBlock
  102021. * @param name defines the block name
  102022. */
  102023. constructor(name: string);
  102024. /**
  102025. * Gets the current class name
  102026. * @returns the class name
  102027. */
  102028. getClassName(): string;
  102029. /**
  102030. * Gets the uv input component
  102031. */
  102032. get uv(): NodeMaterialConnectionPoint;
  102033. /**
  102034. * Gets the rgba output component
  102035. */
  102036. get rgba(): NodeMaterialConnectionPoint;
  102037. /**
  102038. * Gets the rgb output component
  102039. */
  102040. get rgb(): NodeMaterialConnectionPoint;
  102041. /**
  102042. * Gets the r output component
  102043. */
  102044. get r(): NodeMaterialConnectionPoint;
  102045. /**
  102046. * Gets the g output component
  102047. */
  102048. get g(): NodeMaterialConnectionPoint;
  102049. /**
  102050. * Gets the b output component
  102051. */
  102052. get b(): NodeMaterialConnectionPoint;
  102053. /**
  102054. * Gets the a output component
  102055. */
  102056. get a(): NodeMaterialConnectionPoint;
  102057. /**
  102058. * Initialize the block and prepare the context for build
  102059. * @param state defines the state that will be used for the build
  102060. */
  102061. initialize(state: NodeMaterialBuildState): void;
  102062. autoConfigure(material: NodeMaterial): void;
  102063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102064. isReady(): boolean;
  102065. private _writeOutput;
  102066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102067. serialize(): any;
  102068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102069. }
  102070. }
  102071. declare module BABYLON {
  102072. /**
  102073. * Class used to store shared data between 2 NodeMaterialBuildState
  102074. */
  102075. export class NodeMaterialBuildStateSharedData {
  102076. /**
  102077. * Gets the list of emitted varyings
  102078. */
  102079. temps: string[];
  102080. /**
  102081. * Gets the list of emitted varyings
  102082. */
  102083. varyings: string[];
  102084. /**
  102085. * Gets the varying declaration string
  102086. */
  102087. varyingDeclaration: string;
  102088. /**
  102089. * Input blocks
  102090. */
  102091. inputBlocks: InputBlock[];
  102092. /**
  102093. * Input blocks
  102094. */
  102095. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102096. /**
  102097. * Bindable blocks (Blocks that need to set data to the effect)
  102098. */
  102099. bindableBlocks: NodeMaterialBlock[];
  102100. /**
  102101. * List of blocks that can provide a compilation fallback
  102102. */
  102103. blocksWithFallbacks: NodeMaterialBlock[];
  102104. /**
  102105. * List of blocks that can provide a define update
  102106. */
  102107. blocksWithDefines: NodeMaterialBlock[];
  102108. /**
  102109. * List of blocks that can provide a repeatable content
  102110. */
  102111. repeatableContentBlocks: NodeMaterialBlock[];
  102112. /**
  102113. * List of blocks that can provide a dynamic list of uniforms
  102114. */
  102115. dynamicUniformBlocks: NodeMaterialBlock[];
  102116. /**
  102117. * List of blocks that can block the isReady function for the material
  102118. */
  102119. blockingBlocks: NodeMaterialBlock[];
  102120. /**
  102121. * Gets the list of animated inputs
  102122. */
  102123. animatedInputs: InputBlock[];
  102124. /**
  102125. * Build Id used to avoid multiple recompilations
  102126. */
  102127. buildId: number;
  102128. /** List of emitted variables */
  102129. variableNames: {
  102130. [key: string]: number;
  102131. };
  102132. /** List of emitted defines */
  102133. defineNames: {
  102134. [key: string]: number;
  102135. };
  102136. /** Should emit comments? */
  102137. emitComments: boolean;
  102138. /** Emit build activity */
  102139. verbose: boolean;
  102140. /** Gets or sets the hosting scene */
  102141. scene: Scene;
  102142. /**
  102143. * Gets the compilation hints emitted at compilation time
  102144. */
  102145. hints: {
  102146. needWorldViewMatrix: boolean;
  102147. needWorldViewProjectionMatrix: boolean;
  102148. needAlphaBlending: boolean;
  102149. needAlphaTesting: boolean;
  102150. };
  102151. /**
  102152. * List of compilation checks
  102153. */
  102154. checks: {
  102155. emitVertex: boolean;
  102156. emitFragment: boolean;
  102157. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102158. };
  102159. /**
  102160. * Is vertex program allowed to be empty?
  102161. */
  102162. allowEmptyVertexProgram: boolean;
  102163. /** Creates a new shared data */
  102164. constructor();
  102165. /**
  102166. * Emits console errors and exceptions if there is a failing check
  102167. */
  102168. emitErrors(): void;
  102169. }
  102170. }
  102171. declare module BABYLON {
  102172. /**
  102173. * Class used to store node based material build state
  102174. */
  102175. export class NodeMaterialBuildState {
  102176. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102177. supportUniformBuffers: boolean;
  102178. /**
  102179. * Gets the list of emitted attributes
  102180. */
  102181. attributes: string[];
  102182. /**
  102183. * Gets the list of emitted uniforms
  102184. */
  102185. uniforms: string[];
  102186. /**
  102187. * Gets the list of emitted constants
  102188. */
  102189. constants: string[];
  102190. /**
  102191. * Gets the list of emitted samplers
  102192. */
  102193. samplers: string[];
  102194. /**
  102195. * Gets the list of emitted functions
  102196. */
  102197. functions: {
  102198. [key: string]: string;
  102199. };
  102200. /**
  102201. * Gets the list of emitted extensions
  102202. */
  102203. extensions: {
  102204. [key: string]: string;
  102205. };
  102206. /**
  102207. * Gets the target of the compilation state
  102208. */
  102209. target: NodeMaterialBlockTargets;
  102210. /**
  102211. * Gets the list of emitted counters
  102212. */
  102213. counters: {
  102214. [key: string]: number;
  102215. };
  102216. /**
  102217. * Shared data between multiple NodeMaterialBuildState instances
  102218. */
  102219. sharedData: NodeMaterialBuildStateSharedData;
  102220. /** @hidden */
  102221. _vertexState: NodeMaterialBuildState;
  102222. /** @hidden */
  102223. _attributeDeclaration: string;
  102224. /** @hidden */
  102225. _uniformDeclaration: string;
  102226. /** @hidden */
  102227. _constantDeclaration: string;
  102228. /** @hidden */
  102229. _samplerDeclaration: string;
  102230. /** @hidden */
  102231. _varyingTransfer: string;
  102232. /** @hidden */
  102233. _injectAtEnd: string;
  102234. private _repeatableContentAnchorIndex;
  102235. /** @hidden */
  102236. _builtCompilationString: string;
  102237. /**
  102238. * Gets the emitted compilation strings
  102239. */
  102240. compilationString: string;
  102241. /**
  102242. * Finalize the compilation strings
  102243. * @param state defines the current compilation state
  102244. */
  102245. finalize(state: NodeMaterialBuildState): void;
  102246. /** @hidden */
  102247. get _repeatableContentAnchor(): string;
  102248. /** @hidden */
  102249. _getFreeVariableName(prefix: string): string;
  102250. /** @hidden */
  102251. _getFreeDefineName(prefix: string): string;
  102252. /** @hidden */
  102253. _excludeVariableName(name: string): void;
  102254. /** @hidden */
  102255. _emit2DSampler(name: string): void;
  102256. /** @hidden */
  102257. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102258. /** @hidden */
  102259. _emitExtension(name: string, extension: string, define?: string): void;
  102260. /** @hidden */
  102261. _emitFunction(name: string, code: string, comments: string): void;
  102262. /** @hidden */
  102263. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102264. replaceStrings?: {
  102265. search: RegExp;
  102266. replace: string;
  102267. }[];
  102268. repeatKey?: string;
  102269. }): string;
  102270. /** @hidden */
  102271. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102272. repeatKey?: string;
  102273. removeAttributes?: boolean;
  102274. removeUniforms?: boolean;
  102275. removeVaryings?: boolean;
  102276. removeIfDef?: boolean;
  102277. replaceStrings?: {
  102278. search: RegExp;
  102279. replace: string;
  102280. }[];
  102281. }, storeKey?: string): void;
  102282. /** @hidden */
  102283. _registerTempVariable(name: string): boolean;
  102284. /** @hidden */
  102285. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102286. /** @hidden */
  102287. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102288. /** @hidden */
  102289. _emitFloat(value: number): string;
  102290. }
  102291. }
  102292. declare module BABYLON {
  102293. /**
  102294. * Helper class used to generate session unique ID
  102295. */
  102296. export class UniqueIdGenerator {
  102297. private static _UniqueIdCounter;
  102298. /**
  102299. * Gets an unique (relatively to the current scene) Id
  102300. */
  102301. static get UniqueId(): number;
  102302. }
  102303. }
  102304. declare module BABYLON {
  102305. /**
  102306. * Defines a block that can be used inside a node based material
  102307. */
  102308. export class NodeMaterialBlock {
  102309. private _buildId;
  102310. private _buildTarget;
  102311. private _target;
  102312. private _isFinalMerger;
  102313. private _isInput;
  102314. private _name;
  102315. protected _isUnique: boolean;
  102316. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102317. inputsAreExclusive: boolean;
  102318. /** @hidden */
  102319. _codeVariableName: string;
  102320. /** @hidden */
  102321. _inputs: NodeMaterialConnectionPoint[];
  102322. /** @hidden */
  102323. _outputs: NodeMaterialConnectionPoint[];
  102324. /** @hidden */
  102325. _preparationId: number;
  102326. /**
  102327. * Gets the name of the block
  102328. */
  102329. get name(): string;
  102330. /**
  102331. * Sets the name of the block. Will check if the name is valid.
  102332. */
  102333. set name(newName: string);
  102334. /**
  102335. * Gets or sets the unique id of the node
  102336. */
  102337. uniqueId: number;
  102338. /**
  102339. * Gets or sets the comments associated with this block
  102340. */
  102341. comments: string;
  102342. /**
  102343. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102344. */
  102345. get isUnique(): boolean;
  102346. /**
  102347. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102348. */
  102349. get isFinalMerger(): boolean;
  102350. /**
  102351. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102352. */
  102353. get isInput(): boolean;
  102354. /**
  102355. * Gets or sets the build Id
  102356. */
  102357. get buildId(): number;
  102358. set buildId(value: number);
  102359. /**
  102360. * Gets or sets the target of the block
  102361. */
  102362. get target(): NodeMaterialBlockTargets;
  102363. set target(value: NodeMaterialBlockTargets);
  102364. /**
  102365. * Gets the list of input points
  102366. */
  102367. get inputs(): NodeMaterialConnectionPoint[];
  102368. /** Gets the list of output points */
  102369. get outputs(): NodeMaterialConnectionPoint[];
  102370. /**
  102371. * Find an input by its name
  102372. * @param name defines the name of the input to look for
  102373. * @returns the input or null if not found
  102374. */
  102375. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102376. /**
  102377. * Find an output by its name
  102378. * @param name defines the name of the outputto look for
  102379. * @returns the output or null if not found
  102380. */
  102381. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102382. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102383. visibleInInspector: boolean;
  102384. /**
  102385. * Creates a new NodeMaterialBlock
  102386. * @param name defines the block name
  102387. * @param target defines the target of that block (Vertex by default)
  102388. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102389. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102390. */
  102391. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102392. /**
  102393. * Initialize the block and prepare the context for build
  102394. * @param state defines the state that will be used for the build
  102395. */
  102396. initialize(state: NodeMaterialBuildState): void;
  102397. /**
  102398. * Bind data to effect. Will only be called for blocks with isBindable === true
  102399. * @param effect defines the effect to bind data to
  102400. * @param nodeMaterial defines the hosting NodeMaterial
  102401. * @param mesh defines the mesh that will be rendered
  102402. * @param subMesh defines the submesh that will be rendered
  102403. */
  102404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102405. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102406. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102407. protected _writeFloat(value: number): string;
  102408. /**
  102409. * Gets the current class name e.g. "NodeMaterialBlock"
  102410. * @returns the class name
  102411. */
  102412. getClassName(): string;
  102413. /**
  102414. * Register a new input. Must be called inside a block constructor
  102415. * @param name defines the connection point name
  102416. * @param type defines the connection point type
  102417. * @param isOptional defines a boolean indicating that this input can be omitted
  102418. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102419. * @param point an already created connection point. If not provided, create a new one
  102420. * @returns the current block
  102421. */
  102422. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102423. /**
  102424. * Register a new output. Must be called inside a block constructor
  102425. * @param name defines the connection point name
  102426. * @param type defines the connection point type
  102427. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102428. * @param point an already created connection point. If not provided, create a new one
  102429. * @returns the current block
  102430. */
  102431. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102432. /**
  102433. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102434. * @param forOutput defines an optional connection point to check compatibility with
  102435. * @returns the first available input or null
  102436. */
  102437. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102438. /**
  102439. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102440. * @param forBlock defines an optional block to check compatibility with
  102441. * @returns the first available input or null
  102442. */
  102443. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102444. /**
  102445. * Gets the sibling of the given output
  102446. * @param current defines the current output
  102447. * @returns the next output in the list or null
  102448. */
  102449. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102450. /**
  102451. * Connect current block with another block
  102452. * @param other defines the block to connect with
  102453. * @param options define the various options to help pick the right connections
  102454. * @returns the current block
  102455. */
  102456. connectTo(other: NodeMaterialBlock, options?: {
  102457. input?: string;
  102458. output?: string;
  102459. outputSwizzle?: string;
  102460. }): this | undefined;
  102461. protected _buildBlock(state: NodeMaterialBuildState): void;
  102462. /**
  102463. * Add uniforms, samplers and uniform buffers at compilation time
  102464. * @param state defines the state to update
  102465. * @param nodeMaterial defines the node material requesting the update
  102466. * @param defines defines the material defines to update
  102467. * @param uniformBuffers defines the list of uniform buffer names
  102468. */
  102469. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102470. /**
  102471. * Add potential fallbacks if shader compilation fails
  102472. * @param mesh defines the mesh to be rendered
  102473. * @param fallbacks defines the current prioritized list of fallbacks
  102474. */
  102475. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102476. /**
  102477. * Initialize defines for shader compilation
  102478. * @param mesh defines the mesh to be rendered
  102479. * @param nodeMaterial defines the node material requesting the update
  102480. * @param defines defines the material defines to update
  102481. * @param useInstances specifies that instances should be used
  102482. */
  102483. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102484. /**
  102485. * Update defines for shader compilation
  102486. * @param mesh defines the mesh to be rendered
  102487. * @param nodeMaterial defines the node material requesting the update
  102488. * @param defines defines the material defines to update
  102489. * @param useInstances specifies that instances should be used
  102490. * @param subMesh defines which submesh to render
  102491. */
  102492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102493. /**
  102494. * Lets the block try to connect some inputs automatically
  102495. * @param material defines the hosting NodeMaterial
  102496. */
  102497. autoConfigure(material: NodeMaterial): void;
  102498. /**
  102499. * Function called when a block is declared as repeatable content generator
  102500. * @param vertexShaderState defines the current compilation state for the vertex shader
  102501. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102502. * @param mesh defines the mesh to be rendered
  102503. * @param defines defines the material defines to update
  102504. */
  102505. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102506. /**
  102507. * Checks if the block is ready
  102508. * @param mesh defines the mesh to be rendered
  102509. * @param nodeMaterial defines the node material requesting the update
  102510. * @param defines defines the material defines to update
  102511. * @param useInstances specifies that instances should be used
  102512. * @returns true if the block is ready
  102513. */
  102514. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102515. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102516. private _processBuild;
  102517. /**
  102518. * Validates the new name for the block node.
  102519. * @param newName the new name to be given to the node.
  102520. * @returns false if the name is a reserve word, else true.
  102521. */
  102522. validateBlockName(newName: string): boolean;
  102523. /**
  102524. * Compile the current node and generate the shader code
  102525. * @param state defines the current compilation state (uniforms, samplers, current string)
  102526. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102527. * @returns true if already built
  102528. */
  102529. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102530. protected _inputRename(name: string): string;
  102531. protected _outputRename(name: string): string;
  102532. protected _dumpPropertiesCode(): string;
  102533. /** @hidden */
  102534. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102535. /** @hidden */
  102536. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102537. /**
  102538. * Clone the current block to a new identical block
  102539. * @param scene defines the hosting scene
  102540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102541. * @returns a copy of the current block
  102542. */
  102543. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102544. /**
  102545. * Serializes this block in a JSON representation
  102546. * @returns the serialized block object
  102547. */
  102548. serialize(): any;
  102549. /** @hidden */
  102550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102551. private _deserializePortDisplayNamesAndExposedOnFrame;
  102552. /**
  102553. * Release resources
  102554. */
  102555. dispose(): void;
  102556. }
  102557. }
  102558. declare module BABYLON {
  102559. /**
  102560. * Base class of materials working in push mode in babylon JS
  102561. * @hidden
  102562. */
  102563. export class PushMaterial extends Material {
  102564. protected _activeEffect: Effect;
  102565. protected _normalMatrix: Matrix;
  102566. constructor(name: string, scene: Scene);
  102567. getEffect(): Effect;
  102568. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102569. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102570. /**
  102571. * Binds the given world matrix to the active effect
  102572. *
  102573. * @param world the matrix to bind
  102574. */
  102575. bindOnlyWorldMatrix(world: Matrix): void;
  102576. /**
  102577. * Binds the given normal matrix to the active effect
  102578. *
  102579. * @param normalMatrix the matrix to bind
  102580. */
  102581. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102582. bind(world: Matrix, mesh?: Mesh): void;
  102583. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102584. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102585. }
  102586. }
  102587. declare module BABYLON {
  102588. /**
  102589. * Root class for all node material optimizers
  102590. */
  102591. export class NodeMaterialOptimizer {
  102592. /**
  102593. * Function used to optimize a NodeMaterial graph
  102594. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102595. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102596. */
  102597. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102598. }
  102599. }
  102600. declare module BABYLON {
  102601. /**
  102602. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102603. */
  102604. export class TransformBlock extends NodeMaterialBlock {
  102605. /**
  102606. * Defines the value to use to complement W value to transform it to a Vector4
  102607. */
  102608. complementW: number;
  102609. /**
  102610. * Defines the value to use to complement z value to transform it to a Vector4
  102611. */
  102612. complementZ: number;
  102613. /**
  102614. * Creates a new TransformBlock
  102615. * @param name defines the block name
  102616. */
  102617. constructor(name: string);
  102618. /**
  102619. * Gets the current class name
  102620. * @returns the class name
  102621. */
  102622. getClassName(): string;
  102623. /**
  102624. * Gets the vector input
  102625. */
  102626. get vector(): NodeMaterialConnectionPoint;
  102627. /**
  102628. * Gets the output component
  102629. */
  102630. get output(): NodeMaterialConnectionPoint;
  102631. /**
  102632. * Gets the xyz output component
  102633. */
  102634. get xyz(): NodeMaterialConnectionPoint;
  102635. /**
  102636. * Gets the matrix transform input
  102637. */
  102638. get transform(): NodeMaterialConnectionPoint;
  102639. protected _buildBlock(state: NodeMaterialBuildState): this;
  102640. /**
  102641. * Update defines for shader compilation
  102642. * @param mesh defines the mesh to be rendered
  102643. * @param nodeMaterial defines the node material requesting the update
  102644. * @param defines defines the material defines to update
  102645. * @param useInstances specifies that instances should be used
  102646. * @param subMesh defines which submesh to render
  102647. */
  102648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102649. serialize(): any;
  102650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102651. protected _dumpPropertiesCode(): string;
  102652. }
  102653. }
  102654. declare module BABYLON {
  102655. /**
  102656. * Block used to output the vertex position
  102657. */
  102658. export class VertexOutputBlock extends NodeMaterialBlock {
  102659. /**
  102660. * Creates a new VertexOutputBlock
  102661. * @param name defines the block name
  102662. */
  102663. constructor(name: string);
  102664. /**
  102665. * Gets the current class name
  102666. * @returns the class name
  102667. */
  102668. getClassName(): string;
  102669. /**
  102670. * Gets the vector input component
  102671. */
  102672. get vector(): NodeMaterialConnectionPoint;
  102673. protected _buildBlock(state: NodeMaterialBuildState): this;
  102674. }
  102675. }
  102676. declare module BABYLON {
  102677. /**
  102678. * Block used to output the final color
  102679. */
  102680. export class FragmentOutputBlock extends NodeMaterialBlock {
  102681. /**
  102682. * Create a new FragmentOutputBlock
  102683. * @param name defines the block name
  102684. */
  102685. constructor(name: string);
  102686. /**
  102687. * Gets the current class name
  102688. * @returns the class name
  102689. */
  102690. getClassName(): string;
  102691. /**
  102692. * Gets the rgba input component
  102693. */
  102694. get rgba(): NodeMaterialConnectionPoint;
  102695. /**
  102696. * Gets the rgb input component
  102697. */
  102698. get rgb(): NodeMaterialConnectionPoint;
  102699. /**
  102700. * Gets the a input component
  102701. */
  102702. get a(): NodeMaterialConnectionPoint;
  102703. protected _buildBlock(state: NodeMaterialBuildState): this;
  102704. }
  102705. }
  102706. declare module BABYLON {
  102707. /**
  102708. * Block used for the particle ramp gradient section
  102709. */
  102710. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102711. /**
  102712. * Create a new ParticleRampGradientBlock
  102713. * @param name defines the block name
  102714. */
  102715. constructor(name: string);
  102716. /**
  102717. * Gets the current class name
  102718. * @returns the class name
  102719. */
  102720. getClassName(): string;
  102721. /**
  102722. * Gets the color input component
  102723. */
  102724. get color(): NodeMaterialConnectionPoint;
  102725. /**
  102726. * Gets the rampColor output component
  102727. */
  102728. get rampColor(): NodeMaterialConnectionPoint;
  102729. /**
  102730. * Initialize the block and prepare the context for build
  102731. * @param state defines the state that will be used for the build
  102732. */
  102733. initialize(state: NodeMaterialBuildState): void;
  102734. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102735. }
  102736. }
  102737. declare module BABYLON {
  102738. /**
  102739. * Block used for the particle blend multiply section
  102740. */
  102741. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102742. /**
  102743. * Create a new ParticleBlendMultiplyBlock
  102744. * @param name defines the block name
  102745. */
  102746. constructor(name: string);
  102747. /**
  102748. * Gets the current class name
  102749. * @returns the class name
  102750. */
  102751. getClassName(): string;
  102752. /**
  102753. * Gets the color input component
  102754. */
  102755. get color(): NodeMaterialConnectionPoint;
  102756. /**
  102757. * Gets the alphaTexture input component
  102758. */
  102759. get alphaTexture(): NodeMaterialConnectionPoint;
  102760. /**
  102761. * Gets the alphaColor input component
  102762. */
  102763. get alphaColor(): NodeMaterialConnectionPoint;
  102764. /**
  102765. * Gets the blendColor output component
  102766. */
  102767. get blendColor(): NodeMaterialConnectionPoint;
  102768. /**
  102769. * Initialize the block and prepare the context for build
  102770. * @param state defines the state that will be used for the build
  102771. */
  102772. initialize(state: NodeMaterialBuildState): void;
  102773. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102774. }
  102775. }
  102776. declare module BABYLON {
  102777. /**
  102778. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102779. */
  102780. export class VectorMergerBlock extends NodeMaterialBlock {
  102781. /**
  102782. * Create a new VectorMergerBlock
  102783. * @param name defines the block name
  102784. */
  102785. constructor(name: string);
  102786. /**
  102787. * Gets the current class name
  102788. * @returns the class name
  102789. */
  102790. getClassName(): string;
  102791. /**
  102792. * Gets the xyz component (input)
  102793. */
  102794. get xyzIn(): NodeMaterialConnectionPoint;
  102795. /**
  102796. * Gets the xy component (input)
  102797. */
  102798. get xyIn(): NodeMaterialConnectionPoint;
  102799. /**
  102800. * Gets the x component (input)
  102801. */
  102802. get x(): NodeMaterialConnectionPoint;
  102803. /**
  102804. * Gets the y component (input)
  102805. */
  102806. get y(): NodeMaterialConnectionPoint;
  102807. /**
  102808. * Gets the z component (input)
  102809. */
  102810. get z(): NodeMaterialConnectionPoint;
  102811. /**
  102812. * Gets the w component (input)
  102813. */
  102814. get w(): NodeMaterialConnectionPoint;
  102815. /**
  102816. * Gets the xyzw component (output)
  102817. */
  102818. get xyzw(): NodeMaterialConnectionPoint;
  102819. /**
  102820. * Gets the xyz component (output)
  102821. */
  102822. get xyzOut(): NodeMaterialConnectionPoint;
  102823. /**
  102824. * Gets the xy component (output)
  102825. */
  102826. get xyOut(): NodeMaterialConnectionPoint;
  102827. /**
  102828. * Gets the xy component (output)
  102829. * @deprecated Please use xyOut instead.
  102830. */
  102831. get xy(): NodeMaterialConnectionPoint;
  102832. /**
  102833. * Gets the xyz component (output)
  102834. * @deprecated Please use xyzOut instead.
  102835. */
  102836. get xyz(): NodeMaterialConnectionPoint;
  102837. protected _buildBlock(state: NodeMaterialBuildState): this;
  102838. }
  102839. }
  102840. declare module BABYLON {
  102841. /**
  102842. * Block used to remap a float from a range to a new one
  102843. */
  102844. export class RemapBlock extends NodeMaterialBlock {
  102845. /**
  102846. * Gets or sets the source range
  102847. */
  102848. sourceRange: Vector2;
  102849. /**
  102850. * Gets or sets the target range
  102851. */
  102852. targetRange: Vector2;
  102853. /**
  102854. * Creates a new RemapBlock
  102855. * @param name defines the block name
  102856. */
  102857. constructor(name: string);
  102858. /**
  102859. * Gets the current class name
  102860. * @returns the class name
  102861. */
  102862. getClassName(): string;
  102863. /**
  102864. * Gets the input component
  102865. */
  102866. get input(): NodeMaterialConnectionPoint;
  102867. /**
  102868. * Gets the source min input component
  102869. */
  102870. get sourceMin(): NodeMaterialConnectionPoint;
  102871. /**
  102872. * Gets the source max input component
  102873. */
  102874. get sourceMax(): NodeMaterialConnectionPoint;
  102875. /**
  102876. * Gets the target min input component
  102877. */
  102878. get targetMin(): NodeMaterialConnectionPoint;
  102879. /**
  102880. * Gets the target max input component
  102881. */
  102882. get targetMax(): NodeMaterialConnectionPoint;
  102883. /**
  102884. * Gets the output component
  102885. */
  102886. get output(): NodeMaterialConnectionPoint;
  102887. protected _buildBlock(state: NodeMaterialBuildState): this;
  102888. protected _dumpPropertiesCode(): string;
  102889. serialize(): any;
  102890. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102891. }
  102892. }
  102893. declare module BABYLON {
  102894. /**
  102895. * Block used to multiply 2 values
  102896. */
  102897. export class MultiplyBlock extends NodeMaterialBlock {
  102898. /**
  102899. * Creates a new MultiplyBlock
  102900. * @param name defines the block name
  102901. */
  102902. constructor(name: string);
  102903. /**
  102904. * Gets the current class name
  102905. * @returns the class name
  102906. */
  102907. getClassName(): string;
  102908. /**
  102909. * Gets the left operand input component
  102910. */
  102911. get left(): NodeMaterialConnectionPoint;
  102912. /**
  102913. * Gets the right operand input component
  102914. */
  102915. get right(): NodeMaterialConnectionPoint;
  102916. /**
  102917. * Gets the output component
  102918. */
  102919. get output(): NodeMaterialConnectionPoint;
  102920. protected _buildBlock(state: NodeMaterialBuildState): this;
  102921. }
  102922. }
  102923. declare module BABYLON {
  102924. /**
  102925. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102926. */
  102927. export class ColorSplitterBlock extends NodeMaterialBlock {
  102928. /**
  102929. * Create a new ColorSplitterBlock
  102930. * @param name defines the block name
  102931. */
  102932. constructor(name: string);
  102933. /**
  102934. * Gets the current class name
  102935. * @returns the class name
  102936. */
  102937. getClassName(): string;
  102938. /**
  102939. * Gets the rgba component (input)
  102940. */
  102941. get rgba(): NodeMaterialConnectionPoint;
  102942. /**
  102943. * Gets the rgb component (input)
  102944. */
  102945. get rgbIn(): NodeMaterialConnectionPoint;
  102946. /**
  102947. * Gets the rgb component (output)
  102948. */
  102949. get rgbOut(): NodeMaterialConnectionPoint;
  102950. /**
  102951. * Gets the r component (output)
  102952. */
  102953. get r(): NodeMaterialConnectionPoint;
  102954. /**
  102955. * Gets the g component (output)
  102956. */
  102957. get g(): NodeMaterialConnectionPoint;
  102958. /**
  102959. * Gets the b component (output)
  102960. */
  102961. get b(): NodeMaterialConnectionPoint;
  102962. /**
  102963. * Gets the a component (output)
  102964. */
  102965. get a(): NodeMaterialConnectionPoint;
  102966. protected _inputRename(name: string): string;
  102967. protected _outputRename(name: string): string;
  102968. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102969. }
  102970. }
  102971. declare module BABYLON {
  102972. /**
  102973. * Operations supported by the Trigonometry block
  102974. */
  102975. export enum TrigonometryBlockOperations {
  102976. /** Cos */
  102977. Cos = 0,
  102978. /** Sin */
  102979. Sin = 1,
  102980. /** Abs */
  102981. Abs = 2,
  102982. /** Exp */
  102983. Exp = 3,
  102984. /** Exp2 */
  102985. Exp2 = 4,
  102986. /** Round */
  102987. Round = 5,
  102988. /** Floor */
  102989. Floor = 6,
  102990. /** Ceiling */
  102991. Ceiling = 7,
  102992. /** Square root */
  102993. Sqrt = 8,
  102994. /** Log */
  102995. Log = 9,
  102996. /** Tangent */
  102997. Tan = 10,
  102998. /** Arc tangent */
  102999. ArcTan = 11,
  103000. /** Arc cosinus */
  103001. ArcCos = 12,
  103002. /** Arc sinus */
  103003. ArcSin = 13,
  103004. /** Fraction */
  103005. Fract = 14,
  103006. /** Sign */
  103007. Sign = 15,
  103008. /** To radians (from degrees) */
  103009. Radians = 16,
  103010. /** To degrees (from radians) */
  103011. Degrees = 17
  103012. }
  103013. /**
  103014. * Block used to apply trigonometry operation to floats
  103015. */
  103016. export class TrigonometryBlock extends NodeMaterialBlock {
  103017. /**
  103018. * Gets or sets the operation applied by the block
  103019. */
  103020. operation: TrigonometryBlockOperations;
  103021. /**
  103022. * Creates a new TrigonometryBlock
  103023. * @param name defines the block name
  103024. */
  103025. constructor(name: string);
  103026. /**
  103027. * Gets the current class name
  103028. * @returns the class name
  103029. */
  103030. getClassName(): string;
  103031. /**
  103032. * Gets the input component
  103033. */
  103034. get input(): NodeMaterialConnectionPoint;
  103035. /**
  103036. * Gets the output component
  103037. */
  103038. get output(): NodeMaterialConnectionPoint;
  103039. protected _buildBlock(state: NodeMaterialBuildState): this;
  103040. serialize(): any;
  103041. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103042. protected _dumpPropertiesCode(): string;
  103043. }
  103044. }
  103045. declare module BABYLON {
  103046. /**
  103047. * Interface used to configure the node material editor
  103048. */
  103049. export interface INodeMaterialEditorOptions {
  103050. /** Define the URl to load node editor script */
  103051. editorURL?: string;
  103052. }
  103053. /** @hidden */
  103054. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103055. NORMAL: boolean;
  103056. TANGENT: boolean;
  103057. UV1: boolean;
  103058. /** BONES */
  103059. NUM_BONE_INFLUENCERS: number;
  103060. BonesPerMesh: number;
  103061. BONETEXTURE: boolean;
  103062. /** MORPH TARGETS */
  103063. MORPHTARGETS: boolean;
  103064. MORPHTARGETS_NORMAL: boolean;
  103065. MORPHTARGETS_TANGENT: boolean;
  103066. MORPHTARGETS_UV: boolean;
  103067. NUM_MORPH_INFLUENCERS: number;
  103068. /** IMAGE PROCESSING */
  103069. IMAGEPROCESSING: boolean;
  103070. VIGNETTE: boolean;
  103071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103072. VIGNETTEBLENDMODEOPAQUE: boolean;
  103073. TONEMAPPING: boolean;
  103074. TONEMAPPING_ACES: boolean;
  103075. CONTRAST: boolean;
  103076. EXPOSURE: boolean;
  103077. COLORCURVES: boolean;
  103078. COLORGRADING: boolean;
  103079. COLORGRADING3D: boolean;
  103080. SAMPLER3DGREENDEPTH: boolean;
  103081. SAMPLER3DBGRMAP: boolean;
  103082. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103083. /** MISC. */
  103084. BUMPDIRECTUV: number;
  103085. constructor();
  103086. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103087. }
  103088. /**
  103089. * Class used to configure NodeMaterial
  103090. */
  103091. export interface INodeMaterialOptions {
  103092. /**
  103093. * Defines if blocks should emit comments
  103094. */
  103095. emitComments: boolean;
  103096. }
  103097. /**
  103098. * Class used to create a node based material built by assembling shader blocks
  103099. */
  103100. export class NodeMaterial extends PushMaterial {
  103101. private static _BuildIdGenerator;
  103102. private _options;
  103103. private _vertexCompilationState;
  103104. private _fragmentCompilationState;
  103105. private _sharedData;
  103106. private _buildId;
  103107. private _buildWasSuccessful;
  103108. private _cachedWorldViewMatrix;
  103109. private _cachedWorldViewProjectionMatrix;
  103110. private _optimizers;
  103111. private _animationFrame;
  103112. /** Define the Url to load node editor script */
  103113. static EditorURL: string;
  103114. /** Define the Url to load snippets */
  103115. static SnippetUrl: string;
  103116. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103117. static IgnoreTexturesAtLoadTime: boolean;
  103118. private BJSNODEMATERIALEDITOR;
  103119. /** Get the inspector from bundle or global */
  103120. private _getGlobalNodeMaterialEditor;
  103121. /**
  103122. * Snippet ID if the material was created from the snippet server
  103123. */
  103124. snippetId: string;
  103125. /**
  103126. * Gets or sets data used by visual editor
  103127. * @see https://nme.babylonjs.com
  103128. */
  103129. editorData: any;
  103130. /**
  103131. * 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)
  103132. */
  103133. ignoreAlpha: boolean;
  103134. /**
  103135. * Defines the maximum number of lights that can be used in the material
  103136. */
  103137. maxSimultaneousLights: number;
  103138. /**
  103139. * Observable raised when the material is built
  103140. */
  103141. onBuildObservable: Observable<NodeMaterial>;
  103142. /**
  103143. * Gets or sets the root nodes of the material vertex shader
  103144. */
  103145. _vertexOutputNodes: NodeMaterialBlock[];
  103146. /**
  103147. * Gets or sets the root nodes of the material fragment (pixel) shader
  103148. */
  103149. _fragmentOutputNodes: NodeMaterialBlock[];
  103150. /** Gets or sets options to control the node material overall behavior */
  103151. get options(): INodeMaterialOptions;
  103152. set options(options: INodeMaterialOptions);
  103153. /**
  103154. * Default configuration related to image processing available in the standard Material.
  103155. */
  103156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103157. /**
  103158. * Gets the image processing configuration used either in this material.
  103159. */
  103160. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103161. /**
  103162. * Sets the Default image processing configuration used either in the this material.
  103163. *
  103164. * If sets to null, the scene one is in use.
  103165. */
  103166. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103167. /**
  103168. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103169. */
  103170. attachedBlocks: NodeMaterialBlock[];
  103171. /**
  103172. * Specifies the mode of the node material
  103173. * @hidden
  103174. */
  103175. _mode: NodeMaterialModes;
  103176. /**
  103177. * Gets the mode property
  103178. */
  103179. get mode(): NodeMaterialModes;
  103180. /**
  103181. * Create a new node based material
  103182. * @param name defines the material name
  103183. * @param scene defines the hosting scene
  103184. * @param options defines creation option
  103185. */
  103186. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103187. /**
  103188. * Gets the current class name of the material e.g. "NodeMaterial"
  103189. * @returns the class name
  103190. */
  103191. getClassName(): string;
  103192. /**
  103193. * Keep track of the image processing observer to allow dispose and replace.
  103194. */
  103195. private _imageProcessingObserver;
  103196. /**
  103197. * Attaches a new image processing configuration to the Standard Material.
  103198. * @param configuration
  103199. */
  103200. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103201. /**
  103202. * Get a block by its name
  103203. * @param name defines the name of the block to retrieve
  103204. * @returns the required block or null if not found
  103205. */
  103206. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103207. /**
  103208. * Get a block by its name
  103209. * @param predicate defines the predicate used to find the good candidate
  103210. * @returns the required block or null if not found
  103211. */
  103212. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103213. /**
  103214. * Get an input block by its name
  103215. * @param predicate defines the predicate used to find the good candidate
  103216. * @returns the required input block or null if not found
  103217. */
  103218. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103219. /**
  103220. * Gets the list of input blocks attached to this material
  103221. * @returns an array of InputBlocks
  103222. */
  103223. getInputBlocks(): InputBlock[];
  103224. /**
  103225. * Adds a new optimizer to the list of optimizers
  103226. * @param optimizer defines the optimizers to add
  103227. * @returns the current material
  103228. */
  103229. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103230. /**
  103231. * Remove an optimizer from the list of optimizers
  103232. * @param optimizer defines the optimizers to remove
  103233. * @returns the current material
  103234. */
  103235. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103236. /**
  103237. * Add a new block to the list of output nodes
  103238. * @param node defines the node to add
  103239. * @returns the current material
  103240. */
  103241. addOutputNode(node: NodeMaterialBlock): this;
  103242. /**
  103243. * Remove a block from the list of root nodes
  103244. * @param node defines the node to remove
  103245. * @returns the current material
  103246. */
  103247. removeOutputNode(node: NodeMaterialBlock): this;
  103248. private _addVertexOutputNode;
  103249. private _removeVertexOutputNode;
  103250. private _addFragmentOutputNode;
  103251. private _removeFragmentOutputNode;
  103252. /**
  103253. * Specifies if the material will require alpha blending
  103254. * @returns a boolean specifying if alpha blending is needed
  103255. */
  103256. needAlphaBlending(): boolean;
  103257. /**
  103258. * Specifies if this material should be rendered in alpha test mode
  103259. * @returns a boolean specifying if an alpha test is needed.
  103260. */
  103261. needAlphaTesting(): boolean;
  103262. private _initializeBlock;
  103263. private _resetDualBlocks;
  103264. /**
  103265. * Remove a block from the current node material
  103266. * @param block defines the block to remove
  103267. */
  103268. removeBlock(block: NodeMaterialBlock): void;
  103269. /**
  103270. * Build the material and generates the inner effect
  103271. * @param verbose defines if the build should log activity
  103272. */
  103273. build(verbose?: boolean): void;
  103274. /**
  103275. * Runs an otpimization phase to try to improve the shader code
  103276. */
  103277. optimize(): void;
  103278. private _prepareDefinesForAttributes;
  103279. /**
  103280. * Create a post process from the material
  103281. * @param camera The camera to apply the render pass to.
  103282. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103284. * @param engine The engine which the post process will be applied. (default: current engine)
  103285. * @param reusable If the post process can be reused on the same frame. (default: false)
  103286. * @param textureType Type of textures used when performing the post process. (default: 0)
  103287. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103288. * @returns the post process created
  103289. */
  103290. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103291. /**
  103292. * Create the post process effect from the material
  103293. * @param postProcess The post process to create the effect for
  103294. */
  103295. createEffectForPostProcess(postProcess: PostProcess): void;
  103296. private _createEffectForPostProcess;
  103297. /**
  103298. * Create a new procedural texture based on this node material
  103299. * @param size defines the size of the texture
  103300. * @param scene defines the hosting scene
  103301. * @returns the new procedural texture attached to this node material
  103302. */
  103303. createProceduralTexture(size: number | {
  103304. width: number;
  103305. height: number;
  103306. layers?: number;
  103307. }, scene: Scene): Nullable<ProceduralTexture>;
  103308. private _createEffectForParticles;
  103309. private _checkInternals;
  103310. /**
  103311. * Create the effect to be used as the custom effect for a particle system
  103312. * @param particleSystem Particle system to create the effect for
  103313. * @param onCompiled defines a function to call when the effect creation is successful
  103314. * @param onError defines a function to call when the effect creation has failed
  103315. */
  103316. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103317. private _processDefines;
  103318. /**
  103319. * Get if the submesh is ready to be used and all its information available.
  103320. * Child classes can use it to update shaders
  103321. * @param mesh defines the mesh to check
  103322. * @param subMesh defines which submesh to check
  103323. * @param useInstances specifies that instances should be used
  103324. * @returns a boolean indicating that the submesh is ready or not
  103325. */
  103326. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103327. /**
  103328. * Get a string representing the shaders built by the current node graph
  103329. */
  103330. get compiledShaders(): string;
  103331. /**
  103332. * Binds the world matrix to the material
  103333. * @param world defines the world transformation matrix
  103334. */
  103335. bindOnlyWorldMatrix(world: Matrix): void;
  103336. /**
  103337. * Binds the submesh to this material by preparing the effect and shader to draw
  103338. * @param world defines the world transformation matrix
  103339. * @param mesh defines the mesh containing the submesh
  103340. * @param subMesh defines the submesh to bind the material to
  103341. */
  103342. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103343. /**
  103344. * Gets the active textures from the material
  103345. * @returns an array of textures
  103346. */
  103347. getActiveTextures(): BaseTexture[];
  103348. /**
  103349. * Gets the list of texture blocks
  103350. * @returns an array of texture blocks
  103351. */
  103352. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103353. /**
  103354. * Specifies if the material uses a texture
  103355. * @param texture defines the texture to check against the material
  103356. * @returns a boolean specifying if the material uses the texture
  103357. */
  103358. hasTexture(texture: BaseTexture): boolean;
  103359. /**
  103360. * Disposes the material
  103361. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103362. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103363. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103364. */
  103365. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103366. /** Creates the node editor window. */
  103367. private _createNodeEditor;
  103368. /**
  103369. * Launch the node material editor
  103370. * @param config Define the configuration of the editor
  103371. * @return a promise fulfilled when the node editor is visible
  103372. */
  103373. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103374. /**
  103375. * Clear the current material
  103376. */
  103377. clear(): void;
  103378. /**
  103379. * Clear the current material and set it to a default state
  103380. */
  103381. setToDefault(): void;
  103382. /**
  103383. * Clear the current material and set it to a default state for post process
  103384. */
  103385. setToDefaultPostProcess(): void;
  103386. /**
  103387. * Clear the current material and set it to a default state for procedural texture
  103388. */
  103389. setToDefaultProceduralTexture(): void;
  103390. /**
  103391. * Clear the current material and set it to a default state for particle
  103392. */
  103393. setToDefaultParticle(): void;
  103394. /**
  103395. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103396. * @param url defines the url to load from
  103397. * @returns a promise that will fullfil when the material is fully loaded
  103398. */
  103399. loadAsync(url: string): Promise<void>;
  103400. private _gatherBlocks;
  103401. /**
  103402. * Generate a string containing the code declaration required to create an equivalent of this material
  103403. * @returns a string
  103404. */
  103405. generateCode(): string;
  103406. /**
  103407. * Serializes this material in a JSON representation
  103408. * @returns the serialized material object
  103409. */
  103410. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103411. private _restoreConnections;
  103412. /**
  103413. * Clear the current graph and load a new one from a serialization object
  103414. * @param source defines the JSON representation of the material
  103415. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103416. * @param merge defines whether or not the source must be merged or replace the current content
  103417. */
  103418. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103419. /**
  103420. * Makes a duplicate of the current material.
  103421. * @param name - name to use for the new material.
  103422. */
  103423. clone(name: string): NodeMaterial;
  103424. /**
  103425. * Creates a node material from parsed material data
  103426. * @param source defines the JSON representation of the material
  103427. * @param scene defines the hosting scene
  103428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103429. * @returns a new node material
  103430. */
  103431. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103432. /**
  103433. * Creates a node material from a snippet saved in a remote file
  103434. * @param name defines the name of the material to create
  103435. * @param url defines the url to load from
  103436. * @param scene defines the hosting scene
  103437. * @returns a promise that will resolve to the new node material
  103438. */
  103439. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103440. /**
  103441. * Creates a node material from a snippet saved by the node material editor
  103442. * @param snippetId defines the snippet to load
  103443. * @param scene defines the hosting scene
  103444. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103445. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103446. * @returns a promise that will resolve to the new node material
  103447. */
  103448. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103449. /**
  103450. * Creates a new node material set to default basic configuration
  103451. * @param name defines the name of the material
  103452. * @param scene defines the hosting scene
  103453. * @returns a new NodeMaterial
  103454. */
  103455. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103456. }
  103457. }
  103458. declare module BABYLON {
  103459. interface ThinEngine {
  103460. /**
  103461. * Unbind a list of render target textures from the webGL context
  103462. * This is used only when drawBuffer extension or webGL2 are active
  103463. * @param textures defines the render target textures to unbind
  103464. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103465. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103466. */
  103467. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103468. /**
  103469. * Create a multi render target texture
  103470. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103471. * @param size defines the size of the texture
  103472. * @param options defines the creation options
  103473. * @returns the cube texture as an InternalTexture
  103474. */
  103475. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103476. /**
  103477. * Update the sample count for a given multiple render target texture
  103478. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103479. * @param textures defines the textures to update
  103480. * @param samples defines the sample count to set
  103481. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103482. */
  103483. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103484. /**
  103485. * Select a subsets of attachments to draw to.
  103486. * @param attachments gl attachments
  103487. */
  103488. bindAttachments(attachments: number[]): void;
  103489. /**
  103490. * Creates a layout object to draw/clear on specific textures in a MRT
  103491. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103492. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103493. */
  103494. buildTextureLayout(textureStatus: boolean[]): number[];
  103495. /**
  103496. * Restores the webgl state to only draw on the main color attachment
  103497. */
  103498. restoreSingleAttachment(): void;
  103499. }
  103500. }
  103501. declare module BABYLON {
  103502. /**
  103503. * Creation options of the multi render target texture.
  103504. */
  103505. export interface IMultiRenderTargetOptions {
  103506. /**
  103507. * Define if the texture needs to create mip maps after render.
  103508. */
  103509. generateMipMaps?: boolean;
  103510. /**
  103511. * Define the types of all the draw buffers we want to create
  103512. */
  103513. types?: number[];
  103514. /**
  103515. * Define the sampling modes of all the draw buffers we want to create
  103516. */
  103517. samplingModes?: number[];
  103518. /**
  103519. * Define if a depth buffer is required
  103520. */
  103521. generateDepthBuffer?: boolean;
  103522. /**
  103523. * Define if a stencil buffer is required
  103524. */
  103525. generateStencilBuffer?: boolean;
  103526. /**
  103527. * Define if a depth texture is required instead of a depth buffer
  103528. */
  103529. generateDepthTexture?: boolean;
  103530. /**
  103531. * Define the number of desired draw buffers
  103532. */
  103533. textureCount?: number;
  103534. /**
  103535. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103536. */
  103537. doNotChangeAspectRatio?: boolean;
  103538. /**
  103539. * Define the default type of the buffers we are creating
  103540. */
  103541. defaultType?: number;
  103542. }
  103543. /**
  103544. * A multi render target, like a render target provides the ability to render to a texture.
  103545. * Unlike the render target, it can render to several draw buffers in one draw.
  103546. * This is specially interesting in deferred rendering or for any effects requiring more than
  103547. * just one color from a single pass.
  103548. */
  103549. export class MultiRenderTarget extends RenderTargetTexture {
  103550. private _internalTextures;
  103551. private _textures;
  103552. private _multiRenderTargetOptions;
  103553. private _count;
  103554. /**
  103555. * Get if draw buffers are currently supported by the used hardware and browser.
  103556. */
  103557. get isSupported(): boolean;
  103558. /**
  103559. * Get the list of textures generated by the multi render target.
  103560. */
  103561. get textures(): Texture[];
  103562. /**
  103563. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103564. */
  103565. get count(): number;
  103566. /**
  103567. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103568. */
  103569. get depthTexture(): Texture;
  103570. /**
  103571. * Set the wrapping mode on U of all the textures we are rendering to.
  103572. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103573. */
  103574. set wrapU(wrap: number);
  103575. /**
  103576. * Set the wrapping mode on V of all the textures we are rendering to.
  103577. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103578. */
  103579. set wrapV(wrap: number);
  103580. /**
  103581. * Instantiate a new multi render target texture.
  103582. * A multi render target, like a render target provides the ability to render to a texture.
  103583. * Unlike the render target, it can render to several draw buffers in one draw.
  103584. * This is specially interesting in deferred rendering or for any effects requiring more than
  103585. * just one color from a single pass.
  103586. * @param name Define the name of the texture
  103587. * @param size Define the size of the buffers to render to
  103588. * @param count Define the number of target we are rendering into
  103589. * @param scene Define the scene the texture belongs to
  103590. * @param options Define the options used to create the multi render target
  103591. */
  103592. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103593. private _initTypes;
  103594. /** @hidden */
  103595. _rebuild(forceFullRebuild?: boolean): void;
  103596. private _createInternalTextures;
  103597. private _createTextures;
  103598. /**
  103599. * Replaces a texture within the MRT.
  103600. * @param texture The new texture to insert in the MRT
  103601. * @param index The index of the texture to replace
  103602. */
  103603. replaceTexture(texture: Texture, index: number): void;
  103604. /**
  103605. * Define the number of samples used if MSAA is enabled.
  103606. */
  103607. get samples(): number;
  103608. set samples(value: number);
  103609. /**
  103610. * Resize all the textures in the multi render target.
  103611. * Be careful as it will recreate all the data in the new texture.
  103612. * @param size Define the new size
  103613. */
  103614. resize(size: any): void;
  103615. /**
  103616. * Changes the number of render targets in this MRT
  103617. * Be careful as it will recreate all the data in the new texture.
  103618. * @param count new texture count
  103619. * @param options Specifies texture types and sampling modes for new textures
  103620. */
  103621. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103622. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103623. /**
  103624. * Dispose the render targets and their associated resources
  103625. */
  103626. dispose(): void;
  103627. /**
  103628. * Release all the underlying texture used as draw buffers.
  103629. */
  103630. releaseInternalTextures(): void;
  103631. }
  103632. }
  103633. declare module BABYLON {
  103634. /** @hidden */
  103635. export var imageProcessingPixelShader: {
  103636. name: string;
  103637. shader: string;
  103638. };
  103639. }
  103640. declare module BABYLON {
  103641. /**
  103642. * ImageProcessingPostProcess
  103643. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103644. */
  103645. export class ImageProcessingPostProcess extends PostProcess {
  103646. /**
  103647. * Default configuration related to image processing available in the PBR Material.
  103648. */
  103649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103650. /**
  103651. * Gets the image processing configuration used either in this material.
  103652. */
  103653. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103654. /**
  103655. * Sets the Default image processing configuration used either in the this material.
  103656. *
  103657. * If sets to null, the scene one is in use.
  103658. */
  103659. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103660. /**
  103661. * Keep track of the image processing observer to allow dispose and replace.
  103662. */
  103663. private _imageProcessingObserver;
  103664. /**
  103665. * Attaches a new image processing configuration to the PBR Material.
  103666. * @param configuration
  103667. */
  103668. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103669. /**
  103670. * If the post process is supported.
  103671. */
  103672. get isSupported(): boolean;
  103673. /**
  103674. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103675. */
  103676. get colorCurves(): Nullable<ColorCurves>;
  103677. /**
  103678. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103679. */
  103680. set colorCurves(value: Nullable<ColorCurves>);
  103681. /**
  103682. * Gets wether the color curves effect is enabled.
  103683. */
  103684. get colorCurvesEnabled(): boolean;
  103685. /**
  103686. * Sets wether the color curves effect is enabled.
  103687. */
  103688. set colorCurvesEnabled(value: boolean);
  103689. /**
  103690. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103691. */
  103692. get colorGradingTexture(): Nullable<BaseTexture>;
  103693. /**
  103694. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103695. */
  103696. set colorGradingTexture(value: Nullable<BaseTexture>);
  103697. /**
  103698. * Gets wether the color grading effect is enabled.
  103699. */
  103700. get colorGradingEnabled(): boolean;
  103701. /**
  103702. * Gets wether the color grading effect is enabled.
  103703. */
  103704. set colorGradingEnabled(value: boolean);
  103705. /**
  103706. * Gets exposure used in the effect.
  103707. */
  103708. get exposure(): number;
  103709. /**
  103710. * Sets exposure used in the effect.
  103711. */
  103712. set exposure(value: number);
  103713. /**
  103714. * Gets wether tonemapping is enabled or not.
  103715. */
  103716. get toneMappingEnabled(): boolean;
  103717. /**
  103718. * Sets wether tonemapping is enabled or not
  103719. */
  103720. set toneMappingEnabled(value: boolean);
  103721. /**
  103722. * Gets the type of tone mapping effect.
  103723. */
  103724. get toneMappingType(): number;
  103725. /**
  103726. * Sets the type of tone mapping effect.
  103727. */
  103728. set toneMappingType(value: number);
  103729. /**
  103730. * Gets contrast used in the effect.
  103731. */
  103732. get contrast(): number;
  103733. /**
  103734. * Sets contrast used in the effect.
  103735. */
  103736. set contrast(value: number);
  103737. /**
  103738. * Gets Vignette stretch size.
  103739. */
  103740. get vignetteStretch(): number;
  103741. /**
  103742. * Sets Vignette stretch size.
  103743. */
  103744. set vignetteStretch(value: number);
  103745. /**
  103746. * Gets Vignette centre X Offset.
  103747. */
  103748. get vignetteCentreX(): number;
  103749. /**
  103750. * Sets Vignette centre X Offset.
  103751. */
  103752. set vignetteCentreX(value: number);
  103753. /**
  103754. * Gets Vignette centre Y Offset.
  103755. */
  103756. get vignetteCentreY(): number;
  103757. /**
  103758. * Sets Vignette centre Y Offset.
  103759. */
  103760. set vignetteCentreY(value: number);
  103761. /**
  103762. * Gets Vignette weight or intensity of the vignette effect.
  103763. */
  103764. get vignetteWeight(): number;
  103765. /**
  103766. * Sets Vignette weight or intensity of the vignette effect.
  103767. */
  103768. set vignetteWeight(value: number);
  103769. /**
  103770. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103771. * if vignetteEnabled is set to true.
  103772. */
  103773. get vignetteColor(): Color4;
  103774. /**
  103775. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103776. * if vignetteEnabled is set to true.
  103777. */
  103778. set vignetteColor(value: Color4);
  103779. /**
  103780. * Gets Camera field of view used by the Vignette effect.
  103781. */
  103782. get vignetteCameraFov(): number;
  103783. /**
  103784. * Sets Camera field of view used by the Vignette effect.
  103785. */
  103786. set vignetteCameraFov(value: number);
  103787. /**
  103788. * Gets the vignette blend mode allowing different kind of effect.
  103789. */
  103790. get vignetteBlendMode(): number;
  103791. /**
  103792. * Sets the vignette blend mode allowing different kind of effect.
  103793. */
  103794. set vignetteBlendMode(value: number);
  103795. /**
  103796. * Gets wether the vignette effect is enabled.
  103797. */
  103798. get vignetteEnabled(): boolean;
  103799. /**
  103800. * Sets wether the vignette effect is enabled.
  103801. */
  103802. set vignetteEnabled(value: boolean);
  103803. private _fromLinearSpace;
  103804. /**
  103805. * Gets wether the input of the processing is in Gamma or Linear Space.
  103806. */
  103807. get fromLinearSpace(): boolean;
  103808. /**
  103809. * Sets wether the input of the processing is in Gamma or Linear Space.
  103810. */
  103811. set fromLinearSpace(value: boolean);
  103812. /**
  103813. * Defines cache preventing GC.
  103814. */
  103815. private _defines;
  103816. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103817. /**
  103818. * "ImageProcessingPostProcess"
  103819. * @returns "ImageProcessingPostProcess"
  103820. */
  103821. getClassName(): string;
  103822. /**
  103823. * @hidden
  103824. */
  103825. _updateParameters(): void;
  103826. dispose(camera?: Camera): void;
  103827. }
  103828. }
  103829. declare module BABYLON {
  103830. /**
  103831. * Interface for defining prepass effects in the prepass post-process pipeline
  103832. */
  103833. export interface PrePassEffectConfiguration {
  103834. /**
  103835. * Name of the effect
  103836. */
  103837. name: string;
  103838. /**
  103839. * Post process to attach for this effect
  103840. */
  103841. postProcess?: PostProcess;
  103842. /**
  103843. * Textures required in the MRT
  103844. */
  103845. texturesRequired: number[];
  103846. /**
  103847. * Is the effect enabled
  103848. */
  103849. enabled: boolean;
  103850. /**
  103851. * Disposes the effect configuration
  103852. */
  103853. dispose?: () => void;
  103854. /**
  103855. * Creates the associated post process
  103856. */
  103857. createPostProcess?: () => PostProcess;
  103858. }
  103859. }
  103860. declare module BABYLON {
  103861. /**
  103862. * Options to be used when creating a FresnelParameters.
  103863. */
  103864. export type IFresnelParametersCreationOptions = {
  103865. /**
  103866. * Define the color used on edges (grazing angle)
  103867. */
  103868. leftColor?: Color3;
  103869. /**
  103870. * Define the color used on center
  103871. */
  103872. rightColor?: Color3;
  103873. /**
  103874. * Define bias applied to computed fresnel term
  103875. */
  103876. bias?: number;
  103877. /**
  103878. * Defined the power exponent applied to fresnel term
  103879. */
  103880. power?: number;
  103881. /**
  103882. * Define if the fresnel effect is enable or not.
  103883. */
  103884. isEnabled?: boolean;
  103885. };
  103886. /**
  103887. * Serialized format for FresnelParameters.
  103888. */
  103889. export type IFresnelParametersSerialized = {
  103890. /**
  103891. * Define the color used on edges (grazing angle) [as an array]
  103892. */
  103893. leftColor: number[];
  103894. /**
  103895. * Define the color used on center [as an array]
  103896. */
  103897. rightColor: number[];
  103898. /**
  103899. * Define bias applied to computed fresnel term
  103900. */
  103901. bias: number;
  103902. /**
  103903. * Defined the power exponent applied to fresnel term
  103904. */
  103905. power?: number;
  103906. /**
  103907. * Define if the fresnel effect is enable or not.
  103908. */
  103909. isEnabled: boolean;
  103910. };
  103911. /**
  103912. * This represents all the required information to add a fresnel effect on a material:
  103913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103914. */
  103915. export class FresnelParameters {
  103916. private _isEnabled;
  103917. /**
  103918. * Define if the fresnel effect is enable or not.
  103919. */
  103920. get isEnabled(): boolean;
  103921. set isEnabled(value: boolean);
  103922. /**
  103923. * Define the color used on edges (grazing angle)
  103924. */
  103925. leftColor: Color3;
  103926. /**
  103927. * Define the color used on center
  103928. */
  103929. rightColor: Color3;
  103930. /**
  103931. * Define bias applied to computed fresnel term
  103932. */
  103933. bias: number;
  103934. /**
  103935. * Defined the power exponent applied to fresnel term
  103936. */
  103937. power: number;
  103938. /**
  103939. * Creates a new FresnelParameters object.
  103940. *
  103941. * @param options provide your own settings to optionally to override defaults
  103942. */
  103943. constructor(options?: IFresnelParametersCreationOptions);
  103944. /**
  103945. * Clones the current fresnel and its valuues
  103946. * @returns a clone fresnel configuration
  103947. */
  103948. clone(): FresnelParameters;
  103949. /**
  103950. * Determines equality between FresnelParameters objects
  103951. * @param otherFresnelParameters defines the second operand
  103952. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  103953. */
  103954. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  103955. /**
  103956. * Serializes the current fresnel parameters to a JSON representation.
  103957. * @return the JSON serialization
  103958. */
  103959. serialize(): IFresnelParametersSerialized;
  103960. /**
  103961. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  103962. * @param parsedFresnelParameters Define the JSON representation
  103963. * @returns the parsed parameters
  103964. */
  103965. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  103966. }
  103967. }
  103968. declare module BABYLON {
  103969. /**
  103970. * This groups all the flags used to control the materials channel.
  103971. */
  103972. export class MaterialFlags {
  103973. private static _DiffuseTextureEnabled;
  103974. /**
  103975. * Are diffuse textures enabled in the application.
  103976. */
  103977. static get DiffuseTextureEnabled(): boolean;
  103978. static set DiffuseTextureEnabled(value: boolean);
  103979. private static _DetailTextureEnabled;
  103980. /**
  103981. * Are detail textures enabled in the application.
  103982. */
  103983. static get DetailTextureEnabled(): boolean;
  103984. static set DetailTextureEnabled(value: boolean);
  103985. private static _AmbientTextureEnabled;
  103986. /**
  103987. * Are ambient textures enabled in the application.
  103988. */
  103989. static get AmbientTextureEnabled(): boolean;
  103990. static set AmbientTextureEnabled(value: boolean);
  103991. private static _OpacityTextureEnabled;
  103992. /**
  103993. * Are opacity textures enabled in the application.
  103994. */
  103995. static get OpacityTextureEnabled(): boolean;
  103996. static set OpacityTextureEnabled(value: boolean);
  103997. private static _ReflectionTextureEnabled;
  103998. /**
  103999. * Are reflection textures enabled in the application.
  104000. */
  104001. static get ReflectionTextureEnabled(): boolean;
  104002. static set ReflectionTextureEnabled(value: boolean);
  104003. private static _EmissiveTextureEnabled;
  104004. /**
  104005. * Are emissive textures enabled in the application.
  104006. */
  104007. static get EmissiveTextureEnabled(): boolean;
  104008. static set EmissiveTextureEnabled(value: boolean);
  104009. private static _SpecularTextureEnabled;
  104010. /**
  104011. * Are specular textures enabled in the application.
  104012. */
  104013. static get SpecularTextureEnabled(): boolean;
  104014. static set SpecularTextureEnabled(value: boolean);
  104015. private static _BumpTextureEnabled;
  104016. /**
  104017. * Are bump textures enabled in the application.
  104018. */
  104019. static get BumpTextureEnabled(): boolean;
  104020. static set BumpTextureEnabled(value: boolean);
  104021. private static _LightmapTextureEnabled;
  104022. /**
  104023. * Are lightmap textures enabled in the application.
  104024. */
  104025. static get LightmapTextureEnabled(): boolean;
  104026. static set LightmapTextureEnabled(value: boolean);
  104027. private static _RefractionTextureEnabled;
  104028. /**
  104029. * Are refraction textures enabled in the application.
  104030. */
  104031. static get RefractionTextureEnabled(): boolean;
  104032. static set RefractionTextureEnabled(value: boolean);
  104033. private static _ColorGradingTextureEnabled;
  104034. /**
  104035. * Are color grading textures enabled in the application.
  104036. */
  104037. static get ColorGradingTextureEnabled(): boolean;
  104038. static set ColorGradingTextureEnabled(value: boolean);
  104039. private static _FresnelEnabled;
  104040. /**
  104041. * Are fresnels enabled in the application.
  104042. */
  104043. static get FresnelEnabled(): boolean;
  104044. static set FresnelEnabled(value: boolean);
  104045. private static _ClearCoatTextureEnabled;
  104046. /**
  104047. * Are clear coat textures enabled in the application.
  104048. */
  104049. static get ClearCoatTextureEnabled(): boolean;
  104050. static set ClearCoatTextureEnabled(value: boolean);
  104051. private static _ClearCoatBumpTextureEnabled;
  104052. /**
  104053. * Are clear coat bump textures enabled in the application.
  104054. */
  104055. static get ClearCoatBumpTextureEnabled(): boolean;
  104056. static set ClearCoatBumpTextureEnabled(value: boolean);
  104057. private static _ClearCoatTintTextureEnabled;
  104058. /**
  104059. * Are clear coat tint textures enabled in the application.
  104060. */
  104061. static get ClearCoatTintTextureEnabled(): boolean;
  104062. static set ClearCoatTintTextureEnabled(value: boolean);
  104063. private static _SheenTextureEnabled;
  104064. /**
  104065. * Are sheen textures enabled in the application.
  104066. */
  104067. static get SheenTextureEnabled(): boolean;
  104068. static set SheenTextureEnabled(value: boolean);
  104069. private static _AnisotropicTextureEnabled;
  104070. /**
  104071. * Are anisotropic textures enabled in the application.
  104072. */
  104073. static get AnisotropicTextureEnabled(): boolean;
  104074. static set AnisotropicTextureEnabled(value: boolean);
  104075. private static _ThicknessTextureEnabled;
  104076. /**
  104077. * Are thickness textures enabled in the application.
  104078. */
  104079. static get ThicknessTextureEnabled(): boolean;
  104080. static set ThicknessTextureEnabled(value: boolean);
  104081. }
  104082. }
  104083. declare module BABYLON {
  104084. /** @hidden */
  104085. export var defaultFragmentDeclaration: {
  104086. name: string;
  104087. shader: string;
  104088. };
  104089. }
  104090. declare module BABYLON {
  104091. /** @hidden */
  104092. export var defaultUboDeclaration: {
  104093. name: string;
  104094. shader: string;
  104095. };
  104096. }
  104097. declare module BABYLON {
  104098. /** @hidden */
  104099. export var prePassDeclaration: {
  104100. name: string;
  104101. shader: string;
  104102. };
  104103. }
  104104. declare module BABYLON {
  104105. /** @hidden */
  104106. export var lightFragmentDeclaration: {
  104107. name: string;
  104108. shader: string;
  104109. };
  104110. }
  104111. declare module BABYLON {
  104112. /** @hidden */
  104113. export var lightUboDeclaration: {
  104114. name: string;
  104115. shader: string;
  104116. };
  104117. }
  104118. declare module BABYLON {
  104119. /** @hidden */
  104120. export var lightsFragmentFunctions: {
  104121. name: string;
  104122. shader: string;
  104123. };
  104124. }
  104125. declare module BABYLON {
  104126. /** @hidden */
  104127. export var shadowsFragmentFunctions: {
  104128. name: string;
  104129. shader: string;
  104130. };
  104131. }
  104132. declare module BABYLON {
  104133. /** @hidden */
  104134. export var fresnelFunction: {
  104135. name: string;
  104136. shader: string;
  104137. };
  104138. }
  104139. declare module BABYLON {
  104140. /** @hidden */
  104141. export var bumpFragmentMainFunctions: {
  104142. name: string;
  104143. shader: string;
  104144. };
  104145. }
  104146. declare module BABYLON {
  104147. /** @hidden */
  104148. export var bumpFragmentFunctions: {
  104149. name: string;
  104150. shader: string;
  104151. };
  104152. }
  104153. declare module BABYLON {
  104154. /** @hidden */
  104155. export var logDepthDeclaration: {
  104156. name: string;
  104157. shader: string;
  104158. };
  104159. }
  104160. declare module BABYLON {
  104161. /** @hidden */
  104162. export var bumpFragment: {
  104163. name: string;
  104164. shader: string;
  104165. };
  104166. }
  104167. declare module BABYLON {
  104168. /** @hidden */
  104169. export var depthPrePass: {
  104170. name: string;
  104171. shader: string;
  104172. };
  104173. }
  104174. declare module BABYLON {
  104175. /** @hidden */
  104176. export var lightFragment: {
  104177. name: string;
  104178. shader: string;
  104179. };
  104180. }
  104181. declare module BABYLON {
  104182. /** @hidden */
  104183. export var logDepthFragment: {
  104184. name: string;
  104185. shader: string;
  104186. };
  104187. }
  104188. declare module BABYLON {
  104189. /** @hidden */
  104190. export var defaultPixelShader: {
  104191. name: string;
  104192. shader: string;
  104193. };
  104194. }
  104195. declare module BABYLON {
  104196. /** @hidden */
  104197. export var defaultVertexDeclaration: {
  104198. name: string;
  104199. shader: string;
  104200. };
  104201. }
  104202. declare module BABYLON {
  104203. /** @hidden */
  104204. export var prePassVertexDeclaration: {
  104205. name: string;
  104206. shader: string;
  104207. };
  104208. }
  104209. declare module BABYLON {
  104210. /** @hidden */
  104211. export var bumpVertexDeclaration: {
  104212. name: string;
  104213. shader: string;
  104214. };
  104215. }
  104216. declare module BABYLON {
  104217. /** @hidden */
  104218. export var prePassVertex: {
  104219. name: string;
  104220. shader: string;
  104221. };
  104222. }
  104223. declare module BABYLON {
  104224. /** @hidden */
  104225. export var bumpVertex: {
  104226. name: string;
  104227. shader: string;
  104228. };
  104229. }
  104230. declare module BABYLON {
  104231. /** @hidden */
  104232. export var fogVertex: {
  104233. name: string;
  104234. shader: string;
  104235. };
  104236. }
  104237. declare module BABYLON {
  104238. /** @hidden */
  104239. export var shadowsVertex: {
  104240. name: string;
  104241. shader: string;
  104242. };
  104243. }
  104244. declare module BABYLON {
  104245. /** @hidden */
  104246. export var pointCloudVertex: {
  104247. name: string;
  104248. shader: string;
  104249. };
  104250. }
  104251. declare module BABYLON {
  104252. /** @hidden */
  104253. export var logDepthVertex: {
  104254. name: string;
  104255. shader: string;
  104256. };
  104257. }
  104258. declare module BABYLON {
  104259. /** @hidden */
  104260. export var defaultVertexShader: {
  104261. name: string;
  104262. shader: string;
  104263. };
  104264. }
  104265. declare module BABYLON {
  104266. /**
  104267. * @hidden
  104268. */
  104269. export interface IMaterialDetailMapDefines {
  104270. DETAIL: boolean;
  104271. DETAILDIRECTUV: number;
  104272. DETAIL_NORMALBLENDMETHOD: number;
  104273. /** @hidden */
  104274. _areTexturesDirty: boolean;
  104275. }
  104276. /**
  104277. * Define the code related to the detail map parameters of a material
  104278. *
  104279. * Inspired from:
  104280. * 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
  104281. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104282. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104283. */
  104284. export class DetailMapConfiguration {
  104285. private _texture;
  104286. /**
  104287. * The detail texture of the material.
  104288. */
  104289. texture: Nullable<BaseTexture>;
  104290. /**
  104291. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104292. * Bigger values mean stronger blending
  104293. */
  104294. diffuseBlendLevel: number;
  104295. /**
  104296. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104297. * Bigger values mean stronger blending. Only used with PBR materials
  104298. */
  104299. roughnessBlendLevel: number;
  104300. /**
  104301. * Defines how strong the bump effect from the detail map is
  104302. * Bigger values mean stronger effect
  104303. */
  104304. bumpLevel: number;
  104305. private _normalBlendMethod;
  104306. /**
  104307. * The method used to blend the bump and detail normals together
  104308. */
  104309. normalBlendMethod: number;
  104310. private _isEnabled;
  104311. /**
  104312. * Enable or disable the detail map on this material
  104313. */
  104314. isEnabled: boolean;
  104315. /** @hidden */
  104316. private _internalMarkAllSubMeshesAsTexturesDirty;
  104317. /** @hidden */
  104318. _markAllSubMeshesAsTexturesDirty(): void;
  104319. /**
  104320. * Instantiate a new detail map
  104321. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104322. */
  104323. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104324. /**
  104325. * Gets whether the submesh is ready to be used or not.
  104326. * @param defines the list of "defines" to update.
  104327. * @param scene defines the scene the material belongs to.
  104328. * @returns - boolean indicating that the submesh is ready or not.
  104329. */
  104330. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104331. /**
  104332. * Update the defines for detail map usage
  104333. * @param defines the list of "defines" to update.
  104334. * @param scene defines the scene the material belongs to.
  104335. */
  104336. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104337. /**
  104338. * Binds the material data.
  104339. * @param uniformBuffer defines the Uniform buffer to fill in.
  104340. * @param scene defines the scene the material belongs to.
  104341. * @param isFrozen defines whether the material is frozen or not.
  104342. */
  104343. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104344. /**
  104345. * Checks to see if a texture is used in the material.
  104346. * @param texture - Base texture to use.
  104347. * @returns - Boolean specifying if a texture is used in the material.
  104348. */
  104349. hasTexture(texture: BaseTexture): boolean;
  104350. /**
  104351. * Returns an array of the actively used textures.
  104352. * @param activeTextures Array of BaseTextures
  104353. */
  104354. getActiveTextures(activeTextures: BaseTexture[]): void;
  104355. /**
  104356. * Returns the animatable textures.
  104357. * @param animatables Array of animatable textures.
  104358. */
  104359. getAnimatables(animatables: IAnimatable[]): void;
  104360. /**
  104361. * Disposes the resources of the material.
  104362. * @param forceDisposeTextures - Forces the disposal of all textures.
  104363. */
  104364. dispose(forceDisposeTextures?: boolean): void;
  104365. /**
  104366. * Get the current class name useful for serialization or dynamic coding.
  104367. * @returns "DetailMap"
  104368. */
  104369. getClassName(): string;
  104370. /**
  104371. * Add the required uniforms to the current list.
  104372. * @param uniforms defines the current uniform list.
  104373. */
  104374. static AddUniforms(uniforms: string[]): void;
  104375. /**
  104376. * Add the required samplers to the current list.
  104377. * @param samplers defines the current sampler list.
  104378. */
  104379. static AddSamplers(samplers: string[]): void;
  104380. /**
  104381. * Add the required uniforms to the current buffer.
  104382. * @param uniformBuffer defines the current uniform buffer.
  104383. */
  104384. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104385. /**
  104386. * Makes a duplicate of the current instance into another one.
  104387. * @param detailMap define the instance where to copy the info
  104388. */
  104389. copyTo(detailMap: DetailMapConfiguration): void;
  104390. /**
  104391. * Serializes this detail map instance
  104392. * @returns - An object with the serialized instance.
  104393. */
  104394. serialize(): any;
  104395. /**
  104396. * Parses a detail map setting from a serialized object.
  104397. * @param source - Serialized object.
  104398. * @param scene Defines the scene we are parsing for
  104399. * @param rootUrl Defines the rootUrl to load from
  104400. */
  104401. parse(source: any, scene: Scene, rootUrl: string): void;
  104402. }
  104403. }
  104404. declare module BABYLON {
  104405. /** @hidden */
  104406. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104407. MAINUV1: boolean;
  104408. MAINUV2: boolean;
  104409. DIFFUSE: boolean;
  104410. DIFFUSEDIRECTUV: number;
  104411. DETAIL: boolean;
  104412. DETAILDIRECTUV: number;
  104413. DETAIL_NORMALBLENDMETHOD: number;
  104414. AMBIENT: boolean;
  104415. AMBIENTDIRECTUV: number;
  104416. OPACITY: boolean;
  104417. OPACITYDIRECTUV: number;
  104418. OPACITYRGB: boolean;
  104419. REFLECTION: boolean;
  104420. EMISSIVE: boolean;
  104421. EMISSIVEDIRECTUV: number;
  104422. SPECULAR: boolean;
  104423. SPECULARDIRECTUV: number;
  104424. BUMP: boolean;
  104425. BUMPDIRECTUV: number;
  104426. PARALLAX: boolean;
  104427. PARALLAXOCCLUSION: boolean;
  104428. SPECULAROVERALPHA: boolean;
  104429. CLIPPLANE: boolean;
  104430. CLIPPLANE2: boolean;
  104431. CLIPPLANE3: boolean;
  104432. CLIPPLANE4: boolean;
  104433. CLIPPLANE5: boolean;
  104434. CLIPPLANE6: boolean;
  104435. ALPHATEST: boolean;
  104436. DEPTHPREPASS: boolean;
  104437. ALPHAFROMDIFFUSE: boolean;
  104438. POINTSIZE: boolean;
  104439. FOG: boolean;
  104440. SPECULARTERM: boolean;
  104441. DIFFUSEFRESNEL: boolean;
  104442. OPACITYFRESNEL: boolean;
  104443. REFLECTIONFRESNEL: boolean;
  104444. REFRACTIONFRESNEL: boolean;
  104445. EMISSIVEFRESNEL: boolean;
  104446. FRESNEL: boolean;
  104447. NORMAL: boolean;
  104448. UV1: boolean;
  104449. UV2: boolean;
  104450. VERTEXCOLOR: boolean;
  104451. VERTEXALPHA: boolean;
  104452. NUM_BONE_INFLUENCERS: number;
  104453. BonesPerMesh: number;
  104454. BONETEXTURE: boolean;
  104455. BONES_VELOCITY_ENABLED: boolean;
  104456. INSTANCES: boolean;
  104457. THIN_INSTANCES: boolean;
  104458. GLOSSINESS: boolean;
  104459. ROUGHNESS: boolean;
  104460. EMISSIVEASILLUMINATION: boolean;
  104461. LINKEMISSIVEWITHDIFFUSE: boolean;
  104462. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104463. LIGHTMAP: boolean;
  104464. LIGHTMAPDIRECTUV: number;
  104465. OBJECTSPACE_NORMALMAP: boolean;
  104466. USELIGHTMAPASSHADOWMAP: boolean;
  104467. REFLECTIONMAP_3D: boolean;
  104468. REFLECTIONMAP_SPHERICAL: boolean;
  104469. REFLECTIONMAP_PLANAR: boolean;
  104470. REFLECTIONMAP_CUBIC: boolean;
  104471. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104472. REFLECTIONMAP_PROJECTION: boolean;
  104473. REFLECTIONMAP_SKYBOX: boolean;
  104474. REFLECTIONMAP_EXPLICIT: boolean;
  104475. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104476. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104477. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104478. INVERTCUBICMAP: boolean;
  104479. LOGARITHMICDEPTH: boolean;
  104480. REFRACTION: boolean;
  104481. REFRACTIONMAP_3D: boolean;
  104482. REFLECTIONOVERALPHA: boolean;
  104483. TWOSIDEDLIGHTING: boolean;
  104484. SHADOWFLOAT: boolean;
  104485. MORPHTARGETS: boolean;
  104486. MORPHTARGETS_NORMAL: boolean;
  104487. MORPHTARGETS_TANGENT: boolean;
  104488. MORPHTARGETS_UV: boolean;
  104489. NUM_MORPH_INFLUENCERS: number;
  104490. NONUNIFORMSCALING: boolean;
  104491. PREMULTIPLYALPHA: boolean;
  104492. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104493. ALPHABLEND: boolean;
  104494. PREPASS: boolean;
  104495. PREPASS_IRRADIANCE: boolean;
  104496. PREPASS_IRRADIANCE_INDEX: number;
  104497. PREPASS_ALBEDO: boolean;
  104498. PREPASS_ALBEDO_INDEX: number;
  104499. PREPASS_DEPTHNORMAL: boolean;
  104500. PREPASS_DEPTHNORMAL_INDEX: number;
  104501. PREPASS_POSITION: boolean;
  104502. PREPASS_POSITION_INDEX: number;
  104503. PREPASS_VELOCITY: boolean;
  104504. PREPASS_VELOCITY_INDEX: number;
  104505. PREPASS_REFLECTIVITY: boolean;
  104506. PREPASS_REFLECTIVITY_INDEX: number;
  104507. SCENE_MRT_COUNT: number;
  104508. RGBDLIGHTMAP: boolean;
  104509. RGBDREFLECTION: boolean;
  104510. RGBDREFRACTION: boolean;
  104511. IMAGEPROCESSING: boolean;
  104512. VIGNETTE: boolean;
  104513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104514. VIGNETTEBLENDMODEOPAQUE: boolean;
  104515. TONEMAPPING: boolean;
  104516. TONEMAPPING_ACES: boolean;
  104517. CONTRAST: boolean;
  104518. COLORCURVES: boolean;
  104519. COLORGRADING: boolean;
  104520. COLORGRADING3D: boolean;
  104521. SAMPLER3DGREENDEPTH: boolean;
  104522. SAMPLER3DBGRMAP: boolean;
  104523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104524. MULTIVIEW: boolean;
  104525. /**
  104526. * If the reflection texture on this material is in linear color space
  104527. * @hidden
  104528. */
  104529. IS_REFLECTION_LINEAR: boolean;
  104530. /**
  104531. * If the refraction texture on this material is in linear color space
  104532. * @hidden
  104533. */
  104534. IS_REFRACTION_LINEAR: boolean;
  104535. EXPOSURE: boolean;
  104536. constructor();
  104537. setReflectionMode(modeToEnable: string): void;
  104538. }
  104539. /**
  104540. * This is the default material used in Babylon. It is the best trade off between quality
  104541. * and performances.
  104542. * @see https://doc.babylonjs.com/babylon101/materials
  104543. */
  104544. export class StandardMaterial extends PushMaterial {
  104545. private _diffuseTexture;
  104546. /**
  104547. * The basic texture of the material as viewed under a light.
  104548. */
  104549. diffuseTexture: Nullable<BaseTexture>;
  104550. private _ambientTexture;
  104551. /**
  104552. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104553. */
  104554. ambientTexture: Nullable<BaseTexture>;
  104555. private _opacityTexture;
  104556. /**
  104557. * Define the transparency of the material from a texture.
  104558. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104559. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104560. */
  104561. opacityTexture: Nullable<BaseTexture>;
  104562. private _reflectionTexture;
  104563. /**
  104564. * Define the texture used to display the reflection.
  104565. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104566. */
  104567. reflectionTexture: Nullable<BaseTexture>;
  104568. private _emissiveTexture;
  104569. /**
  104570. * Define texture of the material as if self lit.
  104571. * This will be mixed in the final result even in the absence of light.
  104572. */
  104573. emissiveTexture: Nullable<BaseTexture>;
  104574. private _specularTexture;
  104575. /**
  104576. * Define how the color and intensity of the highlight given by the light in the material.
  104577. */
  104578. specularTexture: Nullable<BaseTexture>;
  104579. private _bumpTexture;
  104580. /**
  104581. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104582. * 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.
  104583. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104584. */
  104585. bumpTexture: Nullable<BaseTexture>;
  104586. private _lightmapTexture;
  104587. /**
  104588. * Complex lighting can be computationally expensive to compute at runtime.
  104589. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104590. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104591. */
  104592. lightmapTexture: Nullable<BaseTexture>;
  104593. private _refractionTexture;
  104594. /**
  104595. * Define the texture used to display the refraction.
  104596. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104597. */
  104598. refractionTexture: Nullable<BaseTexture>;
  104599. /**
  104600. * The color of the material lit by the environmental background lighting.
  104601. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104602. */
  104603. ambientColor: Color3;
  104604. /**
  104605. * The basic color of the material as viewed under a light.
  104606. */
  104607. diffuseColor: Color3;
  104608. /**
  104609. * Define how the color and intensity of the highlight given by the light in the material.
  104610. */
  104611. specularColor: Color3;
  104612. /**
  104613. * Define the color of the material as if self lit.
  104614. * This will be mixed in the final result even in the absence of light.
  104615. */
  104616. emissiveColor: Color3;
  104617. /**
  104618. * Defines how sharp are the highlights in the material.
  104619. * The bigger the value the sharper giving a more glossy feeling to the result.
  104620. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104621. */
  104622. specularPower: number;
  104623. private _useAlphaFromDiffuseTexture;
  104624. /**
  104625. * Does the transparency come from the diffuse texture alpha channel.
  104626. */
  104627. useAlphaFromDiffuseTexture: boolean;
  104628. private _useEmissiveAsIllumination;
  104629. /**
  104630. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104631. */
  104632. useEmissiveAsIllumination: boolean;
  104633. private _linkEmissiveWithDiffuse;
  104634. /**
  104635. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104636. * the emissive level when the final color is close to one.
  104637. */
  104638. linkEmissiveWithDiffuse: boolean;
  104639. private _useSpecularOverAlpha;
  104640. /**
  104641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104643. */
  104644. useSpecularOverAlpha: boolean;
  104645. private _useReflectionOverAlpha;
  104646. /**
  104647. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104648. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104649. */
  104650. useReflectionOverAlpha: boolean;
  104651. private _disableLighting;
  104652. /**
  104653. * Does lights from the scene impacts this material.
  104654. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104655. */
  104656. disableLighting: boolean;
  104657. private _useObjectSpaceNormalMap;
  104658. /**
  104659. * Allows using an object space normal map (instead of tangent space).
  104660. */
  104661. useObjectSpaceNormalMap: boolean;
  104662. private _useParallax;
  104663. /**
  104664. * Is parallax enabled or not.
  104665. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104666. */
  104667. useParallax: boolean;
  104668. private _useParallaxOcclusion;
  104669. /**
  104670. * Is parallax occlusion enabled or not.
  104671. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104672. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104673. */
  104674. useParallaxOcclusion: boolean;
  104675. /**
  104676. * 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.
  104677. */
  104678. parallaxScaleBias: number;
  104679. private _roughness;
  104680. /**
  104681. * Helps to define how blurry the reflections should appears in the material.
  104682. */
  104683. roughness: number;
  104684. /**
  104685. * In case of refraction, define the value of the index of refraction.
  104686. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104687. */
  104688. indexOfRefraction: number;
  104689. /**
  104690. * Invert the refraction texture alongside the y axis.
  104691. * It can be useful with procedural textures or probe for instance.
  104692. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104693. */
  104694. invertRefractionY: boolean;
  104695. /**
  104696. * Defines the alpha limits in alpha test mode.
  104697. */
  104698. alphaCutOff: number;
  104699. private _useLightmapAsShadowmap;
  104700. /**
  104701. * In case of light mapping, define whether the map contains light or shadow informations.
  104702. */
  104703. useLightmapAsShadowmap: boolean;
  104704. private _diffuseFresnelParameters;
  104705. /**
  104706. * Define the diffuse fresnel parameters of the material.
  104707. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104708. */
  104709. diffuseFresnelParameters: FresnelParameters;
  104710. private _opacityFresnelParameters;
  104711. /**
  104712. * Define the opacity fresnel parameters of the material.
  104713. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104714. */
  104715. opacityFresnelParameters: FresnelParameters;
  104716. private _reflectionFresnelParameters;
  104717. /**
  104718. * Define the reflection fresnel parameters of the material.
  104719. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104720. */
  104721. reflectionFresnelParameters: FresnelParameters;
  104722. private _refractionFresnelParameters;
  104723. /**
  104724. * Define the refraction fresnel parameters of the material.
  104725. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104726. */
  104727. refractionFresnelParameters: FresnelParameters;
  104728. private _emissiveFresnelParameters;
  104729. /**
  104730. * Define the emissive fresnel parameters of the material.
  104731. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104732. */
  104733. emissiveFresnelParameters: FresnelParameters;
  104734. private _useReflectionFresnelFromSpecular;
  104735. /**
  104736. * If true automatically deducts the fresnels values from the material specularity.
  104737. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104738. */
  104739. useReflectionFresnelFromSpecular: boolean;
  104740. private _useGlossinessFromSpecularMapAlpha;
  104741. /**
  104742. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104743. */
  104744. useGlossinessFromSpecularMapAlpha: boolean;
  104745. private _maxSimultaneousLights;
  104746. /**
  104747. * Defines the maximum number of lights that can be used in the material
  104748. */
  104749. maxSimultaneousLights: number;
  104750. private _invertNormalMapX;
  104751. /**
  104752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104753. */
  104754. invertNormalMapX: boolean;
  104755. private _invertNormalMapY;
  104756. /**
  104757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104758. */
  104759. invertNormalMapY: boolean;
  104760. private _twoSidedLighting;
  104761. /**
  104762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104763. */
  104764. twoSidedLighting: boolean;
  104765. /**
  104766. * Default configuration related to image processing available in the standard Material.
  104767. */
  104768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104769. /**
  104770. * Gets the image processing configuration used either in this material.
  104771. */
  104772. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104773. /**
  104774. * Sets the Default image processing configuration used either in the this material.
  104775. *
  104776. * If sets to null, the scene one is in use.
  104777. */
  104778. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104779. /**
  104780. * Keep track of the image processing observer to allow dispose and replace.
  104781. */
  104782. private _imageProcessingObserver;
  104783. /**
  104784. * Attaches a new image processing configuration to the Standard Material.
  104785. * @param configuration
  104786. */
  104787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104788. /**
  104789. * Defines additionnal PrePass parameters for the material.
  104790. */
  104791. readonly prePassConfiguration: PrePassConfiguration;
  104792. /**
  104793. * Gets wether the color curves effect is enabled.
  104794. */
  104795. get cameraColorCurvesEnabled(): boolean;
  104796. /**
  104797. * Sets wether the color curves effect is enabled.
  104798. */
  104799. set cameraColorCurvesEnabled(value: boolean);
  104800. /**
  104801. * Gets wether the color grading effect is enabled.
  104802. */
  104803. get cameraColorGradingEnabled(): boolean;
  104804. /**
  104805. * Gets wether the color grading effect is enabled.
  104806. */
  104807. set cameraColorGradingEnabled(value: boolean);
  104808. /**
  104809. * Gets wether tonemapping is enabled or not.
  104810. */
  104811. get cameraToneMappingEnabled(): boolean;
  104812. /**
  104813. * Sets wether tonemapping is enabled or not
  104814. */
  104815. set cameraToneMappingEnabled(value: boolean);
  104816. /**
  104817. * The camera exposure used on this material.
  104818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104819. * This corresponds to a photographic exposure.
  104820. */
  104821. get cameraExposure(): number;
  104822. /**
  104823. * The camera exposure used on this material.
  104824. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104825. * This corresponds to a photographic exposure.
  104826. */
  104827. set cameraExposure(value: number);
  104828. /**
  104829. * Gets The camera contrast used on this material.
  104830. */
  104831. get cameraContrast(): number;
  104832. /**
  104833. * Sets The camera contrast used on this material.
  104834. */
  104835. set cameraContrast(value: number);
  104836. /**
  104837. * Gets the Color Grading 2D Lookup Texture.
  104838. */
  104839. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104840. /**
  104841. * Sets the Color Grading 2D Lookup Texture.
  104842. */
  104843. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104844. /**
  104845. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104846. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104847. * 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;
  104848. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104849. */
  104850. get cameraColorCurves(): Nullable<ColorCurves>;
  104851. /**
  104852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104854. * 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;
  104855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104856. */
  104857. set cameraColorCurves(value: Nullable<ColorCurves>);
  104858. /**
  104859. * Can this material render to several textures at once
  104860. */
  104861. get canRenderToMRT(): boolean;
  104862. /**
  104863. * Defines the detail map parameters for the material.
  104864. */
  104865. readonly detailMap: DetailMapConfiguration;
  104866. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104867. protected _worldViewProjectionMatrix: Matrix;
  104868. protected _globalAmbientColor: Color3;
  104869. protected _useLogarithmicDepth: boolean;
  104870. protected _rebuildInParallel: boolean;
  104871. /**
  104872. * Instantiates a new standard material.
  104873. * This is the default material used in Babylon. It is the best trade off between quality
  104874. * and performances.
  104875. * @see https://doc.babylonjs.com/babylon101/materials
  104876. * @param name Define the name of the material in the scene
  104877. * @param scene Define the scene the material belong to
  104878. */
  104879. constructor(name: string, scene: Scene);
  104880. /**
  104881. * Gets a boolean indicating that current material needs to register RTT
  104882. */
  104883. get hasRenderTargetTextures(): boolean;
  104884. /**
  104885. * Gets the current class name of the material e.g. "StandardMaterial"
  104886. * Mainly use in serialization.
  104887. * @returns the class name
  104888. */
  104889. getClassName(): string;
  104890. /**
  104891. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104892. * You can try switching to logarithmic depth.
  104893. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104894. */
  104895. get useLogarithmicDepth(): boolean;
  104896. set useLogarithmicDepth(value: boolean);
  104897. /**
  104898. * Specifies if the material will require alpha blending
  104899. * @returns a boolean specifying if alpha blending is needed
  104900. */
  104901. needAlphaBlending(): boolean;
  104902. /**
  104903. * Specifies if this material should be rendered in alpha test mode
  104904. * @returns a boolean specifying if an alpha test is needed.
  104905. */
  104906. needAlphaTesting(): boolean;
  104907. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104908. /**
  104909. * Get the texture used for alpha test purpose.
  104910. * @returns the diffuse texture in case of the standard material.
  104911. */
  104912. getAlphaTestTexture(): Nullable<BaseTexture>;
  104913. /**
  104914. * Get if the submesh is ready to be used and all its information available.
  104915. * Child classes can use it to update shaders
  104916. * @param mesh defines the mesh to check
  104917. * @param subMesh defines which submesh to check
  104918. * @param useInstances specifies that instances should be used
  104919. * @returns a boolean indicating that the submesh is ready or not
  104920. */
  104921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104922. /**
  104923. * Builds the material UBO layouts.
  104924. * Used internally during the effect preparation.
  104925. */
  104926. buildUniformLayout(): void;
  104927. /**
  104928. * Unbinds the material from the mesh
  104929. */
  104930. unbind(): void;
  104931. /**
  104932. * Binds the submesh to this material by preparing the effect and shader to draw
  104933. * @param world defines the world transformation matrix
  104934. * @param mesh defines the mesh containing the submesh
  104935. * @param subMesh defines the submesh to bind the material to
  104936. */
  104937. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104938. /**
  104939. * Get the list of animatables in the material.
  104940. * @returns the list of animatables object used in the material
  104941. */
  104942. getAnimatables(): IAnimatable[];
  104943. /**
  104944. * Gets the active textures from the material
  104945. * @returns an array of textures
  104946. */
  104947. getActiveTextures(): BaseTexture[];
  104948. /**
  104949. * Specifies if the material uses a texture
  104950. * @param texture defines the texture to check against the material
  104951. * @returns a boolean specifying if the material uses the texture
  104952. */
  104953. hasTexture(texture: BaseTexture): boolean;
  104954. /**
  104955. * Disposes the material
  104956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104958. */
  104959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104960. /**
  104961. * Makes a duplicate of the material, and gives it a new name
  104962. * @param name defines the new name for the duplicated material
  104963. * @returns the cloned material
  104964. */
  104965. clone(name: string): StandardMaterial;
  104966. /**
  104967. * Serializes this material in a JSON representation
  104968. * @returns the serialized material object
  104969. */
  104970. serialize(): any;
  104971. /**
  104972. * Creates a standard material from parsed material data
  104973. * @param source defines the JSON representation of the material
  104974. * @param scene defines the hosting scene
  104975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104976. * @returns a new standard material
  104977. */
  104978. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104979. /**
  104980. * Are diffuse textures enabled in the application.
  104981. */
  104982. static get DiffuseTextureEnabled(): boolean;
  104983. static set DiffuseTextureEnabled(value: boolean);
  104984. /**
  104985. * Are detail textures enabled in the application.
  104986. */
  104987. static get DetailTextureEnabled(): boolean;
  104988. static set DetailTextureEnabled(value: boolean);
  104989. /**
  104990. * Are ambient textures enabled in the application.
  104991. */
  104992. static get AmbientTextureEnabled(): boolean;
  104993. static set AmbientTextureEnabled(value: boolean);
  104994. /**
  104995. * Are opacity textures enabled in the application.
  104996. */
  104997. static get OpacityTextureEnabled(): boolean;
  104998. static set OpacityTextureEnabled(value: boolean);
  104999. /**
  105000. * Are reflection textures enabled in the application.
  105001. */
  105002. static get ReflectionTextureEnabled(): boolean;
  105003. static set ReflectionTextureEnabled(value: boolean);
  105004. /**
  105005. * Are emissive textures enabled in the application.
  105006. */
  105007. static get EmissiveTextureEnabled(): boolean;
  105008. static set EmissiveTextureEnabled(value: boolean);
  105009. /**
  105010. * Are specular textures enabled in the application.
  105011. */
  105012. static get SpecularTextureEnabled(): boolean;
  105013. static set SpecularTextureEnabled(value: boolean);
  105014. /**
  105015. * Are bump textures enabled in the application.
  105016. */
  105017. static get BumpTextureEnabled(): boolean;
  105018. static set BumpTextureEnabled(value: boolean);
  105019. /**
  105020. * Are lightmap textures enabled in the application.
  105021. */
  105022. static get LightmapTextureEnabled(): boolean;
  105023. static set LightmapTextureEnabled(value: boolean);
  105024. /**
  105025. * Are refraction textures enabled in the application.
  105026. */
  105027. static get RefractionTextureEnabled(): boolean;
  105028. static set RefractionTextureEnabled(value: boolean);
  105029. /**
  105030. * Are color grading textures enabled in the application.
  105031. */
  105032. static get ColorGradingTextureEnabled(): boolean;
  105033. static set ColorGradingTextureEnabled(value: boolean);
  105034. /**
  105035. * Are fresnels enabled in the application.
  105036. */
  105037. static get FresnelEnabled(): boolean;
  105038. static set FresnelEnabled(value: boolean);
  105039. }
  105040. }
  105041. declare module BABYLON {
  105042. /** @hidden */
  105043. export var rgbdDecodePixelShader: {
  105044. name: string;
  105045. shader: string;
  105046. };
  105047. }
  105048. declare module BABYLON {
  105049. /**
  105050. * Class used to host RGBD texture specific utilities
  105051. */
  105052. export class RGBDTextureTools {
  105053. /**
  105054. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105055. * @param texture the texture to expand.
  105056. */
  105057. static ExpandRGBDTexture(texture: Texture): void;
  105058. }
  105059. }
  105060. declare module BABYLON {
  105061. /**
  105062. * Class used to host texture specific utilities
  105063. */
  105064. export class BRDFTextureTools {
  105065. /**
  105066. * Prevents texture cache collision
  105067. */
  105068. private static _instanceNumber;
  105069. /**
  105070. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105071. * @param scene defines the hosting scene
  105072. * @returns the environment BRDF texture
  105073. */
  105074. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105075. private static _environmentBRDFBase64Texture;
  105076. }
  105077. }
  105078. declare module BABYLON {
  105079. /**
  105080. * @hidden
  105081. */
  105082. export interface IMaterialClearCoatDefines {
  105083. CLEARCOAT: boolean;
  105084. CLEARCOAT_DEFAULTIOR: boolean;
  105085. CLEARCOAT_TEXTURE: boolean;
  105086. CLEARCOAT_TEXTUREDIRECTUV: number;
  105087. CLEARCOAT_BUMP: boolean;
  105088. CLEARCOAT_BUMPDIRECTUV: number;
  105089. CLEARCOAT_REMAP_F0: boolean;
  105090. CLEARCOAT_TINT: boolean;
  105091. CLEARCOAT_TINT_TEXTURE: boolean;
  105092. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105093. /** @hidden */
  105094. _areTexturesDirty: boolean;
  105095. }
  105096. /**
  105097. * Define the code related to the clear coat parameters of the pbr material.
  105098. */
  105099. export class PBRClearCoatConfiguration {
  105100. /**
  105101. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105102. * The default fits with a polyurethane material.
  105103. */
  105104. private static readonly _DefaultIndexOfRefraction;
  105105. private _isEnabled;
  105106. /**
  105107. * Defines if the clear coat is enabled in the material.
  105108. */
  105109. isEnabled: boolean;
  105110. /**
  105111. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105112. */
  105113. intensity: number;
  105114. /**
  105115. * Defines the clear coat layer roughness.
  105116. */
  105117. roughness: number;
  105118. private _indexOfRefraction;
  105119. /**
  105120. * Defines the index of refraction of the clear coat.
  105121. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105122. * The default fits with a polyurethane material.
  105123. * Changing the default value is more performance intensive.
  105124. */
  105125. indexOfRefraction: number;
  105126. private _texture;
  105127. /**
  105128. * Stores the clear coat values in a texture.
  105129. */
  105130. texture: Nullable<BaseTexture>;
  105131. private _remapF0OnInterfaceChange;
  105132. /**
  105133. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105134. */
  105135. remapF0OnInterfaceChange: boolean;
  105136. private _bumpTexture;
  105137. /**
  105138. * Define the clear coat specific bump texture.
  105139. */
  105140. bumpTexture: Nullable<BaseTexture>;
  105141. private _isTintEnabled;
  105142. /**
  105143. * Defines if the clear coat tint is enabled in the material.
  105144. */
  105145. isTintEnabled: boolean;
  105146. /**
  105147. * Defines the clear coat tint of the material.
  105148. * This is only use if tint is enabled
  105149. */
  105150. tintColor: Color3;
  105151. /**
  105152. * Defines the distance at which the tint color should be found in the
  105153. * clear coat media.
  105154. * This is only use if tint is enabled
  105155. */
  105156. tintColorAtDistance: number;
  105157. /**
  105158. * Defines the clear coat layer thickness.
  105159. * This is only use if tint is enabled
  105160. */
  105161. tintThickness: number;
  105162. private _tintTexture;
  105163. /**
  105164. * Stores the clear tint values in a texture.
  105165. * rgb is tint
  105166. * a is a thickness factor
  105167. */
  105168. tintTexture: Nullable<BaseTexture>;
  105169. /** @hidden */
  105170. private _internalMarkAllSubMeshesAsTexturesDirty;
  105171. /** @hidden */
  105172. _markAllSubMeshesAsTexturesDirty(): void;
  105173. /**
  105174. * Instantiate a new istance of clear coat configuration.
  105175. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105176. */
  105177. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105178. /**
  105179. * Gets wehter the submesh is ready to be used or not.
  105180. * @param defines the list of "defines" to update.
  105181. * @param scene defines the scene the material belongs to.
  105182. * @param engine defines the engine the material belongs to.
  105183. * @param disableBumpMap defines wether the material disables bump or not.
  105184. * @returns - boolean indicating that the submesh is ready or not.
  105185. */
  105186. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105187. /**
  105188. * Checks to see if a texture is used in the material.
  105189. * @param defines the list of "defines" to update.
  105190. * @param scene defines the scene to the material belongs to.
  105191. */
  105192. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105193. /**
  105194. * Binds the material data.
  105195. * @param uniformBuffer defines the Uniform buffer to fill in.
  105196. * @param scene defines the scene the material belongs to.
  105197. * @param engine defines the engine the material belongs to.
  105198. * @param disableBumpMap defines wether the material disables bump or not.
  105199. * @param isFrozen defines wether the material is frozen or not.
  105200. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105201. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105202. */
  105203. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  105204. /**
  105205. * Checks to see if a texture is used in the material.
  105206. * @param texture - Base texture to use.
  105207. * @returns - Boolean specifying if a texture is used in the material.
  105208. */
  105209. hasTexture(texture: BaseTexture): boolean;
  105210. /**
  105211. * Returns an array of the actively used textures.
  105212. * @param activeTextures Array of BaseTextures
  105213. */
  105214. getActiveTextures(activeTextures: BaseTexture[]): void;
  105215. /**
  105216. * Returns the animatable textures.
  105217. * @param animatables Array of animatable textures.
  105218. */
  105219. getAnimatables(animatables: IAnimatable[]): void;
  105220. /**
  105221. * Disposes the resources of the material.
  105222. * @param forceDisposeTextures - Forces the disposal of all textures.
  105223. */
  105224. dispose(forceDisposeTextures?: boolean): void;
  105225. /**
  105226. * Get the current class name of the texture useful for serialization or dynamic coding.
  105227. * @returns "PBRClearCoatConfiguration"
  105228. */
  105229. getClassName(): string;
  105230. /**
  105231. * Add fallbacks to the effect fallbacks list.
  105232. * @param defines defines the Base texture to use.
  105233. * @param fallbacks defines the current fallback list.
  105234. * @param currentRank defines the current fallback rank.
  105235. * @returns the new fallback rank.
  105236. */
  105237. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105238. /**
  105239. * Add the required uniforms to the current list.
  105240. * @param uniforms defines the current uniform list.
  105241. */
  105242. static AddUniforms(uniforms: string[]): void;
  105243. /**
  105244. * Add the required samplers to the current list.
  105245. * @param samplers defines the current sampler list.
  105246. */
  105247. static AddSamplers(samplers: string[]): void;
  105248. /**
  105249. * Add the required uniforms to the current buffer.
  105250. * @param uniformBuffer defines the current uniform buffer.
  105251. */
  105252. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105253. /**
  105254. * Makes a duplicate of the current configuration into another one.
  105255. * @param clearCoatConfiguration define the config where to copy the info
  105256. */
  105257. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105258. /**
  105259. * Serializes this clear coat configuration.
  105260. * @returns - An object with the serialized config.
  105261. */
  105262. serialize(): any;
  105263. /**
  105264. * Parses a anisotropy Configuration from a serialized object.
  105265. * @param source - Serialized object.
  105266. * @param scene Defines the scene we are parsing for
  105267. * @param rootUrl Defines the rootUrl to load from
  105268. */
  105269. parse(source: any, scene: Scene, rootUrl: string): void;
  105270. }
  105271. }
  105272. declare module BABYLON {
  105273. /**
  105274. * @hidden
  105275. */
  105276. export interface IMaterialAnisotropicDefines {
  105277. ANISOTROPIC: boolean;
  105278. ANISOTROPIC_TEXTURE: boolean;
  105279. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105280. MAINUV1: boolean;
  105281. _areTexturesDirty: boolean;
  105282. _needUVs: boolean;
  105283. }
  105284. /**
  105285. * Define the code related to the anisotropic parameters of the pbr material.
  105286. */
  105287. export class PBRAnisotropicConfiguration {
  105288. private _isEnabled;
  105289. /**
  105290. * Defines if the anisotropy is enabled in the material.
  105291. */
  105292. isEnabled: boolean;
  105293. /**
  105294. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105295. */
  105296. intensity: number;
  105297. /**
  105298. * Defines if the effect is along the tangents, bitangents or in between.
  105299. * By default, the effect is "strectching" the highlights along the tangents.
  105300. */
  105301. direction: Vector2;
  105302. private _texture;
  105303. /**
  105304. * Stores the anisotropy values in a texture.
  105305. * rg is direction (like normal from -1 to 1)
  105306. * b is a intensity
  105307. */
  105308. texture: Nullable<BaseTexture>;
  105309. /** @hidden */
  105310. private _internalMarkAllSubMeshesAsTexturesDirty;
  105311. /** @hidden */
  105312. _markAllSubMeshesAsTexturesDirty(): void;
  105313. /**
  105314. * Instantiate a new istance of anisotropy configuration.
  105315. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105316. */
  105317. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105318. /**
  105319. * Specifies that the submesh is ready to be used.
  105320. * @param defines the list of "defines" to update.
  105321. * @param scene defines the scene the material belongs to.
  105322. * @returns - boolean indicating that the submesh is ready or not.
  105323. */
  105324. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105325. /**
  105326. * Checks to see if a texture is used in the material.
  105327. * @param defines the list of "defines" to update.
  105328. * @param mesh the mesh we are preparing the defines for.
  105329. * @param scene defines the scene the material belongs to.
  105330. */
  105331. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105332. /**
  105333. * Binds the material data.
  105334. * @param uniformBuffer defines the Uniform buffer to fill in.
  105335. * @param scene defines the scene the material belongs to.
  105336. * @param isFrozen defines wether the material is frozen or not.
  105337. */
  105338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105339. /**
  105340. * Checks to see if a texture is used in the material.
  105341. * @param texture - Base texture to use.
  105342. * @returns - Boolean specifying if a texture is used in the material.
  105343. */
  105344. hasTexture(texture: BaseTexture): boolean;
  105345. /**
  105346. * Returns an array of the actively used textures.
  105347. * @param activeTextures Array of BaseTextures
  105348. */
  105349. getActiveTextures(activeTextures: BaseTexture[]): void;
  105350. /**
  105351. * Returns the animatable textures.
  105352. * @param animatables Array of animatable textures.
  105353. */
  105354. getAnimatables(animatables: IAnimatable[]): void;
  105355. /**
  105356. * Disposes the resources of the material.
  105357. * @param forceDisposeTextures - Forces the disposal of all textures.
  105358. */
  105359. dispose(forceDisposeTextures?: boolean): void;
  105360. /**
  105361. * Get the current class name of the texture useful for serialization or dynamic coding.
  105362. * @returns "PBRAnisotropicConfiguration"
  105363. */
  105364. getClassName(): string;
  105365. /**
  105366. * Add fallbacks to the effect fallbacks list.
  105367. * @param defines defines the Base texture to use.
  105368. * @param fallbacks defines the current fallback list.
  105369. * @param currentRank defines the current fallback rank.
  105370. * @returns the new fallback rank.
  105371. */
  105372. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105373. /**
  105374. * Add the required uniforms to the current list.
  105375. * @param uniforms defines the current uniform list.
  105376. */
  105377. static AddUniforms(uniforms: string[]): void;
  105378. /**
  105379. * Add the required uniforms to the current buffer.
  105380. * @param uniformBuffer defines the current uniform buffer.
  105381. */
  105382. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105383. /**
  105384. * Add the required samplers to the current list.
  105385. * @param samplers defines the current sampler list.
  105386. */
  105387. static AddSamplers(samplers: string[]): void;
  105388. /**
  105389. * Makes a duplicate of the current configuration into another one.
  105390. * @param anisotropicConfiguration define the config where to copy the info
  105391. */
  105392. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105393. /**
  105394. * Serializes this anisotropy configuration.
  105395. * @returns - An object with the serialized config.
  105396. */
  105397. serialize(): any;
  105398. /**
  105399. * Parses a anisotropy Configuration from a serialized object.
  105400. * @param source - Serialized object.
  105401. * @param scene Defines the scene we are parsing for
  105402. * @param rootUrl Defines the rootUrl to load from
  105403. */
  105404. parse(source: any, scene: Scene, rootUrl: string): void;
  105405. }
  105406. }
  105407. declare module BABYLON {
  105408. /**
  105409. * @hidden
  105410. */
  105411. export interface IMaterialBRDFDefines {
  105412. BRDF_V_HEIGHT_CORRELATED: boolean;
  105413. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105414. SPHERICAL_HARMONICS: boolean;
  105415. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105416. /** @hidden */
  105417. _areMiscDirty: boolean;
  105418. }
  105419. /**
  105420. * Define the code related to the BRDF parameters of the pbr material.
  105421. */
  105422. export class PBRBRDFConfiguration {
  105423. /**
  105424. * Default value used for the energy conservation.
  105425. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105426. */
  105427. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105428. /**
  105429. * Default value used for the Smith Visibility Height Correlated mode.
  105430. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105431. */
  105432. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105433. /**
  105434. * Default value used for the IBL diffuse part.
  105435. * This can help switching back to the polynomials mode globally which is a tiny bit
  105436. * less GPU intensive at the drawback of a lower quality.
  105437. */
  105438. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105439. /**
  105440. * Default value used for activating energy conservation for the specular workflow.
  105441. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105442. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105443. */
  105444. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105445. private _useEnergyConservation;
  105446. /**
  105447. * Defines if the material uses energy conservation.
  105448. */
  105449. useEnergyConservation: boolean;
  105450. private _useSmithVisibilityHeightCorrelated;
  105451. /**
  105452. * LEGACY Mode set to false
  105453. * Defines if the material uses height smith correlated visibility term.
  105454. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105455. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105456. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105457. * Not relying on height correlated will also disable energy conservation.
  105458. */
  105459. useSmithVisibilityHeightCorrelated: boolean;
  105460. private _useSphericalHarmonics;
  105461. /**
  105462. * LEGACY Mode set to false
  105463. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105464. * diffuse part of the IBL.
  105465. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105466. * to the ground truth.
  105467. */
  105468. useSphericalHarmonics: boolean;
  105469. private _useSpecularGlossinessInputEnergyConservation;
  105470. /**
  105471. * Defines if the material uses energy conservation, when the specular workflow is active.
  105472. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105473. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105474. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105475. */
  105476. useSpecularGlossinessInputEnergyConservation: boolean;
  105477. /** @hidden */
  105478. private _internalMarkAllSubMeshesAsMiscDirty;
  105479. /** @hidden */
  105480. _markAllSubMeshesAsMiscDirty(): void;
  105481. /**
  105482. * Instantiate a new istance of clear coat configuration.
  105483. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105484. */
  105485. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105486. /**
  105487. * Checks to see if a texture is used in the material.
  105488. * @param defines the list of "defines" to update.
  105489. */
  105490. prepareDefines(defines: IMaterialBRDFDefines): void;
  105491. /**
  105492. * Get the current class name of the texture useful for serialization or dynamic coding.
  105493. * @returns "PBRClearCoatConfiguration"
  105494. */
  105495. getClassName(): string;
  105496. /**
  105497. * Makes a duplicate of the current configuration into another one.
  105498. * @param brdfConfiguration define the config where to copy the info
  105499. */
  105500. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105501. /**
  105502. * Serializes this BRDF configuration.
  105503. * @returns - An object with the serialized config.
  105504. */
  105505. serialize(): any;
  105506. /**
  105507. * Parses a anisotropy Configuration from a serialized object.
  105508. * @param source - Serialized object.
  105509. * @param scene Defines the scene we are parsing for
  105510. * @param rootUrl Defines the rootUrl to load from
  105511. */
  105512. parse(source: any, scene: Scene, rootUrl: string): void;
  105513. }
  105514. }
  105515. declare module BABYLON {
  105516. /**
  105517. * @hidden
  105518. */
  105519. export interface IMaterialSheenDefines {
  105520. SHEEN: boolean;
  105521. SHEEN_TEXTURE: boolean;
  105522. SHEEN_TEXTUREDIRECTUV: number;
  105523. SHEEN_LINKWITHALBEDO: boolean;
  105524. SHEEN_ROUGHNESS: boolean;
  105525. SHEEN_ALBEDOSCALING: boolean;
  105526. /** @hidden */
  105527. _areTexturesDirty: boolean;
  105528. }
  105529. /**
  105530. * Define the code related to the Sheen parameters of the pbr material.
  105531. */
  105532. export class PBRSheenConfiguration {
  105533. private _isEnabled;
  105534. /**
  105535. * Defines if the material uses sheen.
  105536. */
  105537. isEnabled: boolean;
  105538. private _linkSheenWithAlbedo;
  105539. /**
  105540. * Defines if the sheen is linked to the sheen color.
  105541. */
  105542. linkSheenWithAlbedo: boolean;
  105543. /**
  105544. * Defines the sheen intensity.
  105545. */
  105546. intensity: number;
  105547. /**
  105548. * Defines the sheen color.
  105549. */
  105550. color: Color3;
  105551. private _texture;
  105552. /**
  105553. * Stores the sheen tint values in a texture.
  105554. * rgb is tint
  105555. * a is a intensity or roughness if roughness has been defined
  105556. */
  105557. texture: Nullable<BaseTexture>;
  105558. private _roughness;
  105559. /**
  105560. * Defines the sheen roughness.
  105561. * It is not taken into account if linkSheenWithAlbedo is true.
  105562. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105563. */
  105564. roughness: Nullable<number>;
  105565. private _albedoScaling;
  105566. /**
  105567. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105568. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105569. * making it easier to setup and tweak the effect
  105570. */
  105571. albedoScaling: boolean;
  105572. /** @hidden */
  105573. private _internalMarkAllSubMeshesAsTexturesDirty;
  105574. /** @hidden */
  105575. _markAllSubMeshesAsTexturesDirty(): void;
  105576. /**
  105577. * Instantiate a new istance of clear coat configuration.
  105578. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105579. */
  105580. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105581. /**
  105582. * Specifies that the submesh is ready to be used.
  105583. * @param defines the list of "defines" to update.
  105584. * @param scene defines the scene the material belongs to.
  105585. * @returns - boolean indicating that the submesh is ready or not.
  105586. */
  105587. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105588. /**
  105589. * Checks to see if a texture is used in the material.
  105590. * @param defines the list of "defines" to update.
  105591. * @param scene defines the scene the material belongs to.
  105592. */
  105593. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105594. /**
  105595. * Binds the material data.
  105596. * @param uniformBuffer defines the Uniform buffer to fill in.
  105597. * @param scene defines the scene the material belongs to.
  105598. * @param isFrozen defines wether the material is frozen or not.
  105599. */
  105600. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105601. /**
  105602. * Checks to see if a texture is used in the material.
  105603. * @param texture - Base texture to use.
  105604. * @returns - Boolean specifying if a texture is used in the material.
  105605. */
  105606. hasTexture(texture: BaseTexture): boolean;
  105607. /**
  105608. * Returns an array of the actively used textures.
  105609. * @param activeTextures Array of BaseTextures
  105610. */
  105611. getActiveTextures(activeTextures: BaseTexture[]): void;
  105612. /**
  105613. * Returns the animatable textures.
  105614. * @param animatables Array of animatable textures.
  105615. */
  105616. getAnimatables(animatables: IAnimatable[]): void;
  105617. /**
  105618. * Disposes the resources of the material.
  105619. * @param forceDisposeTextures - Forces the disposal of all textures.
  105620. */
  105621. dispose(forceDisposeTextures?: boolean): void;
  105622. /**
  105623. * Get the current class name of the texture useful for serialization or dynamic coding.
  105624. * @returns "PBRSheenConfiguration"
  105625. */
  105626. getClassName(): string;
  105627. /**
  105628. * Add fallbacks to the effect fallbacks list.
  105629. * @param defines defines the Base texture to use.
  105630. * @param fallbacks defines the current fallback list.
  105631. * @param currentRank defines the current fallback rank.
  105632. * @returns the new fallback rank.
  105633. */
  105634. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105635. /**
  105636. * Add the required uniforms to the current list.
  105637. * @param uniforms defines the current uniform list.
  105638. */
  105639. static AddUniforms(uniforms: string[]): void;
  105640. /**
  105641. * Add the required uniforms to the current buffer.
  105642. * @param uniformBuffer defines the current uniform buffer.
  105643. */
  105644. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105645. /**
  105646. * Add the required samplers to the current list.
  105647. * @param samplers defines the current sampler list.
  105648. */
  105649. static AddSamplers(samplers: string[]): void;
  105650. /**
  105651. * Makes a duplicate of the current configuration into another one.
  105652. * @param sheenConfiguration define the config where to copy the info
  105653. */
  105654. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105655. /**
  105656. * Serializes this BRDF configuration.
  105657. * @returns - An object with the serialized config.
  105658. */
  105659. serialize(): any;
  105660. /**
  105661. * Parses a anisotropy Configuration from a serialized object.
  105662. * @param source - Serialized object.
  105663. * @param scene Defines the scene we are parsing for
  105664. * @param rootUrl Defines the rootUrl to load from
  105665. */
  105666. parse(source: any, scene: Scene, rootUrl: string): void;
  105667. }
  105668. }
  105669. declare module BABYLON {
  105670. /**
  105671. * @hidden
  105672. */
  105673. export interface IMaterialSubSurfaceDefines {
  105674. SUBSURFACE: boolean;
  105675. SS_REFRACTION: boolean;
  105676. SS_TRANSLUCENCY: boolean;
  105677. SS_SCATTERING: boolean;
  105678. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105679. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105680. SS_REFRACTIONMAP_3D: boolean;
  105681. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105682. SS_LODINREFRACTIONALPHA: boolean;
  105683. SS_GAMMAREFRACTION: boolean;
  105684. SS_RGBDREFRACTION: boolean;
  105685. SS_LINEARSPECULARREFRACTION: boolean;
  105686. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105687. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105688. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105689. /** @hidden */
  105690. _areTexturesDirty: boolean;
  105691. }
  105692. /**
  105693. * Define the code related to the sub surface parameters of the pbr material.
  105694. */
  105695. export class PBRSubSurfaceConfiguration {
  105696. private _isRefractionEnabled;
  105697. /**
  105698. * Defines if the refraction is enabled in the material.
  105699. */
  105700. isRefractionEnabled: boolean;
  105701. private _isTranslucencyEnabled;
  105702. /**
  105703. * Defines if the translucency is enabled in the material.
  105704. */
  105705. isTranslucencyEnabled: boolean;
  105706. private _isScatteringEnabled;
  105707. /**
  105708. * Defines if the sub surface scattering is enabled in the material.
  105709. */
  105710. isScatteringEnabled: boolean;
  105711. private _scatteringDiffusionProfileIndex;
  105712. /**
  105713. * Diffusion profile for subsurface scattering.
  105714. * Useful for better scattering in the skins or foliages.
  105715. */
  105716. get scatteringDiffusionProfile(): Nullable<Color3>;
  105717. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105718. /**
  105719. * Defines the refraction intensity of the material.
  105720. * The refraction when enabled replaces the Diffuse part of the material.
  105721. * The intensity helps transitionning between diffuse and refraction.
  105722. */
  105723. refractionIntensity: number;
  105724. /**
  105725. * Defines the translucency intensity of the material.
  105726. * When translucency has been enabled, this defines how much of the "translucency"
  105727. * is addded to the diffuse part of the material.
  105728. */
  105729. translucencyIntensity: number;
  105730. /**
  105731. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105732. */
  105733. useAlbedoToTintRefraction: boolean;
  105734. private _thicknessTexture;
  105735. /**
  105736. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105737. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105738. * 0 would mean minimumThickness
  105739. * 1 would mean maximumThickness
  105740. * The other channels might be use as a mask to vary the different effects intensity.
  105741. */
  105742. thicknessTexture: Nullable<BaseTexture>;
  105743. private _refractionTexture;
  105744. /**
  105745. * Defines the texture to use for refraction.
  105746. */
  105747. refractionTexture: Nullable<BaseTexture>;
  105748. private _indexOfRefraction;
  105749. /**
  105750. * Index of refraction of the material base layer.
  105751. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105752. *
  105753. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105754. *
  105755. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105756. */
  105757. indexOfRefraction: number;
  105758. private _volumeIndexOfRefraction;
  105759. /**
  105760. * Index of refraction of the material's volume.
  105761. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105762. *
  105763. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105764. * the volume will use the same IOR as the surface.
  105765. */
  105766. get volumeIndexOfRefraction(): number;
  105767. set volumeIndexOfRefraction(value: number);
  105768. private _invertRefractionY;
  105769. /**
  105770. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105771. */
  105772. invertRefractionY: boolean;
  105773. private _linkRefractionWithTransparency;
  105774. /**
  105775. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105776. * Materials half opaque for instance using refraction could benefit from this control.
  105777. */
  105778. linkRefractionWithTransparency: boolean;
  105779. /**
  105780. * Defines the minimum thickness stored in the thickness map.
  105781. * If no thickness map is defined, this value will be used to simulate thickness.
  105782. */
  105783. minimumThickness: number;
  105784. /**
  105785. * Defines the maximum thickness stored in the thickness map.
  105786. */
  105787. maximumThickness: number;
  105788. /**
  105789. * Defines the volume tint of the material.
  105790. * This is used for both translucency and scattering.
  105791. */
  105792. tintColor: Color3;
  105793. /**
  105794. * Defines the distance at which the tint color should be found in the media.
  105795. * This is used for refraction only.
  105796. */
  105797. tintColorAtDistance: number;
  105798. /**
  105799. * Defines how far each channel transmit through the media.
  105800. * It is defined as a color to simplify it selection.
  105801. */
  105802. diffusionDistance: Color3;
  105803. private _useMaskFromThicknessTexture;
  105804. /**
  105805. * Stores the intensity of the different subsurface effects in the thickness texture.
  105806. * * the green channel is the translucency intensity.
  105807. * * the blue channel is the scattering intensity.
  105808. * * the alpha channel is the refraction intensity.
  105809. */
  105810. useMaskFromThicknessTexture: boolean;
  105811. private _scene;
  105812. /** @hidden */
  105813. private _internalMarkAllSubMeshesAsTexturesDirty;
  105814. private _internalMarkScenePrePassDirty;
  105815. /** @hidden */
  105816. _markAllSubMeshesAsTexturesDirty(): void;
  105817. /** @hidden */
  105818. _markScenePrePassDirty(): void;
  105819. /**
  105820. * Instantiate a new istance of sub surface configuration.
  105821. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105822. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105823. * @param scene The scene
  105824. */
  105825. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105826. /**
  105827. * Gets wehter the submesh is ready to be used or not.
  105828. * @param defines the list of "defines" to update.
  105829. * @param scene defines the scene the material belongs to.
  105830. * @returns - boolean indicating that the submesh is ready or not.
  105831. */
  105832. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105833. /**
  105834. * Checks to see if a texture is used in the material.
  105835. * @param defines the list of "defines" to update.
  105836. * @param scene defines the scene to the material belongs to.
  105837. */
  105838. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105839. /**
  105840. * Binds the material data.
  105841. * @param uniformBuffer defines the Uniform buffer to fill in.
  105842. * @param scene defines the scene the material belongs to.
  105843. * @param engine defines the engine the material belongs to.
  105844. * @param isFrozen defines whether the material is frozen or not.
  105845. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105846. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105847. */
  105848. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105849. /**
  105850. * Unbinds the material from the mesh.
  105851. * @param activeEffect defines the effect that should be unbound from.
  105852. * @returns true if unbound, otherwise false
  105853. */
  105854. unbind(activeEffect: Effect): boolean;
  105855. /**
  105856. * Returns the texture used for refraction or null if none is used.
  105857. * @param scene defines the scene the material belongs to.
  105858. * @returns - Refraction texture if present. If no refraction texture and refraction
  105859. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105860. */
  105861. private _getRefractionTexture;
  105862. /**
  105863. * Returns true if alpha blending should be disabled.
  105864. */
  105865. get disableAlphaBlending(): boolean;
  105866. /**
  105867. * Fills the list of render target textures.
  105868. * @param renderTargets the list of render targets to update
  105869. */
  105870. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  105871. /**
  105872. * Checks to see if a texture is used in the material.
  105873. * @param texture - Base texture to use.
  105874. * @returns - Boolean specifying if a texture is used in the material.
  105875. */
  105876. hasTexture(texture: BaseTexture): boolean;
  105877. /**
  105878. * Gets a boolean indicating that current material needs to register RTT
  105879. * @returns true if this uses a render target otherwise false.
  105880. */
  105881. hasRenderTargetTextures(): boolean;
  105882. /**
  105883. * Returns an array of the actively used textures.
  105884. * @param activeTextures Array of BaseTextures
  105885. */
  105886. getActiveTextures(activeTextures: BaseTexture[]): void;
  105887. /**
  105888. * Returns the animatable textures.
  105889. * @param animatables Array of animatable textures.
  105890. */
  105891. getAnimatables(animatables: IAnimatable[]): void;
  105892. /**
  105893. * Disposes the resources of the material.
  105894. * @param forceDisposeTextures - Forces the disposal of all textures.
  105895. */
  105896. dispose(forceDisposeTextures?: boolean): void;
  105897. /**
  105898. * Get the current class name of the texture useful for serialization or dynamic coding.
  105899. * @returns "PBRSubSurfaceConfiguration"
  105900. */
  105901. getClassName(): string;
  105902. /**
  105903. * Add fallbacks to the effect fallbacks list.
  105904. * @param defines defines the Base texture to use.
  105905. * @param fallbacks defines the current fallback list.
  105906. * @param currentRank defines the current fallback rank.
  105907. * @returns the new fallback rank.
  105908. */
  105909. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105910. /**
  105911. * Add the required uniforms to the current list.
  105912. * @param uniforms defines the current uniform list.
  105913. */
  105914. static AddUniforms(uniforms: string[]): void;
  105915. /**
  105916. * Add the required samplers to the current list.
  105917. * @param samplers defines the current sampler list.
  105918. */
  105919. static AddSamplers(samplers: string[]): void;
  105920. /**
  105921. * Add the required uniforms to the current buffer.
  105922. * @param uniformBuffer defines the current uniform buffer.
  105923. */
  105924. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105925. /**
  105926. * Makes a duplicate of the current configuration into another one.
  105927. * @param configuration define the config where to copy the info
  105928. */
  105929. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  105930. /**
  105931. * Serializes this Sub Surface configuration.
  105932. * @returns - An object with the serialized config.
  105933. */
  105934. serialize(): any;
  105935. /**
  105936. * Parses a anisotropy Configuration from a serialized object.
  105937. * @param source - Serialized object.
  105938. * @param scene Defines the scene we are parsing for
  105939. * @param rootUrl Defines the rootUrl to load from
  105940. */
  105941. parse(source: any, scene: Scene, rootUrl: string): void;
  105942. }
  105943. }
  105944. declare module BABYLON {
  105945. /**
  105946. * Class representing spherical harmonics coefficients to the 3rd degree
  105947. */
  105948. export class SphericalHarmonics {
  105949. /**
  105950. * Defines whether or not the harmonics have been prescaled for rendering.
  105951. */
  105952. preScaled: boolean;
  105953. /**
  105954. * The l0,0 coefficients of the spherical harmonics
  105955. */
  105956. l00: Vector3;
  105957. /**
  105958. * The l1,-1 coefficients of the spherical harmonics
  105959. */
  105960. l1_1: Vector3;
  105961. /**
  105962. * The l1,0 coefficients of the spherical harmonics
  105963. */
  105964. l10: Vector3;
  105965. /**
  105966. * The l1,1 coefficients of the spherical harmonics
  105967. */
  105968. l11: Vector3;
  105969. /**
  105970. * The l2,-2 coefficients of the spherical harmonics
  105971. */
  105972. l2_2: Vector3;
  105973. /**
  105974. * The l2,-1 coefficients of the spherical harmonics
  105975. */
  105976. l2_1: Vector3;
  105977. /**
  105978. * The l2,0 coefficients of the spherical harmonics
  105979. */
  105980. l20: Vector3;
  105981. /**
  105982. * The l2,1 coefficients of the spherical harmonics
  105983. */
  105984. l21: Vector3;
  105985. /**
  105986. * The l2,2 coefficients of the spherical harmonics
  105987. */
  105988. l22: Vector3;
  105989. /**
  105990. * Adds a light to the spherical harmonics
  105991. * @param direction the direction of the light
  105992. * @param color the color of the light
  105993. * @param deltaSolidAngle the delta solid angle of the light
  105994. */
  105995. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105996. /**
  105997. * Scales the spherical harmonics by the given amount
  105998. * @param scale the amount to scale
  105999. */
  106000. scaleInPlace(scale: number): void;
  106001. /**
  106002. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106003. *
  106004. * ```
  106005. * E_lm = A_l * L_lm
  106006. * ```
  106007. *
  106008. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106009. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106010. * the scaling factors are given in equation 9.
  106011. */
  106012. convertIncidentRadianceToIrradiance(): void;
  106013. /**
  106014. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106015. *
  106016. * ```
  106017. * L = (1/pi) * E * rho
  106018. * ```
  106019. *
  106020. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106021. */
  106022. convertIrradianceToLambertianRadiance(): void;
  106023. /**
  106024. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106025. * required operations at run time.
  106026. *
  106027. * This is simply done by scaling back the SH with Ylm constants parameter.
  106028. * The trigonometric part being applied by the shader at run time.
  106029. */
  106030. preScaleForRendering(): void;
  106031. /**
  106032. * Constructs a spherical harmonics from an array.
  106033. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106034. * @returns the spherical harmonics
  106035. */
  106036. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106037. /**
  106038. * Gets the spherical harmonics from polynomial
  106039. * @param polynomial the spherical polynomial
  106040. * @returns the spherical harmonics
  106041. */
  106042. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106043. }
  106044. /**
  106045. * Class representing spherical polynomial coefficients to the 3rd degree
  106046. */
  106047. export class SphericalPolynomial {
  106048. private _harmonics;
  106049. /**
  106050. * The spherical harmonics used to create the polynomials.
  106051. */
  106052. get preScaledHarmonics(): SphericalHarmonics;
  106053. /**
  106054. * The x coefficients of the spherical polynomial
  106055. */
  106056. x: Vector3;
  106057. /**
  106058. * The y coefficients of the spherical polynomial
  106059. */
  106060. y: Vector3;
  106061. /**
  106062. * The z coefficients of the spherical polynomial
  106063. */
  106064. z: Vector3;
  106065. /**
  106066. * The xx coefficients of the spherical polynomial
  106067. */
  106068. xx: Vector3;
  106069. /**
  106070. * The yy coefficients of the spherical polynomial
  106071. */
  106072. yy: Vector3;
  106073. /**
  106074. * The zz coefficients of the spherical polynomial
  106075. */
  106076. zz: Vector3;
  106077. /**
  106078. * The xy coefficients of the spherical polynomial
  106079. */
  106080. xy: Vector3;
  106081. /**
  106082. * The yz coefficients of the spherical polynomial
  106083. */
  106084. yz: Vector3;
  106085. /**
  106086. * The zx coefficients of the spherical polynomial
  106087. */
  106088. zx: Vector3;
  106089. /**
  106090. * Adds an ambient color to the spherical polynomial
  106091. * @param color the color to add
  106092. */
  106093. addAmbient(color: Color3): void;
  106094. /**
  106095. * Scales the spherical polynomial by the given amount
  106096. * @param scale the amount to scale
  106097. */
  106098. scaleInPlace(scale: number): void;
  106099. /**
  106100. * Gets the spherical polynomial from harmonics
  106101. * @param harmonics the spherical harmonics
  106102. * @returns the spherical polynomial
  106103. */
  106104. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106105. /**
  106106. * Constructs a spherical polynomial from an array.
  106107. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106108. * @returns the spherical polynomial
  106109. */
  106110. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /**
  106115. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106116. */
  106117. export interface CubeMapInfo {
  106118. /**
  106119. * The pixel array for the front face.
  106120. * This is stored in format, left to right, up to down format.
  106121. */
  106122. front: Nullable<ArrayBufferView>;
  106123. /**
  106124. * The pixel array for the back face.
  106125. * This is stored in format, left to right, up to down format.
  106126. */
  106127. back: Nullable<ArrayBufferView>;
  106128. /**
  106129. * The pixel array for the left face.
  106130. * This is stored in format, left to right, up to down format.
  106131. */
  106132. left: Nullable<ArrayBufferView>;
  106133. /**
  106134. * The pixel array for the right face.
  106135. * This is stored in format, left to right, up to down format.
  106136. */
  106137. right: Nullable<ArrayBufferView>;
  106138. /**
  106139. * The pixel array for the up face.
  106140. * This is stored in format, left to right, up to down format.
  106141. */
  106142. up: Nullable<ArrayBufferView>;
  106143. /**
  106144. * The pixel array for the down face.
  106145. * This is stored in format, left to right, up to down format.
  106146. */
  106147. down: Nullable<ArrayBufferView>;
  106148. /**
  106149. * The size of the cubemap stored.
  106150. *
  106151. * Each faces will be size * size pixels.
  106152. */
  106153. size: number;
  106154. /**
  106155. * The format of the texture.
  106156. *
  106157. * RGBA, RGB.
  106158. */
  106159. format: number;
  106160. /**
  106161. * The type of the texture data.
  106162. *
  106163. * UNSIGNED_INT, FLOAT.
  106164. */
  106165. type: number;
  106166. /**
  106167. * Specifies whether the texture is in gamma space.
  106168. */
  106169. gammaSpace: boolean;
  106170. }
  106171. /**
  106172. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106173. */
  106174. export class PanoramaToCubeMapTools {
  106175. private static FACE_LEFT;
  106176. private static FACE_RIGHT;
  106177. private static FACE_FRONT;
  106178. private static FACE_BACK;
  106179. private static FACE_DOWN;
  106180. private static FACE_UP;
  106181. /**
  106182. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106183. *
  106184. * @param float32Array The source data.
  106185. * @param inputWidth The width of the input panorama.
  106186. * @param inputHeight The height of the input panorama.
  106187. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106188. * @return The cubemap data
  106189. */
  106190. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106191. private static CreateCubemapTexture;
  106192. private static CalcProjectionSpherical;
  106193. }
  106194. }
  106195. declare module BABYLON {
  106196. /**
  106197. * Helper class dealing with the extraction of spherical polynomial dataArray
  106198. * from a cube map.
  106199. */
  106200. export class CubeMapToSphericalPolynomialTools {
  106201. private static FileFaces;
  106202. /**
  106203. * Converts a texture to the according Spherical Polynomial data.
  106204. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106205. *
  106206. * @param texture The texture to extract the information from.
  106207. * @return The Spherical Polynomial data.
  106208. */
  106209. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106210. /**
  106211. * Converts a cubemap to the according Spherical Polynomial data.
  106212. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106213. *
  106214. * @param cubeInfo The Cube map to extract the information from.
  106215. * @return The Spherical Polynomial data.
  106216. */
  106217. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106218. }
  106219. }
  106220. declare module BABYLON {
  106221. interface BaseTexture {
  106222. /**
  106223. * Get the polynomial representation of the texture data.
  106224. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106225. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106226. */
  106227. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106228. }
  106229. }
  106230. declare module BABYLON {
  106231. /** @hidden */
  106232. export var pbrFragmentDeclaration: {
  106233. name: string;
  106234. shader: string;
  106235. };
  106236. }
  106237. declare module BABYLON {
  106238. /** @hidden */
  106239. export var pbrUboDeclaration: {
  106240. name: string;
  106241. shader: string;
  106242. };
  106243. }
  106244. declare module BABYLON {
  106245. /** @hidden */
  106246. export var pbrFragmentExtraDeclaration: {
  106247. name: string;
  106248. shader: string;
  106249. };
  106250. }
  106251. declare module BABYLON {
  106252. /** @hidden */
  106253. export var pbrFragmentSamplersDeclaration: {
  106254. name: string;
  106255. shader: string;
  106256. };
  106257. }
  106258. declare module BABYLON {
  106259. /** @hidden */
  106260. export var subSurfaceScatteringFunctions: {
  106261. name: string;
  106262. shader: string;
  106263. };
  106264. }
  106265. declare module BABYLON {
  106266. /** @hidden */
  106267. export var importanceSampling: {
  106268. name: string;
  106269. shader: string;
  106270. };
  106271. }
  106272. declare module BABYLON {
  106273. /** @hidden */
  106274. export var pbrHelperFunctions: {
  106275. name: string;
  106276. shader: string;
  106277. };
  106278. }
  106279. declare module BABYLON {
  106280. /** @hidden */
  106281. export var harmonicsFunctions: {
  106282. name: string;
  106283. shader: string;
  106284. };
  106285. }
  106286. declare module BABYLON {
  106287. /** @hidden */
  106288. export var pbrDirectLightingSetupFunctions: {
  106289. name: string;
  106290. shader: string;
  106291. };
  106292. }
  106293. declare module BABYLON {
  106294. /** @hidden */
  106295. export var pbrDirectLightingFalloffFunctions: {
  106296. name: string;
  106297. shader: string;
  106298. };
  106299. }
  106300. declare module BABYLON {
  106301. /** @hidden */
  106302. export var pbrBRDFFunctions: {
  106303. name: string;
  106304. shader: string;
  106305. };
  106306. }
  106307. declare module BABYLON {
  106308. /** @hidden */
  106309. export var hdrFilteringFunctions: {
  106310. name: string;
  106311. shader: string;
  106312. };
  106313. }
  106314. declare module BABYLON {
  106315. /** @hidden */
  106316. export var pbrDirectLightingFunctions: {
  106317. name: string;
  106318. shader: string;
  106319. };
  106320. }
  106321. declare module BABYLON {
  106322. /** @hidden */
  106323. export var pbrIBLFunctions: {
  106324. name: string;
  106325. shader: string;
  106326. };
  106327. }
  106328. declare module BABYLON {
  106329. /** @hidden */
  106330. export var pbrBlockAlbedoOpacity: {
  106331. name: string;
  106332. shader: string;
  106333. };
  106334. }
  106335. declare module BABYLON {
  106336. /** @hidden */
  106337. export var pbrBlockReflectivity: {
  106338. name: string;
  106339. shader: string;
  106340. };
  106341. }
  106342. declare module BABYLON {
  106343. /** @hidden */
  106344. export var pbrBlockAmbientOcclusion: {
  106345. name: string;
  106346. shader: string;
  106347. };
  106348. }
  106349. declare module BABYLON {
  106350. /** @hidden */
  106351. export var pbrBlockAlphaFresnel: {
  106352. name: string;
  106353. shader: string;
  106354. };
  106355. }
  106356. declare module BABYLON {
  106357. /** @hidden */
  106358. export var pbrBlockAnisotropic: {
  106359. name: string;
  106360. shader: string;
  106361. };
  106362. }
  106363. declare module BABYLON {
  106364. /** @hidden */
  106365. export var pbrBlockReflection: {
  106366. name: string;
  106367. shader: string;
  106368. };
  106369. }
  106370. declare module BABYLON {
  106371. /** @hidden */
  106372. export var pbrBlockSheen: {
  106373. name: string;
  106374. shader: string;
  106375. };
  106376. }
  106377. declare module BABYLON {
  106378. /** @hidden */
  106379. export var pbrBlockClearcoat: {
  106380. name: string;
  106381. shader: string;
  106382. };
  106383. }
  106384. declare module BABYLON {
  106385. /** @hidden */
  106386. export var pbrBlockSubSurface: {
  106387. name: string;
  106388. shader: string;
  106389. };
  106390. }
  106391. declare module BABYLON {
  106392. /** @hidden */
  106393. export var pbrBlockNormalGeometric: {
  106394. name: string;
  106395. shader: string;
  106396. };
  106397. }
  106398. declare module BABYLON {
  106399. /** @hidden */
  106400. export var pbrBlockNormalFinal: {
  106401. name: string;
  106402. shader: string;
  106403. };
  106404. }
  106405. declare module BABYLON {
  106406. /** @hidden */
  106407. export var pbrBlockLightmapInit: {
  106408. name: string;
  106409. shader: string;
  106410. };
  106411. }
  106412. declare module BABYLON {
  106413. /** @hidden */
  106414. export var pbrBlockGeometryInfo: {
  106415. name: string;
  106416. shader: string;
  106417. };
  106418. }
  106419. declare module BABYLON {
  106420. /** @hidden */
  106421. export var pbrBlockReflectance0: {
  106422. name: string;
  106423. shader: string;
  106424. };
  106425. }
  106426. declare module BABYLON {
  106427. /** @hidden */
  106428. export var pbrBlockReflectance: {
  106429. name: string;
  106430. shader: string;
  106431. };
  106432. }
  106433. declare module BABYLON {
  106434. /** @hidden */
  106435. export var pbrBlockDirectLighting: {
  106436. name: string;
  106437. shader: string;
  106438. };
  106439. }
  106440. declare module BABYLON {
  106441. /** @hidden */
  106442. export var pbrBlockFinalLitComponents: {
  106443. name: string;
  106444. shader: string;
  106445. };
  106446. }
  106447. declare module BABYLON {
  106448. /** @hidden */
  106449. export var pbrBlockFinalUnlitComponents: {
  106450. name: string;
  106451. shader: string;
  106452. };
  106453. }
  106454. declare module BABYLON {
  106455. /** @hidden */
  106456. export var pbrBlockFinalColorComposition: {
  106457. name: string;
  106458. shader: string;
  106459. };
  106460. }
  106461. declare module BABYLON {
  106462. /** @hidden */
  106463. export var pbrBlockImageProcessing: {
  106464. name: string;
  106465. shader: string;
  106466. };
  106467. }
  106468. declare module BABYLON {
  106469. /** @hidden */
  106470. export var pbrDebug: {
  106471. name: string;
  106472. shader: string;
  106473. };
  106474. }
  106475. declare module BABYLON {
  106476. /** @hidden */
  106477. export var pbrPixelShader: {
  106478. name: string;
  106479. shader: string;
  106480. };
  106481. }
  106482. declare module BABYLON {
  106483. /** @hidden */
  106484. export var pbrVertexDeclaration: {
  106485. name: string;
  106486. shader: string;
  106487. };
  106488. }
  106489. declare module BABYLON {
  106490. /** @hidden */
  106491. export var pbrVertexShader: {
  106492. name: string;
  106493. shader: string;
  106494. };
  106495. }
  106496. declare module BABYLON {
  106497. /**
  106498. * Manages the defines for the PBR Material.
  106499. * @hidden
  106500. */
  106501. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106502. PBR: boolean;
  106503. NUM_SAMPLES: string;
  106504. REALTIME_FILTERING: boolean;
  106505. MAINUV1: boolean;
  106506. MAINUV2: boolean;
  106507. UV1: boolean;
  106508. UV2: boolean;
  106509. ALBEDO: boolean;
  106510. GAMMAALBEDO: boolean;
  106511. ALBEDODIRECTUV: number;
  106512. VERTEXCOLOR: boolean;
  106513. DETAIL: boolean;
  106514. DETAILDIRECTUV: number;
  106515. DETAIL_NORMALBLENDMETHOD: number;
  106516. AMBIENT: boolean;
  106517. AMBIENTDIRECTUV: number;
  106518. AMBIENTINGRAYSCALE: boolean;
  106519. OPACITY: boolean;
  106520. VERTEXALPHA: boolean;
  106521. OPACITYDIRECTUV: number;
  106522. OPACITYRGB: boolean;
  106523. ALPHATEST: boolean;
  106524. DEPTHPREPASS: boolean;
  106525. ALPHABLEND: boolean;
  106526. ALPHAFROMALBEDO: boolean;
  106527. ALPHATESTVALUE: string;
  106528. SPECULAROVERALPHA: boolean;
  106529. RADIANCEOVERALPHA: boolean;
  106530. ALPHAFRESNEL: boolean;
  106531. LINEARALPHAFRESNEL: boolean;
  106532. PREMULTIPLYALPHA: boolean;
  106533. EMISSIVE: boolean;
  106534. EMISSIVEDIRECTUV: number;
  106535. REFLECTIVITY: boolean;
  106536. REFLECTIVITYDIRECTUV: number;
  106537. SPECULARTERM: boolean;
  106538. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106539. MICROSURFACEAUTOMATIC: boolean;
  106540. LODBASEDMICROSFURACE: boolean;
  106541. MICROSURFACEMAP: boolean;
  106542. MICROSURFACEMAPDIRECTUV: number;
  106543. METALLICWORKFLOW: boolean;
  106544. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106545. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106546. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106547. AOSTOREINMETALMAPRED: boolean;
  106548. METALLIC_REFLECTANCE: boolean;
  106549. METALLIC_REFLECTANCEDIRECTUV: number;
  106550. ENVIRONMENTBRDF: boolean;
  106551. ENVIRONMENTBRDF_RGBD: boolean;
  106552. NORMAL: boolean;
  106553. TANGENT: boolean;
  106554. BUMP: boolean;
  106555. BUMPDIRECTUV: number;
  106556. OBJECTSPACE_NORMALMAP: boolean;
  106557. PARALLAX: boolean;
  106558. PARALLAXOCCLUSION: boolean;
  106559. NORMALXYSCALE: boolean;
  106560. LIGHTMAP: boolean;
  106561. LIGHTMAPDIRECTUV: number;
  106562. USELIGHTMAPASSHADOWMAP: boolean;
  106563. GAMMALIGHTMAP: boolean;
  106564. RGBDLIGHTMAP: boolean;
  106565. REFLECTION: boolean;
  106566. REFLECTIONMAP_3D: boolean;
  106567. REFLECTIONMAP_SPHERICAL: boolean;
  106568. REFLECTIONMAP_PLANAR: boolean;
  106569. REFLECTIONMAP_CUBIC: boolean;
  106570. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106571. REFLECTIONMAP_PROJECTION: boolean;
  106572. REFLECTIONMAP_SKYBOX: boolean;
  106573. REFLECTIONMAP_EXPLICIT: boolean;
  106574. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106575. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106576. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106577. INVERTCUBICMAP: boolean;
  106578. USESPHERICALFROMREFLECTIONMAP: boolean;
  106579. USEIRRADIANCEMAP: boolean;
  106580. SPHERICAL_HARMONICS: boolean;
  106581. USESPHERICALINVERTEX: boolean;
  106582. REFLECTIONMAP_OPPOSITEZ: boolean;
  106583. LODINREFLECTIONALPHA: boolean;
  106584. GAMMAREFLECTION: boolean;
  106585. RGBDREFLECTION: boolean;
  106586. LINEARSPECULARREFLECTION: boolean;
  106587. RADIANCEOCCLUSION: boolean;
  106588. HORIZONOCCLUSION: boolean;
  106589. INSTANCES: boolean;
  106590. THIN_INSTANCES: boolean;
  106591. PREPASS: boolean;
  106592. PREPASS_IRRADIANCE: boolean;
  106593. PREPASS_IRRADIANCE_INDEX: number;
  106594. PREPASS_ALBEDO: boolean;
  106595. PREPASS_ALBEDO_INDEX: number;
  106596. PREPASS_DEPTHNORMAL: boolean;
  106597. PREPASS_DEPTHNORMAL_INDEX: number;
  106598. PREPASS_POSITION: boolean;
  106599. PREPASS_POSITION_INDEX: number;
  106600. PREPASS_VELOCITY: boolean;
  106601. PREPASS_VELOCITY_INDEX: number;
  106602. PREPASS_REFLECTIVITY: boolean;
  106603. PREPASS_REFLECTIVITY_INDEX: number;
  106604. SCENE_MRT_COUNT: number;
  106605. NUM_BONE_INFLUENCERS: number;
  106606. BonesPerMesh: number;
  106607. BONETEXTURE: boolean;
  106608. BONES_VELOCITY_ENABLED: boolean;
  106609. NONUNIFORMSCALING: boolean;
  106610. MORPHTARGETS: boolean;
  106611. MORPHTARGETS_NORMAL: boolean;
  106612. MORPHTARGETS_TANGENT: boolean;
  106613. MORPHTARGETS_UV: boolean;
  106614. NUM_MORPH_INFLUENCERS: number;
  106615. IMAGEPROCESSING: boolean;
  106616. VIGNETTE: boolean;
  106617. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106618. VIGNETTEBLENDMODEOPAQUE: boolean;
  106619. TONEMAPPING: boolean;
  106620. TONEMAPPING_ACES: boolean;
  106621. CONTRAST: boolean;
  106622. COLORCURVES: boolean;
  106623. COLORGRADING: boolean;
  106624. COLORGRADING3D: boolean;
  106625. SAMPLER3DGREENDEPTH: boolean;
  106626. SAMPLER3DBGRMAP: boolean;
  106627. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106628. EXPOSURE: boolean;
  106629. MULTIVIEW: boolean;
  106630. USEPHYSICALLIGHTFALLOFF: boolean;
  106631. USEGLTFLIGHTFALLOFF: boolean;
  106632. TWOSIDEDLIGHTING: boolean;
  106633. SHADOWFLOAT: boolean;
  106634. CLIPPLANE: boolean;
  106635. CLIPPLANE2: boolean;
  106636. CLIPPLANE3: boolean;
  106637. CLIPPLANE4: boolean;
  106638. CLIPPLANE5: boolean;
  106639. CLIPPLANE6: boolean;
  106640. POINTSIZE: boolean;
  106641. FOG: boolean;
  106642. LOGARITHMICDEPTH: boolean;
  106643. FORCENORMALFORWARD: boolean;
  106644. SPECULARAA: boolean;
  106645. CLEARCOAT: boolean;
  106646. CLEARCOAT_DEFAULTIOR: boolean;
  106647. CLEARCOAT_TEXTURE: boolean;
  106648. CLEARCOAT_TEXTUREDIRECTUV: number;
  106649. CLEARCOAT_BUMP: boolean;
  106650. CLEARCOAT_BUMPDIRECTUV: number;
  106651. CLEARCOAT_REMAP_F0: boolean;
  106652. CLEARCOAT_TINT: boolean;
  106653. CLEARCOAT_TINT_TEXTURE: boolean;
  106654. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106655. ANISOTROPIC: boolean;
  106656. ANISOTROPIC_TEXTURE: boolean;
  106657. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106658. BRDF_V_HEIGHT_CORRELATED: boolean;
  106659. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106660. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106661. SHEEN: boolean;
  106662. SHEEN_TEXTURE: boolean;
  106663. SHEEN_TEXTUREDIRECTUV: number;
  106664. SHEEN_LINKWITHALBEDO: boolean;
  106665. SHEEN_ROUGHNESS: boolean;
  106666. SHEEN_ALBEDOSCALING: boolean;
  106667. SUBSURFACE: boolean;
  106668. SS_REFRACTION: boolean;
  106669. SS_TRANSLUCENCY: boolean;
  106670. SS_SCATTERING: boolean;
  106671. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106672. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106673. SS_REFRACTIONMAP_3D: boolean;
  106674. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106675. SS_LODINREFRACTIONALPHA: boolean;
  106676. SS_GAMMAREFRACTION: boolean;
  106677. SS_RGBDREFRACTION: boolean;
  106678. SS_LINEARSPECULARREFRACTION: boolean;
  106679. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106680. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106681. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106682. UNLIT: boolean;
  106683. DEBUGMODE: number;
  106684. /**
  106685. * Initializes the PBR Material defines.
  106686. */
  106687. constructor();
  106688. /**
  106689. * Resets the PBR Material defines.
  106690. */
  106691. reset(): void;
  106692. }
  106693. /**
  106694. * The Physically based material base class of BJS.
  106695. *
  106696. * This offers the main features of a standard PBR material.
  106697. * For more information, please refer to the documentation :
  106698. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106699. */
  106700. export abstract class PBRBaseMaterial extends PushMaterial {
  106701. /**
  106702. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106703. */
  106704. static readonly PBRMATERIAL_OPAQUE: number;
  106705. /**
  106706. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106707. */
  106708. static readonly PBRMATERIAL_ALPHATEST: number;
  106709. /**
  106710. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106711. */
  106712. static readonly PBRMATERIAL_ALPHABLEND: number;
  106713. /**
  106714. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106715. * They are also discarded below the alpha cutoff threshold to improve performances.
  106716. */
  106717. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106718. /**
  106719. * Defines the default value of how much AO map is occluding the analytical lights
  106720. * (point spot...).
  106721. */
  106722. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106723. /**
  106724. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106725. */
  106726. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106727. /**
  106728. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106729. * to enhance interoperability with other engines.
  106730. */
  106731. static readonly LIGHTFALLOFF_GLTF: number;
  106732. /**
  106733. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106734. * to enhance interoperability with other materials.
  106735. */
  106736. static readonly LIGHTFALLOFF_STANDARD: number;
  106737. /**
  106738. * Intensity of the direct lights e.g. the four lights available in your scene.
  106739. * This impacts both the direct diffuse and specular highlights.
  106740. */
  106741. protected _directIntensity: number;
  106742. /**
  106743. * Intensity of the emissive part of the material.
  106744. * This helps controlling the emissive effect without modifying the emissive color.
  106745. */
  106746. protected _emissiveIntensity: number;
  106747. /**
  106748. * Intensity of the environment e.g. how much the environment will light the object
  106749. * either through harmonics for rough material or through the refelction for shiny ones.
  106750. */
  106751. protected _environmentIntensity: number;
  106752. /**
  106753. * This is a special control allowing the reduction of the specular highlights coming from the
  106754. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106755. */
  106756. protected _specularIntensity: number;
  106757. /**
  106758. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106759. */
  106760. private _lightingInfos;
  106761. /**
  106762. * Debug Control allowing disabling the bump map on this material.
  106763. */
  106764. protected _disableBumpMap: boolean;
  106765. /**
  106766. * AKA Diffuse Texture in standard nomenclature.
  106767. */
  106768. protected _albedoTexture: Nullable<BaseTexture>;
  106769. /**
  106770. * AKA Occlusion Texture in other nomenclature.
  106771. */
  106772. protected _ambientTexture: Nullable<BaseTexture>;
  106773. /**
  106774. * AKA Occlusion Texture Intensity in other nomenclature.
  106775. */
  106776. protected _ambientTextureStrength: number;
  106777. /**
  106778. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106779. * 1 means it completely occludes it
  106780. * 0 mean it has no impact
  106781. */
  106782. protected _ambientTextureImpactOnAnalyticalLights: number;
  106783. /**
  106784. * Stores the alpha values in a texture.
  106785. */
  106786. protected _opacityTexture: Nullable<BaseTexture>;
  106787. /**
  106788. * Stores the reflection values in a texture.
  106789. */
  106790. protected _reflectionTexture: Nullable<BaseTexture>;
  106791. /**
  106792. * Stores the emissive values in a texture.
  106793. */
  106794. protected _emissiveTexture: Nullable<BaseTexture>;
  106795. /**
  106796. * AKA Specular texture in other nomenclature.
  106797. */
  106798. protected _reflectivityTexture: Nullable<BaseTexture>;
  106799. /**
  106800. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106801. */
  106802. protected _metallicTexture: Nullable<BaseTexture>;
  106803. /**
  106804. * Specifies the metallic scalar of the metallic/roughness workflow.
  106805. * Can also be used to scale the metalness values of the metallic texture.
  106806. */
  106807. protected _metallic: Nullable<number>;
  106808. /**
  106809. * Specifies the roughness scalar of the metallic/roughness workflow.
  106810. * Can also be used to scale the roughness values of the metallic texture.
  106811. */
  106812. protected _roughness: Nullable<number>;
  106813. /**
  106814. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106815. * By default the indexOfrefraction is used to compute F0;
  106816. *
  106817. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106818. *
  106819. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106820. * F90 = metallicReflectanceColor;
  106821. */
  106822. protected _metallicF0Factor: number;
  106823. /**
  106824. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106825. * By default the F90 is always 1;
  106826. *
  106827. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106828. *
  106829. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106830. * F90 = metallicReflectanceColor;
  106831. */
  106832. protected _metallicReflectanceColor: Color3;
  106833. /**
  106834. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106835. * This is multiply against the scalar values defined in the material.
  106836. */
  106837. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106838. /**
  106839. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106840. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106841. */
  106842. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106843. /**
  106844. * Stores surface normal data used to displace a mesh in a texture.
  106845. */
  106846. protected _bumpTexture: Nullable<BaseTexture>;
  106847. /**
  106848. * Stores the pre-calculated light information of a mesh in a texture.
  106849. */
  106850. protected _lightmapTexture: Nullable<BaseTexture>;
  106851. /**
  106852. * The color of a material in ambient lighting.
  106853. */
  106854. protected _ambientColor: Color3;
  106855. /**
  106856. * AKA Diffuse Color in other nomenclature.
  106857. */
  106858. protected _albedoColor: Color3;
  106859. /**
  106860. * AKA Specular Color in other nomenclature.
  106861. */
  106862. protected _reflectivityColor: Color3;
  106863. /**
  106864. * The color applied when light is reflected from a material.
  106865. */
  106866. protected _reflectionColor: Color3;
  106867. /**
  106868. * The color applied when light is emitted from a material.
  106869. */
  106870. protected _emissiveColor: Color3;
  106871. /**
  106872. * AKA Glossiness in other nomenclature.
  106873. */
  106874. protected _microSurface: number;
  106875. /**
  106876. * Specifies that the material will use the light map as a show map.
  106877. */
  106878. protected _useLightmapAsShadowmap: boolean;
  106879. /**
  106880. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  106881. * makes the reflect vector face the model (under horizon).
  106882. */
  106883. protected _useHorizonOcclusion: boolean;
  106884. /**
  106885. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  106886. * too much the area relying on ambient texture to define their ambient occlusion.
  106887. */
  106888. protected _useRadianceOcclusion: boolean;
  106889. /**
  106890. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106891. */
  106892. protected _useAlphaFromAlbedoTexture: boolean;
  106893. /**
  106894. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  106895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106896. */
  106897. protected _useSpecularOverAlpha: boolean;
  106898. /**
  106899. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106900. */
  106901. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106902. /**
  106903. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106904. */
  106905. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  106906. /**
  106907. * Specifies if the metallic texture contains the roughness information in its green channel.
  106908. */
  106909. protected _useRoughnessFromMetallicTextureGreen: boolean;
  106910. /**
  106911. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106912. */
  106913. protected _useMetallnessFromMetallicTextureBlue: boolean;
  106914. /**
  106915. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106916. */
  106917. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  106918. /**
  106919. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106920. */
  106921. protected _useAmbientInGrayScale: boolean;
  106922. /**
  106923. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106924. * The material will try to infer what glossiness each pixel should be.
  106925. */
  106926. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  106927. /**
  106928. * Defines the falloff type used in this material.
  106929. * It by default is Physical.
  106930. */
  106931. protected _lightFalloff: number;
  106932. /**
  106933. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106934. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106935. */
  106936. protected _useRadianceOverAlpha: boolean;
  106937. /**
  106938. * Allows using an object space normal map (instead of tangent space).
  106939. */
  106940. protected _useObjectSpaceNormalMap: boolean;
  106941. /**
  106942. * Allows using the bump map in parallax mode.
  106943. */
  106944. protected _useParallax: boolean;
  106945. /**
  106946. * Allows using the bump map in parallax occlusion mode.
  106947. */
  106948. protected _useParallaxOcclusion: boolean;
  106949. /**
  106950. * Controls the scale bias of the parallax mode.
  106951. */
  106952. protected _parallaxScaleBias: number;
  106953. /**
  106954. * If sets to true, disables all the lights affecting the material.
  106955. */
  106956. protected _disableLighting: boolean;
  106957. /**
  106958. * Number of Simultaneous lights allowed on the material.
  106959. */
  106960. protected _maxSimultaneousLights: number;
  106961. /**
  106962. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106963. */
  106964. protected _invertNormalMapX: boolean;
  106965. /**
  106966. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106967. */
  106968. protected _invertNormalMapY: boolean;
  106969. /**
  106970. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106971. */
  106972. protected _twoSidedLighting: boolean;
  106973. /**
  106974. * Defines the alpha limits in alpha test mode.
  106975. */
  106976. protected _alphaCutOff: number;
  106977. /**
  106978. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  106979. */
  106980. protected _forceAlphaTest: boolean;
  106981. /**
  106982. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106983. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  106984. */
  106985. protected _useAlphaFresnel: boolean;
  106986. /**
  106987. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106988. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  106989. */
  106990. protected _useLinearAlphaFresnel: boolean;
  106991. /**
  106992. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  106993. * from cos thetav and roughness:
  106994. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  106995. */
  106996. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  106997. /**
  106998. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  106999. */
  107000. protected _forceIrradianceInFragment: boolean;
  107001. private _realTimeFiltering;
  107002. /**
  107003. * Enables realtime filtering on the texture.
  107004. */
  107005. get realTimeFiltering(): boolean;
  107006. set realTimeFiltering(b: boolean);
  107007. private _realTimeFilteringQuality;
  107008. /**
  107009. * Quality switch for realtime filtering
  107010. */
  107011. get realTimeFilteringQuality(): number;
  107012. set realTimeFilteringQuality(n: number);
  107013. /**
  107014. * Can this material render to several textures at once
  107015. */
  107016. get canRenderToMRT(): boolean;
  107017. /**
  107018. * Force normal to face away from face.
  107019. */
  107020. protected _forceNormalForward: boolean;
  107021. /**
  107022. * Enables specular anti aliasing in the PBR shader.
  107023. * It will both interacts on the Geometry for analytical and IBL lighting.
  107024. * It also prefilter the roughness map based on the bump values.
  107025. */
  107026. protected _enableSpecularAntiAliasing: boolean;
  107027. /**
  107028. * Default configuration related to image processing available in the PBR Material.
  107029. */
  107030. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107031. /**
  107032. * Keep track of the image processing observer to allow dispose and replace.
  107033. */
  107034. private _imageProcessingObserver;
  107035. /**
  107036. * Attaches a new image processing configuration to the PBR Material.
  107037. * @param configuration
  107038. */
  107039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107040. /**
  107041. * Stores the available render targets.
  107042. */
  107043. private _renderTargets;
  107044. /**
  107045. * Sets the global ambient color for the material used in lighting calculations.
  107046. */
  107047. private _globalAmbientColor;
  107048. /**
  107049. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107050. */
  107051. private _useLogarithmicDepth;
  107052. /**
  107053. * If set to true, no lighting calculations will be applied.
  107054. */
  107055. private _unlit;
  107056. private _debugMode;
  107057. /**
  107058. * @hidden
  107059. * This is reserved for the inspector.
  107060. * Defines the material debug mode.
  107061. * It helps seeing only some components of the material while troubleshooting.
  107062. */
  107063. debugMode: number;
  107064. /**
  107065. * @hidden
  107066. * This is reserved for the inspector.
  107067. * Specify from where on screen the debug mode should start.
  107068. * The value goes from -1 (full screen) to 1 (not visible)
  107069. * It helps with side by side comparison against the final render
  107070. * This defaults to -1
  107071. */
  107072. private debugLimit;
  107073. /**
  107074. * @hidden
  107075. * This is reserved for the inspector.
  107076. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107077. * You can use the factor to better multiply the final value.
  107078. */
  107079. private debugFactor;
  107080. /**
  107081. * Defines the clear coat layer parameters for the material.
  107082. */
  107083. readonly clearCoat: PBRClearCoatConfiguration;
  107084. /**
  107085. * Defines the anisotropic parameters for the material.
  107086. */
  107087. readonly anisotropy: PBRAnisotropicConfiguration;
  107088. /**
  107089. * Defines the BRDF parameters for the material.
  107090. */
  107091. readonly brdf: PBRBRDFConfiguration;
  107092. /**
  107093. * Defines the Sheen parameters for the material.
  107094. */
  107095. readonly sheen: PBRSheenConfiguration;
  107096. /**
  107097. * Defines the SubSurface parameters for the material.
  107098. */
  107099. readonly subSurface: PBRSubSurfaceConfiguration;
  107100. /**
  107101. * Defines additionnal PrePass parameters for the material.
  107102. */
  107103. readonly prePassConfiguration: PrePassConfiguration;
  107104. /**
  107105. * Defines the detail map parameters for the material.
  107106. */
  107107. readonly detailMap: DetailMapConfiguration;
  107108. protected _rebuildInParallel: boolean;
  107109. /**
  107110. * Instantiates a new PBRMaterial instance.
  107111. *
  107112. * @param name The material name
  107113. * @param scene The scene the material will be use in.
  107114. */
  107115. constructor(name: string, scene: Scene);
  107116. /**
  107117. * Gets a boolean indicating that current material needs to register RTT
  107118. */
  107119. get hasRenderTargetTextures(): boolean;
  107120. /**
  107121. * Gets the name of the material class.
  107122. */
  107123. getClassName(): string;
  107124. /**
  107125. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107126. */
  107127. get useLogarithmicDepth(): boolean;
  107128. /**
  107129. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107130. */
  107131. set useLogarithmicDepth(value: boolean);
  107132. /**
  107133. * Returns true if alpha blending should be disabled.
  107134. */
  107135. protected get _disableAlphaBlending(): boolean;
  107136. /**
  107137. * Specifies whether or not this material should be rendered in alpha blend mode.
  107138. */
  107139. needAlphaBlending(): boolean;
  107140. /**
  107141. * Specifies whether or not this material should be rendered in alpha test mode.
  107142. */
  107143. needAlphaTesting(): boolean;
  107144. /**
  107145. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107146. */
  107147. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107148. /**
  107149. * Gets the texture used for the alpha test.
  107150. */
  107151. getAlphaTestTexture(): Nullable<BaseTexture>;
  107152. /**
  107153. * Specifies that the submesh is ready to be used.
  107154. * @param mesh - BJS mesh.
  107155. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107156. * @param useInstances - Specifies that instances should be used.
  107157. * @returns - boolean indicating that the submesh is ready or not.
  107158. */
  107159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107160. /**
  107161. * Specifies if the material uses metallic roughness workflow.
  107162. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107163. */
  107164. isMetallicWorkflow(): boolean;
  107165. private _prepareEffect;
  107166. private _prepareDefines;
  107167. /**
  107168. * Force shader compilation
  107169. */
  107170. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107171. /**
  107172. * Initializes the uniform buffer layout for the shader.
  107173. */
  107174. buildUniformLayout(): void;
  107175. /**
  107176. * Unbinds the material from the mesh
  107177. */
  107178. unbind(): void;
  107179. /**
  107180. * Binds the submesh data.
  107181. * @param world - The world matrix.
  107182. * @param mesh - The BJS mesh.
  107183. * @param subMesh - A submesh of the BJS mesh.
  107184. */
  107185. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107186. /**
  107187. * Returns the animatable textures.
  107188. * @returns - Array of animatable textures.
  107189. */
  107190. getAnimatables(): IAnimatable[];
  107191. /**
  107192. * Returns the texture used for reflections.
  107193. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107194. */
  107195. private _getReflectionTexture;
  107196. /**
  107197. * Returns an array of the actively used textures.
  107198. * @returns - Array of BaseTextures
  107199. */
  107200. getActiveTextures(): BaseTexture[];
  107201. /**
  107202. * Checks to see if a texture is used in the material.
  107203. * @param texture - Base texture to use.
  107204. * @returns - Boolean specifying if a texture is used in the material.
  107205. */
  107206. hasTexture(texture: BaseTexture): boolean;
  107207. /**
  107208. * Sets the required values to the prepass renderer.
  107209. * @param prePassRenderer defines the prepass renderer to setup
  107210. */
  107211. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107212. /**
  107213. * Disposes the resources of the material.
  107214. * @param forceDisposeEffect - Forces the disposal of effects.
  107215. * @param forceDisposeTextures - Forces the disposal of all textures.
  107216. */
  107217. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107218. }
  107219. }
  107220. declare module BABYLON {
  107221. /**
  107222. * The Physically based material of BJS.
  107223. *
  107224. * This offers the main features of a standard PBR material.
  107225. * For more information, please refer to the documentation :
  107226. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107227. */
  107228. export class PBRMaterial extends PBRBaseMaterial {
  107229. /**
  107230. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107231. */
  107232. static readonly PBRMATERIAL_OPAQUE: number;
  107233. /**
  107234. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107235. */
  107236. static readonly PBRMATERIAL_ALPHATEST: number;
  107237. /**
  107238. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107239. */
  107240. static readonly PBRMATERIAL_ALPHABLEND: number;
  107241. /**
  107242. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107243. * They are also discarded below the alpha cutoff threshold to improve performances.
  107244. */
  107245. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107246. /**
  107247. * Defines the default value of how much AO map is occluding the analytical lights
  107248. * (point spot...).
  107249. */
  107250. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107251. /**
  107252. * Intensity of the direct lights e.g. the four lights available in your scene.
  107253. * This impacts both the direct diffuse and specular highlights.
  107254. */
  107255. directIntensity: number;
  107256. /**
  107257. * Intensity of the emissive part of the material.
  107258. * This helps controlling the emissive effect without modifying the emissive color.
  107259. */
  107260. emissiveIntensity: number;
  107261. /**
  107262. * Intensity of the environment e.g. how much the environment will light the object
  107263. * either through harmonics for rough material or through the refelction for shiny ones.
  107264. */
  107265. environmentIntensity: number;
  107266. /**
  107267. * This is a special control allowing the reduction of the specular highlights coming from the
  107268. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107269. */
  107270. specularIntensity: number;
  107271. /**
  107272. * Debug Control allowing disabling the bump map on this material.
  107273. */
  107274. disableBumpMap: boolean;
  107275. /**
  107276. * AKA Diffuse Texture in standard nomenclature.
  107277. */
  107278. albedoTexture: BaseTexture;
  107279. /**
  107280. * AKA Occlusion Texture in other nomenclature.
  107281. */
  107282. ambientTexture: BaseTexture;
  107283. /**
  107284. * AKA Occlusion Texture Intensity in other nomenclature.
  107285. */
  107286. ambientTextureStrength: number;
  107287. /**
  107288. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107289. * 1 means it completely occludes it
  107290. * 0 mean it has no impact
  107291. */
  107292. ambientTextureImpactOnAnalyticalLights: number;
  107293. /**
  107294. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107295. */
  107296. opacityTexture: BaseTexture;
  107297. /**
  107298. * Stores the reflection values in a texture.
  107299. */
  107300. reflectionTexture: Nullable<BaseTexture>;
  107301. /**
  107302. * Stores the emissive values in a texture.
  107303. */
  107304. emissiveTexture: BaseTexture;
  107305. /**
  107306. * AKA Specular texture in other nomenclature.
  107307. */
  107308. reflectivityTexture: BaseTexture;
  107309. /**
  107310. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107311. */
  107312. metallicTexture: BaseTexture;
  107313. /**
  107314. * Specifies the metallic scalar of the metallic/roughness workflow.
  107315. * Can also be used to scale the metalness values of the metallic texture.
  107316. */
  107317. metallic: Nullable<number>;
  107318. /**
  107319. * Specifies the roughness scalar of the metallic/roughness workflow.
  107320. * Can also be used to scale the roughness values of the metallic texture.
  107321. */
  107322. roughness: Nullable<number>;
  107323. /**
  107324. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107325. * By default the indexOfrefraction is used to compute F0;
  107326. *
  107327. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107328. *
  107329. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107330. * F90 = metallicReflectanceColor;
  107331. */
  107332. metallicF0Factor: number;
  107333. /**
  107334. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107335. * By default the F90 is always 1;
  107336. *
  107337. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107338. *
  107339. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107340. * F90 = metallicReflectanceColor;
  107341. */
  107342. metallicReflectanceColor: Color3;
  107343. /**
  107344. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107345. * This is multiply against the scalar values defined in the material.
  107346. */
  107347. metallicReflectanceTexture: Nullable<BaseTexture>;
  107348. /**
  107349. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107350. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107351. */
  107352. microSurfaceTexture: BaseTexture;
  107353. /**
  107354. * Stores surface normal data used to displace a mesh in a texture.
  107355. */
  107356. bumpTexture: BaseTexture;
  107357. /**
  107358. * Stores the pre-calculated light information of a mesh in a texture.
  107359. */
  107360. lightmapTexture: BaseTexture;
  107361. /**
  107362. * Stores the refracted light information in a texture.
  107363. */
  107364. get refractionTexture(): Nullable<BaseTexture>;
  107365. set refractionTexture(value: Nullable<BaseTexture>);
  107366. /**
  107367. * The color of a material in ambient lighting.
  107368. */
  107369. ambientColor: Color3;
  107370. /**
  107371. * AKA Diffuse Color in other nomenclature.
  107372. */
  107373. albedoColor: Color3;
  107374. /**
  107375. * AKA Specular Color in other nomenclature.
  107376. */
  107377. reflectivityColor: Color3;
  107378. /**
  107379. * The color reflected from the material.
  107380. */
  107381. reflectionColor: Color3;
  107382. /**
  107383. * The color emitted from the material.
  107384. */
  107385. emissiveColor: Color3;
  107386. /**
  107387. * AKA Glossiness in other nomenclature.
  107388. */
  107389. microSurface: number;
  107390. /**
  107391. * Index of refraction of the material base layer.
  107392. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107393. *
  107394. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107395. *
  107396. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107397. */
  107398. get indexOfRefraction(): number;
  107399. set indexOfRefraction(value: number);
  107400. /**
  107401. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107402. */
  107403. get invertRefractionY(): boolean;
  107404. set invertRefractionY(value: boolean);
  107405. /**
  107406. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107407. * Materials half opaque for instance using refraction could benefit from this control.
  107408. */
  107409. get linkRefractionWithTransparency(): boolean;
  107410. set linkRefractionWithTransparency(value: boolean);
  107411. /**
  107412. * If true, the light map contains occlusion information instead of lighting info.
  107413. */
  107414. useLightmapAsShadowmap: boolean;
  107415. /**
  107416. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107417. */
  107418. useAlphaFromAlbedoTexture: boolean;
  107419. /**
  107420. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107421. */
  107422. forceAlphaTest: boolean;
  107423. /**
  107424. * Defines the alpha limits in alpha test mode.
  107425. */
  107426. alphaCutOff: number;
  107427. /**
  107428. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107429. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107430. */
  107431. useSpecularOverAlpha: boolean;
  107432. /**
  107433. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107434. */
  107435. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107436. /**
  107437. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107438. */
  107439. useRoughnessFromMetallicTextureAlpha: boolean;
  107440. /**
  107441. * Specifies if the metallic texture contains the roughness information in its green channel.
  107442. */
  107443. useRoughnessFromMetallicTextureGreen: boolean;
  107444. /**
  107445. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107446. */
  107447. useMetallnessFromMetallicTextureBlue: boolean;
  107448. /**
  107449. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107450. */
  107451. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107452. /**
  107453. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107454. */
  107455. useAmbientInGrayScale: boolean;
  107456. /**
  107457. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107458. * The material will try to infer what glossiness each pixel should be.
  107459. */
  107460. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107461. /**
  107462. * BJS is using an harcoded light falloff based on a manually sets up range.
  107463. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107464. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107465. */
  107466. get usePhysicalLightFalloff(): boolean;
  107467. /**
  107468. * BJS is using an harcoded light falloff based on a manually sets up range.
  107469. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107470. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107471. */
  107472. set usePhysicalLightFalloff(value: boolean);
  107473. /**
  107474. * In order to support the falloff compatibility with gltf, a special mode has been added
  107475. * to reproduce the gltf light falloff.
  107476. */
  107477. get useGLTFLightFalloff(): boolean;
  107478. /**
  107479. * In order to support the falloff compatibility with gltf, a special mode has been added
  107480. * to reproduce the gltf light falloff.
  107481. */
  107482. set useGLTFLightFalloff(value: boolean);
  107483. /**
  107484. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107485. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107486. */
  107487. useRadianceOverAlpha: boolean;
  107488. /**
  107489. * Allows using an object space normal map (instead of tangent space).
  107490. */
  107491. useObjectSpaceNormalMap: boolean;
  107492. /**
  107493. * Allows using the bump map in parallax mode.
  107494. */
  107495. useParallax: boolean;
  107496. /**
  107497. * Allows using the bump map in parallax occlusion mode.
  107498. */
  107499. useParallaxOcclusion: boolean;
  107500. /**
  107501. * Controls the scale bias of the parallax mode.
  107502. */
  107503. parallaxScaleBias: number;
  107504. /**
  107505. * If sets to true, disables all the lights affecting the material.
  107506. */
  107507. disableLighting: boolean;
  107508. /**
  107509. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107510. */
  107511. forceIrradianceInFragment: boolean;
  107512. /**
  107513. * Number of Simultaneous lights allowed on the material.
  107514. */
  107515. maxSimultaneousLights: number;
  107516. /**
  107517. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107518. */
  107519. invertNormalMapX: boolean;
  107520. /**
  107521. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107522. */
  107523. invertNormalMapY: boolean;
  107524. /**
  107525. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107526. */
  107527. twoSidedLighting: boolean;
  107528. /**
  107529. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107530. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107531. */
  107532. useAlphaFresnel: boolean;
  107533. /**
  107534. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107535. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107536. */
  107537. useLinearAlphaFresnel: boolean;
  107538. /**
  107539. * Let user defines the brdf lookup texture used for IBL.
  107540. * A default 8bit version is embedded but you could point at :
  107541. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107542. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107543. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107544. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107545. */
  107546. environmentBRDFTexture: Nullable<BaseTexture>;
  107547. /**
  107548. * Force normal to face away from face.
  107549. */
  107550. forceNormalForward: boolean;
  107551. /**
  107552. * Enables specular anti aliasing in the PBR shader.
  107553. * It will both interacts on the Geometry for analytical and IBL lighting.
  107554. * It also prefilter the roughness map based on the bump values.
  107555. */
  107556. enableSpecularAntiAliasing: boolean;
  107557. /**
  107558. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107559. * makes the reflect vector face the model (under horizon).
  107560. */
  107561. useHorizonOcclusion: boolean;
  107562. /**
  107563. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107564. * too much the area relying on ambient texture to define their ambient occlusion.
  107565. */
  107566. useRadianceOcclusion: boolean;
  107567. /**
  107568. * If set to true, no lighting calculations will be applied.
  107569. */
  107570. unlit: boolean;
  107571. /**
  107572. * Gets the image processing configuration used either in this material.
  107573. */
  107574. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107575. /**
  107576. * Sets the Default image processing configuration used either in the this material.
  107577. *
  107578. * If sets to null, the scene one is in use.
  107579. */
  107580. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107581. /**
  107582. * Gets wether the color curves effect is enabled.
  107583. */
  107584. get cameraColorCurvesEnabled(): boolean;
  107585. /**
  107586. * Sets wether the color curves effect is enabled.
  107587. */
  107588. set cameraColorCurvesEnabled(value: boolean);
  107589. /**
  107590. * Gets wether the color grading effect is enabled.
  107591. */
  107592. get cameraColorGradingEnabled(): boolean;
  107593. /**
  107594. * Gets wether the color grading effect is enabled.
  107595. */
  107596. set cameraColorGradingEnabled(value: boolean);
  107597. /**
  107598. * Gets wether tonemapping is enabled or not.
  107599. */
  107600. get cameraToneMappingEnabled(): boolean;
  107601. /**
  107602. * Sets wether tonemapping is enabled or not
  107603. */
  107604. set cameraToneMappingEnabled(value: boolean);
  107605. /**
  107606. * The camera exposure used on this material.
  107607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107608. * This corresponds to a photographic exposure.
  107609. */
  107610. get cameraExposure(): number;
  107611. /**
  107612. * The camera exposure used on this material.
  107613. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107614. * This corresponds to a photographic exposure.
  107615. */
  107616. set cameraExposure(value: number);
  107617. /**
  107618. * Gets The camera contrast used on this material.
  107619. */
  107620. get cameraContrast(): number;
  107621. /**
  107622. * Sets The camera contrast used on this material.
  107623. */
  107624. set cameraContrast(value: number);
  107625. /**
  107626. * Gets the Color Grading 2D Lookup Texture.
  107627. */
  107628. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107629. /**
  107630. * Sets the Color Grading 2D Lookup Texture.
  107631. */
  107632. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107633. /**
  107634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107636. * 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;
  107637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107638. */
  107639. get cameraColorCurves(): Nullable<ColorCurves>;
  107640. /**
  107641. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107642. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107643. * 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;
  107644. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107645. */
  107646. set cameraColorCurves(value: Nullable<ColorCurves>);
  107647. /**
  107648. * Instantiates a new PBRMaterial instance.
  107649. *
  107650. * @param name The material name
  107651. * @param scene The scene the material will be use in.
  107652. */
  107653. constructor(name: string, scene: Scene);
  107654. /**
  107655. * Returns the name of this material class.
  107656. */
  107657. getClassName(): string;
  107658. /**
  107659. * Makes a duplicate of the current material.
  107660. * @param name - name to use for the new material.
  107661. */
  107662. clone(name: string): PBRMaterial;
  107663. /**
  107664. * Serializes this PBR Material.
  107665. * @returns - An object with the serialized material.
  107666. */
  107667. serialize(): any;
  107668. /**
  107669. * Parses a PBR Material from a serialized object.
  107670. * @param source - Serialized object.
  107671. * @param scene - BJS scene instance.
  107672. * @param rootUrl - url for the scene object
  107673. * @returns - PBRMaterial
  107674. */
  107675. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107676. }
  107677. }
  107678. declare module BABYLON {
  107679. /** @hidden */
  107680. export var mrtFragmentDeclaration: {
  107681. name: string;
  107682. shader: string;
  107683. };
  107684. }
  107685. declare module BABYLON {
  107686. /** @hidden */
  107687. export var geometryPixelShader: {
  107688. name: string;
  107689. shader: string;
  107690. };
  107691. }
  107692. declare module BABYLON {
  107693. /** @hidden */
  107694. export var geometryVertexShader: {
  107695. name: string;
  107696. shader: string;
  107697. };
  107698. }
  107699. declare module BABYLON {
  107700. /** @hidden */
  107701. interface ISavedTransformationMatrix {
  107702. world: Matrix;
  107703. viewProjection: Matrix;
  107704. }
  107705. /**
  107706. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107707. */
  107708. export class GeometryBufferRenderer {
  107709. /**
  107710. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107711. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107712. */
  107713. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107714. /**
  107715. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107716. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107717. */
  107718. static readonly POSITION_TEXTURE_TYPE: number;
  107719. /**
  107720. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107721. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107722. */
  107723. static readonly VELOCITY_TEXTURE_TYPE: number;
  107724. /**
  107725. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107726. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107727. */
  107728. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107729. /**
  107730. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107731. * in order to compute objects velocities when enableVelocity is set to "true"
  107732. * @hidden
  107733. */
  107734. _previousTransformationMatrices: {
  107735. [index: number]: ISavedTransformationMatrix;
  107736. };
  107737. /**
  107738. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107739. * in order to compute objects velocities when enableVelocity is set to "true"
  107740. * @hidden
  107741. */
  107742. _previousBonesTransformationMatrices: {
  107743. [index: number]: Float32Array;
  107744. };
  107745. /**
  107746. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107747. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107748. */
  107749. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107750. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107751. renderTransparentMeshes: boolean;
  107752. private _scene;
  107753. private _resizeObserver;
  107754. private _multiRenderTarget;
  107755. private _ratio;
  107756. private _enablePosition;
  107757. private _enableVelocity;
  107758. private _enableReflectivity;
  107759. private _positionIndex;
  107760. private _velocityIndex;
  107761. private _reflectivityIndex;
  107762. private _depthNormalIndex;
  107763. private _linkedWithPrePass;
  107764. private _prePassRenderer;
  107765. private _attachments;
  107766. protected _effect: Effect;
  107767. protected _cachedDefines: string;
  107768. /**
  107769. * @hidden
  107770. * Sets up internal structures to share outputs with PrePassRenderer
  107771. * This method should only be called by the PrePassRenderer itself
  107772. */
  107773. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107774. /**
  107775. * @hidden
  107776. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107777. * This method should only be called by the PrePassRenderer itself
  107778. */
  107779. _unlinkPrePassRenderer(): void;
  107780. /**
  107781. * @hidden
  107782. * Resets the geometry buffer layout
  107783. */
  107784. _resetLayout(): void;
  107785. /**
  107786. * @hidden
  107787. * Replaces a texture in the geometry buffer renderer
  107788. * Useful when linking textures of the prepass renderer
  107789. */
  107790. _forceTextureType(geometryBufferType: number, index: number): void;
  107791. /**
  107792. * @hidden
  107793. * Sets texture attachments
  107794. * Useful when linking textures of the prepass renderer
  107795. */
  107796. _setAttachments(attachments: number[]): void;
  107797. /**
  107798. * @hidden
  107799. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107800. * Useful when linking textures of the prepass renderer
  107801. */
  107802. _linkInternalTexture(internalTexture: InternalTexture): void;
  107803. /**
  107804. * Gets the render list (meshes to be rendered) used in the G buffer.
  107805. */
  107806. get renderList(): Nullable<AbstractMesh[]>;
  107807. /**
  107808. * Set the render list (meshes to be rendered) used in the G buffer.
  107809. */
  107810. set renderList(meshes: Nullable<AbstractMesh[]>);
  107811. /**
  107812. * Gets wether or not G buffer are supported by the running hardware.
  107813. * This requires draw buffer supports
  107814. */
  107815. get isSupported(): boolean;
  107816. /**
  107817. * Returns the index of the given texture type in the G-Buffer textures array
  107818. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107819. * @returns the index of the given texture type in the G-Buffer textures array
  107820. */
  107821. getTextureIndex(textureType: number): number;
  107822. /**
  107823. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107824. */
  107825. get enablePosition(): boolean;
  107826. /**
  107827. * Sets whether or not objects positions are enabled for the G buffer.
  107828. */
  107829. set enablePosition(enable: boolean);
  107830. /**
  107831. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107832. */
  107833. get enableVelocity(): boolean;
  107834. /**
  107835. * Sets wether or not objects velocities are enabled for the G buffer.
  107836. */
  107837. set enableVelocity(enable: boolean);
  107838. /**
  107839. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107840. */
  107841. get enableReflectivity(): boolean;
  107842. /**
  107843. * Sets wether or not objects roughness are enabled for the G buffer.
  107844. */
  107845. set enableReflectivity(enable: boolean);
  107846. /**
  107847. * Gets the scene associated with the buffer.
  107848. */
  107849. get scene(): Scene;
  107850. /**
  107851. * Gets the ratio used by the buffer during its creation.
  107852. * How big is the buffer related to the main canvas.
  107853. */
  107854. get ratio(): number;
  107855. /** @hidden */
  107856. static _SceneComponentInitialization: (scene: Scene) => void;
  107857. /**
  107858. * Creates a new G Buffer for the scene
  107859. * @param scene The scene the buffer belongs to
  107860. * @param ratio How big is the buffer related to the main canvas.
  107861. */
  107862. constructor(scene: Scene, ratio?: number);
  107863. /**
  107864. * Checks wether everything is ready to render a submesh to the G buffer.
  107865. * @param subMesh the submesh to check readiness for
  107866. * @param useInstances is the mesh drawn using instance or not
  107867. * @returns true if ready otherwise false
  107868. */
  107869. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107870. /**
  107871. * Gets the current underlying G Buffer.
  107872. * @returns the buffer
  107873. */
  107874. getGBuffer(): MultiRenderTarget;
  107875. /**
  107876. * Gets the number of samples used to render the buffer (anti aliasing).
  107877. */
  107878. get samples(): number;
  107879. /**
  107880. * Sets the number of samples used to render the buffer (anti aliasing).
  107881. */
  107882. set samples(value: number);
  107883. /**
  107884. * Disposes the renderer and frees up associated resources.
  107885. */
  107886. dispose(): void;
  107887. private _assignRenderTargetIndices;
  107888. protected _createRenderTargets(): void;
  107889. private _copyBonesTransformationMatrices;
  107890. }
  107891. }
  107892. declare module BABYLON {
  107893. /**
  107894. * Renders a pre pass of the scene
  107895. * This means every mesh in the scene will be rendered to a render target texture
  107896. * And then this texture will be composited to the rendering canvas with post processes
  107897. * It is necessary for effects like subsurface scattering or deferred shading
  107898. */
  107899. export class PrePassRenderer {
  107900. /** @hidden */
  107901. static _SceneComponentInitialization: (scene: Scene) => void;
  107902. private _textureFormats;
  107903. /**
  107904. * To save performance, we can excluded skinned meshes from the prepass
  107905. */
  107906. excludedSkinnedMesh: AbstractMesh[];
  107907. /**
  107908. * Force material to be excluded from the prepass
  107909. * Can be useful when `useGeometryBufferFallback` is set to `true`
  107910. * and you don't want a material to show in the effect.
  107911. */
  107912. excludedMaterials: Material[];
  107913. private _textureIndices;
  107914. private _scene;
  107915. private _engine;
  107916. private _isDirty;
  107917. /**
  107918. * Number of textures in the multi render target texture where the scene is directly rendered
  107919. */
  107920. mrtCount: number;
  107921. /**
  107922. * The render target where the scene is directly rendered
  107923. */
  107924. prePassRT: MultiRenderTarget;
  107925. private _multiRenderAttachments;
  107926. private _defaultAttachments;
  107927. private _clearAttachments;
  107928. private _postProcesses;
  107929. private readonly _clearColor;
  107930. /**
  107931. * Image processing post process for composition
  107932. */
  107933. imageProcessingPostProcess: ImageProcessingPostProcess;
  107934. /**
  107935. * Configuration for prepass effects
  107936. */
  107937. private _effectConfigurations;
  107938. private _mrtFormats;
  107939. private _mrtLayout;
  107940. private _enabled;
  107941. /**
  107942. * Indicates if the prepass is enabled
  107943. */
  107944. get enabled(): boolean;
  107945. /**
  107946. * How many samples are used for MSAA of the scene render target
  107947. */
  107948. get samples(): number;
  107949. set samples(n: number);
  107950. private _geometryBuffer;
  107951. private _useGeometryBufferFallback;
  107952. /**
  107953. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  107954. */
  107955. get useGeometryBufferFallback(): boolean;
  107956. set useGeometryBufferFallback(value: boolean);
  107957. /**
  107958. * Instanciates a prepass renderer
  107959. * @param scene The scene
  107960. */
  107961. constructor(scene: Scene);
  107962. private _initializeAttachments;
  107963. private _createCompositionEffect;
  107964. /**
  107965. * Indicates if rendering a prepass is supported
  107966. */
  107967. get isSupported(): boolean;
  107968. /**
  107969. * Sets the proper output textures to draw in the engine.
  107970. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  107971. * @param subMesh Submesh on which the effect is applied
  107972. */
  107973. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  107974. /**
  107975. * @hidden
  107976. */
  107977. _beforeCameraDraw(): void;
  107978. /**
  107979. * @hidden
  107980. */
  107981. _afterCameraDraw(): void;
  107982. private _checkRTSize;
  107983. private _bindFrameBuffer;
  107984. /**
  107985. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  107986. */
  107987. clear(): void;
  107988. private _setState;
  107989. private _updateGeometryBufferLayout;
  107990. /**
  107991. * Adds an effect configuration to the prepass.
  107992. * If an effect has already been added, it won't add it twice and will return the configuration
  107993. * already present.
  107994. * @param cfg the effect configuration
  107995. * @return the effect configuration now used by the prepass
  107996. */
  107997. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  107998. /**
  107999. * Returns the index of a texture in the multi render target texture array.
  108000. * @param type Texture type
  108001. * @return The index
  108002. */
  108003. getIndex(type: number): number;
  108004. private _enable;
  108005. private _disable;
  108006. private _resetLayout;
  108007. private _resetPostProcessChain;
  108008. private _bindPostProcessChain;
  108009. /**
  108010. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108011. */
  108012. markAsDirty(): void;
  108013. /**
  108014. * Enables a texture on the MultiRenderTarget for prepass
  108015. */
  108016. private _enableTextures;
  108017. private _update;
  108018. private _markAllMaterialsAsPrePassDirty;
  108019. /**
  108020. * Disposes the prepass renderer.
  108021. */
  108022. dispose(): void;
  108023. }
  108024. }
  108025. declare module BABYLON {
  108026. /**
  108027. * Size options for a post process
  108028. */
  108029. export type PostProcessOptions = {
  108030. width: number;
  108031. height: number;
  108032. };
  108033. /**
  108034. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108035. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108036. */
  108037. export class PostProcess {
  108038. /**
  108039. * Gets or sets the unique id of the post process
  108040. */
  108041. uniqueId: number;
  108042. /** Name of the PostProcess. */
  108043. name: string;
  108044. /**
  108045. * Width of the texture to apply the post process on
  108046. */
  108047. width: number;
  108048. /**
  108049. * Height of the texture to apply the post process on
  108050. */
  108051. height: number;
  108052. /**
  108053. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108054. */
  108055. nodeMaterialSource: Nullable<NodeMaterial>;
  108056. /**
  108057. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108058. * @hidden
  108059. */
  108060. _outputTexture: Nullable<InternalTexture>;
  108061. /**
  108062. * Sampling mode used by the shader
  108063. * See https://doc.babylonjs.com/classes/3.1/texture
  108064. */
  108065. renderTargetSamplingMode: number;
  108066. /**
  108067. * Clear color to use when screen clearing
  108068. */
  108069. clearColor: Color4;
  108070. /**
  108071. * If the buffer needs to be cleared before applying the post process. (default: true)
  108072. * Should be set to false if shader will overwrite all previous pixels.
  108073. */
  108074. autoClear: boolean;
  108075. /**
  108076. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108077. */
  108078. alphaMode: number;
  108079. /**
  108080. * Sets the setAlphaBlendConstants of the babylon engine
  108081. */
  108082. alphaConstants: Color4;
  108083. /**
  108084. * Animations to be used for the post processing
  108085. */
  108086. animations: Animation[];
  108087. /**
  108088. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108089. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108090. */
  108091. enablePixelPerfectMode: boolean;
  108092. /**
  108093. * Force the postprocess to be applied without taking in account viewport
  108094. */
  108095. forceFullscreenViewport: boolean;
  108096. /**
  108097. * List of inspectable custom properties (used by the Inspector)
  108098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108099. */
  108100. inspectableCustomProperties: IInspectable[];
  108101. /**
  108102. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108103. *
  108104. * | Value | Type | Description |
  108105. * | ----- | ----------------------------------- | ----------- |
  108106. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108107. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108108. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108109. *
  108110. */
  108111. scaleMode: number;
  108112. /**
  108113. * Force textures to be a power of two (default: false)
  108114. */
  108115. alwaysForcePOT: boolean;
  108116. private _samples;
  108117. /**
  108118. * Number of sample textures (default: 1)
  108119. */
  108120. get samples(): number;
  108121. set samples(n: number);
  108122. /**
  108123. * Modify the scale of the post process to be the same as the viewport (default: false)
  108124. */
  108125. adaptScaleToCurrentViewport: boolean;
  108126. private _camera;
  108127. protected _scene: Scene;
  108128. private _engine;
  108129. private _options;
  108130. private _reusable;
  108131. private _textureType;
  108132. private _textureFormat;
  108133. /**
  108134. * Smart array of input and output textures for the post process.
  108135. * @hidden
  108136. */
  108137. _textures: SmartArray<InternalTexture>;
  108138. /**
  108139. * The index in _textures that corresponds to the output texture.
  108140. * @hidden
  108141. */
  108142. _currentRenderTextureInd: number;
  108143. private _effect;
  108144. private _samplers;
  108145. private _fragmentUrl;
  108146. private _vertexUrl;
  108147. private _parameters;
  108148. private _scaleRatio;
  108149. protected _indexParameters: any;
  108150. private _shareOutputWithPostProcess;
  108151. private _texelSize;
  108152. private _forcedOutputTexture;
  108153. /**
  108154. * Prepass configuration in case this post process needs a texture from prepass
  108155. * @hidden
  108156. */
  108157. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108158. /**
  108159. * Returns the fragment url or shader name used in the post process.
  108160. * @returns the fragment url or name in the shader store.
  108161. */
  108162. getEffectName(): string;
  108163. /**
  108164. * An event triggered when the postprocess is activated.
  108165. */
  108166. onActivateObservable: Observable<Camera>;
  108167. private _onActivateObserver;
  108168. /**
  108169. * A function that is added to the onActivateObservable
  108170. */
  108171. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108172. /**
  108173. * An event triggered when the postprocess changes its size.
  108174. */
  108175. onSizeChangedObservable: Observable<PostProcess>;
  108176. private _onSizeChangedObserver;
  108177. /**
  108178. * A function that is added to the onSizeChangedObservable
  108179. */
  108180. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108181. /**
  108182. * An event triggered when the postprocess applies its effect.
  108183. */
  108184. onApplyObservable: Observable<Effect>;
  108185. private _onApplyObserver;
  108186. /**
  108187. * A function that is added to the onApplyObservable
  108188. */
  108189. set onApply(callback: (effect: Effect) => void);
  108190. /**
  108191. * An event triggered before rendering the postprocess
  108192. */
  108193. onBeforeRenderObservable: Observable<Effect>;
  108194. private _onBeforeRenderObserver;
  108195. /**
  108196. * A function that is added to the onBeforeRenderObservable
  108197. */
  108198. set onBeforeRender(callback: (effect: Effect) => void);
  108199. /**
  108200. * An event triggered after rendering the postprocess
  108201. */
  108202. onAfterRenderObservable: Observable<Effect>;
  108203. private _onAfterRenderObserver;
  108204. /**
  108205. * A function that is added to the onAfterRenderObservable
  108206. */
  108207. set onAfterRender(callback: (efect: Effect) => void);
  108208. /**
  108209. * 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
  108210. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108211. */
  108212. get inputTexture(): InternalTexture;
  108213. set inputTexture(value: InternalTexture);
  108214. /**
  108215. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108216. * the only way to unset it is to use this function to restore its internal state
  108217. */
  108218. restoreDefaultInputTexture(): void;
  108219. /**
  108220. * Gets the camera which post process is applied to.
  108221. * @returns The camera the post process is applied to.
  108222. */
  108223. getCamera(): Camera;
  108224. /**
  108225. * Gets the texel size of the postprocess.
  108226. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108227. */
  108228. get texelSize(): Vector2;
  108229. /**
  108230. * Creates a new instance PostProcess
  108231. * @param name The name of the PostProcess.
  108232. * @param fragmentUrl The url of the fragment shader to be used.
  108233. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108234. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108235. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108236. * @param camera The camera to apply the render pass to.
  108237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108238. * @param engine The engine which the post process will be applied. (default: current engine)
  108239. * @param reusable If the post process can be reused on the same frame. (default: false)
  108240. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108241. * @param textureType Type of textures used when performing the post process. (default: 0)
  108242. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108243. * @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
  108244. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108245. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108246. */
  108247. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  108248. /**
  108249. * Gets a string identifying the name of the class
  108250. * @returns "PostProcess" string
  108251. */
  108252. getClassName(): string;
  108253. /**
  108254. * Gets the engine which this post process belongs to.
  108255. * @returns The engine the post process was enabled with.
  108256. */
  108257. getEngine(): Engine;
  108258. /**
  108259. * The effect that is created when initializing the post process.
  108260. * @returns The created effect corresponding the the postprocess.
  108261. */
  108262. getEffect(): Effect;
  108263. /**
  108264. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108265. * @param postProcess The post process to share the output with.
  108266. * @returns This post process.
  108267. */
  108268. shareOutputWith(postProcess: PostProcess): PostProcess;
  108269. /**
  108270. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108271. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108272. */
  108273. useOwnOutput(): void;
  108274. /**
  108275. * Updates the effect with the current post process compile time values and recompiles the shader.
  108276. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108277. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108278. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108279. * @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
  108280. * @param onCompiled Called when the shader has been compiled.
  108281. * @param onError Called if there is an error when compiling a shader.
  108282. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108283. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108284. */
  108285. 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;
  108286. /**
  108287. * The post process is reusable if it can be used multiple times within one frame.
  108288. * @returns If the post process is reusable
  108289. */
  108290. isReusable(): boolean;
  108291. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108292. markTextureDirty(): void;
  108293. /**
  108294. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108295. * 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.
  108296. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108297. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108298. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108299. * @returns The target texture that was bound to be written to.
  108300. */
  108301. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108302. /**
  108303. * If the post process is supported.
  108304. */
  108305. get isSupported(): boolean;
  108306. /**
  108307. * The aspect ratio of the output texture.
  108308. */
  108309. get aspectRatio(): number;
  108310. /**
  108311. * Get a value indicating if the post-process is ready to be used
  108312. * @returns true if the post-process is ready (shader is compiled)
  108313. */
  108314. isReady(): boolean;
  108315. /**
  108316. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108317. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108318. */
  108319. apply(): Nullable<Effect>;
  108320. private _disposeTextures;
  108321. /**
  108322. * Sets the required values to the prepass renderer.
  108323. * @param prePassRenderer defines the prepass renderer to setup.
  108324. * @returns true if the pre pass is needed.
  108325. */
  108326. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108327. /**
  108328. * Disposes the post process.
  108329. * @param camera The camera to dispose the post process on.
  108330. */
  108331. dispose(camera?: Camera): void;
  108332. /**
  108333. * Serializes the particle system to a JSON object
  108334. * @returns the JSON object
  108335. */
  108336. serialize(): any;
  108337. /**
  108338. * Creates a material from parsed material data
  108339. * @param parsedPostProcess defines parsed post process data
  108340. * @param scene defines the hosting scene
  108341. * @param rootUrl defines the root URL to use to load textures
  108342. * @returns a new post process
  108343. */
  108344. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108345. }
  108346. }
  108347. declare module BABYLON {
  108348. /** @hidden */
  108349. export var kernelBlurVaryingDeclaration: {
  108350. name: string;
  108351. shader: string;
  108352. };
  108353. }
  108354. declare module BABYLON {
  108355. /** @hidden */
  108356. export var kernelBlurFragment: {
  108357. name: string;
  108358. shader: string;
  108359. };
  108360. }
  108361. declare module BABYLON {
  108362. /** @hidden */
  108363. export var kernelBlurFragment2: {
  108364. name: string;
  108365. shader: string;
  108366. };
  108367. }
  108368. declare module BABYLON {
  108369. /** @hidden */
  108370. export var kernelBlurPixelShader: {
  108371. name: string;
  108372. shader: string;
  108373. };
  108374. }
  108375. declare module BABYLON {
  108376. /** @hidden */
  108377. export var kernelBlurVertex: {
  108378. name: string;
  108379. shader: string;
  108380. };
  108381. }
  108382. declare module BABYLON {
  108383. /** @hidden */
  108384. export var kernelBlurVertexShader: {
  108385. name: string;
  108386. shader: string;
  108387. };
  108388. }
  108389. declare module BABYLON {
  108390. /**
  108391. * The Blur Post Process which blurs an image based on a kernel and direction.
  108392. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108393. */
  108394. export class BlurPostProcess extends PostProcess {
  108395. private blockCompilation;
  108396. protected _kernel: number;
  108397. protected _idealKernel: number;
  108398. protected _packedFloat: boolean;
  108399. private _staticDefines;
  108400. /** The direction in which to blur the image. */
  108401. direction: Vector2;
  108402. /**
  108403. * Sets the length in pixels of the blur sample region
  108404. */
  108405. set kernel(v: number);
  108406. /**
  108407. * Gets the length in pixels of the blur sample region
  108408. */
  108409. get kernel(): number;
  108410. /**
  108411. * Sets wether or not the blur needs to unpack/repack floats
  108412. */
  108413. set packedFloat(v: boolean);
  108414. /**
  108415. * Gets wether or not the blur is unpacking/repacking floats
  108416. */
  108417. get packedFloat(): boolean;
  108418. /**
  108419. * Gets a string identifying the name of the class
  108420. * @returns "BlurPostProcess" string
  108421. */
  108422. getClassName(): string;
  108423. /**
  108424. * Creates a new instance BlurPostProcess
  108425. * @param name The name of the effect.
  108426. * @param direction The direction in which to blur the image.
  108427. * @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.
  108428. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108429. * @param camera The camera to apply the render pass to.
  108430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108431. * @param engine The engine which the post process will be applied. (default: current engine)
  108432. * @param reusable If the post process can be reused on the same frame. (default: false)
  108433. * @param textureType Type of textures used when performing the post process. (default: 0)
  108434. * @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)
  108435. */
  108436. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  108437. /**
  108438. * Updates the effect with the current post process compile time values and recompiles the shader.
  108439. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108440. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108441. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108442. * @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
  108443. * @param onCompiled Called when the shader has been compiled.
  108444. * @param onError Called if there is an error when compiling a shader.
  108445. */
  108446. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108447. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108448. /**
  108449. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108450. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108451. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108452. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108453. * The gaps between physical kernels are compensated for in the weighting of the samples
  108454. * @param idealKernel Ideal blur kernel.
  108455. * @return Nearest best kernel.
  108456. */
  108457. protected _nearestBestKernel(idealKernel: number): number;
  108458. /**
  108459. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108460. * @param x The point on the Gaussian distribution to sample.
  108461. * @return the value of the Gaussian function at x.
  108462. */
  108463. protected _gaussianWeight(x: number): number;
  108464. /**
  108465. * Generates a string that can be used as a floating point number in GLSL.
  108466. * @param x Value to print.
  108467. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108468. * @return GLSL float string.
  108469. */
  108470. protected _glslFloat(x: number, decimalFigures?: number): string;
  108471. /** @hidden */
  108472. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108473. }
  108474. }
  108475. declare module BABYLON {
  108476. /**
  108477. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108478. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108479. * You can then easily use it as a reflectionTexture on a flat surface.
  108480. * In case the surface is not a plane, please consider relying on reflection probes.
  108481. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108482. */
  108483. export class MirrorTexture extends RenderTargetTexture {
  108484. private scene;
  108485. /**
  108486. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108487. * 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.
  108488. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108489. */
  108490. mirrorPlane: Plane;
  108491. /**
  108492. * Define the blur ratio used to blur the reflection if needed.
  108493. */
  108494. set blurRatio(value: number);
  108495. get blurRatio(): number;
  108496. /**
  108497. * Define the adaptive blur kernel used to blur the reflection if needed.
  108498. * This will autocompute the closest best match for the `blurKernel`
  108499. */
  108500. set adaptiveBlurKernel(value: number);
  108501. /**
  108502. * Define the blur kernel used to blur the reflection if needed.
  108503. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108504. */
  108505. set blurKernel(value: number);
  108506. /**
  108507. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108508. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108509. */
  108510. set blurKernelX(value: number);
  108511. get blurKernelX(): number;
  108512. /**
  108513. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108514. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108515. */
  108516. set blurKernelY(value: number);
  108517. get blurKernelY(): number;
  108518. private _autoComputeBlurKernel;
  108519. protected _onRatioRescale(): void;
  108520. private _updateGammaSpace;
  108521. private _imageProcessingConfigChangeObserver;
  108522. private _transformMatrix;
  108523. private _mirrorMatrix;
  108524. private _savedViewMatrix;
  108525. private _blurX;
  108526. private _blurY;
  108527. private _adaptiveBlurKernel;
  108528. private _blurKernelX;
  108529. private _blurKernelY;
  108530. private _blurRatio;
  108531. /**
  108532. * Instantiates a Mirror Texture.
  108533. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108534. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108535. * You can then easily use it as a reflectionTexture on a flat surface.
  108536. * In case the surface is not a plane, please consider relying on reflection probes.
  108537. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108538. * @param name
  108539. * @param size
  108540. * @param scene
  108541. * @param generateMipMaps
  108542. * @param type
  108543. * @param samplingMode
  108544. * @param generateDepthBuffer
  108545. */
  108546. constructor(name: string, size: number | {
  108547. width: number;
  108548. height: number;
  108549. } | {
  108550. ratio: number;
  108551. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108552. private _preparePostProcesses;
  108553. /**
  108554. * Clone the mirror texture.
  108555. * @returns the cloned texture
  108556. */
  108557. clone(): MirrorTexture;
  108558. /**
  108559. * Serialize the texture to a JSON representation you could use in Parse later on
  108560. * @returns the serialized JSON representation
  108561. */
  108562. serialize(): any;
  108563. /**
  108564. * Dispose the texture and release its associated resources.
  108565. */
  108566. dispose(): void;
  108567. }
  108568. }
  108569. declare module BABYLON {
  108570. /**
  108571. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108572. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108573. */
  108574. export class Texture extends BaseTexture {
  108575. /**
  108576. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108577. */
  108578. static SerializeBuffers: boolean;
  108579. /** @hidden */
  108580. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108581. /** @hidden */
  108582. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108583. /** @hidden */
  108584. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108585. /** nearest is mag = nearest and min = nearest and mip = linear */
  108586. static readonly NEAREST_SAMPLINGMODE: number;
  108587. /** nearest is mag = nearest and min = nearest and mip = linear */
  108588. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108589. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108590. static readonly BILINEAR_SAMPLINGMODE: number;
  108591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108592. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108593. /** Trilinear is mag = linear and min = linear and mip = linear */
  108594. static readonly TRILINEAR_SAMPLINGMODE: number;
  108595. /** Trilinear is mag = linear and min = linear and mip = linear */
  108596. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108597. /** mag = nearest and min = nearest and mip = nearest */
  108598. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108599. /** mag = nearest and min = linear and mip = nearest */
  108600. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108601. /** mag = nearest and min = linear and mip = linear */
  108602. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108603. /** mag = nearest and min = linear and mip = none */
  108604. static readonly NEAREST_LINEAR: number;
  108605. /** mag = nearest and min = nearest and mip = none */
  108606. static readonly NEAREST_NEAREST: number;
  108607. /** mag = linear and min = nearest and mip = nearest */
  108608. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108609. /** mag = linear and min = nearest and mip = linear */
  108610. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108611. /** mag = linear and min = linear and mip = none */
  108612. static readonly LINEAR_LINEAR: number;
  108613. /** mag = linear and min = nearest and mip = none */
  108614. static readonly LINEAR_NEAREST: number;
  108615. /** Explicit coordinates mode */
  108616. static readonly EXPLICIT_MODE: number;
  108617. /** Spherical coordinates mode */
  108618. static readonly SPHERICAL_MODE: number;
  108619. /** Planar coordinates mode */
  108620. static readonly PLANAR_MODE: number;
  108621. /** Cubic coordinates mode */
  108622. static readonly CUBIC_MODE: number;
  108623. /** Projection coordinates mode */
  108624. static readonly PROJECTION_MODE: number;
  108625. /** Inverse Cubic coordinates mode */
  108626. static readonly SKYBOX_MODE: number;
  108627. /** Inverse Cubic coordinates mode */
  108628. static readonly INVCUBIC_MODE: number;
  108629. /** Equirectangular coordinates mode */
  108630. static readonly EQUIRECTANGULAR_MODE: number;
  108631. /** Equirectangular Fixed coordinates mode */
  108632. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108633. /** Equirectangular Fixed Mirrored coordinates mode */
  108634. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108635. /** Texture is not repeating outside of 0..1 UVs */
  108636. static readonly CLAMP_ADDRESSMODE: number;
  108637. /** Texture is repeating outside of 0..1 UVs */
  108638. static readonly WRAP_ADDRESSMODE: number;
  108639. /** Texture is repeating and mirrored */
  108640. static readonly MIRROR_ADDRESSMODE: number;
  108641. /**
  108642. * 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
  108643. */
  108644. static UseSerializedUrlIfAny: boolean;
  108645. /**
  108646. * Define the url of the texture.
  108647. */
  108648. url: Nullable<string>;
  108649. /**
  108650. * Define an offset on the texture to offset the u coordinates of the UVs
  108651. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108652. */
  108653. uOffset: number;
  108654. /**
  108655. * Define an offset on the texture to offset the v coordinates of the UVs
  108656. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108657. */
  108658. vOffset: number;
  108659. /**
  108660. * Define an offset on the texture to scale the u coordinates of the UVs
  108661. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108662. */
  108663. uScale: number;
  108664. /**
  108665. * Define an offset on the texture to scale the v coordinates of the UVs
  108666. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108667. */
  108668. vScale: number;
  108669. /**
  108670. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108671. * @see https://doc.babylonjs.com/how_to/more_materials
  108672. */
  108673. uAng: number;
  108674. /**
  108675. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108676. * @see https://doc.babylonjs.com/how_to/more_materials
  108677. */
  108678. vAng: number;
  108679. /**
  108680. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108681. * @see https://doc.babylonjs.com/how_to/more_materials
  108682. */
  108683. wAng: number;
  108684. /**
  108685. * Defines the center of rotation (U)
  108686. */
  108687. uRotationCenter: number;
  108688. /**
  108689. * Defines the center of rotation (V)
  108690. */
  108691. vRotationCenter: number;
  108692. /**
  108693. * Defines the center of rotation (W)
  108694. */
  108695. wRotationCenter: number;
  108696. /**
  108697. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108698. */
  108699. homogeneousRotationInUVTransform: boolean;
  108700. /**
  108701. * Are mip maps generated for this texture or not.
  108702. */
  108703. get noMipmap(): boolean;
  108704. /**
  108705. * List of inspectable custom properties (used by the Inspector)
  108706. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108707. */
  108708. inspectableCustomProperties: Nullable<IInspectable[]>;
  108709. private _noMipmap;
  108710. /** @hidden */
  108711. _invertY: boolean;
  108712. private _rowGenerationMatrix;
  108713. private _cachedTextureMatrix;
  108714. private _projectionModeMatrix;
  108715. private _t0;
  108716. private _t1;
  108717. private _t2;
  108718. private _cachedUOffset;
  108719. private _cachedVOffset;
  108720. private _cachedUScale;
  108721. private _cachedVScale;
  108722. private _cachedUAng;
  108723. private _cachedVAng;
  108724. private _cachedWAng;
  108725. private _cachedProjectionMatrixId;
  108726. private _cachedURotationCenter;
  108727. private _cachedVRotationCenter;
  108728. private _cachedWRotationCenter;
  108729. private _cachedHomogeneousRotationInUVTransform;
  108730. private _cachedCoordinatesMode;
  108731. /** @hidden */
  108732. protected _initialSamplingMode: number;
  108733. /** @hidden */
  108734. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108735. private _deleteBuffer;
  108736. protected _format: Nullable<number>;
  108737. private _delayedOnLoad;
  108738. private _delayedOnError;
  108739. private _mimeType?;
  108740. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108741. get mimeType(): string | undefined;
  108742. /**
  108743. * Observable triggered once the texture has been loaded.
  108744. */
  108745. onLoadObservable: Observable<Texture>;
  108746. protected _isBlocking: boolean;
  108747. /**
  108748. * Is the texture preventing material to render while loading.
  108749. * If false, a default texture will be used instead of the loading one during the preparation step.
  108750. */
  108751. set isBlocking(value: boolean);
  108752. get isBlocking(): boolean;
  108753. /**
  108754. * Get the current sampling mode associated with the texture.
  108755. */
  108756. get samplingMode(): number;
  108757. /**
  108758. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108759. */
  108760. get invertY(): boolean;
  108761. /**
  108762. * Instantiates a new texture.
  108763. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108764. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108765. * @param url defines the url of the picture to load as a texture
  108766. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108767. * @param noMipmap defines if the texture will require mip maps or not
  108768. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108769. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108770. * @param onLoad defines a callback triggered when the texture has been loaded
  108771. * @param onError defines a callback triggered when an error occurred during the loading session
  108772. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108773. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108774. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108775. * @param mimeType defines an optional mime type information
  108776. */
  108777. 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);
  108778. /**
  108779. * Update the url (and optional buffer) of this texture if url was null during construction.
  108780. * @param url the url of the texture
  108781. * @param buffer the buffer of the texture (defaults to null)
  108782. * @param onLoad callback called when the texture is loaded (defaults to null)
  108783. */
  108784. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108785. /**
  108786. * Finish the loading sequence of a texture flagged as delayed load.
  108787. * @hidden
  108788. */
  108789. delayLoad(): void;
  108790. private _prepareRowForTextureGeneration;
  108791. /**
  108792. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108793. * @returns the transform matrix of the texture.
  108794. */
  108795. getTextureMatrix(uBase?: number): Matrix;
  108796. /**
  108797. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108798. * @returns The reflection texture transform
  108799. */
  108800. getReflectionTextureMatrix(): Matrix;
  108801. /**
  108802. * Clones the texture.
  108803. * @returns the cloned texture
  108804. */
  108805. clone(): Texture;
  108806. /**
  108807. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108808. * @returns The JSON representation of the texture
  108809. */
  108810. serialize(): any;
  108811. /**
  108812. * Get the current class name of the texture useful for serialization or dynamic coding.
  108813. * @returns "Texture"
  108814. */
  108815. getClassName(): string;
  108816. /**
  108817. * Dispose the texture and release its associated resources.
  108818. */
  108819. dispose(): void;
  108820. /**
  108821. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108822. * @param parsedTexture Define the JSON representation of the texture
  108823. * @param scene Define the scene the parsed texture should be instantiated in
  108824. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108825. * @returns The parsed texture if successful
  108826. */
  108827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108828. /**
  108829. * Creates a texture from its base 64 representation.
  108830. * @param data Define the base64 payload without the data: prefix
  108831. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108832. * @param scene Define the scene the texture should belong to
  108833. * @param noMipmap Forces the texture to not create mip map information if true
  108834. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108835. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108836. * @param onLoad define a callback triggered when the texture has been loaded
  108837. * @param onError define a callback triggered when an error occurred during the loading session
  108838. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108839. * @returns the created texture
  108840. */
  108841. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108842. /**
  108843. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108844. * @param data Define the base64 payload without the data: prefix
  108845. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108846. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108847. * @param scene Define the scene the texture should belong to
  108848. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108849. * @param noMipmap Forces the texture to not create mip map information if true
  108850. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108851. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108852. * @param onLoad define a callback triggered when the texture has been loaded
  108853. * @param onError define a callback triggered when an error occurred during the loading session
  108854. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108855. * @returns the created texture
  108856. */
  108857. 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;
  108858. }
  108859. }
  108860. declare module BABYLON {
  108861. /**
  108862. * PostProcessManager is used to manage one or more post processes or post process pipelines
  108863. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108864. */
  108865. export class PostProcessManager {
  108866. private _scene;
  108867. private _indexBuffer;
  108868. private _vertexBuffers;
  108869. /**
  108870. * Creates a new instance PostProcess
  108871. * @param scene The scene that the post process is associated with.
  108872. */
  108873. constructor(scene: Scene);
  108874. private _prepareBuffers;
  108875. private _buildIndexBuffer;
  108876. /**
  108877. * Rebuilds the vertex buffers of the manager.
  108878. * @hidden
  108879. */
  108880. _rebuild(): void;
  108881. /**
  108882. * Prepares a frame to be run through a post process.
  108883. * @param sourceTexture The input texture to the post procesess. (default: null)
  108884. * @param postProcesses An array of post processes to be run. (default: null)
  108885. * @returns True if the post processes were able to be run.
  108886. * @hidden
  108887. */
  108888. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  108889. /**
  108890. * Manually render a set of post processes to a texture.
  108891. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  108892. * @param postProcesses An array of post processes to be run.
  108893. * @param targetTexture The target texture to render to.
  108894. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  108895. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  108896. * @param lodLevel defines which lod of the texture to render to
  108897. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  108898. */
  108899. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  108900. /**
  108901. * Finalize the result of the output of the postprocesses.
  108902. * @param doNotPresent If true the result will not be displayed to the screen.
  108903. * @param targetTexture The target texture to render to.
  108904. * @param faceIndex The index of the face to bind the target texture to.
  108905. * @param postProcesses The array of post processes to render.
  108906. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  108907. * @hidden
  108908. */
  108909. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  108910. /**
  108911. * Disposes of the post process manager.
  108912. */
  108913. dispose(): void;
  108914. }
  108915. }
  108916. declare module BABYLON {
  108917. /**
  108918. * This Helps creating a texture that will be created from a camera in your scene.
  108919. * It is basically a dynamic texture that could be used to create special effects for instance.
  108920. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  108921. */
  108922. export class RenderTargetTexture extends Texture {
  108923. /**
  108924. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  108925. */
  108926. static readonly REFRESHRATE_RENDER_ONCE: number;
  108927. /**
  108928. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  108929. */
  108930. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  108931. /**
  108932. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  108933. * the central point of your effect and can save a lot of performances.
  108934. */
  108935. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  108936. /**
  108937. * Use this predicate to dynamically define the list of mesh you want to render.
  108938. * If set, the renderList property will be overwritten.
  108939. */
  108940. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  108941. private _renderList;
  108942. /**
  108943. * Use this list to define the list of mesh you want to render.
  108944. */
  108945. get renderList(): Nullable<Array<AbstractMesh>>;
  108946. set renderList(value: Nullable<Array<AbstractMesh>>);
  108947. /**
  108948. * Use this function to overload the renderList array at rendering time.
  108949. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  108950. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  108951. * the cube (if the RTT is a cube, else layerOrFace=0).
  108952. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  108953. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  108954. * hold dummy elements!
  108955. */
  108956. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  108957. private _hookArray;
  108958. /**
  108959. * Define if particles should be rendered in your texture.
  108960. */
  108961. renderParticles: boolean;
  108962. /**
  108963. * Define if sprites should be rendered in your texture.
  108964. */
  108965. renderSprites: boolean;
  108966. /**
  108967. * Define the camera used to render the texture.
  108968. */
  108969. activeCamera: Nullable<Camera>;
  108970. /**
  108971. * Override the mesh isReady function with your own one.
  108972. */
  108973. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  108974. /**
  108975. * Override the render function of the texture with your own one.
  108976. */
  108977. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  108978. /**
  108979. * Define if camera post processes should be use while rendering the texture.
  108980. */
  108981. useCameraPostProcesses: boolean;
  108982. /**
  108983. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  108984. */
  108985. ignoreCameraViewport: boolean;
  108986. private _postProcessManager;
  108987. private _postProcesses;
  108988. private _resizeObserver;
  108989. /**
  108990. * An event triggered when the texture is unbind.
  108991. */
  108992. onBeforeBindObservable: Observable<RenderTargetTexture>;
  108993. /**
  108994. * An event triggered when the texture is unbind.
  108995. */
  108996. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  108997. private _onAfterUnbindObserver;
  108998. /**
  108999. * Set a after unbind callback in the texture.
  109000. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109001. */
  109002. set onAfterUnbind(callback: () => void);
  109003. /**
  109004. * An event triggered before rendering the texture
  109005. */
  109006. onBeforeRenderObservable: Observable<number>;
  109007. private _onBeforeRenderObserver;
  109008. /**
  109009. * Set a before render callback in the texture.
  109010. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109011. */
  109012. set onBeforeRender(callback: (faceIndex: number) => void);
  109013. /**
  109014. * An event triggered after rendering the texture
  109015. */
  109016. onAfterRenderObservable: Observable<number>;
  109017. private _onAfterRenderObserver;
  109018. /**
  109019. * Set a after render callback in the texture.
  109020. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109021. */
  109022. set onAfterRender(callback: (faceIndex: number) => void);
  109023. /**
  109024. * An event triggered after the texture clear
  109025. */
  109026. onClearObservable: Observable<Engine>;
  109027. private _onClearObserver;
  109028. /**
  109029. * Set a clear callback in the texture.
  109030. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109031. */
  109032. set onClear(callback: (Engine: Engine) => void);
  109033. /**
  109034. * An event triggered when the texture is resized.
  109035. */
  109036. onResizeObservable: Observable<RenderTargetTexture>;
  109037. /**
  109038. * Define the clear color of the Render Target if it should be different from the scene.
  109039. */
  109040. clearColor: Color4;
  109041. protected _size: number | {
  109042. width: number;
  109043. height: number;
  109044. layers?: number;
  109045. };
  109046. protected _initialSizeParameter: number | {
  109047. width: number;
  109048. height: number;
  109049. } | {
  109050. ratio: number;
  109051. };
  109052. protected _sizeRatio: Nullable<number>;
  109053. /** @hidden */
  109054. _generateMipMaps: boolean;
  109055. protected _renderingManager: RenderingManager;
  109056. /** @hidden */
  109057. _waitingRenderList?: string[];
  109058. protected _doNotChangeAspectRatio: boolean;
  109059. protected _currentRefreshId: number;
  109060. protected _refreshRate: number;
  109061. protected _textureMatrix: Matrix;
  109062. protected _samples: number;
  109063. protected _renderTargetOptions: RenderTargetCreationOptions;
  109064. /**
  109065. * Gets render target creation options that were used.
  109066. */
  109067. get renderTargetOptions(): RenderTargetCreationOptions;
  109068. protected _onRatioRescale(): void;
  109069. /**
  109070. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109071. * It must define where the camera used to render the texture is set
  109072. */
  109073. boundingBoxPosition: Vector3;
  109074. private _boundingBoxSize;
  109075. /**
  109076. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109077. * When defined, the cubemap will switch to local mode
  109078. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109079. * @example https://www.babylonjs-playground.com/#RNASML
  109080. */
  109081. set boundingBoxSize(value: Vector3);
  109082. get boundingBoxSize(): Vector3;
  109083. /**
  109084. * In case the RTT has been created with a depth texture, get the associated
  109085. * depth texture.
  109086. * Otherwise, return null.
  109087. */
  109088. get depthStencilTexture(): Nullable<InternalTexture>;
  109089. /**
  109090. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109091. * or used a shadow, depth texture...
  109092. * @param name The friendly name of the texture
  109093. * @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)
  109094. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109095. * @param generateMipMaps True if mip maps need to be generated after render.
  109096. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109097. * @param type The type of the buffer in the RTT (int, half float, float...)
  109098. * @param isCube True if a cube texture needs to be created
  109099. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109100. * @param generateDepthBuffer True to generate a depth buffer
  109101. * @param generateStencilBuffer True to generate a stencil buffer
  109102. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109103. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109104. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109105. */
  109106. constructor(name: string, size: number | {
  109107. width: number;
  109108. height: number;
  109109. layers?: number;
  109110. } | {
  109111. ratio: number;
  109112. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109113. /**
  109114. * Creates a depth stencil texture.
  109115. * This is only available in WebGL 2 or with the depth texture extension available.
  109116. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109117. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109118. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109119. */
  109120. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109121. private _processSizeParameter;
  109122. /**
  109123. * Define the number of samples to use in case of MSAA.
  109124. * It defaults to one meaning no MSAA has been enabled.
  109125. */
  109126. get samples(): number;
  109127. set samples(value: number);
  109128. /**
  109129. * Resets the refresh counter of the texture and start bak from scratch.
  109130. * Could be useful to regenerate the texture if it is setup to render only once.
  109131. */
  109132. resetRefreshCounter(): void;
  109133. /**
  109134. * Define the refresh rate of the texture or the rendering frequency.
  109135. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109136. */
  109137. get refreshRate(): number;
  109138. set refreshRate(value: number);
  109139. /**
  109140. * Adds a post process to the render target rendering passes.
  109141. * @param postProcess define the post process to add
  109142. */
  109143. addPostProcess(postProcess: PostProcess): void;
  109144. /**
  109145. * Clear all the post processes attached to the render target
  109146. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109147. */
  109148. clearPostProcesses(dispose?: boolean): void;
  109149. /**
  109150. * Remove one of the post process from the list of attached post processes to the texture
  109151. * @param postProcess define the post process to remove from the list
  109152. */
  109153. removePostProcess(postProcess: PostProcess): void;
  109154. /** @hidden */
  109155. _shouldRender(): boolean;
  109156. /**
  109157. * Gets the actual render size of the texture.
  109158. * @returns the width of the render size
  109159. */
  109160. getRenderSize(): number;
  109161. /**
  109162. * Gets the actual render width of the texture.
  109163. * @returns the width of the render size
  109164. */
  109165. getRenderWidth(): number;
  109166. /**
  109167. * Gets the actual render height of the texture.
  109168. * @returns the height of the render size
  109169. */
  109170. getRenderHeight(): number;
  109171. /**
  109172. * Gets the actual number of layers of the texture.
  109173. * @returns the number of layers
  109174. */
  109175. getRenderLayers(): number;
  109176. /**
  109177. * Get if the texture can be rescaled or not.
  109178. */
  109179. get canRescale(): boolean;
  109180. /**
  109181. * Resize the texture using a ratio.
  109182. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109183. */
  109184. scale(ratio: number): void;
  109185. /**
  109186. * Get the texture reflection matrix used to rotate/transform the reflection.
  109187. * @returns the reflection matrix
  109188. */
  109189. getReflectionTextureMatrix(): Matrix;
  109190. /**
  109191. * Resize the texture to a new desired size.
  109192. * Be carrefull as it will recreate all the data in the new texture.
  109193. * @param size Define the new size. It can be:
  109194. * - a number for squared texture,
  109195. * - an object containing { width: number, height: number }
  109196. * - or an object containing a ratio { ratio: number }
  109197. */
  109198. resize(size: number | {
  109199. width: number;
  109200. height: number;
  109201. } | {
  109202. ratio: number;
  109203. }): void;
  109204. private _defaultRenderListPrepared;
  109205. /**
  109206. * Renders all the objects from the render list into the texture.
  109207. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109208. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109209. */
  109210. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109211. private _bestReflectionRenderTargetDimension;
  109212. private _prepareRenderingManager;
  109213. /**
  109214. * @hidden
  109215. * @param faceIndex face index to bind to if this is a cubetexture
  109216. * @param layer defines the index of the texture to bind in the array
  109217. */
  109218. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109219. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109220. private renderToTarget;
  109221. /**
  109222. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109223. * This allowed control for front to back rendering or reversly depending of the special needs.
  109224. *
  109225. * @param renderingGroupId The rendering group id corresponding to its index
  109226. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109227. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109228. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109229. */
  109230. 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;
  109231. /**
  109232. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109233. *
  109234. * @param renderingGroupId The rendering group id corresponding to its index
  109235. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109236. */
  109237. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109238. /**
  109239. * Clones the texture.
  109240. * @returns the cloned texture
  109241. */
  109242. clone(): RenderTargetTexture;
  109243. /**
  109244. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109245. * @returns The JSON representation of the texture
  109246. */
  109247. serialize(): any;
  109248. /**
  109249. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109250. */
  109251. disposeFramebufferObjects(): void;
  109252. /**
  109253. * Dispose the texture and release its associated resources.
  109254. */
  109255. dispose(): void;
  109256. /** @hidden */
  109257. _rebuild(): void;
  109258. /**
  109259. * Clear the info related to rendering groups preventing retention point in material dispose.
  109260. */
  109261. freeRenderingGroups(): void;
  109262. /**
  109263. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109264. * @returns the view count
  109265. */
  109266. getViewCount(): number;
  109267. }
  109268. }
  109269. declare module BABYLON {
  109270. /**
  109271. * Class used to manipulate GUIDs
  109272. */
  109273. export class GUID {
  109274. /**
  109275. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109276. * Be aware Math.random() could cause collisions, but:
  109277. * "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"
  109278. * @returns a pseudo random id
  109279. */
  109280. static RandomId(): string;
  109281. }
  109282. }
  109283. declare module BABYLON {
  109284. /**
  109285. * Options to be used when creating a shadow depth material
  109286. */
  109287. export interface IIOptionShadowDepthMaterial {
  109288. /** Variables in the vertex shader code that need to have their names remapped.
  109289. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109290. * "var_name" should be either: worldPos or vNormalW
  109291. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109292. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109293. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109294. */
  109295. remappedVariables?: string[];
  109296. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109297. standalone?: boolean;
  109298. }
  109299. /**
  109300. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109301. */
  109302. export class ShadowDepthWrapper {
  109303. private _scene;
  109304. private _options?;
  109305. private _baseMaterial;
  109306. private _onEffectCreatedObserver;
  109307. private _subMeshToEffect;
  109308. private _subMeshToDepthEffect;
  109309. private _meshes;
  109310. /** @hidden */
  109311. _matriceNames: any;
  109312. /** Gets the standalone status of the wrapper */
  109313. get standalone(): boolean;
  109314. /** Gets the base material the wrapper is built upon */
  109315. get baseMaterial(): Material;
  109316. /**
  109317. * Instantiate a new shadow depth wrapper.
  109318. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109319. * generate the shadow depth map. For more information, please refer to the documentation:
  109320. * https://doc.babylonjs.com/babylon101/shadows
  109321. * @param baseMaterial Material to wrap
  109322. * @param scene Define the scene the material belongs to
  109323. * @param options Options used to create the wrapper
  109324. */
  109325. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109326. /**
  109327. * Gets the effect to use to generate the depth map
  109328. * @param subMesh subMesh to get the effect for
  109329. * @param shadowGenerator shadow generator to get the effect for
  109330. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109331. */
  109332. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109333. /**
  109334. * Specifies that the submesh is ready to be used for depth rendering
  109335. * @param subMesh submesh to check
  109336. * @param defines the list of defines to take into account when checking the effect
  109337. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109338. * @param useInstances specifies that instances should be used
  109339. * @returns a boolean indicating that the submesh is ready or not
  109340. */
  109341. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109342. /**
  109343. * Disposes the resources
  109344. */
  109345. dispose(): void;
  109346. private _makeEffect;
  109347. }
  109348. }
  109349. declare module BABYLON {
  109350. /**
  109351. * Options for compiling materials.
  109352. */
  109353. export interface IMaterialCompilationOptions {
  109354. /**
  109355. * Defines whether clip planes are enabled.
  109356. */
  109357. clipPlane: boolean;
  109358. /**
  109359. * Defines whether instances are enabled.
  109360. */
  109361. useInstances: boolean;
  109362. }
  109363. /**
  109364. * Options passed when calling customShaderNameResolve
  109365. */
  109366. export interface ICustomShaderNameResolveOptions {
  109367. /**
  109368. * 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
  109369. */
  109370. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109371. }
  109372. /**
  109373. * Base class for the main features of a material in Babylon.js
  109374. */
  109375. export class Material implements IAnimatable {
  109376. /**
  109377. * Returns the triangle fill mode
  109378. */
  109379. static readonly TriangleFillMode: number;
  109380. /**
  109381. * Returns the wireframe mode
  109382. */
  109383. static readonly WireFrameFillMode: number;
  109384. /**
  109385. * Returns the point fill mode
  109386. */
  109387. static readonly PointFillMode: number;
  109388. /**
  109389. * Returns the point list draw mode
  109390. */
  109391. static readonly PointListDrawMode: number;
  109392. /**
  109393. * Returns the line list draw mode
  109394. */
  109395. static readonly LineListDrawMode: number;
  109396. /**
  109397. * Returns the line loop draw mode
  109398. */
  109399. static readonly LineLoopDrawMode: number;
  109400. /**
  109401. * Returns the line strip draw mode
  109402. */
  109403. static readonly LineStripDrawMode: number;
  109404. /**
  109405. * Returns the triangle strip draw mode
  109406. */
  109407. static readonly TriangleStripDrawMode: number;
  109408. /**
  109409. * Returns the triangle fan draw mode
  109410. */
  109411. static readonly TriangleFanDrawMode: number;
  109412. /**
  109413. * Stores the clock-wise side orientation
  109414. */
  109415. static readonly ClockWiseSideOrientation: number;
  109416. /**
  109417. * Stores the counter clock-wise side orientation
  109418. */
  109419. static readonly CounterClockWiseSideOrientation: number;
  109420. /**
  109421. * The dirty texture flag value
  109422. */
  109423. static readonly TextureDirtyFlag: number;
  109424. /**
  109425. * The dirty light flag value
  109426. */
  109427. static readonly LightDirtyFlag: number;
  109428. /**
  109429. * The dirty fresnel flag value
  109430. */
  109431. static readonly FresnelDirtyFlag: number;
  109432. /**
  109433. * The dirty attribute flag value
  109434. */
  109435. static readonly AttributesDirtyFlag: number;
  109436. /**
  109437. * The dirty misc flag value
  109438. */
  109439. static readonly MiscDirtyFlag: number;
  109440. /**
  109441. * The dirty prepass flag value
  109442. */
  109443. static readonly PrePassDirtyFlag: number;
  109444. /**
  109445. * The all dirty flag value
  109446. */
  109447. static readonly AllDirtyFlag: number;
  109448. /**
  109449. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109450. */
  109451. static readonly MATERIAL_OPAQUE: number;
  109452. /**
  109453. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109454. */
  109455. static readonly MATERIAL_ALPHATEST: number;
  109456. /**
  109457. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109458. */
  109459. static readonly MATERIAL_ALPHABLEND: number;
  109460. /**
  109461. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109462. * They are also discarded below the alpha cutoff threshold to improve performances.
  109463. */
  109464. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109465. /**
  109466. * The Whiteout method is used to blend normals.
  109467. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109468. */
  109469. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109470. /**
  109471. * The Reoriented Normal Mapping method is used to blend normals.
  109472. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109473. */
  109474. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109475. /**
  109476. * Custom callback helping to override the default shader used in the material.
  109477. */
  109478. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109479. /**
  109480. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109481. */
  109482. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109483. /**
  109484. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109485. * This means that the material can keep using a previous shader while a new one is being compiled.
  109486. * This is mostly used when shader parallel compilation is supported (true by default)
  109487. */
  109488. allowShaderHotSwapping: boolean;
  109489. /**
  109490. * The ID of the material
  109491. */
  109492. id: string;
  109493. /**
  109494. * Gets or sets the unique id of the material
  109495. */
  109496. uniqueId: number;
  109497. /**
  109498. * The name of the material
  109499. */
  109500. name: string;
  109501. /**
  109502. * Gets or sets user defined metadata
  109503. */
  109504. metadata: any;
  109505. /**
  109506. * For internal use only. Please do not use.
  109507. */
  109508. reservedDataStore: any;
  109509. /**
  109510. * Specifies if the ready state should be checked on each call
  109511. */
  109512. checkReadyOnEveryCall: boolean;
  109513. /**
  109514. * Specifies if the ready state should be checked once
  109515. */
  109516. checkReadyOnlyOnce: boolean;
  109517. /**
  109518. * The state of the material
  109519. */
  109520. state: string;
  109521. /**
  109522. * If the material can be rendered to several textures with MRT extension
  109523. */
  109524. get canRenderToMRT(): boolean;
  109525. /**
  109526. * The alpha value of the material
  109527. */
  109528. protected _alpha: number;
  109529. /**
  109530. * List of inspectable custom properties (used by the Inspector)
  109531. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109532. */
  109533. inspectableCustomProperties: IInspectable[];
  109534. /**
  109535. * Sets the alpha value of the material
  109536. */
  109537. set alpha(value: number);
  109538. /**
  109539. * Gets the alpha value of the material
  109540. */
  109541. get alpha(): number;
  109542. /**
  109543. * Specifies if back face culling is enabled
  109544. */
  109545. protected _backFaceCulling: boolean;
  109546. /**
  109547. * Sets the back-face culling state
  109548. */
  109549. set backFaceCulling(value: boolean);
  109550. /**
  109551. * Gets the back-face culling state
  109552. */
  109553. get backFaceCulling(): boolean;
  109554. /**
  109555. * Stores the value for side orientation
  109556. */
  109557. sideOrientation: number;
  109558. /**
  109559. * Callback triggered when the material is compiled
  109560. */
  109561. onCompiled: Nullable<(effect: Effect) => void>;
  109562. /**
  109563. * Callback triggered when an error occurs
  109564. */
  109565. onError: Nullable<(effect: Effect, errors: string) => void>;
  109566. /**
  109567. * Callback triggered to get the render target textures
  109568. */
  109569. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109570. /**
  109571. * Gets a boolean indicating that current material needs to register RTT
  109572. */
  109573. get hasRenderTargetTextures(): boolean;
  109574. /**
  109575. * Specifies if the material should be serialized
  109576. */
  109577. doNotSerialize: boolean;
  109578. /**
  109579. * @hidden
  109580. */
  109581. _storeEffectOnSubMeshes: boolean;
  109582. /**
  109583. * Stores the animations for the material
  109584. */
  109585. animations: Nullable<Array<Animation>>;
  109586. /**
  109587. * An event triggered when the material is disposed
  109588. */
  109589. onDisposeObservable: Observable<Material>;
  109590. /**
  109591. * An observer which watches for dispose events
  109592. */
  109593. private _onDisposeObserver;
  109594. private _onUnBindObservable;
  109595. /**
  109596. * Called during a dispose event
  109597. */
  109598. set onDispose(callback: () => void);
  109599. private _onBindObservable;
  109600. /**
  109601. * An event triggered when the material is bound
  109602. */
  109603. get onBindObservable(): Observable<AbstractMesh>;
  109604. /**
  109605. * An observer which watches for bind events
  109606. */
  109607. private _onBindObserver;
  109608. /**
  109609. * Called during a bind event
  109610. */
  109611. set onBind(callback: (Mesh: AbstractMesh) => void);
  109612. /**
  109613. * An event triggered when the material is unbound
  109614. */
  109615. get onUnBindObservable(): Observable<Material>;
  109616. protected _onEffectCreatedObservable: Nullable<Observable<{
  109617. effect: Effect;
  109618. subMesh: Nullable<SubMesh>;
  109619. }>>;
  109620. /**
  109621. * An event triggered when the effect is (re)created
  109622. */
  109623. get onEffectCreatedObservable(): Observable<{
  109624. effect: Effect;
  109625. subMesh: Nullable<SubMesh>;
  109626. }>;
  109627. /**
  109628. * Stores the value of the alpha mode
  109629. */
  109630. private _alphaMode;
  109631. /**
  109632. * Sets the value of the alpha mode.
  109633. *
  109634. * | Value | Type | Description |
  109635. * | --- | --- | --- |
  109636. * | 0 | ALPHA_DISABLE | |
  109637. * | 1 | ALPHA_ADD | |
  109638. * | 2 | ALPHA_COMBINE | |
  109639. * | 3 | ALPHA_SUBTRACT | |
  109640. * | 4 | ALPHA_MULTIPLY | |
  109641. * | 5 | ALPHA_MAXIMIZED | |
  109642. * | 6 | ALPHA_ONEONE | |
  109643. * | 7 | ALPHA_PREMULTIPLIED | |
  109644. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109645. * | 9 | ALPHA_INTERPOLATE | |
  109646. * | 10 | ALPHA_SCREENMODE | |
  109647. *
  109648. */
  109649. set alphaMode(value: number);
  109650. /**
  109651. * Gets the value of the alpha mode
  109652. */
  109653. get alphaMode(): number;
  109654. /**
  109655. * Stores the state of the need depth pre-pass value
  109656. */
  109657. private _needDepthPrePass;
  109658. /**
  109659. * Sets the need depth pre-pass value
  109660. */
  109661. set needDepthPrePass(value: boolean);
  109662. /**
  109663. * Gets the depth pre-pass value
  109664. */
  109665. get needDepthPrePass(): boolean;
  109666. /**
  109667. * Specifies if depth writing should be disabled
  109668. */
  109669. disableDepthWrite: boolean;
  109670. /**
  109671. * Specifies if color writing should be disabled
  109672. */
  109673. disableColorWrite: boolean;
  109674. /**
  109675. * Specifies if depth writing should be forced
  109676. */
  109677. forceDepthWrite: boolean;
  109678. /**
  109679. * Specifies the depth function that should be used. 0 means the default engine function
  109680. */
  109681. depthFunction: number;
  109682. /**
  109683. * Specifies if there should be a separate pass for culling
  109684. */
  109685. separateCullingPass: boolean;
  109686. /**
  109687. * Stores the state specifing if fog should be enabled
  109688. */
  109689. private _fogEnabled;
  109690. /**
  109691. * Sets the state for enabling fog
  109692. */
  109693. set fogEnabled(value: boolean);
  109694. /**
  109695. * Gets the value of the fog enabled state
  109696. */
  109697. get fogEnabled(): boolean;
  109698. /**
  109699. * Stores the size of points
  109700. */
  109701. pointSize: number;
  109702. /**
  109703. * Stores the z offset value
  109704. */
  109705. zOffset: number;
  109706. get wireframe(): boolean;
  109707. /**
  109708. * Sets the state of wireframe mode
  109709. */
  109710. set wireframe(value: boolean);
  109711. /**
  109712. * Gets the value specifying if point clouds are enabled
  109713. */
  109714. get pointsCloud(): boolean;
  109715. /**
  109716. * Sets the state of point cloud mode
  109717. */
  109718. set pointsCloud(value: boolean);
  109719. /**
  109720. * Gets the material fill mode
  109721. */
  109722. get fillMode(): number;
  109723. /**
  109724. * Sets the material fill mode
  109725. */
  109726. set fillMode(value: number);
  109727. /**
  109728. * @hidden
  109729. * Stores the effects for the material
  109730. */
  109731. _effect: Nullable<Effect>;
  109732. /**
  109733. * Specifies if uniform buffers should be used
  109734. */
  109735. private _useUBO;
  109736. /**
  109737. * Stores a reference to the scene
  109738. */
  109739. private _scene;
  109740. /**
  109741. * Stores the fill mode state
  109742. */
  109743. private _fillMode;
  109744. /**
  109745. * Specifies if the depth write state should be cached
  109746. */
  109747. private _cachedDepthWriteState;
  109748. /**
  109749. * Specifies if the color write state should be cached
  109750. */
  109751. private _cachedColorWriteState;
  109752. /**
  109753. * Specifies if the depth function state should be cached
  109754. */
  109755. private _cachedDepthFunctionState;
  109756. /**
  109757. * Stores the uniform buffer
  109758. */
  109759. protected _uniformBuffer: UniformBuffer;
  109760. /** @hidden */
  109761. _indexInSceneMaterialArray: number;
  109762. /** @hidden */
  109763. meshMap: Nullable<{
  109764. [id: string]: AbstractMesh | undefined;
  109765. }>;
  109766. /**
  109767. * Creates a material instance
  109768. * @param name defines the name of the material
  109769. * @param scene defines the scene to reference
  109770. * @param doNotAdd specifies if the material should be added to the scene
  109771. */
  109772. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  109773. /**
  109774. * Returns a string representation of the current material
  109775. * @param fullDetails defines a boolean indicating which levels of logging is desired
  109776. * @returns a string with material information
  109777. */
  109778. toString(fullDetails?: boolean): string;
  109779. /**
  109780. * Gets the class name of the material
  109781. * @returns a string with the class name of the material
  109782. */
  109783. getClassName(): string;
  109784. /**
  109785. * Specifies if updates for the material been locked
  109786. */
  109787. get isFrozen(): boolean;
  109788. /**
  109789. * Locks updates for the material
  109790. */
  109791. freeze(): void;
  109792. /**
  109793. * Unlocks updates for the material
  109794. */
  109795. unfreeze(): void;
  109796. /**
  109797. * Specifies if the material is ready to be used
  109798. * @param mesh defines the mesh to check
  109799. * @param useInstances specifies if instances should be used
  109800. * @returns a boolean indicating if the material is ready to be used
  109801. */
  109802. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109803. /**
  109804. * Specifies that the submesh is ready to be used
  109805. * @param mesh defines the mesh to check
  109806. * @param subMesh defines which submesh to check
  109807. * @param useInstances specifies that instances should be used
  109808. * @returns a boolean indicating that the submesh is ready or not
  109809. */
  109810. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109811. /**
  109812. * Returns the material effect
  109813. * @returns the effect associated with the material
  109814. */
  109815. getEffect(): Nullable<Effect>;
  109816. /**
  109817. * Returns the current scene
  109818. * @returns a Scene
  109819. */
  109820. getScene(): Scene;
  109821. /**
  109822. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109823. */
  109824. protected _forceAlphaTest: boolean;
  109825. /**
  109826. * The transparency mode of the material.
  109827. */
  109828. protected _transparencyMode: Nullable<number>;
  109829. /**
  109830. * Gets the current transparency mode.
  109831. */
  109832. get transparencyMode(): Nullable<number>;
  109833. /**
  109834. * Sets the transparency mode of the material.
  109835. *
  109836. * | Value | Type | Description |
  109837. * | ----- | ----------------------------------- | ----------- |
  109838. * | 0 | OPAQUE | |
  109839. * | 1 | ALPHATEST | |
  109840. * | 2 | ALPHABLEND | |
  109841. * | 3 | ALPHATESTANDBLEND | |
  109842. *
  109843. */
  109844. set transparencyMode(value: Nullable<number>);
  109845. /**
  109846. * Returns true if alpha blending should be disabled.
  109847. */
  109848. protected get _disableAlphaBlending(): boolean;
  109849. /**
  109850. * Specifies whether or not this material should be rendered in alpha blend mode.
  109851. * @returns a boolean specifying if alpha blending is needed
  109852. */
  109853. needAlphaBlending(): boolean;
  109854. /**
  109855. * Specifies if the mesh will require alpha blending
  109856. * @param mesh defines the mesh to check
  109857. * @returns a boolean specifying if alpha blending is needed for the mesh
  109858. */
  109859. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109860. /**
  109861. * Specifies whether or not this material should be rendered in alpha test mode.
  109862. * @returns a boolean specifying if an alpha test is needed.
  109863. */
  109864. needAlphaTesting(): boolean;
  109865. /**
  109866. * Specifies if material alpha testing should be turned on for the mesh
  109867. * @param mesh defines the mesh to check
  109868. */
  109869. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  109870. /**
  109871. * Gets the texture used for the alpha test
  109872. * @returns the texture to use for alpha testing
  109873. */
  109874. getAlphaTestTexture(): Nullable<BaseTexture>;
  109875. /**
  109876. * Marks the material to indicate that it needs to be re-calculated
  109877. */
  109878. markDirty(): void;
  109879. /** @hidden */
  109880. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  109881. /**
  109882. * Binds the material to the mesh
  109883. * @param world defines the world transformation matrix
  109884. * @param mesh defines the mesh to bind the material to
  109885. */
  109886. bind(world: Matrix, mesh?: Mesh): void;
  109887. /**
  109888. * Binds the submesh to the material
  109889. * @param world defines the world transformation matrix
  109890. * @param mesh defines the mesh containing the submesh
  109891. * @param subMesh defines the submesh to bind the material to
  109892. */
  109893. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109894. /**
  109895. * Binds the world matrix to the material
  109896. * @param world defines the world transformation matrix
  109897. */
  109898. bindOnlyWorldMatrix(world: Matrix): void;
  109899. /**
  109900. * Binds the scene's uniform buffer to the effect.
  109901. * @param effect defines the effect to bind to the scene uniform buffer
  109902. * @param sceneUbo defines the uniform buffer storing scene data
  109903. */
  109904. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  109905. /**
  109906. * Binds the view matrix to the effect
  109907. * @param effect defines the effect to bind the view matrix to
  109908. */
  109909. bindView(effect: Effect): void;
  109910. /**
  109911. * Binds the view projection matrix to the effect
  109912. * @param effect defines the effect to bind the view projection matrix to
  109913. */
  109914. bindViewProjection(effect: Effect): void;
  109915. /**
  109916. * Processes to execute after binding the material to a mesh
  109917. * @param mesh defines the rendered mesh
  109918. */
  109919. protected _afterBind(mesh?: Mesh): void;
  109920. /**
  109921. * Unbinds the material from the mesh
  109922. */
  109923. unbind(): void;
  109924. /**
  109925. * Gets the active textures from the material
  109926. * @returns an array of textures
  109927. */
  109928. getActiveTextures(): BaseTexture[];
  109929. /**
  109930. * Specifies if the material uses a texture
  109931. * @param texture defines the texture to check against the material
  109932. * @returns a boolean specifying if the material uses the texture
  109933. */
  109934. hasTexture(texture: BaseTexture): boolean;
  109935. /**
  109936. * Makes a duplicate of the material, and gives it a new name
  109937. * @param name defines the new name for the duplicated material
  109938. * @returns the cloned material
  109939. */
  109940. clone(name: string): Nullable<Material>;
  109941. /**
  109942. * Gets the meshes bound to the material
  109943. * @returns an array of meshes bound to the material
  109944. */
  109945. getBindedMeshes(): AbstractMesh[];
  109946. /**
  109947. * Force shader compilation
  109948. * @param mesh defines the mesh associated with this material
  109949. * @param onCompiled defines a function to execute once the material is compiled
  109950. * @param options defines the options to configure the compilation
  109951. * @param onError defines a function to execute if the material fails compiling
  109952. */
  109953. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  109954. /**
  109955. * Force shader compilation
  109956. * @param mesh defines the mesh that will use this material
  109957. * @param options defines additional options for compiling the shaders
  109958. * @returns a promise that resolves when the compilation completes
  109959. */
  109960. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  109961. private static readonly _AllDirtyCallBack;
  109962. private static readonly _ImageProcessingDirtyCallBack;
  109963. private static readonly _TextureDirtyCallBack;
  109964. private static readonly _FresnelDirtyCallBack;
  109965. private static readonly _MiscDirtyCallBack;
  109966. private static readonly _PrePassDirtyCallBack;
  109967. private static readonly _LightsDirtyCallBack;
  109968. private static readonly _AttributeDirtyCallBack;
  109969. private static _FresnelAndMiscDirtyCallBack;
  109970. private static _TextureAndMiscDirtyCallBack;
  109971. private static readonly _DirtyCallbackArray;
  109972. private static readonly _RunDirtyCallBacks;
  109973. /**
  109974. * Marks a define in the material to indicate that it needs to be re-computed
  109975. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  109976. */
  109977. markAsDirty(flag: number): void;
  109978. /**
  109979. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  109980. * @param func defines a function which checks material defines against the submeshes
  109981. */
  109982. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  109983. /**
  109984. * Indicates that the scene should check if the rendering now needs a prepass
  109985. */
  109986. protected _markScenePrePassDirty(): void;
  109987. /**
  109988. * Indicates that we need to re-calculated for all submeshes
  109989. */
  109990. protected _markAllSubMeshesAsAllDirty(): void;
  109991. /**
  109992. * Indicates that image processing needs to be re-calculated for all submeshes
  109993. */
  109994. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  109995. /**
  109996. * Indicates that textures need to be re-calculated for all submeshes
  109997. */
  109998. protected _markAllSubMeshesAsTexturesDirty(): void;
  109999. /**
  110000. * Indicates that fresnel needs to be re-calculated for all submeshes
  110001. */
  110002. protected _markAllSubMeshesAsFresnelDirty(): void;
  110003. /**
  110004. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110005. */
  110006. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110007. /**
  110008. * Indicates that lights need to be re-calculated for all submeshes
  110009. */
  110010. protected _markAllSubMeshesAsLightsDirty(): void;
  110011. /**
  110012. * Indicates that attributes need to be re-calculated for all submeshes
  110013. */
  110014. protected _markAllSubMeshesAsAttributesDirty(): void;
  110015. /**
  110016. * Indicates that misc needs to be re-calculated for all submeshes
  110017. */
  110018. protected _markAllSubMeshesAsMiscDirty(): void;
  110019. /**
  110020. * Indicates that prepass needs to be re-calculated for all submeshes
  110021. */
  110022. protected _markAllSubMeshesAsPrePassDirty(): void;
  110023. /**
  110024. * Indicates that textures and misc need to be re-calculated for all submeshes
  110025. */
  110026. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110027. /**
  110028. * Sets the required values to the prepass renderer.
  110029. * @param prePassRenderer defines the prepass renderer to setup.
  110030. * @returns true if the pre pass is needed.
  110031. */
  110032. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110033. /**
  110034. * Disposes the material
  110035. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110036. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110037. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110038. */
  110039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110040. /** @hidden */
  110041. private releaseVertexArrayObject;
  110042. /**
  110043. * Serializes this material
  110044. * @returns the serialized material object
  110045. */
  110046. serialize(): any;
  110047. /**
  110048. * Creates a material from parsed material data
  110049. * @param parsedMaterial defines parsed material data
  110050. * @param scene defines the hosting scene
  110051. * @param rootUrl defines the root URL to use to load textures
  110052. * @returns a new material
  110053. */
  110054. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110055. }
  110056. }
  110057. declare module BABYLON {
  110058. /**
  110059. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110060. * separate meshes. This can be use to improve performances.
  110061. * @see https://doc.babylonjs.com/how_to/multi_materials
  110062. */
  110063. export class MultiMaterial extends Material {
  110064. private _subMaterials;
  110065. /**
  110066. * Gets or Sets the list of Materials used within the multi material.
  110067. * They need to be ordered according to the submeshes order in the associated mesh
  110068. */
  110069. get subMaterials(): Nullable<Material>[];
  110070. set subMaterials(value: Nullable<Material>[]);
  110071. /**
  110072. * Function used to align with Node.getChildren()
  110073. * @returns the list of Materials used within the multi material
  110074. */
  110075. getChildren(): Nullable<Material>[];
  110076. /**
  110077. * Instantiates a new Multi Material
  110078. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110079. * separate meshes. This can be use to improve performances.
  110080. * @see https://doc.babylonjs.com/how_to/multi_materials
  110081. * @param name Define the name in the scene
  110082. * @param scene Define the scene the material belongs to
  110083. */
  110084. constructor(name: string, scene: Scene);
  110085. private _hookArray;
  110086. /**
  110087. * Get one of the submaterial by its index in the submaterials array
  110088. * @param index The index to look the sub material at
  110089. * @returns The Material if the index has been defined
  110090. */
  110091. getSubMaterial(index: number): Nullable<Material>;
  110092. /**
  110093. * Get the list of active textures for the whole sub materials list.
  110094. * @returns All the textures that will be used during the rendering
  110095. */
  110096. getActiveTextures(): BaseTexture[];
  110097. /**
  110098. * Gets the current class name of the material e.g. "MultiMaterial"
  110099. * Mainly use in serialization.
  110100. * @returns the class name
  110101. */
  110102. getClassName(): string;
  110103. /**
  110104. * Checks if the material is ready to render the requested sub mesh
  110105. * @param mesh Define the mesh the submesh belongs to
  110106. * @param subMesh Define the sub mesh to look readyness for
  110107. * @param useInstances Define whether or not the material is used with instances
  110108. * @returns true if ready, otherwise false
  110109. */
  110110. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110111. /**
  110112. * Clones the current material and its related sub materials
  110113. * @param name Define the name of the newly cloned material
  110114. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110115. * @returns the cloned material
  110116. */
  110117. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110118. /**
  110119. * Serializes the materials into a JSON representation.
  110120. * @returns the JSON representation
  110121. */
  110122. serialize(): any;
  110123. /**
  110124. * Dispose the material and release its associated resources
  110125. * @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)
  110126. * @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)
  110127. * @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)
  110128. */
  110129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110130. /**
  110131. * Creates a MultiMaterial from parsed MultiMaterial data.
  110132. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110133. * @param scene defines the hosting scene
  110134. * @returns a new MultiMaterial
  110135. */
  110136. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110137. }
  110138. }
  110139. declare module BABYLON {
  110140. /**
  110141. * Defines a subdivision inside a mesh
  110142. */
  110143. export class SubMesh implements ICullable {
  110144. /** the material index to use */
  110145. materialIndex: number;
  110146. /** vertex index start */
  110147. verticesStart: number;
  110148. /** vertices count */
  110149. verticesCount: number;
  110150. /** index start */
  110151. indexStart: number;
  110152. /** indices count */
  110153. indexCount: number;
  110154. /** @hidden */
  110155. _materialDefines: Nullable<MaterialDefines>;
  110156. /** @hidden */
  110157. _materialEffect: Nullable<Effect>;
  110158. /** @hidden */
  110159. _effectOverride: Nullable<Effect>;
  110160. /**
  110161. * Gets material defines used by the effect associated to the sub mesh
  110162. */
  110163. get materialDefines(): Nullable<MaterialDefines>;
  110164. /**
  110165. * Sets material defines used by the effect associated to the sub mesh
  110166. */
  110167. set materialDefines(defines: Nullable<MaterialDefines>);
  110168. /**
  110169. * Gets associated effect
  110170. */
  110171. get effect(): Nullable<Effect>;
  110172. /**
  110173. * Sets associated effect (effect used to render this submesh)
  110174. * @param effect defines the effect to associate with
  110175. * @param defines defines the set of defines used to compile this effect
  110176. */
  110177. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110178. /** @hidden */
  110179. _linesIndexCount: number;
  110180. private _mesh;
  110181. private _renderingMesh;
  110182. private _boundingInfo;
  110183. private _linesIndexBuffer;
  110184. /** @hidden */
  110185. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110186. /** @hidden */
  110187. _trianglePlanes: Plane[];
  110188. /** @hidden */
  110189. _lastColliderTransformMatrix: Nullable<Matrix>;
  110190. /** @hidden */
  110191. _renderId: number;
  110192. /** @hidden */
  110193. _alphaIndex: number;
  110194. /** @hidden */
  110195. _distanceToCamera: number;
  110196. /** @hidden */
  110197. _id: number;
  110198. private _currentMaterial;
  110199. /**
  110200. * Add a new submesh to a mesh
  110201. * @param materialIndex defines the material index to use
  110202. * @param verticesStart defines vertex index start
  110203. * @param verticesCount defines vertices count
  110204. * @param indexStart defines index start
  110205. * @param indexCount defines indices count
  110206. * @param mesh defines the parent mesh
  110207. * @param renderingMesh defines an optional rendering mesh
  110208. * @param createBoundingBox defines if bounding box should be created for this submesh
  110209. * @returns the new submesh
  110210. */
  110211. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110212. /**
  110213. * Creates a new submesh
  110214. * @param materialIndex defines the material index to use
  110215. * @param verticesStart defines vertex index start
  110216. * @param verticesCount defines vertices count
  110217. * @param indexStart defines index start
  110218. * @param indexCount defines indices count
  110219. * @param mesh defines the parent mesh
  110220. * @param renderingMesh defines an optional rendering mesh
  110221. * @param createBoundingBox defines if bounding box should be created for this submesh
  110222. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110223. */
  110224. constructor(
  110225. /** the material index to use */
  110226. materialIndex: number,
  110227. /** vertex index start */
  110228. verticesStart: number,
  110229. /** vertices count */
  110230. verticesCount: number,
  110231. /** index start */
  110232. indexStart: number,
  110233. /** indices count */
  110234. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110235. /**
  110236. * Returns true if this submesh covers the entire parent mesh
  110237. * @ignorenaming
  110238. */
  110239. get IsGlobal(): boolean;
  110240. /**
  110241. * Returns the submesh BoudingInfo object
  110242. * @returns current bounding info (or mesh's one if the submesh is global)
  110243. */
  110244. getBoundingInfo(): BoundingInfo;
  110245. /**
  110246. * Sets the submesh BoundingInfo
  110247. * @param boundingInfo defines the new bounding info to use
  110248. * @returns the SubMesh
  110249. */
  110250. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110251. /**
  110252. * Returns the mesh of the current submesh
  110253. * @return the parent mesh
  110254. */
  110255. getMesh(): AbstractMesh;
  110256. /**
  110257. * Returns the rendering mesh of the submesh
  110258. * @returns the rendering mesh (could be different from parent mesh)
  110259. */
  110260. getRenderingMesh(): Mesh;
  110261. /**
  110262. * Returns the replacement mesh of the submesh
  110263. * @returns the replacement mesh (could be different from parent mesh)
  110264. */
  110265. getReplacementMesh(): Nullable<AbstractMesh>;
  110266. /**
  110267. * Returns the effective mesh of the submesh
  110268. * @returns the effective mesh (could be different from parent mesh)
  110269. */
  110270. getEffectiveMesh(): AbstractMesh;
  110271. /**
  110272. * Returns the submesh material
  110273. * @returns null or the current material
  110274. */
  110275. getMaterial(): Nullable<Material>;
  110276. private _IsMultiMaterial;
  110277. /**
  110278. * Sets a new updated BoundingInfo object to the submesh
  110279. * @param data defines an optional position array to use to determine the bounding info
  110280. * @returns the SubMesh
  110281. */
  110282. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110283. /** @hidden */
  110284. _checkCollision(collider: Collider): boolean;
  110285. /**
  110286. * Updates the submesh BoundingInfo
  110287. * @param world defines the world matrix to use to update the bounding info
  110288. * @returns the submesh
  110289. */
  110290. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110291. /**
  110292. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110293. * @param frustumPlanes defines the frustum planes
  110294. * @returns true if the submesh is intersecting with the frustum
  110295. */
  110296. isInFrustum(frustumPlanes: Plane[]): boolean;
  110297. /**
  110298. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110299. * @param frustumPlanes defines the frustum planes
  110300. * @returns true if the submesh is inside the frustum
  110301. */
  110302. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110303. /**
  110304. * Renders the submesh
  110305. * @param enableAlphaMode defines if alpha needs to be used
  110306. * @returns the submesh
  110307. */
  110308. render(enableAlphaMode: boolean): SubMesh;
  110309. /**
  110310. * @hidden
  110311. */
  110312. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110313. /**
  110314. * Checks if the submesh intersects with a ray
  110315. * @param ray defines the ray to test
  110316. * @returns true is the passed ray intersects the submesh bounding box
  110317. */
  110318. canIntersects(ray: Ray): boolean;
  110319. /**
  110320. * Intersects current submesh with a ray
  110321. * @param ray defines the ray to test
  110322. * @param positions defines mesh's positions array
  110323. * @param indices defines mesh's indices array
  110324. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110326. * @returns intersection info or null if no intersection
  110327. */
  110328. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110329. /** @hidden */
  110330. private _intersectLines;
  110331. /** @hidden */
  110332. private _intersectUnIndexedLines;
  110333. /** @hidden */
  110334. private _intersectTriangles;
  110335. /** @hidden */
  110336. private _intersectUnIndexedTriangles;
  110337. /** @hidden */
  110338. _rebuild(): void;
  110339. /**
  110340. * Creates a new submesh from the passed mesh
  110341. * @param newMesh defines the new hosting mesh
  110342. * @param newRenderingMesh defines an optional rendering mesh
  110343. * @returns the new submesh
  110344. */
  110345. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110346. /**
  110347. * Release associated resources
  110348. */
  110349. dispose(): void;
  110350. /**
  110351. * Gets the class name
  110352. * @returns the string "SubMesh".
  110353. */
  110354. getClassName(): string;
  110355. /**
  110356. * Creates a new submesh from indices data
  110357. * @param materialIndex the index of the main mesh material
  110358. * @param startIndex the index where to start the copy in the mesh indices array
  110359. * @param indexCount the number of indices to copy then from the startIndex
  110360. * @param mesh the main mesh to create the submesh from
  110361. * @param renderingMesh the optional rendering mesh
  110362. * @returns a new submesh
  110363. */
  110364. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110365. }
  110366. }
  110367. declare module BABYLON {
  110368. /**
  110369. * Class used to represent data loading progression
  110370. */
  110371. export class SceneLoaderFlags {
  110372. private static _ForceFullSceneLoadingForIncremental;
  110373. private static _ShowLoadingScreen;
  110374. private static _CleanBoneMatrixWeights;
  110375. private static _loggingLevel;
  110376. /**
  110377. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110378. */
  110379. static get ForceFullSceneLoadingForIncremental(): boolean;
  110380. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110381. /**
  110382. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110383. */
  110384. static get ShowLoadingScreen(): boolean;
  110385. static set ShowLoadingScreen(value: boolean);
  110386. /**
  110387. * Defines the current logging level (while loading the scene)
  110388. * @ignorenaming
  110389. */
  110390. static get loggingLevel(): number;
  110391. static set loggingLevel(value: number);
  110392. /**
  110393. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110394. */
  110395. static get CleanBoneMatrixWeights(): boolean;
  110396. static set CleanBoneMatrixWeights(value: boolean);
  110397. }
  110398. }
  110399. declare module BABYLON {
  110400. /**
  110401. * Class used to store geometry data (vertex buffers + index buffer)
  110402. */
  110403. export class Geometry implements IGetSetVerticesData {
  110404. /**
  110405. * Gets or sets the ID of the geometry
  110406. */
  110407. id: string;
  110408. /**
  110409. * Gets or sets the unique ID of the geometry
  110410. */
  110411. uniqueId: number;
  110412. /**
  110413. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110414. */
  110415. delayLoadState: number;
  110416. /**
  110417. * Gets the file containing the data to load when running in delay load state
  110418. */
  110419. delayLoadingFile: Nullable<string>;
  110420. /**
  110421. * Callback called when the geometry is updated
  110422. */
  110423. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110424. private _scene;
  110425. private _engine;
  110426. private _meshes;
  110427. private _totalVertices;
  110428. /** @hidden */
  110429. _indices: IndicesArray;
  110430. /** @hidden */
  110431. _vertexBuffers: {
  110432. [key: string]: VertexBuffer;
  110433. };
  110434. private _isDisposed;
  110435. private _extend;
  110436. private _boundingBias;
  110437. /** @hidden */
  110438. _delayInfo: Array<string>;
  110439. private _indexBuffer;
  110440. private _indexBufferIsUpdatable;
  110441. /** @hidden */
  110442. _boundingInfo: Nullable<BoundingInfo>;
  110443. /** @hidden */
  110444. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110445. /** @hidden */
  110446. _softwareSkinningFrameId: number;
  110447. private _vertexArrayObjects;
  110448. private _updatable;
  110449. /** @hidden */
  110450. _positions: Nullable<Vector3[]>;
  110451. /**
  110452. * 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
  110453. */
  110454. get boundingBias(): Vector2;
  110455. /**
  110456. * 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
  110457. */
  110458. set boundingBias(value: Vector2);
  110459. /**
  110460. * Static function used to attach a new empty geometry to a mesh
  110461. * @param mesh defines the mesh to attach the geometry to
  110462. * @returns the new Geometry
  110463. */
  110464. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110465. /** Get the list of meshes using this geometry */
  110466. get meshes(): Mesh[];
  110467. /**
  110468. * 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
  110469. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110470. */
  110471. useBoundingInfoFromGeometry: boolean;
  110472. /**
  110473. * Creates a new geometry
  110474. * @param id defines the unique ID
  110475. * @param scene defines the hosting scene
  110476. * @param vertexData defines the VertexData used to get geometry data
  110477. * @param updatable defines if geometry must be updatable (false by default)
  110478. * @param mesh defines the mesh that will be associated with the geometry
  110479. */
  110480. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110481. /**
  110482. * Gets the current extend of the geometry
  110483. */
  110484. get extend(): {
  110485. minimum: Vector3;
  110486. maximum: Vector3;
  110487. };
  110488. /**
  110489. * Gets the hosting scene
  110490. * @returns the hosting Scene
  110491. */
  110492. getScene(): Scene;
  110493. /**
  110494. * Gets the hosting engine
  110495. * @returns the hosting Engine
  110496. */
  110497. getEngine(): Engine;
  110498. /**
  110499. * Defines if the geometry is ready to use
  110500. * @returns true if the geometry is ready to be used
  110501. */
  110502. isReady(): boolean;
  110503. /**
  110504. * Gets a value indicating that the geometry should not be serialized
  110505. */
  110506. get doNotSerialize(): boolean;
  110507. /** @hidden */
  110508. _rebuild(): void;
  110509. /**
  110510. * Affects all geometry data in one call
  110511. * @param vertexData defines the geometry data
  110512. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110513. */
  110514. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110515. /**
  110516. * Set specific vertex data
  110517. * @param kind defines the data kind (Position, normal, etc...)
  110518. * @param data defines the vertex data to use
  110519. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110520. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110521. */
  110522. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110523. /**
  110524. * Removes a specific vertex data
  110525. * @param kind defines the data kind (Position, normal, etc...)
  110526. */
  110527. removeVerticesData(kind: string): void;
  110528. /**
  110529. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110530. * @param buffer defines the vertex buffer to use
  110531. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110532. */
  110533. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110534. /**
  110535. * Update a specific vertex buffer
  110536. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110537. * It will do nothing if the buffer is not updatable
  110538. * @param kind defines the data kind (Position, normal, etc...)
  110539. * @param data defines the data to use
  110540. * @param offset defines the offset in the target buffer where to store the data
  110541. * @param useBytes set to true if the offset is in bytes
  110542. */
  110543. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110544. /**
  110545. * Update a specific vertex buffer
  110546. * This function will create a new buffer if the current one is not updatable
  110547. * @param kind defines the data kind (Position, normal, etc...)
  110548. * @param data defines the data to use
  110549. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110550. */
  110551. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110552. private _updateBoundingInfo;
  110553. /** @hidden */
  110554. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110555. /**
  110556. * Gets total number of vertices
  110557. * @returns the total number of vertices
  110558. */
  110559. getTotalVertices(): number;
  110560. /**
  110561. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110562. * @param kind defines the data kind (Position, normal, etc...)
  110563. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110564. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110565. * @returns a float array containing vertex data
  110566. */
  110567. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110568. /**
  110569. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110570. * @param kind defines the data kind (Position, normal, etc...)
  110571. * @returns true if the vertex buffer with the specified kind is updatable
  110572. */
  110573. isVertexBufferUpdatable(kind: string): boolean;
  110574. /**
  110575. * Gets a specific vertex buffer
  110576. * @param kind defines the data kind (Position, normal, etc...)
  110577. * @returns a VertexBuffer
  110578. */
  110579. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110580. /**
  110581. * Returns all vertex buffers
  110582. * @return an object holding all vertex buffers indexed by kind
  110583. */
  110584. getVertexBuffers(): Nullable<{
  110585. [key: string]: VertexBuffer;
  110586. }>;
  110587. /**
  110588. * Gets a boolean indicating if specific vertex buffer is present
  110589. * @param kind defines the data kind (Position, normal, etc...)
  110590. * @returns true if data is present
  110591. */
  110592. isVerticesDataPresent(kind: string): boolean;
  110593. /**
  110594. * Gets a list of all attached data kinds (Position, normal, etc...)
  110595. * @returns a list of string containing all kinds
  110596. */
  110597. getVerticesDataKinds(): string[];
  110598. /**
  110599. * Update index buffer
  110600. * @param indices defines the indices to store in the index buffer
  110601. * @param offset defines the offset in the target buffer where to store the data
  110602. * @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)
  110603. */
  110604. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110605. /**
  110606. * Creates a new index buffer
  110607. * @param indices defines the indices to store in the index buffer
  110608. * @param totalVertices defines the total number of vertices (could be null)
  110609. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110610. */
  110611. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110612. /**
  110613. * Return the total number of indices
  110614. * @returns the total number of indices
  110615. */
  110616. getTotalIndices(): number;
  110617. /**
  110618. * Gets the index buffer array
  110619. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110620. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110621. * @returns the index buffer array
  110622. */
  110623. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110624. /**
  110625. * Gets the index buffer
  110626. * @return the index buffer
  110627. */
  110628. getIndexBuffer(): Nullable<DataBuffer>;
  110629. /** @hidden */
  110630. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110631. /**
  110632. * Release the associated resources for a specific mesh
  110633. * @param mesh defines the source mesh
  110634. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110635. */
  110636. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110637. /**
  110638. * Apply current geometry to a given mesh
  110639. * @param mesh defines the mesh to apply geometry to
  110640. */
  110641. applyToMesh(mesh: Mesh): void;
  110642. private _updateExtend;
  110643. private _applyToMesh;
  110644. private notifyUpdate;
  110645. /**
  110646. * Load the geometry if it was flagged as delay loaded
  110647. * @param scene defines the hosting scene
  110648. * @param onLoaded defines a callback called when the geometry is loaded
  110649. */
  110650. load(scene: Scene, onLoaded?: () => void): void;
  110651. private _queueLoad;
  110652. /**
  110653. * Invert the geometry to move from a right handed system to a left handed one.
  110654. */
  110655. toLeftHanded(): void;
  110656. /** @hidden */
  110657. _resetPointsArrayCache(): void;
  110658. /** @hidden */
  110659. _generatePointsArray(): boolean;
  110660. /**
  110661. * Gets a value indicating if the geometry is disposed
  110662. * @returns true if the geometry was disposed
  110663. */
  110664. isDisposed(): boolean;
  110665. private _disposeVertexArrayObjects;
  110666. /**
  110667. * Free all associated resources
  110668. */
  110669. dispose(): void;
  110670. /**
  110671. * Clone the current geometry into a new geometry
  110672. * @param id defines the unique ID of the new geometry
  110673. * @returns a new geometry object
  110674. */
  110675. copy(id: string): Geometry;
  110676. /**
  110677. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110678. * @return a JSON representation of the current geometry data (without the vertices data)
  110679. */
  110680. serialize(): any;
  110681. private toNumberArray;
  110682. /**
  110683. * Serialize all vertices data into a JSON oject
  110684. * @returns a JSON representation of the current geometry data
  110685. */
  110686. serializeVerticeData(): any;
  110687. /**
  110688. * Extracts a clone of a mesh geometry
  110689. * @param mesh defines the source mesh
  110690. * @param id defines the unique ID of the new geometry object
  110691. * @returns the new geometry object
  110692. */
  110693. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110694. /**
  110695. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110696. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110697. * Be aware Math.random() could cause collisions, but:
  110698. * "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"
  110699. * @returns a string containing a new GUID
  110700. */
  110701. static RandomId(): string;
  110702. /** @hidden */
  110703. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110704. private static _CleanMatricesWeights;
  110705. /**
  110706. * Create a new geometry from persisted data (Using .babylon file format)
  110707. * @param parsedVertexData defines the persisted data
  110708. * @param scene defines the hosting scene
  110709. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110710. * @returns the new geometry object
  110711. */
  110712. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110713. }
  110714. }
  110715. declare module BABYLON {
  110716. /**
  110717. * Define an interface for all classes that will get and set the data on vertices
  110718. */
  110719. export interface IGetSetVerticesData {
  110720. /**
  110721. * Gets a boolean indicating if specific vertex data is present
  110722. * @param kind defines the vertex data kind to use
  110723. * @returns true is data kind is present
  110724. */
  110725. isVerticesDataPresent(kind: string): boolean;
  110726. /**
  110727. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110728. * @param kind defines the data kind (Position, normal, etc...)
  110729. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110730. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110731. * @returns a float array containing vertex data
  110732. */
  110733. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110734. /**
  110735. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  110736. * @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.
  110737. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110738. * @returns the indices array or an empty array if the mesh has no geometry
  110739. */
  110740. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110741. /**
  110742. * Set specific vertex data
  110743. * @param kind defines the data kind (Position, normal, etc...)
  110744. * @param data defines the vertex data to use
  110745. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110746. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110747. */
  110748. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  110749. /**
  110750. * Update a specific associated vertex buffer
  110751. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  110752. * - VertexBuffer.PositionKind
  110753. * - VertexBuffer.UVKind
  110754. * - VertexBuffer.UV2Kind
  110755. * - VertexBuffer.UV3Kind
  110756. * - VertexBuffer.UV4Kind
  110757. * - VertexBuffer.UV5Kind
  110758. * - VertexBuffer.UV6Kind
  110759. * - VertexBuffer.ColorKind
  110760. * - VertexBuffer.MatricesIndicesKind
  110761. * - VertexBuffer.MatricesIndicesExtraKind
  110762. * - VertexBuffer.MatricesWeightsKind
  110763. * - VertexBuffer.MatricesWeightsExtraKind
  110764. * @param data defines the data source
  110765. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  110766. * @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)
  110767. */
  110768. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  110769. /**
  110770. * Creates a new index buffer
  110771. * @param indices defines the indices to store in the index buffer
  110772. * @param totalVertices defines the total number of vertices (could be null)
  110773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110774. */
  110775. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  110776. }
  110777. /**
  110778. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  110779. */
  110780. export class VertexData {
  110781. /**
  110782. * Mesh side orientation : usually the external or front surface
  110783. */
  110784. static readonly FRONTSIDE: number;
  110785. /**
  110786. * Mesh side orientation : usually the internal or back surface
  110787. */
  110788. static readonly BACKSIDE: number;
  110789. /**
  110790. * Mesh side orientation : both internal and external or front and back surfaces
  110791. */
  110792. static readonly DOUBLESIDE: number;
  110793. /**
  110794. * Mesh side orientation : by default, `FRONTSIDE`
  110795. */
  110796. static readonly DEFAULTSIDE: number;
  110797. /**
  110798. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  110799. */
  110800. positions: Nullable<FloatArray>;
  110801. /**
  110802. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  110803. */
  110804. normals: Nullable<FloatArray>;
  110805. /**
  110806. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  110807. */
  110808. tangents: Nullable<FloatArray>;
  110809. /**
  110810. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110811. */
  110812. uvs: Nullable<FloatArray>;
  110813. /**
  110814. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110815. */
  110816. uvs2: Nullable<FloatArray>;
  110817. /**
  110818. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110819. */
  110820. uvs3: Nullable<FloatArray>;
  110821. /**
  110822. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110823. */
  110824. uvs4: Nullable<FloatArray>;
  110825. /**
  110826. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110827. */
  110828. uvs5: Nullable<FloatArray>;
  110829. /**
  110830. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110831. */
  110832. uvs6: Nullable<FloatArray>;
  110833. /**
  110834. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  110835. */
  110836. colors: Nullable<FloatArray>;
  110837. /**
  110838. * 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).
  110839. */
  110840. matricesIndices: Nullable<FloatArray>;
  110841. /**
  110842. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  110843. */
  110844. matricesWeights: Nullable<FloatArray>;
  110845. /**
  110846. * An array extending the number of possible indices
  110847. */
  110848. matricesIndicesExtra: Nullable<FloatArray>;
  110849. /**
  110850. * An array extending the number of possible weights when the number of indices is extended
  110851. */
  110852. matricesWeightsExtra: Nullable<FloatArray>;
  110853. /**
  110854. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  110855. */
  110856. indices: Nullable<IndicesArray>;
  110857. /**
  110858. * Uses the passed data array to set the set the values for the specified kind of data
  110859. * @param data a linear array of floating numbers
  110860. * @param kind the type of data that is being set, eg positions, colors etc
  110861. */
  110862. set(data: FloatArray, kind: string): void;
  110863. /**
  110864. * Associates the vertexData to the passed Mesh.
  110865. * Sets it as updatable or not (default `false`)
  110866. * @param mesh the mesh the vertexData is applied to
  110867. * @param updatable when used and having the value true allows new data to update the vertexData
  110868. * @returns the VertexData
  110869. */
  110870. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  110871. /**
  110872. * Associates the vertexData to the passed Geometry.
  110873. * Sets it as updatable or not (default `false`)
  110874. * @param geometry the geometry the vertexData is applied to
  110875. * @param updatable when used and having the value true allows new data to update the vertexData
  110876. * @returns VertexData
  110877. */
  110878. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  110879. /**
  110880. * Updates the associated mesh
  110881. * @param mesh the mesh to be updated
  110882. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  110883. * @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
  110884. * @returns VertexData
  110885. */
  110886. updateMesh(mesh: Mesh): VertexData;
  110887. /**
  110888. * Updates the associated geometry
  110889. * @param geometry the geometry to be updated
  110890. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  110891. * @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
  110892. * @returns VertexData.
  110893. */
  110894. updateGeometry(geometry: Geometry): VertexData;
  110895. private _applyTo;
  110896. private _update;
  110897. /**
  110898. * Transforms each position and each normal of the vertexData according to the passed Matrix
  110899. * @param matrix the transforming matrix
  110900. * @returns the VertexData
  110901. */
  110902. transform(matrix: Matrix): VertexData;
  110903. /**
  110904. * Merges the passed VertexData into the current one
  110905. * @param other the VertexData to be merged into the current one
  110906. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  110907. * @returns the modified VertexData
  110908. */
  110909. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  110910. private _mergeElement;
  110911. private _validate;
  110912. /**
  110913. * Serializes the VertexData
  110914. * @returns a serialized object
  110915. */
  110916. serialize(): any;
  110917. /**
  110918. * Extracts the vertexData from a mesh
  110919. * @param mesh the mesh from which to extract the VertexData
  110920. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  110921. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  110922. * @returns the object VertexData associated to the passed mesh
  110923. */
  110924. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  110925. /**
  110926. * Extracts the vertexData from the geometry
  110927. * @param geometry the geometry from which to extract the VertexData
  110928. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  110929. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  110930. * @returns the object VertexData associated to the passed mesh
  110931. */
  110932. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  110933. private static _ExtractFrom;
  110934. /**
  110935. * Creates the VertexData for a Ribbon
  110936. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  110937. * * pathArray array of paths, each of which an array of successive Vector3
  110938. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  110939. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  110940. * * 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
  110941. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110942. * * 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)
  110943. * * 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)
  110944. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  110945. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  110946. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  110947. * @returns the VertexData of the ribbon
  110948. */
  110949. static CreateRibbon(options: {
  110950. pathArray: Vector3[][];
  110951. closeArray?: boolean;
  110952. closePath?: boolean;
  110953. offset?: number;
  110954. sideOrientation?: number;
  110955. frontUVs?: Vector4;
  110956. backUVs?: Vector4;
  110957. invertUV?: boolean;
  110958. uvs?: Vector2[];
  110959. colors?: Color4[];
  110960. }): VertexData;
  110961. /**
  110962. * Creates the VertexData for a box
  110963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  110964. * * size sets the width, height and depth of the box to the value of size, optional default 1
  110965. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  110966. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  110967. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  110968. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  110969. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  110970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110971. * * 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)
  110972. * * 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)
  110973. * @returns the VertexData of the box
  110974. */
  110975. static CreateBox(options: {
  110976. size?: number;
  110977. width?: number;
  110978. height?: number;
  110979. depth?: number;
  110980. faceUV?: Vector4[];
  110981. faceColors?: Color4[];
  110982. sideOrientation?: number;
  110983. frontUVs?: Vector4;
  110984. backUVs?: Vector4;
  110985. }): VertexData;
  110986. /**
  110987. * Creates the VertexData for a tiled box
  110988. * @param options an object used to set the following optional parameters for the box, required but can be empty
  110989. * * faceTiles sets the pattern, tile size and number of tiles for a face
  110990. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  110991. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  110992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110993. * @returns the VertexData of the box
  110994. */
  110995. static CreateTiledBox(options: {
  110996. pattern?: number;
  110997. width?: number;
  110998. height?: number;
  110999. depth?: number;
  111000. tileSize?: number;
  111001. tileWidth?: number;
  111002. tileHeight?: number;
  111003. alignHorizontal?: number;
  111004. alignVertical?: number;
  111005. faceUV?: Vector4[];
  111006. faceColors?: Color4[];
  111007. sideOrientation?: number;
  111008. }): VertexData;
  111009. /**
  111010. * Creates the VertexData for a tiled plane
  111011. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111012. * * pattern a limited pattern arrangement depending on the number
  111013. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111014. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111015. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111017. * * 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)
  111018. * * 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)
  111019. * @returns the VertexData of the tiled plane
  111020. */
  111021. static CreateTiledPlane(options: {
  111022. pattern?: number;
  111023. tileSize?: number;
  111024. tileWidth?: number;
  111025. tileHeight?: number;
  111026. size?: number;
  111027. width?: number;
  111028. height?: number;
  111029. alignHorizontal?: number;
  111030. alignVertical?: number;
  111031. sideOrientation?: number;
  111032. frontUVs?: Vector4;
  111033. backUVs?: Vector4;
  111034. }): VertexData;
  111035. /**
  111036. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111037. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111038. * * segments sets the number of horizontal strips optional, default 32
  111039. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111040. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111041. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111042. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111043. * * 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
  111044. * * 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
  111045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111046. * * 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)
  111047. * * 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)
  111048. * @returns the VertexData of the ellipsoid
  111049. */
  111050. static CreateSphere(options: {
  111051. segments?: number;
  111052. diameter?: number;
  111053. diameterX?: number;
  111054. diameterY?: number;
  111055. diameterZ?: number;
  111056. arc?: number;
  111057. slice?: number;
  111058. sideOrientation?: number;
  111059. frontUVs?: Vector4;
  111060. backUVs?: Vector4;
  111061. }): VertexData;
  111062. /**
  111063. * Creates the VertexData for a cylinder, cone or prism
  111064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111065. * * height sets the height (y direction) of the cylinder, optional, default 2
  111066. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111067. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111068. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111069. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111070. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111071. * * 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
  111072. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111073. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111074. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111075. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111077. * * 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)
  111078. * * 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)
  111079. * @returns the VertexData of the cylinder, cone or prism
  111080. */
  111081. static CreateCylinder(options: {
  111082. height?: number;
  111083. diameterTop?: number;
  111084. diameterBottom?: number;
  111085. diameter?: number;
  111086. tessellation?: number;
  111087. subdivisions?: number;
  111088. arc?: number;
  111089. faceColors?: Color4[];
  111090. faceUV?: Vector4[];
  111091. hasRings?: boolean;
  111092. enclose?: boolean;
  111093. sideOrientation?: number;
  111094. frontUVs?: Vector4;
  111095. backUVs?: Vector4;
  111096. }): VertexData;
  111097. /**
  111098. * Creates the VertexData for a torus
  111099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111100. * * diameter the diameter of the torus, optional default 1
  111101. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111102. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111104. * * 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)
  111105. * * 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)
  111106. * @returns the VertexData of the torus
  111107. */
  111108. static CreateTorus(options: {
  111109. diameter?: number;
  111110. thickness?: number;
  111111. tessellation?: number;
  111112. sideOrientation?: number;
  111113. frontUVs?: Vector4;
  111114. backUVs?: Vector4;
  111115. }): VertexData;
  111116. /**
  111117. * Creates the VertexData of the LineSystem
  111118. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111119. * - lines an array of lines, each line being an array of successive Vector3
  111120. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111121. * @returns the VertexData of the LineSystem
  111122. */
  111123. static CreateLineSystem(options: {
  111124. lines: Vector3[][];
  111125. colors?: Nullable<Color4[][]>;
  111126. }): VertexData;
  111127. /**
  111128. * Create the VertexData for a DashedLines
  111129. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111130. * - points an array successive Vector3
  111131. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111132. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111133. * - dashNb the intended total number of dashes, optional, default 200
  111134. * @returns the VertexData for the DashedLines
  111135. */
  111136. static CreateDashedLines(options: {
  111137. points: Vector3[];
  111138. dashSize?: number;
  111139. gapSize?: number;
  111140. dashNb?: number;
  111141. }): VertexData;
  111142. /**
  111143. * Creates the VertexData for a Ground
  111144. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111145. * - width the width (x direction) of the ground, optional, default 1
  111146. * - height the height (z direction) of the ground, optional, default 1
  111147. * - subdivisions the number of subdivisions per side, optional, default 1
  111148. * @returns the VertexData of the Ground
  111149. */
  111150. static CreateGround(options: {
  111151. width?: number;
  111152. height?: number;
  111153. subdivisions?: number;
  111154. subdivisionsX?: number;
  111155. subdivisionsY?: number;
  111156. }): VertexData;
  111157. /**
  111158. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111159. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111160. * * xmin the ground minimum X coordinate, optional, default -1
  111161. * * zmin the ground minimum Z coordinate, optional, default -1
  111162. * * xmax the ground maximum X coordinate, optional, default 1
  111163. * * zmax the ground maximum Z coordinate, optional, default 1
  111164. * * 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}
  111165. * * 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}
  111166. * @returns the VertexData of the TiledGround
  111167. */
  111168. static CreateTiledGround(options: {
  111169. xmin: number;
  111170. zmin: number;
  111171. xmax: number;
  111172. zmax: number;
  111173. subdivisions?: {
  111174. w: number;
  111175. h: number;
  111176. };
  111177. precision?: {
  111178. w: number;
  111179. h: number;
  111180. };
  111181. }): VertexData;
  111182. /**
  111183. * Creates the VertexData of the Ground designed from a heightmap
  111184. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111185. * * width the width (x direction) of the ground
  111186. * * height the height (z direction) of the ground
  111187. * * subdivisions the number of subdivisions per side
  111188. * * minHeight the minimum altitude on the ground, optional, default 0
  111189. * * maxHeight the maximum altitude on the ground, optional default 1
  111190. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111191. * * buffer the array holding the image color data
  111192. * * bufferWidth the width of image
  111193. * * bufferHeight the height of image
  111194. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111195. * @returns the VertexData of the Ground designed from a heightmap
  111196. */
  111197. static CreateGroundFromHeightMap(options: {
  111198. width: number;
  111199. height: number;
  111200. subdivisions: number;
  111201. minHeight: number;
  111202. maxHeight: number;
  111203. colorFilter: Color3;
  111204. buffer: Uint8Array;
  111205. bufferWidth: number;
  111206. bufferHeight: number;
  111207. alphaFilter: number;
  111208. }): VertexData;
  111209. /**
  111210. * Creates the VertexData for a Plane
  111211. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111212. * * size sets the width and height of the plane to the value of size, optional default 1
  111213. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111214. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111216. * * 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)
  111217. * * 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)
  111218. * @returns the VertexData of the box
  111219. */
  111220. static CreatePlane(options: {
  111221. size?: number;
  111222. width?: number;
  111223. height?: number;
  111224. sideOrientation?: number;
  111225. frontUVs?: Vector4;
  111226. backUVs?: Vector4;
  111227. }): VertexData;
  111228. /**
  111229. * Creates the VertexData of the Disc or regular Polygon
  111230. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111231. * * radius the radius of the disc, optional default 0.5
  111232. * * tessellation the number of polygon sides, optional, default 64
  111233. * * 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
  111234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111235. * * 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)
  111236. * * 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)
  111237. * @returns the VertexData of the box
  111238. */
  111239. static CreateDisc(options: {
  111240. radius?: number;
  111241. tessellation?: number;
  111242. arc?: number;
  111243. sideOrientation?: number;
  111244. frontUVs?: Vector4;
  111245. backUVs?: Vector4;
  111246. }): VertexData;
  111247. /**
  111248. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111249. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111250. * @param polygon a mesh built from polygonTriangulation.build()
  111251. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111252. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111253. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111254. * @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)
  111255. * @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)
  111256. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111257. * @returns the VertexData of the Polygon
  111258. */
  111259. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111260. /**
  111261. * Creates the VertexData of the IcoSphere
  111262. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111263. * * radius the radius of the IcoSphere, optional default 1
  111264. * * radiusX allows stretching in the x direction, optional, default radius
  111265. * * radiusY allows stretching in the y direction, optional, default radius
  111266. * * radiusZ allows stretching in the z direction, optional, default radius
  111267. * * flat when true creates a flat shaded mesh, optional, default true
  111268. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111270. * * 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)
  111271. * * 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)
  111272. * @returns the VertexData of the IcoSphere
  111273. */
  111274. static CreateIcoSphere(options: {
  111275. radius?: number;
  111276. radiusX?: number;
  111277. radiusY?: number;
  111278. radiusZ?: number;
  111279. flat?: boolean;
  111280. subdivisions?: number;
  111281. sideOrientation?: number;
  111282. frontUVs?: Vector4;
  111283. backUVs?: Vector4;
  111284. }): VertexData;
  111285. /**
  111286. * Creates the VertexData for a Polyhedron
  111287. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111288. * * type provided types are:
  111289. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111290. * * 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)
  111291. * * size the size of the IcoSphere, optional default 1
  111292. * * sizeX allows stretching in the x direction, optional, default size
  111293. * * sizeY allows stretching in the y direction, optional, default size
  111294. * * sizeZ allows stretching in the z direction, optional, default size
  111295. * * 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
  111296. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111297. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111298. * * flat when true creates a flat shaded mesh, optional, default true
  111299. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111301. * * 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)
  111302. * * 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)
  111303. * @returns the VertexData of the Polyhedron
  111304. */
  111305. static CreatePolyhedron(options: {
  111306. type?: number;
  111307. size?: number;
  111308. sizeX?: number;
  111309. sizeY?: number;
  111310. sizeZ?: number;
  111311. custom?: any;
  111312. faceUV?: Vector4[];
  111313. faceColors?: Color4[];
  111314. flat?: boolean;
  111315. sideOrientation?: number;
  111316. frontUVs?: Vector4;
  111317. backUVs?: Vector4;
  111318. }): VertexData;
  111319. /**
  111320. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111321. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111322. * @returns the VertexData of the Capsule
  111323. */
  111324. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111325. /**
  111326. * Creates the VertexData for a TorusKnot
  111327. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111328. * * radius the radius of the torus knot, optional, default 2
  111329. * * tube the thickness of the tube, optional, default 0.5
  111330. * * radialSegments the number of sides on each tube segments, optional, default 32
  111331. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111332. * * p the number of windings around the z axis, optional, default 2
  111333. * * q the number of windings around the x axis, optional, default 3
  111334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111335. * * 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)
  111336. * * 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)
  111337. * @returns the VertexData of the Torus Knot
  111338. */
  111339. static CreateTorusKnot(options: {
  111340. radius?: number;
  111341. tube?: number;
  111342. radialSegments?: number;
  111343. tubularSegments?: number;
  111344. p?: number;
  111345. q?: number;
  111346. sideOrientation?: number;
  111347. frontUVs?: Vector4;
  111348. backUVs?: Vector4;
  111349. }): VertexData;
  111350. /**
  111351. * Compute normals for given positions and indices
  111352. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111353. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111354. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111355. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111356. * * facetNormals : optional array of facet normals (vector3)
  111357. * * facetPositions : optional array of facet positions (vector3)
  111358. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111359. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111360. * * bInfo : optional bounding info, required for facetPartitioning computation
  111361. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111362. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111363. * * useRightHandedSystem: optional boolean to for right handed system computation
  111364. * * depthSort : optional boolean to enable the facet depth sort computation
  111365. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111366. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111367. */
  111368. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111369. facetNormals?: any;
  111370. facetPositions?: any;
  111371. facetPartitioning?: any;
  111372. ratio?: number;
  111373. bInfo?: any;
  111374. bbSize?: Vector3;
  111375. subDiv?: any;
  111376. useRightHandedSystem?: boolean;
  111377. depthSort?: boolean;
  111378. distanceTo?: Vector3;
  111379. depthSortedFacets?: any;
  111380. }): void;
  111381. /** @hidden */
  111382. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111383. /**
  111384. * Applies VertexData created from the imported parameters to the geometry
  111385. * @param parsedVertexData the parsed data from an imported file
  111386. * @param geometry the geometry to apply the VertexData to
  111387. */
  111388. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111389. }
  111390. }
  111391. declare module BABYLON {
  111392. /**
  111393. * Defines a target to use with MorphTargetManager
  111394. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111395. */
  111396. export class MorphTarget implements IAnimatable {
  111397. /** defines the name of the target */
  111398. name: string;
  111399. /**
  111400. * Gets or sets the list of animations
  111401. */
  111402. animations: Animation[];
  111403. private _scene;
  111404. private _positions;
  111405. private _normals;
  111406. private _tangents;
  111407. private _uvs;
  111408. private _influence;
  111409. private _uniqueId;
  111410. /**
  111411. * Observable raised when the influence changes
  111412. */
  111413. onInfluenceChanged: Observable<boolean>;
  111414. /** @hidden */
  111415. _onDataLayoutChanged: Observable<void>;
  111416. /**
  111417. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111418. */
  111419. get influence(): number;
  111420. set influence(influence: number);
  111421. /**
  111422. * Gets or sets the id of the morph Target
  111423. */
  111424. id: string;
  111425. private _animationPropertiesOverride;
  111426. /**
  111427. * Gets or sets the animation properties override
  111428. */
  111429. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111430. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111431. /**
  111432. * Creates a new MorphTarget
  111433. * @param name defines the name of the target
  111434. * @param influence defines the influence to use
  111435. * @param scene defines the scene the morphtarget belongs to
  111436. */
  111437. constructor(
  111438. /** defines the name of the target */
  111439. name: string, influence?: number, scene?: Nullable<Scene>);
  111440. /**
  111441. * Gets the unique ID of this manager
  111442. */
  111443. get uniqueId(): number;
  111444. /**
  111445. * Gets a boolean defining if the target contains position data
  111446. */
  111447. get hasPositions(): boolean;
  111448. /**
  111449. * Gets a boolean defining if the target contains normal data
  111450. */
  111451. get hasNormals(): boolean;
  111452. /**
  111453. * Gets a boolean defining if the target contains tangent data
  111454. */
  111455. get hasTangents(): boolean;
  111456. /**
  111457. * Gets a boolean defining if the target contains texture coordinates data
  111458. */
  111459. get hasUVs(): boolean;
  111460. /**
  111461. * Affects position data to this target
  111462. * @param data defines the position data to use
  111463. */
  111464. setPositions(data: Nullable<FloatArray>): void;
  111465. /**
  111466. * Gets the position data stored in this target
  111467. * @returns a FloatArray containing the position data (or null if not present)
  111468. */
  111469. getPositions(): Nullable<FloatArray>;
  111470. /**
  111471. * Affects normal data to this target
  111472. * @param data defines the normal data to use
  111473. */
  111474. setNormals(data: Nullable<FloatArray>): void;
  111475. /**
  111476. * Gets the normal data stored in this target
  111477. * @returns a FloatArray containing the normal data (or null if not present)
  111478. */
  111479. getNormals(): Nullable<FloatArray>;
  111480. /**
  111481. * Affects tangent data to this target
  111482. * @param data defines the tangent data to use
  111483. */
  111484. setTangents(data: Nullable<FloatArray>): void;
  111485. /**
  111486. * Gets the tangent data stored in this target
  111487. * @returns a FloatArray containing the tangent data (or null if not present)
  111488. */
  111489. getTangents(): Nullable<FloatArray>;
  111490. /**
  111491. * Affects texture coordinates data to this target
  111492. * @param data defines the texture coordinates data to use
  111493. */
  111494. setUVs(data: Nullable<FloatArray>): void;
  111495. /**
  111496. * Gets the texture coordinates data stored in this target
  111497. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111498. */
  111499. getUVs(): Nullable<FloatArray>;
  111500. /**
  111501. * Clone the current target
  111502. * @returns a new MorphTarget
  111503. */
  111504. clone(): MorphTarget;
  111505. /**
  111506. * Serializes the current target into a Serialization object
  111507. * @returns the serialized object
  111508. */
  111509. serialize(): any;
  111510. /**
  111511. * Returns the string "MorphTarget"
  111512. * @returns "MorphTarget"
  111513. */
  111514. getClassName(): string;
  111515. /**
  111516. * Creates a new target from serialized data
  111517. * @param serializationObject defines the serialized data to use
  111518. * @returns a new MorphTarget
  111519. */
  111520. static Parse(serializationObject: any): MorphTarget;
  111521. /**
  111522. * Creates a MorphTarget from mesh data
  111523. * @param mesh defines the source mesh
  111524. * @param name defines the name to use for the new target
  111525. * @param influence defines the influence to attach to the target
  111526. * @returns a new MorphTarget
  111527. */
  111528. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111529. }
  111530. }
  111531. declare module BABYLON {
  111532. /**
  111533. * This class is used to deform meshes using morphing between different targets
  111534. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111535. */
  111536. export class MorphTargetManager {
  111537. private _targets;
  111538. private _targetInfluenceChangedObservers;
  111539. private _targetDataLayoutChangedObservers;
  111540. private _activeTargets;
  111541. private _scene;
  111542. private _influences;
  111543. private _supportsNormals;
  111544. private _supportsTangents;
  111545. private _supportsUVs;
  111546. private _vertexCount;
  111547. private _uniqueId;
  111548. private _tempInfluences;
  111549. /**
  111550. * Gets or sets a boolean indicating if normals must be morphed
  111551. */
  111552. enableNormalMorphing: boolean;
  111553. /**
  111554. * Gets or sets a boolean indicating if tangents must be morphed
  111555. */
  111556. enableTangentMorphing: boolean;
  111557. /**
  111558. * Gets or sets a boolean indicating if UV must be morphed
  111559. */
  111560. enableUVMorphing: boolean;
  111561. /**
  111562. * Creates a new MorphTargetManager
  111563. * @param scene defines the current scene
  111564. */
  111565. constructor(scene?: Nullable<Scene>);
  111566. /**
  111567. * Gets the unique ID of this manager
  111568. */
  111569. get uniqueId(): number;
  111570. /**
  111571. * Gets the number of vertices handled by this manager
  111572. */
  111573. get vertexCount(): number;
  111574. /**
  111575. * Gets a boolean indicating if this manager supports morphing of normals
  111576. */
  111577. get supportsNormals(): boolean;
  111578. /**
  111579. * Gets a boolean indicating if this manager supports morphing of tangents
  111580. */
  111581. get supportsTangents(): boolean;
  111582. /**
  111583. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111584. */
  111585. get supportsUVs(): boolean;
  111586. /**
  111587. * Gets the number of targets stored in this manager
  111588. */
  111589. get numTargets(): number;
  111590. /**
  111591. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111592. */
  111593. get numInfluencers(): number;
  111594. /**
  111595. * Gets the list of influences (one per target)
  111596. */
  111597. get influences(): Float32Array;
  111598. /**
  111599. * Gets the active target at specified index. An active target is a target with an influence > 0
  111600. * @param index defines the index to check
  111601. * @returns the requested target
  111602. */
  111603. getActiveTarget(index: number): MorphTarget;
  111604. /**
  111605. * Gets the target at specified index
  111606. * @param index defines the index to check
  111607. * @returns the requested target
  111608. */
  111609. getTarget(index: number): MorphTarget;
  111610. /**
  111611. * Add a new target to this manager
  111612. * @param target defines the target to add
  111613. */
  111614. addTarget(target: MorphTarget): void;
  111615. /**
  111616. * Removes a target from the manager
  111617. * @param target defines the target to remove
  111618. */
  111619. removeTarget(target: MorphTarget): void;
  111620. /**
  111621. * Clone the current manager
  111622. * @returns a new MorphTargetManager
  111623. */
  111624. clone(): MorphTargetManager;
  111625. /**
  111626. * Serializes the current manager into a Serialization object
  111627. * @returns the serialized object
  111628. */
  111629. serialize(): any;
  111630. private _syncActiveTargets;
  111631. /**
  111632. * Syncrhonize the targets with all the meshes using this morph target manager
  111633. */
  111634. synchronize(): void;
  111635. /**
  111636. * Creates a new MorphTargetManager from serialized data
  111637. * @param serializationObject defines the serialized data
  111638. * @param scene defines the hosting scene
  111639. * @returns the new MorphTargetManager
  111640. */
  111641. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111642. }
  111643. }
  111644. declare module BABYLON {
  111645. /**
  111646. * Class used to represent a specific level of detail of a mesh
  111647. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111648. */
  111649. export class MeshLODLevel {
  111650. /** Defines the distance where this level should start being displayed */
  111651. distance: number;
  111652. /** Defines the mesh to use to render this level */
  111653. mesh: Nullable<Mesh>;
  111654. /**
  111655. * Creates a new LOD level
  111656. * @param distance defines the distance where this level should star being displayed
  111657. * @param mesh defines the mesh to use to render this level
  111658. */
  111659. constructor(
  111660. /** Defines the distance where this level should start being displayed */
  111661. distance: number,
  111662. /** Defines the mesh to use to render this level */
  111663. mesh: Nullable<Mesh>);
  111664. }
  111665. }
  111666. declare module BABYLON {
  111667. /**
  111668. * Helper class used to generate a canvas to manipulate images
  111669. */
  111670. export class CanvasGenerator {
  111671. /**
  111672. * Create a new canvas (or offscreen canvas depending on the context)
  111673. * @param width defines the expected width
  111674. * @param height defines the expected height
  111675. * @return a new canvas or offscreen canvas
  111676. */
  111677. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111678. }
  111679. }
  111680. declare module BABYLON {
  111681. /**
  111682. * Mesh representing the gorund
  111683. */
  111684. export class GroundMesh extends Mesh {
  111685. /** If octree should be generated */
  111686. generateOctree: boolean;
  111687. private _heightQuads;
  111688. /** @hidden */
  111689. _subdivisionsX: number;
  111690. /** @hidden */
  111691. _subdivisionsY: number;
  111692. /** @hidden */
  111693. _width: number;
  111694. /** @hidden */
  111695. _height: number;
  111696. /** @hidden */
  111697. _minX: number;
  111698. /** @hidden */
  111699. _maxX: number;
  111700. /** @hidden */
  111701. _minZ: number;
  111702. /** @hidden */
  111703. _maxZ: number;
  111704. constructor(name: string, scene: Scene);
  111705. /**
  111706. * "GroundMesh"
  111707. * @returns "GroundMesh"
  111708. */
  111709. getClassName(): string;
  111710. /**
  111711. * The minimum of x and y subdivisions
  111712. */
  111713. get subdivisions(): number;
  111714. /**
  111715. * X subdivisions
  111716. */
  111717. get subdivisionsX(): number;
  111718. /**
  111719. * Y subdivisions
  111720. */
  111721. get subdivisionsY(): number;
  111722. /**
  111723. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  111724. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111725. * @param chunksCount the number of subdivisions for x and y
  111726. * @param octreeBlocksSize (Default: 32)
  111727. */
  111728. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  111729. /**
  111730. * Returns a height (y) value in the Worl system :
  111731. * the ground altitude at the coordinates (x, z) expressed in the World system.
  111732. * @param x x coordinate
  111733. * @param z z coordinate
  111734. * @returns the ground y position if (x, z) are outside the ground surface.
  111735. */
  111736. getHeightAtCoordinates(x: number, z: number): number;
  111737. /**
  111738. * Returns a normalized vector (Vector3) orthogonal to the ground
  111739. * at the ground coordinates (x, z) expressed in the World system.
  111740. * @param x x coordinate
  111741. * @param z z coordinate
  111742. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  111743. */
  111744. getNormalAtCoordinates(x: number, z: number): Vector3;
  111745. /**
  111746. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  111747. * at the ground coordinates (x, z) expressed in the World system.
  111748. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  111749. * @param x x coordinate
  111750. * @param z z coordinate
  111751. * @param ref vector to store the result
  111752. * @returns the GroundMesh.
  111753. */
  111754. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  111755. /**
  111756. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  111757. * if the ground has been updated.
  111758. * This can be used in the render loop.
  111759. * @returns the GroundMesh.
  111760. */
  111761. updateCoordinateHeights(): GroundMesh;
  111762. private _getFacetAt;
  111763. private _initHeightQuads;
  111764. private _computeHeightQuads;
  111765. /**
  111766. * Serializes this ground mesh
  111767. * @param serializationObject object to write serialization to
  111768. */
  111769. serialize(serializationObject: any): void;
  111770. /**
  111771. * Parses a serialized ground mesh
  111772. * @param parsedMesh the serialized mesh
  111773. * @param scene the scene to create the ground mesh in
  111774. * @returns the created ground mesh
  111775. */
  111776. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  111777. }
  111778. }
  111779. declare module BABYLON {
  111780. /**
  111781. * Interface for Physics-Joint data
  111782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111783. */
  111784. export interface PhysicsJointData {
  111785. /**
  111786. * The main pivot of the joint
  111787. */
  111788. mainPivot?: Vector3;
  111789. /**
  111790. * The connected pivot of the joint
  111791. */
  111792. connectedPivot?: Vector3;
  111793. /**
  111794. * The main axis of the joint
  111795. */
  111796. mainAxis?: Vector3;
  111797. /**
  111798. * The connected axis of the joint
  111799. */
  111800. connectedAxis?: Vector3;
  111801. /**
  111802. * The collision of the joint
  111803. */
  111804. collision?: boolean;
  111805. /**
  111806. * Native Oimo/Cannon/Energy data
  111807. */
  111808. nativeParams?: any;
  111809. }
  111810. /**
  111811. * This is a holder class for the physics joint created by the physics plugin
  111812. * It holds a set of functions to control the underlying joint
  111813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111814. */
  111815. export class PhysicsJoint {
  111816. /**
  111817. * The type of the physics joint
  111818. */
  111819. type: number;
  111820. /**
  111821. * The data for the physics joint
  111822. */
  111823. jointData: PhysicsJointData;
  111824. private _physicsJoint;
  111825. protected _physicsPlugin: IPhysicsEnginePlugin;
  111826. /**
  111827. * Initializes the physics joint
  111828. * @param type The type of the physics joint
  111829. * @param jointData The data for the physics joint
  111830. */
  111831. constructor(
  111832. /**
  111833. * The type of the physics joint
  111834. */
  111835. type: number,
  111836. /**
  111837. * The data for the physics joint
  111838. */
  111839. jointData: PhysicsJointData);
  111840. /**
  111841. * Gets the physics joint
  111842. */
  111843. get physicsJoint(): any;
  111844. /**
  111845. * Sets the physics joint
  111846. */
  111847. set physicsJoint(newJoint: any);
  111848. /**
  111849. * Sets the physics plugin
  111850. */
  111851. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  111852. /**
  111853. * Execute a function that is physics-plugin specific.
  111854. * @param {Function} func the function that will be executed.
  111855. * It accepts two parameters: the physics world and the physics joint
  111856. */
  111857. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  111858. /**
  111859. * Distance-Joint type
  111860. */
  111861. static DistanceJoint: number;
  111862. /**
  111863. * Hinge-Joint type
  111864. */
  111865. static HingeJoint: number;
  111866. /**
  111867. * Ball-and-Socket joint type
  111868. */
  111869. static BallAndSocketJoint: number;
  111870. /**
  111871. * Wheel-Joint type
  111872. */
  111873. static WheelJoint: number;
  111874. /**
  111875. * Slider-Joint type
  111876. */
  111877. static SliderJoint: number;
  111878. /**
  111879. * Prismatic-Joint type
  111880. */
  111881. static PrismaticJoint: number;
  111882. /**
  111883. * Universal-Joint type
  111884. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  111885. */
  111886. static UniversalJoint: number;
  111887. /**
  111888. * Hinge-Joint 2 type
  111889. */
  111890. static Hinge2Joint: number;
  111891. /**
  111892. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  111893. */
  111894. static PointToPointJoint: number;
  111895. /**
  111896. * Spring-Joint type
  111897. */
  111898. static SpringJoint: number;
  111899. /**
  111900. * Lock-Joint type
  111901. */
  111902. static LockJoint: number;
  111903. }
  111904. /**
  111905. * A class representing a physics distance joint
  111906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111907. */
  111908. export class DistanceJoint extends PhysicsJoint {
  111909. /**
  111910. *
  111911. * @param jointData The data for the Distance-Joint
  111912. */
  111913. constructor(jointData: DistanceJointData);
  111914. /**
  111915. * Update the predefined distance.
  111916. * @param maxDistance The maximum preferred distance
  111917. * @param minDistance The minimum preferred distance
  111918. */
  111919. updateDistance(maxDistance: number, minDistance?: number): void;
  111920. }
  111921. /**
  111922. * Represents a Motor-Enabled Joint
  111923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111924. */
  111925. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  111926. /**
  111927. * Initializes the Motor-Enabled Joint
  111928. * @param type The type of the joint
  111929. * @param jointData The physica joint data for the joint
  111930. */
  111931. constructor(type: number, jointData: PhysicsJointData);
  111932. /**
  111933. * Set the motor values.
  111934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111935. * @param force the force to apply
  111936. * @param maxForce max force for this motor.
  111937. */
  111938. setMotor(force?: number, maxForce?: number): void;
  111939. /**
  111940. * Set the motor's limits.
  111941. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111942. * @param upperLimit The upper limit of the motor
  111943. * @param lowerLimit The lower limit of the motor
  111944. */
  111945. setLimit(upperLimit: number, lowerLimit?: number): void;
  111946. }
  111947. /**
  111948. * This class represents a single physics Hinge-Joint
  111949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111950. */
  111951. export class HingeJoint extends MotorEnabledJoint {
  111952. /**
  111953. * Initializes the Hinge-Joint
  111954. * @param jointData The joint data for the Hinge-Joint
  111955. */
  111956. constructor(jointData: PhysicsJointData);
  111957. /**
  111958. * Set the motor values.
  111959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111960. * @param {number} force the force to apply
  111961. * @param {number} maxForce max force for this motor.
  111962. */
  111963. setMotor(force?: number, maxForce?: number): void;
  111964. /**
  111965. * Set the motor's limits.
  111966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111967. * @param upperLimit The upper limit of the motor
  111968. * @param lowerLimit The lower limit of the motor
  111969. */
  111970. setLimit(upperLimit: number, lowerLimit?: number): void;
  111971. }
  111972. /**
  111973. * This class represents a dual hinge physics joint (same as wheel joint)
  111974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111975. */
  111976. export class Hinge2Joint extends MotorEnabledJoint {
  111977. /**
  111978. * Initializes the Hinge2-Joint
  111979. * @param jointData The joint data for the Hinge2-Joint
  111980. */
  111981. constructor(jointData: PhysicsJointData);
  111982. /**
  111983. * Set the motor values.
  111984. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111985. * @param {number} targetSpeed the speed the motor is to reach
  111986. * @param {number} maxForce max force for this motor.
  111987. * @param {motorIndex} the motor's index, 0 or 1.
  111988. */
  111989. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  111990. /**
  111991. * Set the motor limits.
  111992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111993. * @param {number} upperLimit the upper limit
  111994. * @param {number} lowerLimit lower limit
  111995. * @param {motorIndex} the motor's index, 0 or 1.
  111996. */
  111997. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111998. }
  111999. /**
  112000. * Interface for a motor enabled joint
  112001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112002. */
  112003. export interface IMotorEnabledJoint {
  112004. /**
  112005. * Physics joint
  112006. */
  112007. physicsJoint: any;
  112008. /**
  112009. * Sets the motor of the motor-enabled joint
  112010. * @param force The force of the motor
  112011. * @param maxForce The maximum force of the motor
  112012. * @param motorIndex The index of the motor
  112013. */
  112014. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112015. /**
  112016. * Sets the limit of the motor
  112017. * @param upperLimit The upper limit of the motor
  112018. * @param lowerLimit The lower limit of the motor
  112019. * @param motorIndex The index of the motor
  112020. */
  112021. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112022. }
  112023. /**
  112024. * Joint data for a Distance-Joint
  112025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112026. */
  112027. export interface DistanceJointData extends PhysicsJointData {
  112028. /**
  112029. * Max distance the 2 joint objects can be apart
  112030. */
  112031. maxDistance: number;
  112032. }
  112033. /**
  112034. * Joint data from a spring joint
  112035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112036. */
  112037. export interface SpringJointData extends PhysicsJointData {
  112038. /**
  112039. * Length of the spring
  112040. */
  112041. length: number;
  112042. /**
  112043. * Stiffness of the spring
  112044. */
  112045. stiffness: number;
  112046. /**
  112047. * Damping of the spring
  112048. */
  112049. damping: number;
  112050. /** this callback will be called when applying the force to the impostors. */
  112051. forceApplicationCallback: () => void;
  112052. }
  112053. }
  112054. declare module BABYLON {
  112055. /**
  112056. * Holds the data for the raycast result
  112057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112058. */
  112059. export class PhysicsRaycastResult {
  112060. private _hasHit;
  112061. private _hitDistance;
  112062. private _hitNormalWorld;
  112063. private _hitPointWorld;
  112064. private _rayFromWorld;
  112065. private _rayToWorld;
  112066. /**
  112067. * Gets if there was a hit
  112068. */
  112069. get hasHit(): boolean;
  112070. /**
  112071. * Gets the distance from the hit
  112072. */
  112073. get hitDistance(): number;
  112074. /**
  112075. * Gets the hit normal/direction in the world
  112076. */
  112077. get hitNormalWorld(): Vector3;
  112078. /**
  112079. * Gets the hit point in the world
  112080. */
  112081. get hitPointWorld(): Vector3;
  112082. /**
  112083. * Gets the ray "start point" of the ray in the world
  112084. */
  112085. get rayFromWorld(): Vector3;
  112086. /**
  112087. * Gets the ray "end point" of the ray in the world
  112088. */
  112089. get rayToWorld(): Vector3;
  112090. /**
  112091. * Sets the hit data (normal & point in world space)
  112092. * @param hitNormalWorld defines the normal in world space
  112093. * @param hitPointWorld defines the point in world space
  112094. */
  112095. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112096. /**
  112097. * Sets the distance from the start point to the hit point
  112098. * @param distance
  112099. */
  112100. setHitDistance(distance: number): void;
  112101. /**
  112102. * Calculates the distance manually
  112103. */
  112104. calculateHitDistance(): void;
  112105. /**
  112106. * Resets all the values to default
  112107. * @param from The from point on world space
  112108. * @param to The to point on world space
  112109. */
  112110. reset(from?: Vector3, to?: Vector3): void;
  112111. }
  112112. /**
  112113. * Interface for the size containing width and height
  112114. */
  112115. interface IXYZ {
  112116. /**
  112117. * X
  112118. */
  112119. x: number;
  112120. /**
  112121. * Y
  112122. */
  112123. y: number;
  112124. /**
  112125. * Z
  112126. */
  112127. z: number;
  112128. }
  112129. }
  112130. declare module BABYLON {
  112131. /**
  112132. * Interface used to describe a physics joint
  112133. */
  112134. export interface PhysicsImpostorJoint {
  112135. /** Defines the main impostor to which the joint is linked */
  112136. mainImpostor: PhysicsImpostor;
  112137. /** Defines the impostor that is connected to the main impostor using this joint */
  112138. connectedImpostor: PhysicsImpostor;
  112139. /** Defines the joint itself */
  112140. joint: PhysicsJoint;
  112141. }
  112142. /** @hidden */
  112143. export interface IPhysicsEnginePlugin {
  112144. world: any;
  112145. name: string;
  112146. setGravity(gravity: Vector3): void;
  112147. setTimeStep(timeStep: number): void;
  112148. getTimeStep(): number;
  112149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112150. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112151. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112152. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112153. removePhysicsBody(impostor: PhysicsImpostor): void;
  112154. generateJoint(joint: PhysicsImpostorJoint): void;
  112155. removeJoint(joint: PhysicsImpostorJoint): void;
  112156. isSupported(): boolean;
  112157. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112158. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112159. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112160. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112161. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112162. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112163. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112164. getBodyMass(impostor: PhysicsImpostor): number;
  112165. getBodyFriction(impostor: PhysicsImpostor): number;
  112166. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112167. getBodyRestitution(impostor: PhysicsImpostor): number;
  112168. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112169. getBodyPressure?(impostor: PhysicsImpostor): number;
  112170. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112171. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112172. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112173. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112174. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112175. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112176. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112177. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112178. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112179. sleepBody(impostor: PhysicsImpostor): void;
  112180. wakeUpBody(impostor: PhysicsImpostor): void;
  112181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112182. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112183. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112184. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112185. getRadius(impostor: PhysicsImpostor): number;
  112186. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112187. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112188. dispose(): void;
  112189. }
  112190. /**
  112191. * Interface used to define a physics engine
  112192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112193. */
  112194. export interface IPhysicsEngine {
  112195. /**
  112196. * Gets the gravity vector used by the simulation
  112197. */
  112198. gravity: Vector3;
  112199. /**
  112200. * Sets the gravity vector used by the simulation
  112201. * @param gravity defines the gravity vector to use
  112202. */
  112203. setGravity(gravity: Vector3): void;
  112204. /**
  112205. * Set the time step of the physics engine.
  112206. * Default is 1/60.
  112207. * To slow it down, enter 1/600 for example.
  112208. * To speed it up, 1/30
  112209. * @param newTimeStep the new timestep to apply to this world.
  112210. */
  112211. setTimeStep(newTimeStep: number): void;
  112212. /**
  112213. * Get the time step of the physics engine.
  112214. * @returns the current time step
  112215. */
  112216. getTimeStep(): number;
  112217. /**
  112218. * Set the sub time step of the physics engine.
  112219. * Default is 0 meaning there is no sub steps
  112220. * To increase physics resolution precision, set a small value (like 1 ms)
  112221. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112222. */
  112223. setSubTimeStep(subTimeStep: number): void;
  112224. /**
  112225. * Get the sub time step of the physics engine.
  112226. * @returns the current sub time step
  112227. */
  112228. getSubTimeStep(): number;
  112229. /**
  112230. * Release all resources
  112231. */
  112232. dispose(): void;
  112233. /**
  112234. * Gets the name of the current physics plugin
  112235. * @returns the name of the plugin
  112236. */
  112237. getPhysicsPluginName(): string;
  112238. /**
  112239. * Adding a new impostor for the impostor tracking.
  112240. * This will be done by the impostor itself.
  112241. * @param impostor the impostor to add
  112242. */
  112243. addImpostor(impostor: PhysicsImpostor): void;
  112244. /**
  112245. * Remove an impostor from the engine.
  112246. * This impostor and its mesh will not longer be updated by the physics engine.
  112247. * @param impostor the impostor to remove
  112248. */
  112249. removeImpostor(impostor: PhysicsImpostor): void;
  112250. /**
  112251. * Add a joint to the physics engine
  112252. * @param mainImpostor defines the main impostor to which the joint is added.
  112253. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112254. * @param joint defines the joint that will connect both impostors.
  112255. */
  112256. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112257. /**
  112258. * Removes a joint from the simulation
  112259. * @param mainImpostor defines the impostor used with the joint
  112260. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112261. * @param joint defines the joint to remove
  112262. */
  112263. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112264. /**
  112265. * Gets the current plugin used to run the simulation
  112266. * @returns current plugin
  112267. */
  112268. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112269. /**
  112270. * Gets the list of physic impostors
  112271. * @returns an array of PhysicsImpostor
  112272. */
  112273. getImpostors(): Array<PhysicsImpostor>;
  112274. /**
  112275. * Gets the impostor for a physics enabled object
  112276. * @param object defines the object impersonated by the impostor
  112277. * @returns the PhysicsImpostor or null if not found
  112278. */
  112279. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112280. /**
  112281. * Gets the impostor for a physics body object
  112282. * @param body defines physics body used by the impostor
  112283. * @returns the PhysicsImpostor or null if not found
  112284. */
  112285. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112286. /**
  112287. * Does a raycast in the physics world
  112288. * @param from when should the ray start?
  112289. * @param to when should the ray end?
  112290. * @returns PhysicsRaycastResult
  112291. */
  112292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112293. /**
  112294. * Called by the scene. No need to call it.
  112295. * @param delta defines the timespam between frames
  112296. */
  112297. _step(delta: number): void;
  112298. }
  112299. }
  112300. declare module BABYLON {
  112301. /**
  112302. * The interface for the physics imposter parameters
  112303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112304. */
  112305. export interface PhysicsImpostorParameters {
  112306. /**
  112307. * The mass of the physics imposter
  112308. */
  112309. mass: number;
  112310. /**
  112311. * The friction of the physics imposter
  112312. */
  112313. friction?: number;
  112314. /**
  112315. * The coefficient of restitution of the physics imposter
  112316. */
  112317. restitution?: number;
  112318. /**
  112319. * The native options of the physics imposter
  112320. */
  112321. nativeOptions?: any;
  112322. /**
  112323. * Specifies if the parent should be ignored
  112324. */
  112325. ignoreParent?: boolean;
  112326. /**
  112327. * Specifies if bi-directional transformations should be disabled
  112328. */
  112329. disableBidirectionalTransformation?: boolean;
  112330. /**
  112331. * The pressure inside the physics imposter, soft object only
  112332. */
  112333. pressure?: number;
  112334. /**
  112335. * The stiffness the physics imposter, soft object only
  112336. */
  112337. stiffness?: number;
  112338. /**
  112339. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112340. */
  112341. velocityIterations?: number;
  112342. /**
  112343. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112344. */
  112345. positionIterations?: number;
  112346. /**
  112347. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112348. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112349. * Add to fix multiple points
  112350. */
  112351. fixedPoints?: number;
  112352. /**
  112353. * The collision margin around a soft object
  112354. */
  112355. margin?: number;
  112356. /**
  112357. * The collision margin around a soft object
  112358. */
  112359. damping?: number;
  112360. /**
  112361. * The path for a rope based on an extrusion
  112362. */
  112363. path?: any;
  112364. /**
  112365. * The shape of an extrusion used for a rope based on an extrusion
  112366. */
  112367. shape?: any;
  112368. }
  112369. /**
  112370. * Interface for a physics-enabled object
  112371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112372. */
  112373. export interface IPhysicsEnabledObject {
  112374. /**
  112375. * The position of the physics-enabled object
  112376. */
  112377. position: Vector3;
  112378. /**
  112379. * The rotation of the physics-enabled object
  112380. */
  112381. rotationQuaternion: Nullable<Quaternion>;
  112382. /**
  112383. * The scale of the physics-enabled object
  112384. */
  112385. scaling: Vector3;
  112386. /**
  112387. * The rotation of the physics-enabled object
  112388. */
  112389. rotation?: Vector3;
  112390. /**
  112391. * The parent of the physics-enabled object
  112392. */
  112393. parent?: any;
  112394. /**
  112395. * The bounding info of the physics-enabled object
  112396. * @returns The bounding info of the physics-enabled object
  112397. */
  112398. getBoundingInfo(): BoundingInfo;
  112399. /**
  112400. * Computes the world matrix
  112401. * @param force Specifies if the world matrix should be computed by force
  112402. * @returns A world matrix
  112403. */
  112404. computeWorldMatrix(force: boolean): Matrix;
  112405. /**
  112406. * Gets the world matrix
  112407. * @returns A world matrix
  112408. */
  112409. getWorldMatrix?(): Matrix;
  112410. /**
  112411. * Gets the child meshes
  112412. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112413. * @returns An array of abstract meshes
  112414. */
  112415. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112416. /**
  112417. * Gets the vertex data
  112418. * @param kind The type of vertex data
  112419. * @returns A nullable array of numbers, or a float32 array
  112420. */
  112421. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112422. /**
  112423. * Gets the indices from the mesh
  112424. * @returns A nullable array of index arrays
  112425. */
  112426. getIndices?(): Nullable<IndicesArray>;
  112427. /**
  112428. * Gets the scene from the mesh
  112429. * @returns the indices array or null
  112430. */
  112431. getScene?(): Scene;
  112432. /**
  112433. * Gets the absolute position from the mesh
  112434. * @returns the absolute position
  112435. */
  112436. getAbsolutePosition(): Vector3;
  112437. /**
  112438. * Gets the absolute pivot point from the mesh
  112439. * @returns the absolute pivot point
  112440. */
  112441. getAbsolutePivotPoint(): Vector3;
  112442. /**
  112443. * Rotates the mesh
  112444. * @param axis The axis of rotation
  112445. * @param amount The amount of rotation
  112446. * @param space The space of the rotation
  112447. * @returns The rotation transform node
  112448. */
  112449. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112450. /**
  112451. * Translates the mesh
  112452. * @param axis The axis of translation
  112453. * @param distance The distance of translation
  112454. * @param space The space of the translation
  112455. * @returns The transform node
  112456. */
  112457. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112458. /**
  112459. * Sets the absolute position of the mesh
  112460. * @param absolutePosition The absolute position of the mesh
  112461. * @returns The transform node
  112462. */
  112463. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112464. /**
  112465. * Gets the class name of the mesh
  112466. * @returns The class name
  112467. */
  112468. getClassName(): string;
  112469. }
  112470. /**
  112471. * Represents a physics imposter
  112472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112473. */
  112474. export class PhysicsImpostor {
  112475. /**
  112476. * The physics-enabled object used as the physics imposter
  112477. */
  112478. object: IPhysicsEnabledObject;
  112479. /**
  112480. * The type of the physics imposter
  112481. */
  112482. type: number;
  112483. private _options;
  112484. private _scene?;
  112485. /**
  112486. * The default object size of the imposter
  112487. */
  112488. static DEFAULT_OBJECT_SIZE: Vector3;
  112489. /**
  112490. * The identity quaternion of the imposter
  112491. */
  112492. static IDENTITY_QUATERNION: Quaternion;
  112493. /** @hidden */
  112494. _pluginData: any;
  112495. private _physicsEngine;
  112496. private _physicsBody;
  112497. private _bodyUpdateRequired;
  112498. private _onBeforePhysicsStepCallbacks;
  112499. private _onAfterPhysicsStepCallbacks;
  112500. /** @hidden */
  112501. _onPhysicsCollideCallbacks: Array<{
  112502. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  112503. otherImpostors: Array<PhysicsImpostor>;
  112504. }>;
  112505. private _deltaPosition;
  112506. private _deltaRotation;
  112507. private _deltaRotationConjugated;
  112508. /** @hidden */
  112509. _isFromLine: boolean;
  112510. private _parent;
  112511. private _isDisposed;
  112512. private static _tmpVecs;
  112513. private static _tmpQuat;
  112514. /**
  112515. * Specifies if the physics imposter is disposed
  112516. */
  112517. get isDisposed(): boolean;
  112518. /**
  112519. * Gets the mass of the physics imposter
  112520. */
  112521. get mass(): number;
  112522. set mass(value: number);
  112523. /**
  112524. * Gets the coefficient of friction
  112525. */
  112526. get friction(): number;
  112527. /**
  112528. * Sets the coefficient of friction
  112529. */
  112530. set friction(value: number);
  112531. /**
  112532. * Gets the coefficient of restitution
  112533. */
  112534. get restitution(): number;
  112535. /**
  112536. * Sets the coefficient of restitution
  112537. */
  112538. set restitution(value: number);
  112539. /**
  112540. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112541. */
  112542. get pressure(): number;
  112543. /**
  112544. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112545. */
  112546. set pressure(value: number);
  112547. /**
  112548. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112549. */
  112550. get stiffness(): number;
  112551. /**
  112552. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112553. */
  112554. set stiffness(value: number);
  112555. /**
  112556. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112557. */
  112558. get velocityIterations(): number;
  112559. /**
  112560. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112561. */
  112562. set velocityIterations(value: number);
  112563. /**
  112564. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112565. */
  112566. get positionIterations(): number;
  112567. /**
  112568. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112569. */
  112570. set positionIterations(value: number);
  112571. /**
  112572. * The unique id of the physics imposter
  112573. * set by the physics engine when adding this impostor to the array
  112574. */
  112575. uniqueId: number;
  112576. /**
  112577. * @hidden
  112578. */
  112579. soft: boolean;
  112580. /**
  112581. * @hidden
  112582. */
  112583. segments: number;
  112584. private _joints;
  112585. /**
  112586. * Initializes the physics imposter
  112587. * @param object The physics-enabled object used as the physics imposter
  112588. * @param type The type of the physics imposter
  112589. * @param _options The options for the physics imposter
  112590. * @param _scene The Babylon scene
  112591. */
  112592. constructor(
  112593. /**
  112594. * The physics-enabled object used as the physics imposter
  112595. */
  112596. object: IPhysicsEnabledObject,
  112597. /**
  112598. * The type of the physics imposter
  112599. */
  112600. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112601. /**
  112602. * This function will completly initialize this impostor.
  112603. * It will create a new body - but only if this mesh has no parent.
  112604. * If it has, this impostor will not be used other than to define the impostor
  112605. * of the child mesh.
  112606. * @hidden
  112607. */
  112608. _init(): void;
  112609. private _getPhysicsParent;
  112610. /**
  112611. * Should a new body be generated.
  112612. * @returns boolean specifying if body initialization is required
  112613. */
  112614. isBodyInitRequired(): boolean;
  112615. /**
  112616. * Sets the updated scaling
  112617. * @param updated Specifies if the scaling is updated
  112618. */
  112619. setScalingUpdated(): void;
  112620. /**
  112621. * Force a regeneration of this or the parent's impostor's body.
  112622. * Use under cautious - This will remove all joints already implemented.
  112623. */
  112624. forceUpdate(): void;
  112625. /**
  112626. * Gets the body that holds this impostor. Either its own, or its parent.
  112627. */
  112628. get physicsBody(): any;
  112629. /**
  112630. * Get the parent of the physics imposter
  112631. * @returns Physics imposter or null
  112632. */
  112633. get parent(): Nullable<PhysicsImpostor>;
  112634. /**
  112635. * Sets the parent of the physics imposter
  112636. */
  112637. set parent(value: Nullable<PhysicsImpostor>);
  112638. /**
  112639. * Set the physics body. Used mainly by the physics engine/plugin
  112640. */
  112641. set physicsBody(physicsBody: any);
  112642. /**
  112643. * Resets the update flags
  112644. */
  112645. resetUpdateFlags(): void;
  112646. /**
  112647. * Gets the object extend size
  112648. * @returns the object extend size
  112649. */
  112650. getObjectExtendSize(): Vector3;
  112651. /**
  112652. * Gets the object center
  112653. * @returns The object center
  112654. */
  112655. getObjectCenter(): Vector3;
  112656. /**
  112657. * Get a specific parameter from the options parameters
  112658. * @param paramName The object parameter name
  112659. * @returns The object parameter
  112660. */
  112661. getParam(paramName: string): any;
  112662. /**
  112663. * Sets a specific parameter in the options given to the physics plugin
  112664. * @param paramName The parameter name
  112665. * @param value The value of the parameter
  112666. */
  112667. setParam(paramName: string, value: number): void;
  112668. /**
  112669. * Specifically change the body's mass option. Won't recreate the physics body object
  112670. * @param mass The mass of the physics imposter
  112671. */
  112672. setMass(mass: number): void;
  112673. /**
  112674. * Gets the linear velocity
  112675. * @returns linear velocity or null
  112676. */
  112677. getLinearVelocity(): Nullable<Vector3>;
  112678. /**
  112679. * Sets the linear velocity
  112680. * @param velocity linear velocity or null
  112681. */
  112682. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112683. /**
  112684. * Gets the angular velocity
  112685. * @returns angular velocity or null
  112686. */
  112687. getAngularVelocity(): Nullable<Vector3>;
  112688. /**
  112689. * Sets the angular velocity
  112690. * @param velocity The velocity or null
  112691. */
  112692. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112693. /**
  112694. * Execute a function with the physics plugin native code
  112695. * Provide a function the will have two variables - the world object and the physics body object
  112696. * @param func The function to execute with the physics plugin native code
  112697. */
  112698. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112699. /**
  112700. * Register a function that will be executed before the physics world is stepping forward
  112701. * @param func The function to execute before the physics world is stepped forward
  112702. */
  112703. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112704. /**
  112705. * Unregister a function that will be executed before the physics world is stepping forward
  112706. * @param func The function to execute before the physics world is stepped forward
  112707. */
  112708. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112709. /**
  112710. * Register a function that will be executed after the physics step
  112711. * @param func The function to execute after physics step
  112712. */
  112713. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112714. /**
  112715. * Unregisters a function that will be executed after the physics step
  112716. * @param func The function to execute after physics step
  112717. */
  112718. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112719. /**
  112720. * register a function that will be executed when this impostor collides against a different body
  112721. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112722. * @param func Callback that is executed on collision
  112723. */
  112724. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  112725. /**
  112726. * Unregisters the physics imposter on contact
  112727. * @param collideAgainst The physics object to collide against
  112728. * @param func Callback to execute on collision
  112729. */
  112730. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  112731. private _tmpQuat;
  112732. private _tmpQuat2;
  112733. /**
  112734. * Get the parent rotation
  112735. * @returns The parent rotation
  112736. */
  112737. getParentsRotation(): Quaternion;
  112738. /**
  112739. * this function is executed by the physics engine.
  112740. */
  112741. beforeStep: () => void;
  112742. /**
  112743. * this function is executed by the physics engine
  112744. */
  112745. afterStep: () => void;
  112746. /**
  112747. * Legacy collision detection event support
  112748. */
  112749. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  112750. /**
  112751. * event and body object due to cannon's event-based architecture.
  112752. */
  112753. onCollide: (e: {
  112754. body: any;
  112755. }) => void;
  112756. /**
  112757. * Apply a force
  112758. * @param force The force to apply
  112759. * @param contactPoint The contact point for the force
  112760. * @returns The physics imposter
  112761. */
  112762. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112763. /**
  112764. * Apply an impulse
  112765. * @param force The impulse force
  112766. * @param contactPoint The contact point for the impulse force
  112767. * @returns The physics imposter
  112768. */
  112769. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112770. /**
  112771. * A help function to create a joint
  112772. * @param otherImpostor A physics imposter used to create a joint
  112773. * @param jointType The type of joint
  112774. * @param jointData The data for the joint
  112775. * @returns The physics imposter
  112776. */
  112777. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  112778. /**
  112779. * Add a joint to this impostor with a different impostor
  112780. * @param otherImpostor A physics imposter used to add a joint
  112781. * @param joint The joint to add
  112782. * @returns The physics imposter
  112783. */
  112784. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  112785. /**
  112786. * Add an anchor to a cloth impostor
  112787. * @param otherImpostor rigid impostor to anchor to
  112788. * @param width ratio across width from 0 to 1
  112789. * @param height ratio up height from 0 to 1
  112790. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112791. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  112792. * @returns impostor the soft imposter
  112793. */
  112794. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112795. /**
  112796. * Add a hook to a rope impostor
  112797. * @param otherImpostor rigid impostor to anchor to
  112798. * @param length ratio across rope from 0 to 1
  112799. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  112800. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112801. * @returns impostor the rope imposter
  112802. */
  112803. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112804. /**
  112805. * Will keep this body still, in a sleep mode.
  112806. * @returns the physics imposter
  112807. */
  112808. sleep(): PhysicsImpostor;
  112809. /**
  112810. * Wake the body up.
  112811. * @returns The physics imposter
  112812. */
  112813. wakeUp(): PhysicsImpostor;
  112814. /**
  112815. * Clones the physics imposter
  112816. * @param newObject The physics imposter clones to this physics-enabled object
  112817. * @returns A nullable physics imposter
  112818. */
  112819. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112820. /**
  112821. * Disposes the physics imposter
  112822. */
  112823. dispose(): void;
  112824. /**
  112825. * Sets the delta position
  112826. * @param position The delta position amount
  112827. */
  112828. setDeltaPosition(position: Vector3): void;
  112829. /**
  112830. * Sets the delta rotation
  112831. * @param rotation The delta rotation amount
  112832. */
  112833. setDeltaRotation(rotation: Quaternion): void;
  112834. /**
  112835. * Gets the box size of the physics imposter and stores the result in the input parameter
  112836. * @param result Stores the box size
  112837. * @returns The physics imposter
  112838. */
  112839. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  112840. /**
  112841. * Gets the radius of the physics imposter
  112842. * @returns Radius of the physics imposter
  112843. */
  112844. getRadius(): number;
  112845. /**
  112846. * Sync a bone with this impostor
  112847. * @param bone The bone to sync to the impostor.
  112848. * @param boneMesh The mesh that the bone is influencing.
  112849. * @param jointPivot The pivot of the joint / bone in local space.
  112850. * @param distToJoint Optional distance from the impostor to the joint.
  112851. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112852. */
  112853. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  112854. /**
  112855. * Sync impostor to a bone
  112856. * @param bone The bone that the impostor will be synced to.
  112857. * @param boneMesh The mesh that the bone is influencing.
  112858. * @param jointPivot The pivot of the joint / bone in local space.
  112859. * @param distToJoint Optional distance from the impostor to the joint.
  112860. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112861. * @param boneAxis Optional vector3 axis the bone is aligned with
  112862. */
  112863. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  112864. /**
  112865. * No-Imposter type
  112866. */
  112867. static NoImpostor: number;
  112868. /**
  112869. * Sphere-Imposter type
  112870. */
  112871. static SphereImpostor: number;
  112872. /**
  112873. * Box-Imposter type
  112874. */
  112875. static BoxImpostor: number;
  112876. /**
  112877. * Plane-Imposter type
  112878. */
  112879. static PlaneImpostor: number;
  112880. /**
  112881. * Mesh-imposter type
  112882. */
  112883. static MeshImpostor: number;
  112884. /**
  112885. * Capsule-Impostor type (Ammo.js plugin only)
  112886. */
  112887. static CapsuleImpostor: number;
  112888. /**
  112889. * Cylinder-Imposter type
  112890. */
  112891. static CylinderImpostor: number;
  112892. /**
  112893. * Particle-Imposter type
  112894. */
  112895. static ParticleImpostor: number;
  112896. /**
  112897. * Heightmap-Imposter type
  112898. */
  112899. static HeightmapImpostor: number;
  112900. /**
  112901. * ConvexHull-Impostor type (Ammo.js plugin only)
  112902. */
  112903. static ConvexHullImpostor: number;
  112904. /**
  112905. * Custom-Imposter type (Ammo.js plugin only)
  112906. */
  112907. static CustomImpostor: number;
  112908. /**
  112909. * Rope-Imposter type
  112910. */
  112911. static RopeImpostor: number;
  112912. /**
  112913. * Cloth-Imposter type
  112914. */
  112915. static ClothImpostor: number;
  112916. /**
  112917. * Softbody-Imposter type
  112918. */
  112919. static SoftbodyImpostor: number;
  112920. }
  112921. }
  112922. declare module BABYLON {
  112923. /**
  112924. * @hidden
  112925. **/
  112926. export class _CreationDataStorage {
  112927. closePath?: boolean;
  112928. closeArray?: boolean;
  112929. idx: number[];
  112930. dashSize: number;
  112931. gapSize: number;
  112932. path3D: Path3D;
  112933. pathArray: Vector3[][];
  112934. arc: number;
  112935. radius: number;
  112936. cap: number;
  112937. tessellation: number;
  112938. }
  112939. /**
  112940. * @hidden
  112941. **/
  112942. class _InstanceDataStorage {
  112943. visibleInstances: any;
  112944. batchCache: _InstancesBatch;
  112945. instancesBufferSize: number;
  112946. instancesBuffer: Nullable<Buffer>;
  112947. instancesData: Float32Array;
  112948. overridenInstanceCount: number;
  112949. isFrozen: boolean;
  112950. previousBatch: Nullable<_InstancesBatch>;
  112951. hardwareInstancedRendering: boolean;
  112952. sideOrientation: number;
  112953. manualUpdate: boolean;
  112954. previousRenderId: number;
  112955. }
  112956. /**
  112957. * @hidden
  112958. **/
  112959. export class _InstancesBatch {
  112960. mustReturn: boolean;
  112961. visibleInstances: Nullable<InstancedMesh[]>[];
  112962. renderSelf: boolean[];
  112963. hardwareInstancedRendering: boolean[];
  112964. }
  112965. /**
  112966. * @hidden
  112967. **/
  112968. class _ThinInstanceDataStorage {
  112969. instancesCount: number;
  112970. matrixBuffer: Nullable<Buffer>;
  112971. matrixBufferSize: number;
  112972. matrixData: Nullable<Float32Array>;
  112973. boundingVectors: Array<Vector3>;
  112974. worldMatrices: Nullable<Matrix[]>;
  112975. }
  112976. /**
  112977. * Class used to represent renderable models
  112978. */
  112979. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  112980. /**
  112981. * Mesh side orientation : usually the external or front surface
  112982. */
  112983. static readonly FRONTSIDE: number;
  112984. /**
  112985. * Mesh side orientation : usually the internal or back surface
  112986. */
  112987. static readonly BACKSIDE: number;
  112988. /**
  112989. * Mesh side orientation : both internal and external or front and back surfaces
  112990. */
  112991. static readonly DOUBLESIDE: number;
  112992. /**
  112993. * Mesh side orientation : by default, `FRONTSIDE`
  112994. */
  112995. static readonly DEFAULTSIDE: number;
  112996. /**
  112997. * Mesh cap setting : no cap
  112998. */
  112999. static readonly NO_CAP: number;
  113000. /**
  113001. * Mesh cap setting : one cap at the beginning of the mesh
  113002. */
  113003. static readonly CAP_START: number;
  113004. /**
  113005. * Mesh cap setting : one cap at the end of the mesh
  113006. */
  113007. static readonly CAP_END: number;
  113008. /**
  113009. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113010. */
  113011. static readonly CAP_ALL: number;
  113012. /**
  113013. * Mesh pattern setting : no flip or rotate
  113014. */
  113015. static readonly NO_FLIP: number;
  113016. /**
  113017. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113018. */
  113019. static readonly FLIP_TILE: number;
  113020. /**
  113021. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113022. */
  113023. static readonly ROTATE_TILE: number;
  113024. /**
  113025. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113026. */
  113027. static readonly FLIP_ROW: number;
  113028. /**
  113029. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113030. */
  113031. static readonly ROTATE_ROW: number;
  113032. /**
  113033. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113034. */
  113035. static readonly FLIP_N_ROTATE_TILE: number;
  113036. /**
  113037. * Mesh pattern setting : rotate pattern and rotate
  113038. */
  113039. static readonly FLIP_N_ROTATE_ROW: number;
  113040. /**
  113041. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113042. */
  113043. static readonly CENTER: number;
  113044. /**
  113045. * Mesh tile positioning : part tiles on left
  113046. */
  113047. static readonly LEFT: number;
  113048. /**
  113049. * Mesh tile positioning : part tiles on right
  113050. */
  113051. static readonly RIGHT: number;
  113052. /**
  113053. * Mesh tile positioning : part tiles on top
  113054. */
  113055. static readonly TOP: number;
  113056. /**
  113057. * Mesh tile positioning : part tiles on bottom
  113058. */
  113059. static readonly BOTTOM: number;
  113060. /**
  113061. * Gets the default side orientation.
  113062. * @param orientation the orientation to value to attempt to get
  113063. * @returns the default orientation
  113064. * @hidden
  113065. */
  113066. static _GetDefaultSideOrientation(orientation?: number): number;
  113067. private _internalMeshDataInfo;
  113068. get computeBonesUsingShaders(): boolean;
  113069. set computeBonesUsingShaders(value: boolean);
  113070. /**
  113071. * An event triggered before rendering the mesh
  113072. */
  113073. get onBeforeRenderObservable(): Observable<Mesh>;
  113074. /**
  113075. * An event triggered before binding the mesh
  113076. */
  113077. get onBeforeBindObservable(): Observable<Mesh>;
  113078. /**
  113079. * An event triggered after rendering the mesh
  113080. */
  113081. get onAfterRenderObservable(): Observable<Mesh>;
  113082. /**
  113083. * An event triggered before drawing the mesh
  113084. */
  113085. get onBeforeDrawObservable(): Observable<Mesh>;
  113086. private _onBeforeDrawObserver;
  113087. /**
  113088. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113089. */
  113090. set onBeforeDraw(callback: () => void);
  113091. get hasInstances(): boolean;
  113092. get hasThinInstances(): boolean;
  113093. /**
  113094. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113095. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113096. */
  113097. delayLoadState: number;
  113098. /**
  113099. * Gets the list of instances created from this mesh
  113100. * it is not supposed to be modified manually.
  113101. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113102. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113103. */
  113104. instances: InstancedMesh[];
  113105. /**
  113106. * Gets the file containing delay loading data for this mesh
  113107. */
  113108. delayLoadingFile: string;
  113109. /** @hidden */
  113110. _binaryInfo: any;
  113111. /**
  113112. * User defined function used to change how LOD level selection is done
  113113. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113114. */
  113115. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113116. /**
  113117. * Gets or sets the morph target manager
  113118. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113119. */
  113120. get morphTargetManager(): Nullable<MorphTargetManager>;
  113121. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113122. /** @hidden */
  113123. _creationDataStorage: Nullable<_CreationDataStorage>;
  113124. /** @hidden */
  113125. _geometry: Nullable<Geometry>;
  113126. /** @hidden */
  113127. _delayInfo: Array<string>;
  113128. /** @hidden */
  113129. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113130. /** @hidden */
  113131. _instanceDataStorage: _InstanceDataStorage;
  113132. /** @hidden */
  113133. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113134. private _effectiveMaterial;
  113135. /** @hidden */
  113136. _shouldGenerateFlatShading: boolean;
  113137. /** @hidden */
  113138. _originalBuilderSideOrientation: number;
  113139. /**
  113140. * Use this property to change the original side orientation defined at construction time
  113141. */
  113142. overrideMaterialSideOrientation: Nullable<number>;
  113143. /**
  113144. * Gets the source mesh (the one used to clone this one from)
  113145. */
  113146. get source(): Nullable<Mesh>;
  113147. /**
  113148. * Gets the list of clones of this mesh
  113149. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113150. * Note that useClonedMeshMap=true is the default setting
  113151. */
  113152. get cloneMeshMap(): Nullable<{
  113153. [id: string]: Mesh | undefined;
  113154. }>;
  113155. /**
  113156. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113157. */
  113158. get isUnIndexed(): boolean;
  113159. set isUnIndexed(value: boolean);
  113160. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113161. get worldMatrixInstancedBuffer(): Float32Array;
  113162. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113163. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113164. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113165. /**
  113166. * @constructor
  113167. * @param name The value used by scene.getMeshByName() to do a lookup.
  113168. * @param scene The scene to add this mesh to.
  113169. * @param parent The parent of this mesh, if it has one
  113170. * @param source An optional Mesh from which geometry is shared, cloned.
  113171. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113172. * When false, achieved by calling a clone(), also passing False.
  113173. * This will make creation of children, recursive.
  113174. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113175. */
  113176. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113177. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113178. doNotInstantiate: boolean;
  113179. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113180. /**
  113181. * Gets the class name
  113182. * @returns the string "Mesh".
  113183. */
  113184. getClassName(): string;
  113185. /** @hidden */
  113186. get _isMesh(): boolean;
  113187. /**
  113188. * Returns a description of this mesh
  113189. * @param fullDetails define if full details about this mesh must be used
  113190. * @returns a descriptive string representing this mesh
  113191. */
  113192. toString(fullDetails?: boolean): string;
  113193. /** @hidden */
  113194. _unBindEffect(): void;
  113195. /**
  113196. * Gets a boolean indicating if this mesh has LOD
  113197. */
  113198. get hasLODLevels(): boolean;
  113199. /**
  113200. * Gets the list of MeshLODLevel associated with the current mesh
  113201. * @returns an array of MeshLODLevel
  113202. */
  113203. getLODLevels(): MeshLODLevel[];
  113204. private _sortLODLevels;
  113205. /**
  113206. * Add a mesh as LOD level triggered at the given distance.
  113207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113208. * @param distance The distance from the center of the object to show this level
  113209. * @param mesh The mesh to be added as LOD level (can be null)
  113210. * @return This mesh (for chaining)
  113211. */
  113212. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113213. /**
  113214. * Returns the LOD level mesh at the passed distance or null if not found.
  113215. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113216. * @param distance The distance from the center of the object to show this level
  113217. * @returns a Mesh or `null`
  113218. */
  113219. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113220. /**
  113221. * Remove a mesh from the LOD array
  113222. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113223. * @param mesh defines the mesh to be removed
  113224. * @return This mesh (for chaining)
  113225. */
  113226. removeLODLevel(mesh: Mesh): Mesh;
  113227. /**
  113228. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113229. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113230. * @param camera defines the camera to use to compute distance
  113231. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113232. * @return This mesh (for chaining)
  113233. */
  113234. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113235. /**
  113236. * Gets the mesh internal Geometry object
  113237. */
  113238. get geometry(): Nullable<Geometry>;
  113239. /**
  113240. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113241. * @returns the total number of vertices
  113242. */
  113243. getTotalVertices(): number;
  113244. /**
  113245. * Returns the content of an associated vertex buffer
  113246. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113247. * - VertexBuffer.PositionKind
  113248. * - VertexBuffer.UVKind
  113249. * - VertexBuffer.UV2Kind
  113250. * - VertexBuffer.UV3Kind
  113251. * - VertexBuffer.UV4Kind
  113252. * - VertexBuffer.UV5Kind
  113253. * - VertexBuffer.UV6Kind
  113254. * - VertexBuffer.ColorKind
  113255. * - VertexBuffer.MatricesIndicesKind
  113256. * - VertexBuffer.MatricesIndicesExtraKind
  113257. * - VertexBuffer.MatricesWeightsKind
  113258. * - VertexBuffer.MatricesWeightsExtraKind
  113259. * @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
  113260. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113261. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113262. */
  113263. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113264. /**
  113265. * Returns the mesh VertexBuffer object from the requested `kind`
  113266. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113267. * - VertexBuffer.PositionKind
  113268. * - VertexBuffer.NormalKind
  113269. * - VertexBuffer.UVKind
  113270. * - VertexBuffer.UV2Kind
  113271. * - VertexBuffer.UV3Kind
  113272. * - VertexBuffer.UV4Kind
  113273. * - VertexBuffer.UV5Kind
  113274. * - VertexBuffer.UV6Kind
  113275. * - VertexBuffer.ColorKind
  113276. * - VertexBuffer.MatricesIndicesKind
  113277. * - VertexBuffer.MatricesIndicesExtraKind
  113278. * - VertexBuffer.MatricesWeightsKind
  113279. * - VertexBuffer.MatricesWeightsExtraKind
  113280. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113281. */
  113282. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113283. /**
  113284. * Tests if a specific vertex buffer is associated with this mesh
  113285. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113286. * - VertexBuffer.PositionKind
  113287. * - VertexBuffer.NormalKind
  113288. * - VertexBuffer.UVKind
  113289. * - VertexBuffer.UV2Kind
  113290. * - VertexBuffer.UV3Kind
  113291. * - VertexBuffer.UV4Kind
  113292. * - VertexBuffer.UV5Kind
  113293. * - VertexBuffer.UV6Kind
  113294. * - VertexBuffer.ColorKind
  113295. * - VertexBuffer.MatricesIndicesKind
  113296. * - VertexBuffer.MatricesIndicesExtraKind
  113297. * - VertexBuffer.MatricesWeightsKind
  113298. * - VertexBuffer.MatricesWeightsExtraKind
  113299. * @returns a boolean
  113300. */
  113301. isVerticesDataPresent(kind: string): boolean;
  113302. /**
  113303. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113304. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113305. * - VertexBuffer.PositionKind
  113306. * - VertexBuffer.UVKind
  113307. * - VertexBuffer.UV2Kind
  113308. * - VertexBuffer.UV3Kind
  113309. * - VertexBuffer.UV4Kind
  113310. * - VertexBuffer.UV5Kind
  113311. * - VertexBuffer.UV6Kind
  113312. * - VertexBuffer.ColorKind
  113313. * - VertexBuffer.MatricesIndicesKind
  113314. * - VertexBuffer.MatricesIndicesExtraKind
  113315. * - VertexBuffer.MatricesWeightsKind
  113316. * - VertexBuffer.MatricesWeightsExtraKind
  113317. * @returns a boolean
  113318. */
  113319. isVertexBufferUpdatable(kind: string): boolean;
  113320. /**
  113321. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113322. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113323. * - VertexBuffer.PositionKind
  113324. * - VertexBuffer.NormalKind
  113325. * - VertexBuffer.UVKind
  113326. * - VertexBuffer.UV2Kind
  113327. * - VertexBuffer.UV3Kind
  113328. * - VertexBuffer.UV4Kind
  113329. * - VertexBuffer.UV5Kind
  113330. * - VertexBuffer.UV6Kind
  113331. * - VertexBuffer.ColorKind
  113332. * - VertexBuffer.MatricesIndicesKind
  113333. * - VertexBuffer.MatricesIndicesExtraKind
  113334. * - VertexBuffer.MatricesWeightsKind
  113335. * - VertexBuffer.MatricesWeightsExtraKind
  113336. * @returns an array of strings
  113337. */
  113338. getVerticesDataKinds(): string[];
  113339. /**
  113340. * Returns a positive integer : the total number of indices in this mesh geometry.
  113341. * @returns the numner of indices or zero if the mesh has no geometry.
  113342. */
  113343. getTotalIndices(): number;
  113344. /**
  113345. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113346. * @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.
  113347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113348. * @returns the indices array or an empty array if the mesh has no geometry
  113349. */
  113350. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113351. get isBlocked(): boolean;
  113352. /**
  113353. * Determine if the current mesh is ready to be rendered
  113354. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113355. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113356. * @returns true if all associated assets are ready (material, textures, shaders)
  113357. */
  113358. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113359. /**
  113360. * 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.
  113361. */
  113362. get areNormalsFrozen(): boolean;
  113363. /**
  113364. * 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.
  113365. * @returns the current mesh
  113366. */
  113367. freezeNormals(): Mesh;
  113368. /**
  113369. * 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
  113370. * @returns the current mesh
  113371. */
  113372. unfreezeNormals(): Mesh;
  113373. /**
  113374. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113375. */
  113376. set overridenInstanceCount(count: number);
  113377. /** @hidden */
  113378. _preActivate(): Mesh;
  113379. /** @hidden */
  113380. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113381. /** @hidden */
  113382. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113383. protected _afterComputeWorldMatrix(): void;
  113384. /** @hidden */
  113385. _postActivate(): void;
  113386. /**
  113387. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113388. * This means the mesh underlying bounding box and sphere are recomputed.
  113389. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113390. * @returns the current mesh
  113391. */
  113392. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113393. /** @hidden */
  113394. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113395. /**
  113396. * This function will subdivide the mesh into multiple submeshes
  113397. * @param count defines the expected number of submeshes
  113398. */
  113399. subdivide(count: number): void;
  113400. /**
  113401. * Copy a FloatArray into a specific associated vertex buffer
  113402. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113403. * - VertexBuffer.PositionKind
  113404. * - VertexBuffer.UVKind
  113405. * - VertexBuffer.UV2Kind
  113406. * - VertexBuffer.UV3Kind
  113407. * - VertexBuffer.UV4Kind
  113408. * - VertexBuffer.UV5Kind
  113409. * - VertexBuffer.UV6Kind
  113410. * - VertexBuffer.ColorKind
  113411. * - VertexBuffer.MatricesIndicesKind
  113412. * - VertexBuffer.MatricesIndicesExtraKind
  113413. * - VertexBuffer.MatricesWeightsKind
  113414. * - VertexBuffer.MatricesWeightsExtraKind
  113415. * @param data defines the data source
  113416. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113417. * @param stride defines the data stride size (can be null)
  113418. * @returns the current mesh
  113419. */
  113420. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113421. /**
  113422. * Delete a vertex buffer associated with this mesh
  113423. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113424. * - VertexBuffer.PositionKind
  113425. * - VertexBuffer.UVKind
  113426. * - VertexBuffer.UV2Kind
  113427. * - VertexBuffer.UV3Kind
  113428. * - VertexBuffer.UV4Kind
  113429. * - VertexBuffer.UV5Kind
  113430. * - VertexBuffer.UV6Kind
  113431. * - VertexBuffer.ColorKind
  113432. * - VertexBuffer.MatricesIndicesKind
  113433. * - VertexBuffer.MatricesIndicesExtraKind
  113434. * - VertexBuffer.MatricesWeightsKind
  113435. * - VertexBuffer.MatricesWeightsExtraKind
  113436. */
  113437. removeVerticesData(kind: string): void;
  113438. /**
  113439. * Flags an associated vertex buffer as updatable
  113440. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113441. * - VertexBuffer.PositionKind
  113442. * - VertexBuffer.UVKind
  113443. * - VertexBuffer.UV2Kind
  113444. * - VertexBuffer.UV3Kind
  113445. * - VertexBuffer.UV4Kind
  113446. * - VertexBuffer.UV5Kind
  113447. * - VertexBuffer.UV6Kind
  113448. * - VertexBuffer.ColorKind
  113449. * - VertexBuffer.MatricesIndicesKind
  113450. * - VertexBuffer.MatricesIndicesExtraKind
  113451. * - VertexBuffer.MatricesWeightsKind
  113452. * - VertexBuffer.MatricesWeightsExtraKind
  113453. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113454. */
  113455. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113456. /**
  113457. * Sets the mesh global Vertex Buffer
  113458. * @param buffer defines the buffer to use
  113459. * @returns the current mesh
  113460. */
  113461. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113462. /**
  113463. * Update a specific associated vertex buffer
  113464. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113465. * - VertexBuffer.PositionKind
  113466. * - VertexBuffer.UVKind
  113467. * - VertexBuffer.UV2Kind
  113468. * - VertexBuffer.UV3Kind
  113469. * - VertexBuffer.UV4Kind
  113470. * - VertexBuffer.UV5Kind
  113471. * - VertexBuffer.UV6Kind
  113472. * - VertexBuffer.ColorKind
  113473. * - VertexBuffer.MatricesIndicesKind
  113474. * - VertexBuffer.MatricesIndicesExtraKind
  113475. * - VertexBuffer.MatricesWeightsKind
  113476. * - VertexBuffer.MatricesWeightsExtraKind
  113477. * @param data defines the data source
  113478. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113479. * @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)
  113480. * @returns the current mesh
  113481. */
  113482. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113483. /**
  113484. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113485. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113486. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113487. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113488. * @returns the current mesh
  113489. */
  113490. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113491. /**
  113492. * Creates a un-shared specific occurence of the geometry for the mesh.
  113493. * @returns the current mesh
  113494. */
  113495. makeGeometryUnique(): Mesh;
  113496. /**
  113497. * Set the index buffer of this mesh
  113498. * @param indices defines the source data
  113499. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113500. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113501. * @returns the current mesh
  113502. */
  113503. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113504. /**
  113505. * Update the current index buffer
  113506. * @param indices defines the source data
  113507. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113508. * @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)
  113509. * @returns the current mesh
  113510. */
  113511. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113512. /**
  113513. * Invert the geometry to move from a right handed system to a left handed one.
  113514. * @returns the current mesh
  113515. */
  113516. toLeftHanded(): Mesh;
  113517. /** @hidden */
  113518. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113519. /** @hidden */
  113520. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113521. /**
  113522. * Registers for this mesh a javascript function called just before the rendering process
  113523. * @param func defines the function to call before rendering this mesh
  113524. * @returns the current mesh
  113525. */
  113526. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113527. /**
  113528. * Disposes a previously registered javascript function called before the rendering
  113529. * @param func defines the function to remove
  113530. * @returns the current mesh
  113531. */
  113532. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113533. /**
  113534. * Registers for this mesh a javascript function called just after the rendering is complete
  113535. * @param func defines the function to call after rendering this mesh
  113536. * @returns the current mesh
  113537. */
  113538. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113539. /**
  113540. * Disposes a previously registered javascript function called after the rendering.
  113541. * @param func defines the function to remove
  113542. * @returns the current mesh
  113543. */
  113544. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113545. /** @hidden */
  113546. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113547. /** @hidden */
  113548. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113549. /** @hidden */
  113550. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113551. /** @hidden */
  113552. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113553. /** @hidden */
  113554. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113555. /** @hidden */
  113556. _rebuild(): void;
  113557. /** @hidden */
  113558. _freeze(): void;
  113559. /** @hidden */
  113560. _unFreeze(): void;
  113561. /**
  113562. * 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
  113563. * @param subMesh defines the subMesh to render
  113564. * @param enableAlphaMode defines if alpha mode can be changed
  113565. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113566. * @returns the current mesh
  113567. */
  113568. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113569. private _onBeforeDraw;
  113570. /**
  113571. * Renormalize the mesh and patch it up if there are no weights
  113572. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113573. * However in the case of zero weights then we set just a single influence to 1.
  113574. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113575. */
  113576. cleanMatrixWeights(): void;
  113577. private normalizeSkinFourWeights;
  113578. private normalizeSkinWeightsAndExtra;
  113579. /**
  113580. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113581. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113582. * the user know there was an issue with importing the mesh
  113583. * @returns a validation object with skinned, valid and report string
  113584. */
  113585. validateSkinning(): {
  113586. skinned: boolean;
  113587. valid: boolean;
  113588. report: string;
  113589. };
  113590. /** @hidden */
  113591. _checkDelayState(): Mesh;
  113592. private _queueLoad;
  113593. /**
  113594. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113595. * A mesh is in the frustum if its bounding box intersects the frustum
  113596. * @param frustumPlanes defines the frustum to test
  113597. * @returns true if the mesh is in the frustum planes
  113598. */
  113599. isInFrustum(frustumPlanes: Plane[]): boolean;
  113600. /**
  113601. * Sets the mesh material by the material or multiMaterial `id` property
  113602. * @param id is a string identifying the material or the multiMaterial
  113603. * @returns the current mesh
  113604. */
  113605. setMaterialByID(id: string): Mesh;
  113606. /**
  113607. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113608. * @returns an array of IAnimatable
  113609. */
  113610. getAnimatables(): IAnimatable[];
  113611. /**
  113612. * Modifies the mesh geometry according to the passed transformation matrix.
  113613. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113614. * The mesh normals are modified using the same transformation.
  113615. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113616. * @param transform defines the transform matrix to use
  113617. * @see https://doc.babylonjs.com/resources/baking_transformations
  113618. * @returns the current mesh
  113619. */
  113620. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113621. /**
  113622. * Modifies the mesh geometry according to its own current World Matrix.
  113623. * The mesh World Matrix is then reset.
  113624. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113625. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113626. * @see https://doc.babylonjs.com/resources/baking_transformations
  113627. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113628. * @returns the current mesh
  113629. */
  113630. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113631. /** @hidden */
  113632. get _positions(): Nullable<Vector3[]>;
  113633. /** @hidden */
  113634. _resetPointsArrayCache(): Mesh;
  113635. /** @hidden */
  113636. _generatePointsArray(): boolean;
  113637. /**
  113638. * Returns a new Mesh object generated from the current mesh properties.
  113639. * This method must not get confused with createInstance()
  113640. * @param name is a string, the name given to the new mesh
  113641. * @param newParent can be any Node object (default `null`)
  113642. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113643. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113644. * @returns a new mesh
  113645. */
  113646. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113647. /**
  113648. * Releases resources associated with this mesh.
  113649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113651. */
  113652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113653. /** @hidden */
  113654. _disposeInstanceSpecificData(): void;
  113655. /** @hidden */
  113656. _disposeThinInstanceSpecificData(): void;
  113657. /**
  113658. * Modifies the mesh geometry according to a displacement map.
  113659. * 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.
  113660. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113661. * @param url is a string, the URL from the image file is to be downloaded.
  113662. * @param minHeight is the lower limit of the displacement.
  113663. * @param maxHeight is the upper limit of the displacement.
  113664. * @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.
  113665. * @param uvOffset is an optional vector2 used to offset UV.
  113666. * @param uvScale is an optional vector2 used to scale UV.
  113667. * @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.
  113668. * @returns the Mesh.
  113669. */
  113670. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113671. /**
  113672. * Modifies the mesh geometry according to a displacementMap buffer.
  113673. * 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.
  113674. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113675. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113676. * @param heightMapWidth is the width of the buffer image.
  113677. * @param heightMapHeight is the height of the buffer image.
  113678. * @param minHeight is the lower limit of the displacement.
  113679. * @param maxHeight is the upper limit of the displacement.
  113680. * @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.
  113681. * @param uvOffset is an optional vector2 used to offset UV.
  113682. * @param uvScale is an optional vector2 used to scale UV.
  113683. * @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.
  113684. * @returns the Mesh.
  113685. */
  113686. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113687. /**
  113688. * Modify the mesh to get a flat shading rendering.
  113689. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113690. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113691. * @returns current mesh
  113692. */
  113693. convertToFlatShadedMesh(): Mesh;
  113694. /**
  113695. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113696. * In other words, more vertices, no more indices and a single bigger VBO.
  113697. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113698. * @returns current mesh
  113699. */
  113700. convertToUnIndexedMesh(): Mesh;
  113701. /**
  113702. * Inverses facet orientations.
  113703. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113704. * @param flipNormals will also inverts the normals
  113705. * @returns current mesh
  113706. */
  113707. flipFaces(flipNormals?: boolean): Mesh;
  113708. /**
  113709. * Increase the number of facets and hence vertices in a mesh
  113710. * Vertex normals are interpolated from existing vertex normals
  113711. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113712. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113713. */
  113714. increaseVertices(numberPerEdge: number): void;
  113715. /**
  113716. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113717. * This will undo any application of covertToFlatShadedMesh
  113718. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113719. */
  113720. forceSharedVertices(): void;
  113721. /** @hidden */
  113722. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  113723. /** @hidden */
  113724. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  113725. /**
  113726. * Creates a new InstancedMesh object from the mesh model.
  113727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113728. * @param name defines the name of the new instance
  113729. * @returns a new InstancedMesh
  113730. */
  113731. createInstance(name: string): InstancedMesh;
  113732. /**
  113733. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  113734. * After this call, all the mesh instances have the same submeshes than the current mesh.
  113735. * @returns the current mesh
  113736. */
  113737. synchronizeInstances(): Mesh;
  113738. /**
  113739. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  113740. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  113741. * This should be used together with the simplification to avoid disappearing triangles.
  113742. * @param successCallback an optional success callback to be called after the optimization finished.
  113743. * @returns the current mesh
  113744. */
  113745. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  113746. /**
  113747. * Serialize current mesh
  113748. * @param serializationObject defines the object which will receive the serialization data
  113749. */
  113750. serialize(serializationObject: any): void;
  113751. /** @hidden */
  113752. _syncGeometryWithMorphTargetManager(): void;
  113753. /** @hidden */
  113754. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  113755. /**
  113756. * Returns a new Mesh object parsed from the source provided.
  113757. * @param parsedMesh is the source
  113758. * @param scene defines the hosting scene
  113759. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  113760. * @returns a new Mesh
  113761. */
  113762. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  113763. /**
  113764. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  113765. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113766. * @param name defines the name of the mesh to create
  113767. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  113768. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  113769. * @param closePath creates a seam between the first and the last points of each path of the path array
  113770. * @param offset is taken in account only if the `pathArray` is containing a single path
  113771. * @param scene defines the hosting scene
  113772. * @param updatable defines if the mesh must be flagged as updatable
  113773. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113774. * @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)
  113775. * @returns a new Mesh
  113776. */
  113777. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113778. /**
  113779. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  113780. * @param name defines the name of the mesh to create
  113781. * @param radius sets the radius size (float) of the polygon (default 0.5)
  113782. * @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
  113783. * @param scene defines the hosting scene
  113784. * @param updatable defines if the mesh must be flagged as updatable
  113785. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113786. * @returns a new Mesh
  113787. */
  113788. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113789. /**
  113790. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  113791. * @param name defines the name of the mesh to create
  113792. * @param size sets the size (float) of each box side (default 1)
  113793. * @param scene defines the hosting scene
  113794. * @param updatable defines if the mesh must be flagged as updatable
  113795. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113796. * @returns a new Mesh
  113797. */
  113798. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113799. /**
  113800. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  113801. * @param name defines the name of the mesh to create
  113802. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113803. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113804. * @param scene defines the hosting scene
  113805. * @param updatable defines if the mesh must be flagged as updatable
  113806. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113807. * @returns a new Mesh
  113808. */
  113809. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113810. /**
  113811. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  113812. * @param name defines the name of the mesh to create
  113813. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113814. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113815. * @param scene defines the hosting scene
  113816. * @returns a new Mesh
  113817. */
  113818. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  113819. /**
  113820. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  113821. * @param name defines the name of the mesh to create
  113822. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  113823. * @param diameterTop set the top cap diameter (floats, default 1)
  113824. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  113825. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  113826. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  113827. * @param scene defines the hosting scene
  113828. * @param updatable defines if the mesh must be flagged as updatable
  113829. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113830. * @returns a new Mesh
  113831. */
  113832. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  113833. /**
  113834. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  113835. * @param name defines the name of the mesh to create
  113836. * @param diameter sets the diameter size (float) of the torus (default 1)
  113837. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  113838. * @param tessellation sets the number of torus sides (postive integer, default 16)
  113839. * @param scene defines the hosting scene
  113840. * @param updatable defines if the mesh must be flagged as updatable
  113841. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113842. * @returns a new Mesh
  113843. */
  113844. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113845. /**
  113846. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  113847. * @param name defines the name of the mesh to create
  113848. * @param radius sets the global radius size (float) of the torus knot (default 2)
  113849. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  113850. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  113851. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  113852. * @param p the number of windings on X axis (positive integers, default 2)
  113853. * @param q the number of windings on Y axis (positive integers, default 3)
  113854. * @param scene defines the hosting scene
  113855. * @param updatable defines if the mesh must be flagged as updatable
  113856. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113857. * @returns a new Mesh
  113858. */
  113859. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113860. /**
  113861. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  113862. * @param name defines the name of the mesh to create
  113863. * @param points is an array successive Vector3
  113864. * @param scene defines the hosting scene
  113865. * @param updatable defines if the mesh must be flagged as updatable
  113866. * @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).
  113867. * @returns a new Mesh
  113868. */
  113869. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  113870. /**
  113871. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  113872. * @param name defines the name of the mesh to create
  113873. * @param points is an array successive Vector3
  113874. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  113875. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113876. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  113877. * @param scene defines the hosting scene
  113878. * @param updatable defines if the mesh must be flagged as updatable
  113879. * @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)
  113880. * @returns a new Mesh
  113881. */
  113882. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  113883. /**
  113884. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  113885. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  113886. * 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.
  113887. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  113888. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113889. * Remember you can only change the shape positions, not their number when updating a polygon.
  113890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  113891. * @param name defines the name of the mesh to create
  113892. * @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
  113893. * @param scene defines the hosting scene
  113894. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  113895. * @param updatable defines if the mesh must be flagged as updatable
  113896. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113897. * @param earcutInjection can be used to inject your own earcut reference
  113898. * @returns a new Mesh
  113899. */
  113900. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  113901. /**
  113902. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  113903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  113904. * @param name defines the name of the mesh to create
  113905. * @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
  113906. * @param depth defines the height of extrusion
  113907. * @param scene defines the hosting scene
  113908. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  113909. * @param updatable defines if the mesh must be flagged as updatable
  113910. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113911. * @param earcutInjection can be used to inject your own earcut reference
  113912. * @returns a new Mesh
  113913. */
  113914. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  113915. /**
  113916. * Creates an extruded shape mesh.
  113917. * 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
  113918. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113920. * @param name defines the name of the mesh to create
  113921. * @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
  113922. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  113923. * @param scale is the value to scale the shape
  113924. * @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
  113925. * @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
  113926. * @param scene defines the hosting scene
  113927. * @param updatable defines if the mesh must be flagged as updatable
  113928. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113929. * @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)
  113930. * @returns a new Mesh
  113931. */
  113932. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113933. /**
  113934. * Creates an custom extruded shape mesh.
  113935. * The custom extrusion is a parametric shape.
  113936. * It has no predefined shape. Its final shape will depend on the input parameters.
  113937. * Please consider using the same method from the MeshBuilder class instead
  113938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113939. * @param name defines the name of the mesh to create
  113940. * @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
  113941. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  113942. * @param scaleFunction is a custom Javascript function called on each path point
  113943. * @param rotationFunction is a custom Javascript function called on each path point
  113944. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113945. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  113946. * @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
  113947. * @param scene defines the hosting scene
  113948. * @param updatable defines if the mesh must be flagged as updatable
  113949. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113950. * @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)
  113951. * @returns a new Mesh
  113952. */
  113953. 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;
  113954. /**
  113955. * Creates lathe mesh.
  113956. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  113957. * Please consider using the same method from the MeshBuilder class instead
  113958. * @param name defines the name of the mesh to create
  113959. * @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
  113960. * @param radius is the radius value of the lathe
  113961. * @param tessellation is the side number of the lathe.
  113962. * @param scene defines the hosting scene
  113963. * @param updatable defines if the mesh must be flagged as updatable
  113964. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113965. * @returns a new Mesh
  113966. */
  113967. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113968. /**
  113969. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  113970. * @param name defines the name of the mesh to create
  113971. * @param size sets the size (float) of both sides of the plane at once (default 1)
  113972. * @param scene defines the hosting scene
  113973. * @param updatable defines if the mesh must be flagged as updatable
  113974. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113975. * @returns a new Mesh
  113976. */
  113977. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113978. /**
  113979. * Creates a ground mesh.
  113980. * Please consider using the same method from the MeshBuilder class instead
  113981. * @param name defines the name of the mesh to create
  113982. * @param width set the width of the ground
  113983. * @param height set the height of the ground
  113984. * @param subdivisions sets the number of subdivisions per side
  113985. * @param scene defines the hosting scene
  113986. * @param updatable defines if the mesh must be flagged as updatable
  113987. * @returns a new Mesh
  113988. */
  113989. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  113990. /**
  113991. * Creates a tiled ground mesh.
  113992. * Please consider using the same method from the MeshBuilder class instead
  113993. * @param name defines the name of the mesh to create
  113994. * @param xmin set the ground minimum X coordinate
  113995. * @param zmin set the ground minimum Y coordinate
  113996. * @param xmax set the ground maximum X coordinate
  113997. * @param zmax set the ground maximum Z coordinate
  113998. * @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
  113999. * @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
  114000. * @param scene defines the hosting scene
  114001. * @param updatable defines if the mesh must be flagged as updatable
  114002. * @returns a new Mesh
  114003. */
  114004. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114005. w: number;
  114006. h: number;
  114007. }, precision: {
  114008. w: number;
  114009. h: number;
  114010. }, scene: Scene, updatable?: boolean): Mesh;
  114011. /**
  114012. * Creates a ground mesh from a height map.
  114013. * Please consider using the same method from the MeshBuilder class instead
  114014. * @see https://doc.babylonjs.com/babylon101/height_map
  114015. * @param name defines the name of the mesh to create
  114016. * @param url sets the URL of the height map image resource
  114017. * @param width set the ground width size
  114018. * @param height set the ground height size
  114019. * @param subdivisions sets the number of subdivision per side
  114020. * @param minHeight is the minimum altitude on the ground
  114021. * @param maxHeight is the maximum altitude on the ground
  114022. * @param scene defines the hosting scene
  114023. * @param updatable defines if the mesh must be flagged as updatable
  114024. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114025. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114026. * @returns a new Mesh
  114027. */
  114028. 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;
  114029. /**
  114030. * Creates a tube mesh.
  114031. * The tube is a parametric shape.
  114032. * It has no predefined shape. Its final shape will depend on the input parameters.
  114033. * Please consider using the same method from the MeshBuilder class instead
  114034. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114035. * @param name defines the name of the mesh to create
  114036. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114037. * @param radius sets the tube radius size
  114038. * @param tessellation is the number of sides on the tubular surface
  114039. * @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
  114040. * @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
  114041. * @param scene defines the hosting scene
  114042. * @param updatable defines if the mesh must be flagged as updatable
  114043. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114044. * @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)
  114045. * @returns a new Mesh
  114046. */
  114047. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114048. (i: number, distance: number): number;
  114049. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114050. /**
  114051. * Creates a polyhedron mesh.
  114052. * Please consider using the same method from the MeshBuilder class instead.
  114053. * * 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
  114054. * * The parameter `size` (positive float, default 1) sets the polygon size
  114055. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114056. * * 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`
  114057. * * 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
  114058. * * 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)`)
  114059. * * 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
  114060. * * 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
  114061. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114064. * @param name defines the name of the mesh to create
  114065. * @param options defines the options used to create the mesh
  114066. * @param scene defines the hosting scene
  114067. * @returns a new Mesh
  114068. */
  114069. static CreatePolyhedron(name: string, options: {
  114070. type?: number;
  114071. size?: number;
  114072. sizeX?: number;
  114073. sizeY?: number;
  114074. sizeZ?: number;
  114075. custom?: any;
  114076. faceUV?: Vector4[];
  114077. faceColors?: Color4[];
  114078. updatable?: boolean;
  114079. sideOrientation?: number;
  114080. }, scene: Scene): Mesh;
  114081. /**
  114082. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114083. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114084. * * 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`)
  114085. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114086. * * 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
  114087. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114090. * @param name defines the name of the mesh
  114091. * @param options defines the options used to create the mesh
  114092. * @param scene defines the hosting scene
  114093. * @returns a new Mesh
  114094. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114095. */
  114096. static CreateIcoSphere(name: string, options: {
  114097. radius?: number;
  114098. flat?: boolean;
  114099. subdivisions?: number;
  114100. sideOrientation?: number;
  114101. updatable?: boolean;
  114102. }, scene: Scene): Mesh;
  114103. /**
  114104. * Creates a decal mesh.
  114105. * Please consider using the same method from the MeshBuilder class instead.
  114106. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114107. * @param name defines the name of the mesh
  114108. * @param sourceMesh defines the mesh receiving the decal
  114109. * @param position sets the position of the decal in world coordinates
  114110. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114111. * @param size sets the decal scaling
  114112. * @param angle sets the angle to rotate the decal
  114113. * @returns a new Mesh
  114114. */
  114115. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114116. /** Creates a Capsule Mesh
  114117. * @param name defines the name of the mesh.
  114118. * @param options the constructors options used to shape the mesh.
  114119. * @param scene defines the scene the mesh is scoped to.
  114120. * @returns the capsule mesh
  114121. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114122. */
  114123. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114124. /**
  114125. * Prepare internal position array for software CPU skinning
  114126. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114127. */
  114128. setPositionsForCPUSkinning(): Float32Array;
  114129. /**
  114130. * Prepare internal normal array for software CPU skinning
  114131. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114132. */
  114133. setNormalsForCPUSkinning(): Float32Array;
  114134. /**
  114135. * Updates the vertex buffer by applying transformation from the bones
  114136. * @param skeleton defines the skeleton to apply to current mesh
  114137. * @returns the current mesh
  114138. */
  114139. applySkeleton(skeleton: Skeleton): Mesh;
  114140. /**
  114141. * 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
  114142. * @param meshes defines the list of meshes to scan
  114143. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114144. */
  114145. static MinMax(meshes: AbstractMesh[]): {
  114146. min: Vector3;
  114147. max: Vector3;
  114148. };
  114149. /**
  114150. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114151. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114152. * @returns a vector3
  114153. */
  114154. static Center(meshesOrMinMaxVector: {
  114155. min: Vector3;
  114156. max: Vector3;
  114157. } | AbstractMesh[]): Vector3;
  114158. /**
  114159. * Merge the array of meshes into a single mesh for performance reasons.
  114160. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114161. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114162. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114163. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114164. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114165. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114166. * @returns a new mesh
  114167. */
  114168. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114169. /** @hidden */
  114170. addInstance(instance: InstancedMesh): void;
  114171. /** @hidden */
  114172. removeInstance(instance: InstancedMesh): void;
  114173. }
  114174. }
  114175. declare module BABYLON {
  114176. /**
  114177. * This is the base class of all the camera used in the application.
  114178. * @see https://doc.babylonjs.com/features/cameras
  114179. */
  114180. export class Camera extends Node {
  114181. /** @hidden */
  114182. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114183. /**
  114184. * This is the default projection mode used by the cameras.
  114185. * It helps recreating a feeling of perspective and better appreciate depth.
  114186. * This is the best way to simulate real life cameras.
  114187. */
  114188. static readonly PERSPECTIVE_CAMERA: number;
  114189. /**
  114190. * This helps creating camera with an orthographic mode.
  114191. * 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.
  114192. */
  114193. static readonly ORTHOGRAPHIC_CAMERA: number;
  114194. /**
  114195. * This is the default FOV mode for perspective cameras.
  114196. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114197. */
  114198. static readonly FOVMODE_VERTICAL_FIXED: number;
  114199. /**
  114200. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114201. */
  114202. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114203. /**
  114204. * This specifies ther is no need for a camera rig.
  114205. * Basically only one eye is rendered corresponding to the camera.
  114206. */
  114207. static readonly RIG_MODE_NONE: number;
  114208. /**
  114209. * Simulates a camera Rig with one blue eye and one red eye.
  114210. * This can be use with 3d blue and red glasses.
  114211. */
  114212. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114213. /**
  114214. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114215. */
  114216. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114217. /**
  114218. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114219. */
  114220. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114221. /**
  114222. * Defines that both eyes of the camera will be rendered over under each other.
  114223. */
  114224. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114225. /**
  114226. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114227. */
  114228. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114229. /**
  114230. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114231. */
  114232. static readonly RIG_MODE_VR: number;
  114233. /**
  114234. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114235. */
  114236. static readonly RIG_MODE_WEBVR: number;
  114237. /**
  114238. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114239. */
  114240. static readonly RIG_MODE_CUSTOM: number;
  114241. /**
  114242. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114243. */
  114244. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114245. /**
  114246. * Define the input manager associated with the camera.
  114247. */
  114248. inputs: CameraInputsManager<Camera>;
  114249. /** @hidden */
  114250. _position: Vector3;
  114251. /**
  114252. * Define the current local position of the camera in the scene
  114253. */
  114254. get position(): Vector3;
  114255. set position(newPosition: Vector3);
  114256. protected _upVector: Vector3;
  114257. /**
  114258. * The vector the camera should consider as up.
  114259. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114260. */
  114261. set upVector(vec: Vector3);
  114262. get upVector(): Vector3;
  114263. /**
  114264. * Define the current limit on the left side for an orthographic camera
  114265. * In scene unit
  114266. */
  114267. orthoLeft: Nullable<number>;
  114268. /**
  114269. * Define the current limit on the right side for an orthographic camera
  114270. * In scene unit
  114271. */
  114272. orthoRight: Nullable<number>;
  114273. /**
  114274. * Define the current limit on the bottom side for an orthographic camera
  114275. * In scene unit
  114276. */
  114277. orthoBottom: Nullable<number>;
  114278. /**
  114279. * Define the current limit on the top side for an orthographic camera
  114280. * In scene unit
  114281. */
  114282. orthoTop: Nullable<number>;
  114283. /**
  114284. * Field Of View is set in Radians. (default is 0.8)
  114285. */
  114286. fov: number;
  114287. /**
  114288. * Define the minimum distance the camera can see from.
  114289. * This is important to note that the depth buffer are not infinite and the closer it starts
  114290. * the more your scene might encounter depth fighting issue.
  114291. */
  114292. minZ: number;
  114293. /**
  114294. * Define the maximum distance the camera can see to.
  114295. * This is important to note that the depth buffer are not infinite and the further it end
  114296. * the more your scene might encounter depth fighting issue.
  114297. */
  114298. maxZ: number;
  114299. /**
  114300. * Define the default inertia of the camera.
  114301. * This helps giving a smooth feeling to the camera movement.
  114302. */
  114303. inertia: number;
  114304. /**
  114305. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114306. */
  114307. mode: number;
  114308. /**
  114309. * Define whether the camera is intermediate.
  114310. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114311. */
  114312. isIntermediate: boolean;
  114313. /**
  114314. * Define the viewport of the camera.
  114315. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114316. */
  114317. viewport: Viewport;
  114318. /**
  114319. * Restricts the camera to viewing objects with the same layerMask.
  114320. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114321. */
  114322. layerMask: number;
  114323. /**
  114324. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114325. */
  114326. fovMode: number;
  114327. /**
  114328. * Rig mode of the camera.
  114329. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114330. * This is normally controlled byt the camera themselves as internal use.
  114331. */
  114332. cameraRigMode: number;
  114333. /**
  114334. * Defines the distance between both "eyes" in case of a RIG
  114335. */
  114336. interaxialDistance: number;
  114337. /**
  114338. * Defines if stereoscopic rendering is done side by side or over under.
  114339. */
  114340. isStereoscopicSideBySide: boolean;
  114341. /**
  114342. * 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
  114343. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114344. * else in the scene. (Eg. security camera)
  114345. *
  114346. * 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)
  114347. */
  114348. customRenderTargets: RenderTargetTexture[];
  114349. /**
  114350. * When set, the camera will render to this render target instead of the default canvas
  114351. *
  114352. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114353. */
  114354. outputRenderTarget: Nullable<RenderTargetTexture>;
  114355. /**
  114356. * Observable triggered when the camera view matrix has changed.
  114357. */
  114358. onViewMatrixChangedObservable: Observable<Camera>;
  114359. /**
  114360. * Observable triggered when the camera Projection matrix has changed.
  114361. */
  114362. onProjectionMatrixChangedObservable: Observable<Camera>;
  114363. /**
  114364. * Observable triggered when the inputs have been processed.
  114365. */
  114366. onAfterCheckInputsObservable: Observable<Camera>;
  114367. /**
  114368. * Observable triggered when reset has been called and applied to the camera.
  114369. */
  114370. onRestoreStateObservable: Observable<Camera>;
  114371. /**
  114372. * Is this camera a part of a rig system?
  114373. */
  114374. isRigCamera: boolean;
  114375. /**
  114376. * If isRigCamera set to true this will be set with the parent camera.
  114377. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114378. */
  114379. rigParent?: Camera;
  114380. /** @hidden */
  114381. _cameraRigParams: any;
  114382. /** @hidden */
  114383. _rigCameras: Camera[];
  114384. /** @hidden */
  114385. _rigPostProcess: Nullable<PostProcess>;
  114386. protected _webvrViewMatrix: Matrix;
  114387. /** @hidden */
  114388. _skipRendering: boolean;
  114389. /** @hidden */
  114390. _projectionMatrix: Matrix;
  114391. /** @hidden */
  114392. _postProcesses: Nullable<PostProcess>[];
  114393. /** @hidden */
  114394. _activeMeshes: SmartArray<AbstractMesh>;
  114395. protected _globalPosition: Vector3;
  114396. /** @hidden */
  114397. _computedViewMatrix: Matrix;
  114398. private _doNotComputeProjectionMatrix;
  114399. private _transformMatrix;
  114400. private _frustumPlanes;
  114401. private _refreshFrustumPlanes;
  114402. private _storedFov;
  114403. private _stateStored;
  114404. /**
  114405. * Instantiates a new camera object.
  114406. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114407. * @see https://doc.babylonjs.com/features/cameras
  114408. * @param name Defines the name of the camera in the scene
  114409. * @param position Defines the position of the camera
  114410. * @param scene Defines the scene the camera belongs too
  114411. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114412. */
  114413. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114414. /**
  114415. * Store current camera state (fov, position, etc..)
  114416. * @returns the camera
  114417. */
  114418. storeState(): Camera;
  114419. /**
  114420. * Restores the camera state values if it has been stored. You must call storeState() first
  114421. */
  114422. protected _restoreStateValues(): boolean;
  114423. /**
  114424. * Restored camera state. You must call storeState() first.
  114425. * @returns true if restored and false otherwise
  114426. */
  114427. restoreState(): boolean;
  114428. /**
  114429. * Gets the class name of the camera.
  114430. * @returns the class name
  114431. */
  114432. getClassName(): string;
  114433. /** @hidden */
  114434. readonly _isCamera: boolean;
  114435. /**
  114436. * Gets a string representation of the camera useful for debug purpose.
  114437. * @param fullDetails Defines that a more verboe level of logging is required
  114438. * @returns the string representation
  114439. */
  114440. toString(fullDetails?: boolean): string;
  114441. /**
  114442. * Gets the current world space position of the camera.
  114443. */
  114444. get globalPosition(): Vector3;
  114445. /**
  114446. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114447. * @returns the active meshe list
  114448. */
  114449. getActiveMeshes(): SmartArray<AbstractMesh>;
  114450. /**
  114451. * Check whether a mesh is part of the current active mesh list of the camera
  114452. * @param mesh Defines the mesh to check
  114453. * @returns true if active, false otherwise
  114454. */
  114455. isActiveMesh(mesh: Mesh): boolean;
  114456. /**
  114457. * Is this camera ready to be used/rendered
  114458. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114459. * @return true if the camera is ready
  114460. */
  114461. isReady(completeCheck?: boolean): boolean;
  114462. /** @hidden */
  114463. _initCache(): void;
  114464. /** @hidden */
  114465. _updateCache(ignoreParentClass?: boolean): void;
  114466. /** @hidden */
  114467. _isSynchronized(): boolean;
  114468. /** @hidden */
  114469. _isSynchronizedViewMatrix(): boolean;
  114470. /** @hidden */
  114471. _isSynchronizedProjectionMatrix(): boolean;
  114472. /**
  114473. * Attach the input controls to a specific dom element to get the input from.
  114474. * @param element Defines the element the controls should be listened from
  114475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114476. */
  114477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114478. /**
  114479. * Detach the current controls from the specified dom element.
  114480. * @param element Defines the element to stop listening the inputs from
  114481. */
  114482. detachControl(element: HTMLElement): void;
  114483. /**
  114484. * Update the camera state according to the different inputs gathered during the frame.
  114485. */
  114486. update(): void;
  114487. /** @hidden */
  114488. _checkInputs(): void;
  114489. /** @hidden */
  114490. get rigCameras(): Camera[];
  114491. /**
  114492. * Gets the post process used by the rig cameras
  114493. */
  114494. get rigPostProcess(): Nullable<PostProcess>;
  114495. /**
  114496. * Internal, gets the first post proces.
  114497. * @returns the first post process to be run on this camera.
  114498. */
  114499. _getFirstPostProcess(): Nullable<PostProcess>;
  114500. private _cascadePostProcessesToRigCams;
  114501. /**
  114502. * Attach a post process to the camera.
  114503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114504. * @param postProcess The post process to attach to the camera
  114505. * @param insertAt The position of the post process in case several of them are in use in the scene
  114506. * @returns the position the post process has been inserted at
  114507. */
  114508. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114509. /**
  114510. * Detach a post process to the camera.
  114511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114512. * @param postProcess The post process to detach from the camera
  114513. */
  114514. detachPostProcess(postProcess: PostProcess): void;
  114515. /**
  114516. * Gets the current world matrix of the camera
  114517. */
  114518. getWorldMatrix(): Matrix;
  114519. /** @hidden */
  114520. _getViewMatrix(): Matrix;
  114521. /**
  114522. * Gets the current view matrix of the camera.
  114523. * @param force forces the camera to recompute the matrix without looking at the cached state
  114524. * @returns the view matrix
  114525. */
  114526. getViewMatrix(force?: boolean): Matrix;
  114527. /**
  114528. * Freeze the projection matrix.
  114529. * It will prevent the cache check of the camera projection compute and can speed up perf
  114530. * if no parameter of the camera are meant to change
  114531. * @param projection Defines manually a projection if necessary
  114532. */
  114533. freezeProjectionMatrix(projection?: Matrix): void;
  114534. /**
  114535. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114536. */
  114537. unfreezeProjectionMatrix(): void;
  114538. /**
  114539. * Gets the current projection matrix of the camera.
  114540. * @param force forces the camera to recompute the matrix without looking at the cached state
  114541. * @returns the projection matrix
  114542. */
  114543. getProjectionMatrix(force?: boolean): Matrix;
  114544. /**
  114545. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114546. * @returns a Matrix
  114547. */
  114548. getTransformationMatrix(): Matrix;
  114549. private _updateFrustumPlanes;
  114550. /**
  114551. * Checks if a cullable object (mesh...) is in the camera frustum
  114552. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114553. * @param target The object to check
  114554. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114555. * @returns true if the object is in frustum otherwise false
  114556. */
  114557. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114558. /**
  114559. * Checks if a cullable object (mesh...) is in the camera frustum
  114560. * Unlike isInFrustum this cheks the full bounding box
  114561. * @param target The object to check
  114562. * @returns true if the object is in frustum otherwise false
  114563. */
  114564. isCompletelyInFrustum(target: ICullable): boolean;
  114565. /**
  114566. * Gets a ray in the forward direction from the camera.
  114567. * @param length Defines the length of the ray to create
  114568. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114569. * @param origin Defines the start point of the ray which defaults to the camera position
  114570. * @returns the forward ray
  114571. */
  114572. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114573. /**
  114574. * Gets a ray in the forward direction from the camera.
  114575. * @param refRay the ray to (re)use when setting the values
  114576. * @param length Defines the length of the ray to create
  114577. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114578. * @param origin Defines the start point of the ray which defaults to the camera position
  114579. * @returns the forward ray
  114580. */
  114581. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114582. /**
  114583. * Releases resources associated with this node.
  114584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114586. */
  114587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114588. /** @hidden */
  114589. _isLeftCamera: boolean;
  114590. /**
  114591. * Gets the left camera of a rig setup in case of Rigged Camera
  114592. */
  114593. get isLeftCamera(): boolean;
  114594. /** @hidden */
  114595. _isRightCamera: boolean;
  114596. /**
  114597. * Gets the right camera of a rig setup in case of Rigged Camera
  114598. */
  114599. get isRightCamera(): boolean;
  114600. /**
  114601. * Gets the left camera of a rig setup in case of Rigged Camera
  114602. */
  114603. get leftCamera(): Nullable<FreeCamera>;
  114604. /**
  114605. * Gets the right camera of a rig setup in case of Rigged Camera
  114606. */
  114607. get rightCamera(): Nullable<FreeCamera>;
  114608. /**
  114609. * Gets the left camera target of a rig setup in case of Rigged Camera
  114610. * @returns the target position
  114611. */
  114612. getLeftTarget(): Nullable<Vector3>;
  114613. /**
  114614. * Gets the right camera target of a rig setup in case of Rigged Camera
  114615. * @returns the target position
  114616. */
  114617. getRightTarget(): Nullable<Vector3>;
  114618. /**
  114619. * @hidden
  114620. */
  114621. setCameraRigMode(mode: number, rigParams: any): void;
  114622. /** @hidden */
  114623. static _setStereoscopicRigMode(camera: Camera): void;
  114624. /** @hidden */
  114625. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114626. /** @hidden */
  114627. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114628. /** @hidden */
  114629. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114630. /** @hidden */
  114631. _getVRProjectionMatrix(): Matrix;
  114632. protected _updateCameraRotationMatrix(): void;
  114633. protected _updateWebVRCameraRotationMatrix(): void;
  114634. /**
  114635. * This function MUST be overwritten by the different WebVR cameras available.
  114636. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114637. * @hidden
  114638. */
  114639. _getWebVRProjectionMatrix(): Matrix;
  114640. /**
  114641. * This function MUST be overwritten by the different WebVR cameras available.
  114642. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114643. * @hidden
  114644. */
  114645. _getWebVRViewMatrix(): Matrix;
  114646. /** @hidden */
  114647. setCameraRigParameter(name: string, value: any): void;
  114648. /**
  114649. * needs to be overridden by children so sub has required properties to be copied
  114650. * @hidden
  114651. */
  114652. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114653. /**
  114654. * May need to be overridden by children
  114655. * @hidden
  114656. */
  114657. _updateRigCameras(): void;
  114658. /** @hidden */
  114659. _setupInputs(): void;
  114660. /**
  114661. * Serialiaze the camera setup to a json represention
  114662. * @returns the JSON representation
  114663. */
  114664. serialize(): any;
  114665. /**
  114666. * Clones the current camera.
  114667. * @param name The cloned camera name
  114668. * @returns the cloned camera
  114669. */
  114670. clone(name: string): Camera;
  114671. /**
  114672. * Gets the direction of the camera relative to a given local axis.
  114673. * @param localAxis Defines the reference axis to provide a relative direction.
  114674. * @return the direction
  114675. */
  114676. getDirection(localAxis: Vector3): Vector3;
  114677. /**
  114678. * Returns the current camera absolute rotation
  114679. */
  114680. get absoluteRotation(): Quaternion;
  114681. /**
  114682. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114683. * @param localAxis Defines the reference axis to provide a relative direction.
  114684. * @param result Defines the vector to store the result in
  114685. */
  114686. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114687. /**
  114688. * Gets a camera constructor for a given camera type
  114689. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114690. * @param name The name of the camera the result will be able to instantiate
  114691. * @param scene The scene the result will construct the camera in
  114692. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114693. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114694. * @returns a factory method to construc the camera
  114695. */
  114696. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114697. /**
  114698. * Compute the world matrix of the camera.
  114699. * @returns the camera world matrix
  114700. */
  114701. computeWorldMatrix(): Matrix;
  114702. /**
  114703. * Parse a JSON and creates the camera from the parsed information
  114704. * @param parsedCamera The JSON to parse
  114705. * @param scene The scene to instantiate the camera in
  114706. * @returns the newly constructed camera
  114707. */
  114708. static Parse(parsedCamera: any, scene: Scene): Camera;
  114709. }
  114710. }
  114711. declare module BABYLON {
  114712. /**
  114713. * Class containing static functions to help procedurally build meshes
  114714. */
  114715. export class DiscBuilder {
  114716. /**
  114717. * Creates a plane polygonal mesh. By default, this is a disc
  114718. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114719. * * 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
  114720. * * 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
  114721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114724. * @param name defines the name of the mesh
  114725. * @param options defines the options used to create the mesh
  114726. * @param scene defines the hosting scene
  114727. * @returns the plane polygonal mesh
  114728. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114729. */
  114730. static CreateDisc(name: string, options: {
  114731. radius?: number;
  114732. tessellation?: number;
  114733. arc?: number;
  114734. updatable?: boolean;
  114735. sideOrientation?: number;
  114736. frontUVs?: Vector4;
  114737. backUVs?: Vector4;
  114738. }, scene?: Nullable<Scene>): Mesh;
  114739. }
  114740. }
  114741. declare module BABYLON {
  114742. /**
  114743. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114744. *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.
  114745. * The SPS is also a particle system. It provides some methods to manage the particles.
  114746. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  114747. *
  114748. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  114749. */
  114750. export class SolidParticleSystem implements IDisposable {
  114751. /**
  114752. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  114753. * Example : var p = SPS.particles[i];
  114754. */
  114755. particles: SolidParticle[];
  114756. /**
  114757. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  114758. */
  114759. nbParticles: number;
  114760. /**
  114761. * If the particles must ever face the camera (default false). Useful for planar particles.
  114762. */
  114763. billboard: boolean;
  114764. /**
  114765. * Recompute normals when adding a shape
  114766. */
  114767. recomputeNormals: boolean;
  114768. /**
  114769. * This a counter ofr your own usage. It's not set by any SPS functions.
  114770. */
  114771. counter: number;
  114772. /**
  114773. * The SPS name. This name is also given to the underlying mesh.
  114774. */
  114775. name: string;
  114776. /**
  114777. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  114778. */
  114779. mesh: Mesh;
  114780. /**
  114781. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  114782. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  114783. */
  114784. vars: any;
  114785. /**
  114786. * This array is populated when the SPS is set as 'pickable'.
  114787. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  114788. * Each element of this array is an object `{idx: int, faceId: int}`.
  114789. * `idx` is the picked particle index in the `SPS.particles` array
  114790. * `faceId` is the picked face index counted within this particle.
  114791. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  114792. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  114793. * Use the method SPS.pickedParticle(pickingInfo) instead.
  114794. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114795. */
  114796. pickedParticles: {
  114797. idx: number;
  114798. faceId: number;
  114799. }[];
  114800. /**
  114801. * This array is populated when the SPS is set as 'pickable'
  114802. * Each key of this array is a submesh index.
  114803. * Each element of this array is a second array defined like this :
  114804. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  114805. * Each element of this second array is an object `{idx: int, faceId: int}`.
  114806. * `idx` is the picked particle index in the `SPS.particles` array
  114807. * `faceId` is the picked face index counted within this particle.
  114808. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  114809. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114810. */
  114811. pickedBySubMesh: {
  114812. idx: number;
  114813. faceId: number;
  114814. }[][];
  114815. /**
  114816. * This array is populated when `enableDepthSort` is set to true.
  114817. * Each element of this array is an instance of the class DepthSortedParticle.
  114818. */
  114819. depthSortedParticles: DepthSortedParticle[];
  114820. /**
  114821. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  114822. * @hidden
  114823. */
  114824. _bSphereOnly: boolean;
  114825. /**
  114826. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  114827. * @hidden
  114828. */
  114829. _bSphereRadiusFactor: number;
  114830. private _scene;
  114831. private _positions;
  114832. private _indices;
  114833. private _normals;
  114834. private _colors;
  114835. private _uvs;
  114836. private _indices32;
  114837. private _positions32;
  114838. private _normals32;
  114839. private _fixedNormal32;
  114840. private _colors32;
  114841. private _uvs32;
  114842. private _index;
  114843. private _updatable;
  114844. private _pickable;
  114845. private _isVisibilityBoxLocked;
  114846. private _alwaysVisible;
  114847. private _depthSort;
  114848. private _expandable;
  114849. private _shapeCounter;
  114850. private _copy;
  114851. private _color;
  114852. private _computeParticleColor;
  114853. private _computeParticleTexture;
  114854. private _computeParticleRotation;
  114855. private _computeParticleVertex;
  114856. private _computeBoundingBox;
  114857. private _depthSortParticles;
  114858. private _camera;
  114859. private _mustUnrotateFixedNormals;
  114860. private _particlesIntersect;
  114861. private _needs32Bits;
  114862. private _isNotBuilt;
  114863. private _lastParticleId;
  114864. private _idxOfId;
  114865. private _multimaterialEnabled;
  114866. private _useModelMaterial;
  114867. private _indicesByMaterial;
  114868. private _materialIndexes;
  114869. private _depthSortFunction;
  114870. private _materialSortFunction;
  114871. private _materials;
  114872. private _multimaterial;
  114873. private _materialIndexesById;
  114874. private _defaultMaterial;
  114875. private _autoUpdateSubMeshes;
  114876. private _tmpVertex;
  114877. /**
  114878. * Creates a SPS (Solid Particle System) object.
  114879. * @param name (String) is the SPS name, this will be the underlying mesh name.
  114880. * @param scene (Scene) is the scene in which the SPS is added.
  114881. * @param options defines the options of the sps e.g.
  114882. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  114883. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  114884. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  114885. * * 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.
  114886. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  114887. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  114888. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  114889. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  114890. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  114891. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  114892. */
  114893. constructor(name: string, scene: Scene, options?: {
  114894. updatable?: boolean;
  114895. isPickable?: boolean;
  114896. enableDepthSort?: boolean;
  114897. particleIntersection?: boolean;
  114898. boundingSphereOnly?: boolean;
  114899. bSphereRadiusFactor?: number;
  114900. expandable?: boolean;
  114901. useModelMaterial?: boolean;
  114902. enableMultiMaterial?: boolean;
  114903. });
  114904. /**
  114905. * Builds the SPS underlying mesh. Returns a standard Mesh.
  114906. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  114907. * @returns the created mesh
  114908. */
  114909. buildMesh(): Mesh;
  114910. /**
  114911. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  114912. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  114913. * Thus the particles generated from `digest()` have their property `position` set yet.
  114914. * @param mesh ( Mesh ) is the mesh to be digested
  114915. * @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
  114916. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  114917. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  114918. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  114919. * @returns the current SPS
  114920. */
  114921. digest(mesh: Mesh, options?: {
  114922. facetNb?: number;
  114923. number?: number;
  114924. delta?: number;
  114925. storage?: [];
  114926. }): SolidParticleSystem;
  114927. /**
  114928. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  114929. * @hidden
  114930. */
  114931. private _unrotateFixedNormals;
  114932. /**
  114933. * Resets the temporary working copy particle
  114934. * @hidden
  114935. */
  114936. private _resetCopy;
  114937. /**
  114938. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  114939. * @param p the current index in the positions array to be updated
  114940. * @param ind the current index in the indices array
  114941. * @param shape a Vector3 array, the shape geometry
  114942. * @param positions the positions array to be updated
  114943. * @param meshInd the shape indices array
  114944. * @param indices the indices array to be updated
  114945. * @param meshUV the shape uv array
  114946. * @param uvs the uv array to be updated
  114947. * @param meshCol the shape color array
  114948. * @param colors the color array to be updated
  114949. * @param meshNor the shape normals array
  114950. * @param normals the normals array to be updated
  114951. * @param idx the particle index
  114952. * @param idxInShape the particle index in its shape
  114953. * @param options the addShape() method passed options
  114954. * @model the particle model
  114955. * @hidden
  114956. */
  114957. private _meshBuilder;
  114958. /**
  114959. * Returns a shape Vector3 array from positions float array
  114960. * @param positions float array
  114961. * @returns a vector3 array
  114962. * @hidden
  114963. */
  114964. private _posToShape;
  114965. /**
  114966. * Returns a shapeUV array from a float uvs (array deep copy)
  114967. * @param uvs as a float array
  114968. * @returns a shapeUV array
  114969. * @hidden
  114970. */
  114971. private _uvsToShapeUV;
  114972. /**
  114973. * Adds a new particle object in the particles array
  114974. * @param idx particle index in particles array
  114975. * @param id particle id
  114976. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  114977. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  114978. * @param model particle ModelShape object
  114979. * @param shapeId model shape identifier
  114980. * @param idxInShape index of the particle in the current model
  114981. * @param bInfo model bounding info object
  114982. * @param storage target storage array, if any
  114983. * @hidden
  114984. */
  114985. private _addParticle;
  114986. /**
  114987. * Adds some particles to the SPS from the model shape. Returns the shape id.
  114988. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  114989. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  114990. * @param nb (positive integer) the number of particles to be created from this model
  114991. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  114992. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  114993. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  114994. * @returns the number of shapes in the system
  114995. */
  114996. addShape(mesh: Mesh, nb: number, options?: {
  114997. positionFunction?: any;
  114998. vertexFunction?: any;
  114999. storage?: [];
  115000. }): number;
  115001. /**
  115002. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115003. * @hidden
  115004. */
  115005. private _rebuildParticle;
  115006. /**
  115007. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115008. * @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.
  115009. * @returns the SPS.
  115010. */
  115011. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115012. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115013. * Returns an array with the removed particles.
  115014. * 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.
  115015. * The SPS can't be empty so at least one particle needs to remain in place.
  115016. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115017. * @param start index of the first particle to remove
  115018. * @param end index of the last particle to remove (included)
  115019. * @returns an array populated with the removed particles
  115020. */
  115021. removeParticles(start: number, end: number): SolidParticle[];
  115022. /**
  115023. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115024. * @param solidParticleArray an array populated with Solid Particles objects
  115025. * @returns the SPS
  115026. */
  115027. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115028. /**
  115029. * Creates a new particle and modifies the SPS mesh geometry :
  115030. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115031. * - calls _addParticle() to populate the particle array
  115032. * factorized code from addShape() and insertParticlesFromArray()
  115033. * @param idx particle index in the particles array
  115034. * @param i particle index in its shape
  115035. * @param modelShape particle ModelShape object
  115036. * @param shape shape vertex array
  115037. * @param meshInd shape indices array
  115038. * @param meshUV shape uv array
  115039. * @param meshCol shape color array
  115040. * @param meshNor shape normals array
  115041. * @param bbInfo shape bounding info
  115042. * @param storage target particle storage
  115043. * @options addShape() passed options
  115044. * @hidden
  115045. */
  115046. private _insertNewParticle;
  115047. /**
  115048. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115049. * This method calls `updateParticle()` for each particle of the SPS.
  115050. * For an animated SPS, it is usually called within the render loop.
  115051. * 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.
  115052. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115053. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115054. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115055. * @returns the SPS.
  115056. */
  115057. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115058. /**
  115059. * Disposes the SPS.
  115060. */
  115061. dispose(): void;
  115062. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115063. * idx is the particle index in the SPS
  115064. * faceId is the picked face index counted within this particle.
  115065. * Returns null if the pickInfo can't identify a picked particle.
  115066. * @param pickingInfo (PickingInfo object)
  115067. * @returns {idx: number, faceId: number} or null
  115068. */
  115069. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115070. idx: number;
  115071. faceId: number;
  115072. }>;
  115073. /**
  115074. * Returns a SolidParticle object from its identifier : particle.id
  115075. * @param id (integer) the particle Id
  115076. * @returns the searched particle or null if not found in the SPS.
  115077. */
  115078. getParticleById(id: number): Nullable<SolidParticle>;
  115079. /**
  115080. * Returns a new array populated with the particles having the passed shapeId.
  115081. * @param shapeId (integer) the shape identifier
  115082. * @returns a new solid particle array
  115083. */
  115084. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115085. /**
  115086. * Populates the passed array "ref" with the particles having the passed shapeId.
  115087. * @param shapeId the shape identifier
  115088. * @returns the SPS
  115089. * @param ref
  115090. */
  115091. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115092. /**
  115093. * Computes the required SubMeshes according the materials assigned to the particles.
  115094. * @returns the solid particle system.
  115095. * Does nothing if called before the SPS mesh is built.
  115096. */
  115097. computeSubMeshes(): SolidParticleSystem;
  115098. /**
  115099. * Sorts the solid particles by material when MultiMaterial is enabled.
  115100. * Updates the indices32 array.
  115101. * Updates the indicesByMaterial array.
  115102. * Updates the mesh indices array.
  115103. * @returns the SPS
  115104. * @hidden
  115105. */
  115106. private _sortParticlesByMaterial;
  115107. /**
  115108. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115109. * @hidden
  115110. */
  115111. private _setMaterialIndexesById;
  115112. /**
  115113. * Returns an array with unique values of Materials from the passed array
  115114. * @param array the material array to be checked and filtered
  115115. * @hidden
  115116. */
  115117. private _filterUniqueMaterialId;
  115118. /**
  115119. * Sets a new Standard Material as _defaultMaterial if not already set.
  115120. * @hidden
  115121. */
  115122. private _setDefaultMaterial;
  115123. /**
  115124. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115125. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115126. * @returns the SPS.
  115127. */
  115128. refreshVisibleSize(): SolidParticleSystem;
  115129. /**
  115130. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115131. * @param size the size (float) of the visibility box
  115132. * note : this doesn't lock the SPS mesh bounding box.
  115133. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115134. */
  115135. setVisibilityBox(size: number): void;
  115136. /**
  115137. * Gets whether the SPS as always visible or not
  115138. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115139. */
  115140. get isAlwaysVisible(): boolean;
  115141. /**
  115142. * Sets the SPS as always visible or not
  115143. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115144. */
  115145. set isAlwaysVisible(val: boolean);
  115146. /**
  115147. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115148. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115149. */
  115150. set isVisibilityBoxLocked(val: boolean);
  115151. /**
  115152. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115153. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115154. */
  115155. get isVisibilityBoxLocked(): boolean;
  115156. /**
  115157. * Tells to `setParticles()` to compute the particle rotations or not.
  115158. * Default value : true. The SPS is faster when it's set to false.
  115159. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115160. */
  115161. set computeParticleRotation(val: boolean);
  115162. /**
  115163. * Tells to `setParticles()` to compute the particle colors or not.
  115164. * Default value : true. The SPS is faster when it's set to false.
  115165. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115166. */
  115167. set computeParticleColor(val: boolean);
  115168. set computeParticleTexture(val: boolean);
  115169. /**
  115170. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115171. * Default value : false. The SPS is faster when it's set to false.
  115172. * Note : the particle custom vertex positions aren't stored values.
  115173. */
  115174. set computeParticleVertex(val: boolean);
  115175. /**
  115176. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115177. */
  115178. set computeBoundingBox(val: boolean);
  115179. /**
  115180. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115181. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115182. * Default : `true`
  115183. */
  115184. set depthSortParticles(val: boolean);
  115185. /**
  115186. * Gets if `setParticles()` computes the particle rotations or not.
  115187. * Default value : true. The SPS is faster when it's set to false.
  115188. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115189. */
  115190. get computeParticleRotation(): boolean;
  115191. /**
  115192. * Gets if `setParticles()` computes the particle colors or not.
  115193. * Default value : true. The SPS is faster when it's set to false.
  115194. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115195. */
  115196. get computeParticleColor(): boolean;
  115197. /**
  115198. * Gets if `setParticles()` computes the particle textures or not.
  115199. * Default value : true. The SPS is faster when it's set to false.
  115200. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115201. */
  115202. get computeParticleTexture(): boolean;
  115203. /**
  115204. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115205. * Default value : false. The SPS is faster when it's set to false.
  115206. * Note : the particle custom vertex positions aren't stored values.
  115207. */
  115208. get computeParticleVertex(): boolean;
  115209. /**
  115210. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115211. */
  115212. get computeBoundingBox(): boolean;
  115213. /**
  115214. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115215. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115216. * Default : `true`
  115217. */
  115218. get depthSortParticles(): boolean;
  115219. /**
  115220. * Gets if the SPS is created as expandable at construction time.
  115221. * Default : `false`
  115222. */
  115223. get expandable(): boolean;
  115224. /**
  115225. * Gets if the SPS supports the Multi Materials
  115226. */
  115227. get multimaterialEnabled(): boolean;
  115228. /**
  115229. * Gets if the SPS uses the model materials for its own multimaterial.
  115230. */
  115231. get useModelMaterial(): boolean;
  115232. /**
  115233. * The SPS used material array.
  115234. */
  115235. get materials(): Material[];
  115236. /**
  115237. * Sets the SPS MultiMaterial from the passed materials.
  115238. * Note : the passed array is internally copied and not used then by reference.
  115239. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115240. */
  115241. setMultiMaterial(materials: Material[]): void;
  115242. /**
  115243. * The SPS computed multimaterial object
  115244. */
  115245. get multimaterial(): MultiMaterial;
  115246. set multimaterial(mm: MultiMaterial);
  115247. /**
  115248. * If the subMeshes must be updated on the next call to setParticles()
  115249. */
  115250. get autoUpdateSubMeshes(): boolean;
  115251. set autoUpdateSubMeshes(val: boolean);
  115252. /**
  115253. * This function does nothing. It may be overwritten to set all the particle first values.
  115254. * The SPS doesn't call this function, you may have to call it by your own.
  115255. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115256. */
  115257. initParticles(): void;
  115258. /**
  115259. * This function does nothing. It may be overwritten to recycle a particle.
  115260. * The SPS doesn't call this function, you may have to call it by your own.
  115261. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115262. * @param particle The particle to recycle
  115263. * @returns the recycled particle
  115264. */
  115265. recycleParticle(particle: SolidParticle): SolidParticle;
  115266. /**
  115267. * Updates a particle : this function should be overwritten by the user.
  115268. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115269. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115270. * @example : just set a particle position or velocity and recycle conditions
  115271. * @param particle The particle to update
  115272. * @returns the updated particle
  115273. */
  115274. updateParticle(particle: SolidParticle): SolidParticle;
  115275. /**
  115276. * Updates a vertex of a particle : it can be overwritten by the user.
  115277. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115278. * @param particle the current particle
  115279. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115280. * @param pt the index of the current vertex in the particle shape
  115281. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115282. * @example : just set a vertex particle position or color
  115283. * @returns the sps
  115284. */
  115285. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115286. /**
  115287. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115288. * This does nothing and may be overwritten by the user.
  115289. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115290. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115291. * @param update the boolean update value actually passed to setParticles()
  115292. */
  115293. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115294. /**
  115295. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115296. * This will be passed three parameters.
  115297. * This does nothing and may be overwritten by the user.
  115298. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115299. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115300. * @param update the boolean update value actually passed to setParticles()
  115301. */
  115302. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115303. }
  115304. }
  115305. declare module BABYLON {
  115306. /**
  115307. * Represents one particle of a solid particle system.
  115308. */
  115309. export class SolidParticle {
  115310. /**
  115311. * particle global index
  115312. */
  115313. idx: number;
  115314. /**
  115315. * particle identifier
  115316. */
  115317. id: number;
  115318. /**
  115319. * The color of the particle
  115320. */
  115321. color: Nullable<Color4>;
  115322. /**
  115323. * The world space position of the particle.
  115324. */
  115325. position: Vector3;
  115326. /**
  115327. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115328. */
  115329. rotation: Vector3;
  115330. /**
  115331. * The world space rotation quaternion of the particle.
  115332. */
  115333. rotationQuaternion: Nullable<Quaternion>;
  115334. /**
  115335. * The scaling of the particle.
  115336. */
  115337. scaling: Vector3;
  115338. /**
  115339. * The uvs of the particle.
  115340. */
  115341. uvs: Vector4;
  115342. /**
  115343. * The current speed of the particle.
  115344. */
  115345. velocity: Vector3;
  115346. /**
  115347. * The pivot point in the particle local space.
  115348. */
  115349. pivot: Vector3;
  115350. /**
  115351. * Must the particle be translated from its pivot point in its local space ?
  115352. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115353. * Default : false
  115354. */
  115355. translateFromPivot: boolean;
  115356. /**
  115357. * Is the particle active or not ?
  115358. */
  115359. alive: boolean;
  115360. /**
  115361. * Is the particle visible or not ?
  115362. */
  115363. isVisible: boolean;
  115364. /**
  115365. * Index of this particle in the global "positions" array (Internal use)
  115366. * @hidden
  115367. */
  115368. _pos: number;
  115369. /**
  115370. * @hidden Index of this particle in the global "indices" array (Internal use)
  115371. */
  115372. _ind: number;
  115373. /**
  115374. * @hidden ModelShape of this particle (Internal use)
  115375. */
  115376. _model: ModelShape;
  115377. /**
  115378. * ModelShape id of this particle
  115379. */
  115380. shapeId: number;
  115381. /**
  115382. * Index of the particle in its shape id
  115383. */
  115384. idxInShape: number;
  115385. /**
  115386. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115387. */
  115388. _modelBoundingInfo: BoundingInfo;
  115389. /**
  115390. * @hidden Particle BoundingInfo object (Internal use)
  115391. */
  115392. _boundingInfo: BoundingInfo;
  115393. /**
  115394. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115395. */
  115396. _sps: SolidParticleSystem;
  115397. /**
  115398. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115399. */
  115400. _stillInvisible: boolean;
  115401. /**
  115402. * @hidden Last computed particle rotation matrix
  115403. */
  115404. _rotationMatrix: number[];
  115405. /**
  115406. * Parent particle Id, if any.
  115407. * Default null.
  115408. */
  115409. parentId: Nullable<number>;
  115410. /**
  115411. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115412. */
  115413. materialIndex: Nullable<number>;
  115414. /**
  115415. * Custom object or properties.
  115416. */
  115417. props: Nullable<any>;
  115418. /**
  115419. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115420. * The possible values are :
  115421. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115422. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115423. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115424. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115425. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115426. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115427. * */
  115428. cullingStrategy: number;
  115429. /**
  115430. * @hidden Internal global position in the SPS.
  115431. */
  115432. _globalPosition: Vector3;
  115433. /**
  115434. * Creates a Solid Particle object.
  115435. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115436. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115437. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115438. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115439. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115440. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115441. * @param shapeId (integer) is the model shape identifier in the SPS.
  115442. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115443. * @param sps defines the sps it is associated to
  115444. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115445. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115446. */
  115447. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115448. /**
  115449. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115450. * @param target the particle target
  115451. * @returns the current particle
  115452. */
  115453. copyToRef(target: SolidParticle): SolidParticle;
  115454. /**
  115455. * Legacy support, changed scale to scaling
  115456. */
  115457. get scale(): Vector3;
  115458. /**
  115459. * Legacy support, changed scale to scaling
  115460. */
  115461. set scale(scale: Vector3);
  115462. /**
  115463. * Legacy support, changed quaternion to rotationQuaternion
  115464. */
  115465. get quaternion(): Nullable<Quaternion>;
  115466. /**
  115467. * Legacy support, changed quaternion to rotationQuaternion
  115468. */
  115469. set quaternion(q: Nullable<Quaternion>);
  115470. /**
  115471. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115472. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115473. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115474. * @returns true if it intersects
  115475. */
  115476. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115477. /**
  115478. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115479. * A particle is in the frustum if its bounding box intersects the frustum
  115480. * @param frustumPlanes defines the frustum to test
  115481. * @returns true if the particle is in the frustum planes
  115482. */
  115483. isInFrustum(frustumPlanes: Plane[]): boolean;
  115484. /**
  115485. * get the rotation matrix of the particle
  115486. * @hidden
  115487. */
  115488. getRotationMatrix(m: Matrix): void;
  115489. }
  115490. /**
  115491. * Represents the shape of the model used by one particle of a solid particle system.
  115492. * SPS internal tool, don't use it manually.
  115493. */
  115494. export class ModelShape {
  115495. /**
  115496. * The shape id
  115497. * @hidden
  115498. */
  115499. shapeID: number;
  115500. /**
  115501. * flat array of model positions (internal use)
  115502. * @hidden
  115503. */
  115504. _shape: Vector3[];
  115505. /**
  115506. * flat array of model UVs (internal use)
  115507. * @hidden
  115508. */
  115509. _shapeUV: number[];
  115510. /**
  115511. * color array of the model
  115512. * @hidden
  115513. */
  115514. _shapeColors: number[];
  115515. /**
  115516. * indices array of the model
  115517. * @hidden
  115518. */
  115519. _indices: number[];
  115520. /**
  115521. * normals array of the model
  115522. * @hidden
  115523. */
  115524. _normals: number[];
  115525. /**
  115526. * length of the shape in the model indices array (internal use)
  115527. * @hidden
  115528. */
  115529. _indicesLength: number;
  115530. /**
  115531. * Custom position function (internal use)
  115532. * @hidden
  115533. */
  115534. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115535. /**
  115536. * Custom vertex function (internal use)
  115537. * @hidden
  115538. */
  115539. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115540. /**
  115541. * Model material (internal use)
  115542. * @hidden
  115543. */
  115544. _material: Nullable<Material>;
  115545. /**
  115546. * 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.
  115547. * SPS internal tool, don't use it manually.
  115548. * @hidden
  115549. */
  115550. 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>);
  115551. }
  115552. /**
  115553. * Represents a Depth Sorted Particle in the solid particle system.
  115554. * @hidden
  115555. */
  115556. export class DepthSortedParticle {
  115557. /**
  115558. * Particle index
  115559. */
  115560. idx: number;
  115561. /**
  115562. * Index of the particle in the "indices" array
  115563. */
  115564. ind: number;
  115565. /**
  115566. * Length of the particle shape in the "indices" array
  115567. */
  115568. indicesLength: number;
  115569. /**
  115570. * Squared distance from the particle to the camera
  115571. */
  115572. sqDistance: number;
  115573. /**
  115574. * Material index when used with MultiMaterials
  115575. */
  115576. materialIndex: number;
  115577. /**
  115578. * Creates a new sorted particle
  115579. * @param materialIndex
  115580. */
  115581. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115582. }
  115583. /**
  115584. * Represents a solid particle vertex
  115585. */
  115586. export class SolidParticleVertex {
  115587. /**
  115588. * Vertex position
  115589. */
  115590. position: Vector3;
  115591. /**
  115592. * Vertex color
  115593. */
  115594. color: Color4;
  115595. /**
  115596. * Vertex UV
  115597. */
  115598. uv: Vector2;
  115599. /**
  115600. * Creates a new solid particle vertex
  115601. */
  115602. constructor();
  115603. /** Vertex x coordinate */
  115604. get x(): number;
  115605. set x(val: number);
  115606. /** Vertex y coordinate */
  115607. get y(): number;
  115608. set y(val: number);
  115609. /** Vertex z coordinate */
  115610. get z(): number;
  115611. set z(val: number);
  115612. }
  115613. }
  115614. declare module BABYLON {
  115615. /**
  115616. * @hidden
  115617. */
  115618. export class _MeshCollisionData {
  115619. _checkCollisions: boolean;
  115620. _collisionMask: number;
  115621. _collisionGroup: number;
  115622. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115623. _collider: Nullable<Collider>;
  115624. _oldPositionForCollisions: Vector3;
  115625. _diffPositionForCollisions: Vector3;
  115626. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115627. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115628. _collisionResponse: boolean;
  115629. }
  115630. }
  115631. declare module BABYLON {
  115632. /** @hidden */
  115633. class _FacetDataStorage {
  115634. facetPositions: Vector3[];
  115635. facetNormals: Vector3[];
  115636. facetPartitioning: number[][];
  115637. facetNb: number;
  115638. partitioningSubdivisions: number;
  115639. partitioningBBoxRatio: number;
  115640. facetDataEnabled: boolean;
  115641. facetParameters: any;
  115642. bbSize: Vector3;
  115643. subDiv: {
  115644. max: number;
  115645. X: number;
  115646. Y: number;
  115647. Z: number;
  115648. };
  115649. facetDepthSort: boolean;
  115650. facetDepthSortEnabled: boolean;
  115651. depthSortedIndices: IndicesArray;
  115652. depthSortedFacets: {
  115653. ind: number;
  115654. sqDistance: number;
  115655. }[];
  115656. facetDepthSortFunction: (f1: {
  115657. ind: number;
  115658. sqDistance: number;
  115659. }, f2: {
  115660. ind: number;
  115661. sqDistance: number;
  115662. }) => number;
  115663. facetDepthSortFrom: Vector3;
  115664. facetDepthSortOrigin: Vector3;
  115665. invertedMatrix: Matrix;
  115666. }
  115667. /**
  115668. * @hidden
  115669. **/
  115670. class _InternalAbstractMeshDataInfo {
  115671. _hasVertexAlpha: boolean;
  115672. _useVertexColors: boolean;
  115673. _numBoneInfluencers: number;
  115674. _applyFog: boolean;
  115675. _receiveShadows: boolean;
  115676. _facetData: _FacetDataStorage;
  115677. _visibility: number;
  115678. _skeleton: Nullable<Skeleton>;
  115679. _layerMask: number;
  115680. _computeBonesUsingShaders: boolean;
  115681. _isActive: boolean;
  115682. _onlyForInstances: boolean;
  115683. _isActiveIntermediate: boolean;
  115684. _onlyForInstancesIntermediate: boolean;
  115685. _actAsRegularMesh: boolean;
  115686. }
  115687. /**
  115688. * Class used to store all common mesh properties
  115689. */
  115690. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115691. /** No occlusion */
  115692. static OCCLUSION_TYPE_NONE: number;
  115693. /** Occlusion set to optimisitic */
  115694. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115695. /** Occlusion set to strict */
  115696. static OCCLUSION_TYPE_STRICT: number;
  115697. /** Use an accurante occlusion algorithm */
  115698. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115699. /** Use a conservative occlusion algorithm */
  115700. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115701. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115702. * Test order :
  115703. * Is the bounding sphere outside the frustum ?
  115704. * If not, are the bounding box vertices outside the frustum ?
  115705. * It not, then the cullable object is in the frustum.
  115706. */
  115707. static readonly CULLINGSTRATEGY_STANDARD: number;
  115708. /** Culling strategy : Bounding Sphere Only.
  115709. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115710. * It's also less accurate than the standard because some not visible objects can still be selected.
  115711. * Test : is the bounding sphere outside the frustum ?
  115712. * If not, then the cullable object is in the frustum.
  115713. */
  115714. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115715. /** Culling strategy : Optimistic Inclusion.
  115716. * This in an inclusion test first, then the standard exclusion test.
  115717. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115718. * 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.
  115719. * Anyway, it's as accurate as the standard strategy.
  115720. * Test :
  115721. * Is the cullable object bounding sphere center in the frustum ?
  115722. * If not, apply the default culling strategy.
  115723. */
  115724. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  115725. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  115726. * This in an inclusion test first, then the bounding sphere only exclusion test.
  115727. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  115728. * 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.
  115729. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  115730. * Test :
  115731. * Is the cullable object bounding sphere center in the frustum ?
  115732. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  115733. */
  115734. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  115735. /**
  115736. * No billboard
  115737. */
  115738. static get BILLBOARDMODE_NONE(): number;
  115739. /** Billboard on X axis */
  115740. static get BILLBOARDMODE_X(): number;
  115741. /** Billboard on Y axis */
  115742. static get BILLBOARDMODE_Y(): number;
  115743. /** Billboard on Z axis */
  115744. static get BILLBOARDMODE_Z(): number;
  115745. /** Billboard on all axes */
  115746. static get BILLBOARDMODE_ALL(): number;
  115747. /** Billboard on using position instead of orientation */
  115748. static get BILLBOARDMODE_USE_POSITION(): number;
  115749. /** @hidden */
  115750. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  115751. /**
  115752. * The culling strategy to use to check whether the mesh must be rendered or not.
  115753. * This value can be changed at any time and will be used on the next render mesh selection.
  115754. * The possible values are :
  115755. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115756. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115758. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115759. * Please read each static variable documentation to get details about the culling process.
  115760. * */
  115761. cullingStrategy: number;
  115762. /**
  115763. * Gets the number of facets in the mesh
  115764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115765. */
  115766. get facetNb(): number;
  115767. /**
  115768. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  115769. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115770. */
  115771. get partitioningSubdivisions(): number;
  115772. set partitioningSubdivisions(nb: number);
  115773. /**
  115774. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  115775. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  115776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115777. */
  115778. get partitioningBBoxRatio(): number;
  115779. set partitioningBBoxRatio(ratio: number);
  115780. /**
  115781. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  115782. * Works only for updatable meshes.
  115783. * Doesn't work with multi-materials
  115784. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115785. */
  115786. get mustDepthSortFacets(): boolean;
  115787. set mustDepthSortFacets(sort: boolean);
  115788. /**
  115789. * The location (Vector3) where the facet depth sort must be computed from.
  115790. * By default, the active camera position.
  115791. * Used only when facet depth sort is enabled
  115792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115793. */
  115794. get facetDepthSortFrom(): Vector3;
  115795. set facetDepthSortFrom(location: Vector3);
  115796. /**
  115797. * gets a boolean indicating if facetData is enabled
  115798. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115799. */
  115800. get isFacetDataEnabled(): boolean;
  115801. /** @hidden */
  115802. _updateNonUniformScalingState(value: boolean): boolean;
  115803. /**
  115804. * An event triggered when this mesh collides with another one
  115805. */
  115806. onCollideObservable: Observable<AbstractMesh>;
  115807. /** Set a function to call when this mesh collides with another one */
  115808. set onCollide(callback: () => void);
  115809. /**
  115810. * An event triggered when the collision's position changes
  115811. */
  115812. onCollisionPositionChangeObservable: Observable<Vector3>;
  115813. /** Set a function to call when the collision's position changes */
  115814. set onCollisionPositionChange(callback: () => void);
  115815. /**
  115816. * An event triggered when material is changed
  115817. */
  115818. onMaterialChangedObservable: Observable<AbstractMesh>;
  115819. /**
  115820. * Gets or sets the orientation for POV movement & rotation
  115821. */
  115822. definedFacingForward: boolean;
  115823. /** @hidden */
  115824. _occlusionQuery: Nullable<WebGLQuery>;
  115825. /** @hidden */
  115826. _renderingGroup: Nullable<RenderingGroup>;
  115827. /**
  115828. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115829. */
  115830. get visibility(): number;
  115831. /**
  115832. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115833. */
  115834. set visibility(value: number);
  115835. /** Gets or sets the alpha index used to sort transparent meshes
  115836. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  115837. */
  115838. alphaIndex: number;
  115839. /**
  115840. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  115841. */
  115842. isVisible: boolean;
  115843. /**
  115844. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  115845. */
  115846. isPickable: boolean;
  115847. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  115848. showSubMeshesBoundingBox: boolean;
  115849. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  115850. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115851. */
  115852. isBlocker: boolean;
  115853. /**
  115854. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  115855. */
  115856. enablePointerMoveEvents: boolean;
  115857. private _renderingGroupId;
  115858. /**
  115859. * Specifies the rendering group id for this mesh (0 by default)
  115860. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  115861. */
  115862. get renderingGroupId(): number;
  115863. set renderingGroupId(value: number);
  115864. private _material;
  115865. /** Gets or sets current material */
  115866. get material(): Nullable<Material>;
  115867. set material(value: Nullable<Material>);
  115868. /**
  115869. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  115870. * @see https://doc.babylonjs.com/babylon101/shadows
  115871. */
  115872. get receiveShadows(): boolean;
  115873. set receiveShadows(value: boolean);
  115874. /** Defines color to use when rendering outline */
  115875. outlineColor: Color3;
  115876. /** Define width to use when rendering outline */
  115877. outlineWidth: number;
  115878. /** Defines color to use when rendering overlay */
  115879. overlayColor: Color3;
  115880. /** Defines alpha to use when rendering overlay */
  115881. overlayAlpha: number;
  115882. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  115883. get hasVertexAlpha(): boolean;
  115884. set hasVertexAlpha(value: boolean);
  115885. /** 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) */
  115886. get useVertexColors(): boolean;
  115887. set useVertexColors(value: boolean);
  115888. /**
  115889. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  115890. */
  115891. get computeBonesUsingShaders(): boolean;
  115892. set computeBonesUsingShaders(value: boolean);
  115893. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  115894. get numBoneInfluencers(): number;
  115895. set numBoneInfluencers(value: number);
  115896. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  115897. get applyFog(): boolean;
  115898. set applyFog(value: boolean);
  115899. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  115900. useOctreeForRenderingSelection: boolean;
  115901. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  115902. useOctreeForPicking: boolean;
  115903. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  115904. useOctreeForCollisions: boolean;
  115905. /**
  115906. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  115907. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  115908. */
  115909. get layerMask(): number;
  115910. set layerMask(value: number);
  115911. /**
  115912. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  115913. */
  115914. alwaysSelectAsActiveMesh: boolean;
  115915. /**
  115916. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  115917. */
  115918. doNotSyncBoundingInfo: boolean;
  115919. /**
  115920. * Gets or sets the current action manager
  115921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  115922. */
  115923. actionManager: Nullable<AbstractActionManager>;
  115924. private _meshCollisionData;
  115925. /**
  115926. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  115927. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115928. */
  115929. ellipsoid: Vector3;
  115930. /**
  115931. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  115932. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115933. */
  115934. ellipsoidOffset: Vector3;
  115935. /**
  115936. * Gets or sets a collision mask used to mask collisions (default is -1).
  115937. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  115938. */
  115939. get collisionMask(): number;
  115940. set collisionMask(mask: number);
  115941. /**
  115942. * Gets or sets a collision response flag (default is true).
  115943. * when collisionResponse is false, events are still triggered but colliding entity has no response
  115944. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  115945. * to respond to the collision.
  115946. */
  115947. get collisionResponse(): boolean;
  115948. set collisionResponse(response: boolean);
  115949. /**
  115950. * Gets or sets the current collision group mask (-1 by default).
  115951. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  115952. */
  115953. get collisionGroup(): number;
  115954. set collisionGroup(mask: number);
  115955. /**
  115956. * Gets or sets current surrounding meshes (null by default).
  115957. *
  115958. * By default collision detection is tested against every mesh in the scene.
  115959. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  115960. * meshes will be tested for the collision.
  115961. *
  115962. * Note: if set to an empty array no collision will happen when this mesh is moved.
  115963. */
  115964. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  115965. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  115966. /**
  115967. * Defines edge width used when edgesRenderer is enabled
  115968. * @see https://www.babylonjs-playground.com/#10OJSG#13
  115969. */
  115970. edgesWidth: number;
  115971. /**
  115972. * Defines edge color used when edgesRenderer is enabled
  115973. * @see https://www.babylonjs-playground.com/#10OJSG#13
  115974. */
  115975. edgesColor: Color4;
  115976. /** @hidden */
  115977. _edgesRenderer: Nullable<IEdgesRenderer>;
  115978. /** @hidden */
  115979. _masterMesh: Nullable<AbstractMesh>;
  115980. /** @hidden */
  115981. _boundingInfo: Nullable<BoundingInfo>;
  115982. /** @hidden */
  115983. _renderId: number;
  115984. /**
  115985. * Gets or sets the list of subMeshes
  115986. * @see https://doc.babylonjs.com/how_to/multi_materials
  115987. */
  115988. subMeshes: SubMesh[];
  115989. /** @hidden */
  115990. _intersectionsInProgress: AbstractMesh[];
  115991. /** @hidden */
  115992. _unIndexed: boolean;
  115993. /** @hidden */
  115994. _lightSources: Light[];
  115995. /** Gets the list of lights affecting that mesh */
  115996. get lightSources(): Light[];
  115997. /** @hidden */
  115998. get _positions(): Nullable<Vector3[]>;
  115999. /** @hidden */
  116000. _waitingData: {
  116001. lods: Nullable<any>;
  116002. actions: Nullable<any>;
  116003. freezeWorldMatrix: Nullable<boolean>;
  116004. };
  116005. /** @hidden */
  116006. _bonesTransformMatrices: Nullable<Float32Array>;
  116007. /** @hidden */
  116008. _transformMatrixTexture: Nullable<RawTexture>;
  116009. /**
  116010. * Gets or sets a skeleton to apply skining transformations
  116011. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116012. */
  116013. set skeleton(value: Nullable<Skeleton>);
  116014. get skeleton(): Nullable<Skeleton>;
  116015. /**
  116016. * An event triggered when the mesh is rebuilt.
  116017. */
  116018. onRebuildObservable: Observable<AbstractMesh>;
  116019. /**
  116020. * Creates a new AbstractMesh
  116021. * @param name defines the name of the mesh
  116022. * @param scene defines the hosting scene
  116023. */
  116024. constructor(name: string, scene?: Nullable<Scene>);
  116025. /**
  116026. * Returns the string "AbstractMesh"
  116027. * @returns "AbstractMesh"
  116028. */
  116029. getClassName(): string;
  116030. /**
  116031. * Gets a string representation of the current mesh
  116032. * @param fullDetails defines a boolean indicating if full details must be included
  116033. * @returns a string representation of the current mesh
  116034. */
  116035. toString(fullDetails?: boolean): string;
  116036. /**
  116037. * @hidden
  116038. */
  116039. protected _getEffectiveParent(): Nullable<Node>;
  116040. /** @hidden */
  116041. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116042. /** @hidden */
  116043. _rebuild(): void;
  116044. /** @hidden */
  116045. _resyncLightSources(): void;
  116046. /** @hidden */
  116047. _resyncLightSource(light: Light): void;
  116048. /** @hidden */
  116049. _unBindEffect(): void;
  116050. /** @hidden */
  116051. _removeLightSource(light: Light, dispose: boolean): void;
  116052. private _markSubMeshesAsDirty;
  116053. /** @hidden */
  116054. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116055. /** @hidden */
  116056. _markSubMeshesAsAttributesDirty(): void;
  116057. /** @hidden */
  116058. _markSubMeshesAsMiscDirty(): void;
  116059. /**
  116060. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116061. */
  116062. get scaling(): Vector3;
  116063. set scaling(newScaling: Vector3);
  116064. /**
  116065. * Returns true if the mesh is blocked. Implemented by child classes
  116066. */
  116067. get isBlocked(): boolean;
  116068. /**
  116069. * Returns the mesh itself by default. Implemented by child classes
  116070. * @param camera defines the camera to use to pick the right LOD level
  116071. * @returns the currentAbstractMesh
  116072. */
  116073. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116074. /**
  116075. * Returns 0 by default. Implemented by child classes
  116076. * @returns an integer
  116077. */
  116078. getTotalVertices(): number;
  116079. /**
  116080. * Returns a positive integer : the total number of indices in this mesh geometry.
  116081. * @returns the numner of indices or zero if the mesh has no geometry.
  116082. */
  116083. getTotalIndices(): number;
  116084. /**
  116085. * Returns null by default. Implemented by child classes
  116086. * @returns null
  116087. */
  116088. getIndices(): Nullable<IndicesArray>;
  116089. /**
  116090. * Returns the array of the requested vertex data kind. Implemented by child classes
  116091. * @param kind defines the vertex data kind to use
  116092. * @returns null
  116093. */
  116094. getVerticesData(kind: string): Nullable<FloatArray>;
  116095. /**
  116096. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116097. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116098. * Note that a new underlying VertexBuffer object is created each call.
  116099. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116100. * @param kind defines vertex data kind:
  116101. * * VertexBuffer.PositionKind
  116102. * * VertexBuffer.UVKind
  116103. * * VertexBuffer.UV2Kind
  116104. * * VertexBuffer.UV3Kind
  116105. * * VertexBuffer.UV4Kind
  116106. * * VertexBuffer.UV5Kind
  116107. * * VertexBuffer.UV6Kind
  116108. * * VertexBuffer.ColorKind
  116109. * * VertexBuffer.MatricesIndicesKind
  116110. * * VertexBuffer.MatricesIndicesExtraKind
  116111. * * VertexBuffer.MatricesWeightsKind
  116112. * * VertexBuffer.MatricesWeightsExtraKind
  116113. * @param data defines the data source
  116114. * @param updatable defines if the data must be flagged as updatable (or static)
  116115. * @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
  116116. * @returns the current mesh
  116117. */
  116118. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116119. /**
  116120. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116121. * If the mesh has no geometry, it is simply returned as it is.
  116122. * @param kind defines vertex data kind:
  116123. * * VertexBuffer.PositionKind
  116124. * * VertexBuffer.UVKind
  116125. * * VertexBuffer.UV2Kind
  116126. * * VertexBuffer.UV3Kind
  116127. * * VertexBuffer.UV4Kind
  116128. * * VertexBuffer.UV5Kind
  116129. * * VertexBuffer.UV6Kind
  116130. * * VertexBuffer.ColorKind
  116131. * * VertexBuffer.MatricesIndicesKind
  116132. * * VertexBuffer.MatricesIndicesExtraKind
  116133. * * VertexBuffer.MatricesWeightsKind
  116134. * * VertexBuffer.MatricesWeightsExtraKind
  116135. * @param data defines the data source
  116136. * @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
  116137. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116138. * @returns the current mesh
  116139. */
  116140. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116141. /**
  116142. * Sets the mesh indices,
  116143. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116144. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116145. * @param totalVertices Defines the total number of vertices
  116146. * @returns the current mesh
  116147. */
  116148. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116149. /**
  116150. * Gets a boolean indicating if specific vertex data is present
  116151. * @param kind defines the vertex data kind to use
  116152. * @returns true is data kind is present
  116153. */
  116154. isVerticesDataPresent(kind: string): boolean;
  116155. /**
  116156. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116157. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116158. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116159. * @returns a BoundingInfo
  116160. */
  116161. getBoundingInfo(): BoundingInfo;
  116162. /**
  116163. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116164. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116165. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116166. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116167. * @returns the current mesh
  116168. */
  116169. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116170. /**
  116171. * Overwrite the current bounding info
  116172. * @param boundingInfo defines the new bounding info
  116173. * @returns the current mesh
  116174. */
  116175. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116176. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116177. get useBones(): boolean;
  116178. /** @hidden */
  116179. _preActivate(): void;
  116180. /** @hidden */
  116181. _preActivateForIntermediateRendering(renderId: number): void;
  116182. /** @hidden */
  116183. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116184. /** @hidden */
  116185. _postActivate(): void;
  116186. /** @hidden */
  116187. _freeze(): void;
  116188. /** @hidden */
  116189. _unFreeze(): void;
  116190. /**
  116191. * Gets the current world matrix
  116192. * @returns a Matrix
  116193. */
  116194. getWorldMatrix(): Matrix;
  116195. /** @hidden */
  116196. _getWorldMatrixDeterminant(): number;
  116197. /**
  116198. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116199. */
  116200. get isAnInstance(): boolean;
  116201. /**
  116202. * Gets a boolean indicating if this mesh has instances
  116203. */
  116204. get hasInstances(): boolean;
  116205. /**
  116206. * Gets a boolean indicating if this mesh has thin instances
  116207. */
  116208. get hasThinInstances(): boolean;
  116209. /**
  116210. * Perform relative position change from the point of view of behind the front of the mesh.
  116211. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116212. * Supports definition of mesh facing forward or backward
  116213. * @param amountRight defines the distance on the right axis
  116214. * @param amountUp defines the distance on the up axis
  116215. * @param amountForward defines the distance on the forward axis
  116216. * @returns the current mesh
  116217. */
  116218. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116219. /**
  116220. * Calculate relative position change from the point of view of behind the front of the mesh.
  116221. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116222. * Supports definition of mesh facing forward or backward
  116223. * @param amountRight defines the distance on the right axis
  116224. * @param amountUp defines the distance on the up axis
  116225. * @param amountForward defines the distance on the forward axis
  116226. * @returns the new displacement vector
  116227. */
  116228. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116229. /**
  116230. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116231. * Supports definition of mesh facing forward or backward
  116232. * @param flipBack defines the flip
  116233. * @param twirlClockwise defines the twirl
  116234. * @param tiltRight defines the tilt
  116235. * @returns the current mesh
  116236. */
  116237. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116238. /**
  116239. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116240. * Supports definition of mesh facing forward or backward.
  116241. * @param flipBack defines the flip
  116242. * @param twirlClockwise defines the twirl
  116243. * @param tiltRight defines the tilt
  116244. * @returns the new rotation vector
  116245. */
  116246. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116247. /**
  116248. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116249. * This means the mesh underlying bounding box and sphere are recomputed.
  116250. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116251. * @returns the current mesh
  116252. */
  116253. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116254. /** @hidden */
  116255. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116256. /** @hidden */
  116257. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116258. /** @hidden */
  116259. _updateBoundingInfo(): AbstractMesh;
  116260. /** @hidden */
  116261. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116262. /** @hidden */
  116263. protected _afterComputeWorldMatrix(): void;
  116264. /** @hidden */
  116265. get _effectiveMesh(): AbstractMesh;
  116266. /**
  116267. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116268. * A mesh is in the frustum if its bounding box intersects the frustum
  116269. * @param frustumPlanes defines the frustum to test
  116270. * @returns true if the mesh is in the frustum planes
  116271. */
  116272. isInFrustum(frustumPlanes: Plane[]): boolean;
  116273. /**
  116274. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116275. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116276. * @param frustumPlanes defines the frustum to test
  116277. * @returns true if the mesh is completely in the frustum planes
  116278. */
  116279. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116280. /**
  116281. * True if the mesh intersects another mesh or a SolidParticle object
  116282. * @param mesh defines a target mesh or SolidParticle to test
  116283. * @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)
  116284. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116285. * @returns true if there is an intersection
  116286. */
  116287. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116288. /**
  116289. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116290. * @param point defines the point to test
  116291. * @returns true if there is an intersection
  116292. */
  116293. intersectsPoint(point: Vector3): boolean;
  116294. /**
  116295. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116296. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116297. */
  116298. get checkCollisions(): boolean;
  116299. set checkCollisions(collisionEnabled: boolean);
  116300. /**
  116301. * Gets Collider object used to compute collisions (not physics)
  116302. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116303. */
  116304. get collider(): Nullable<Collider>;
  116305. /**
  116306. * Move the mesh using collision engine
  116307. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116308. * @param displacement defines the requested displacement vector
  116309. * @returns the current mesh
  116310. */
  116311. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116312. private _onCollisionPositionChange;
  116313. /** @hidden */
  116314. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116315. /** @hidden */
  116316. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116317. /** @hidden */
  116318. _checkCollision(collider: Collider): AbstractMesh;
  116319. /** @hidden */
  116320. _generatePointsArray(): boolean;
  116321. /**
  116322. * Checks if the passed Ray intersects with the mesh
  116323. * @param ray defines the ray to use
  116324. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116326. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116327. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116328. * @returns the picking info
  116329. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116330. */
  116331. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116332. /**
  116333. * Clones the current mesh
  116334. * @param name defines the mesh name
  116335. * @param newParent defines the new mesh parent
  116336. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116337. * @returns the new mesh
  116338. */
  116339. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116340. /**
  116341. * Disposes all the submeshes of the current meshnp
  116342. * @returns the current mesh
  116343. */
  116344. releaseSubMeshes(): AbstractMesh;
  116345. /**
  116346. * Releases resources associated with this abstract mesh.
  116347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116349. */
  116350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116351. /**
  116352. * Adds the passed mesh as a child to the current mesh
  116353. * @param mesh defines the child mesh
  116354. * @returns the current mesh
  116355. */
  116356. addChild(mesh: AbstractMesh): AbstractMesh;
  116357. /**
  116358. * Removes the passed mesh from the current mesh children list
  116359. * @param mesh defines the child mesh
  116360. * @returns the current mesh
  116361. */
  116362. removeChild(mesh: AbstractMesh): AbstractMesh;
  116363. /** @hidden */
  116364. private _initFacetData;
  116365. /**
  116366. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116367. * This method can be called within the render loop.
  116368. * 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
  116369. * @returns the current mesh
  116370. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116371. */
  116372. updateFacetData(): AbstractMesh;
  116373. /**
  116374. * Returns the facetLocalNormals array.
  116375. * The normals are expressed in the mesh local spac
  116376. * @returns an array of Vector3
  116377. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116378. */
  116379. getFacetLocalNormals(): Vector3[];
  116380. /**
  116381. * Returns the facetLocalPositions array.
  116382. * The facet positions are expressed in the mesh local space
  116383. * @returns an array of Vector3
  116384. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116385. */
  116386. getFacetLocalPositions(): Vector3[];
  116387. /**
  116388. * Returns the facetLocalPartioning array
  116389. * @returns an array of array of numbers
  116390. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116391. */
  116392. getFacetLocalPartitioning(): number[][];
  116393. /**
  116394. * Returns the i-th facet position in the world system.
  116395. * This method allocates a new Vector3 per call
  116396. * @param i defines the facet index
  116397. * @returns a new Vector3
  116398. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116399. */
  116400. getFacetPosition(i: number): Vector3;
  116401. /**
  116402. * Sets the reference Vector3 with the i-th facet position in the world system
  116403. * @param i defines the facet index
  116404. * @param ref defines the target vector
  116405. * @returns the current mesh
  116406. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116407. */
  116408. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116409. /**
  116410. * Returns the i-th facet normal in the world system.
  116411. * This method allocates a new Vector3 per call
  116412. * @param i defines the facet index
  116413. * @returns a new Vector3
  116414. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116415. */
  116416. getFacetNormal(i: number): Vector3;
  116417. /**
  116418. * Sets the reference Vector3 with the i-th facet normal in the world system
  116419. * @param i defines the facet index
  116420. * @param ref defines the target vector
  116421. * @returns the current mesh
  116422. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116423. */
  116424. getFacetNormalToRef(i: number, ref: Vector3): this;
  116425. /**
  116426. * 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)
  116427. * @param x defines x coordinate
  116428. * @param y defines y coordinate
  116429. * @param z defines z coordinate
  116430. * @returns the array of facet indexes
  116431. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116432. */
  116433. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116434. /**
  116435. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116436. * @param projected sets as the (x,y,z) world projection on the facet
  116437. * @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
  116438. * @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
  116439. * @param x defines x coordinate
  116440. * @param y defines y coordinate
  116441. * @param z defines z coordinate
  116442. * @returns the face index if found (or null instead)
  116443. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116444. */
  116445. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116446. /**
  116447. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116448. * @param projected sets as the (x,y,z) local projection on the facet
  116449. * @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
  116450. * @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
  116451. * @param x defines x coordinate
  116452. * @param y defines y coordinate
  116453. * @param z defines z coordinate
  116454. * @returns the face index if found (or null instead)
  116455. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116456. */
  116457. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116458. /**
  116459. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116460. * @returns the parameters
  116461. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116462. */
  116463. getFacetDataParameters(): any;
  116464. /**
  116465. * Disables the feature FacetData and frees the related memory
  116466. * @returns the current mesh
  116467. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116468. */
  116469. disableFacetData(): AbstractMesh;
  116470. /**
  116471. * Updates the AbstractMesh indices array
  116472. * @param indices defines the data source
  116473. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116474. * @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)
  116475. * @returns the current mesh
  116476. */
  116477. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116478. /**
  116479. * Creates new normals data for the mesh
  116480. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116481. * @returns the current mesh
  116482. */
  116483. createNormals(updatable: boolean): AbstractMesh;
  116484. /**
  116485. * Align the mesh with a normal
  116486. * @param normal defines the normal to use
  116487. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116488. * @returns the current mesh
  116489. */
  116490. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116491. /** @hidden */
  116492. _checkOcclusionQuery(): boolean;
  116493. /**
  116494. * Disables the mesh edge rendering mode
  116495. * @returns the currentAbstractMesh
  116496. */
  116497. disableEdgesRendering(): AbstractMesh;
  116498. /**
  116499. * Enables the edge rendering mode on the mesh.
  116500. * This mode makes the mesh edges visible
  116501. * @param epsilon defines the maximal distance between two angles to detect a face
  116502. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116503. * @returns the currentAbstractMesh
  116504. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116505. */
  116506. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116507. /**
  116508. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116509. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116510. */
  116511. getConnectedParticleSystems(): IParticleSystem[];
  116512. }
  116513. }
  116514. declare module BABYLON {
  116515. /**
  116516. * Interface used to define ActionEvent
  116517. */
  116518. export interface IActionEvent {
  116519. /** The mesh or sprite that triggered the action */
  116520. source: any;
  116521. /** The X mouse cursor position at the time of the event */
  116522. pointerX: number;
  116523. /** The Y mouse cursor position at the time of the event */
  116524. pointerY: number;
  116525. /** The mesh that is currently pointed at (can be null) */
  116526. meshUnderPointer: Nullable<AbstractMesh>;
  116527. /** the original (browser) event that triggered the ActionEvent */
  116528. sourceEvent?: any;
  116529. /** additional data for the event */
  116530. additionalData?: any;
  116531. }
  116532. /**
  116533. * ActionEvent is the event being sent when an action is triggered.
  116534. */
  116535. export class ActionEvent implements IActionEvent {
  116536. /** The mesh or sprite that triggered the action */
  116537. source: any;
  116538. /** The X mouse cursor position at the time of the event */
  116539. pointerX: number;
  116540. /** The Y mouse cursor position at the time of the event */
  116541. pointerY: number;
  116542. /** The mesh that is currently pointed at (can be null) */
  116543. meshUnderPointer: Nullable<AbstractMesh>;
  116544. /** the original (browser) event that triggered the ActionEvent */
  116545. sourceEvent?: any;
  116546. /** additional data for the event */
  116547. additionalData?: any;
  116548. /**
  116549. * Creates a new ActionEvent
  116550. * @param source The mesh or sprite that triggered the action
  116551. * @param pointerX The X mouse cursor position at the time of the event
  116552. * @param pointerY The Y mouse cursor position at the time of the event
  116553. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116554. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116555. * @param additionalData additional data for the event
  116556. */
  116557. constructor(
  116558. /** The mesh or sprite that triggered the action */
  116559. source: any,
  116560. /** The X mouse cursor position at the time of the event */
  116561. pointerX: number,
  116562. /** The Y mouse cursor position at the time of the event */
  116563. pointerY: number,
  116564. /** The mesh that is currently pointed at (can be null) */
  116565. meshUnderPointer: Nullable<AbstractMesh>,
  116566. /** the original (browser) event that triggered the ActionEvent */
  116567. sourceEvent?: any,
  116568. /** additional data for the event */
  116569. additionalData?: any);
  116570. /**
  116571. * Helper function to auto-create an ActionEvent from a source mesh.
  116572. * @param source The source mesh that triggered the event
  116573. * @param evt The original (browser) event
  116574. * @param additionalData additional data for the event
  116575. * @returns the new ActionEvent
  116576. */
  116577. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116578. /**
  116579. * Helper function to auto-create an ActionEvent from a source sprite
  116580. * @param source The source sprite that triggered the event
  116581. * @param scene Scene associated with the sprite
  116582. * @param evt The original (browser) event
  116583. * @param additionalData additional data for the event
  116584. * @returns the new ActionEvent
  116585. */
  116586. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116587. /**
  116588. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116589. * @param scene the scene where the event occurred
  116590. * @param evt The original (browser) event
  116591. * @returns the new ActionEvent
  116592. */
  116593. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116594. /**
  116595. * Helper function to auto-create an ActionEvent from a primitive
  116596. * @param prim defines the target primitive
  116597. * @param pointerPos defines the pointer position
  116598. * @param evt The original (browser) event
  116599. * @param additionalData additional data for the event
  116600. * @returns the new ActionEvent
  116601. */
  116602. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116603. }
  116604. }
  116605. declare module BABYLON {
  116606. /**
  116607. * Abstract class used to decouple action Manager from scene and meshes.
  116608. * Do not instantiate.
  116609. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116610. */
  116611. export abstract class AbstractActionManager implements IDisposable {
  116612. /** Gets the list of active triggers */
  116613. static Triggers: {
  116614. [key: string]: number;
  116615. };
  116616. /** Gets the cursor to use when hovering items */
  116617. hoverCursor: string;
  116618. /** Gets the list of actions */
  116619. actions: IAction[];
  116620. /**
  116621. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116622. */
  116623. isRecursive: boolean;
  116624. /**
  116625. * Releases all associated resources
  116626. */
  116627. abstract dispose(): void;
  116628. /**
  116629. * Does this action manager has pointer triggers
  116630. */
  116631. abstract get hasPointerTriggers(): boolean;
  116632. /**
  116633. * Does this action manager has pick triggers
  116634. */
  116635. abstract get hasPickTriggers(): boolean;
  116636. /**
  116637. * Process a specific trigger
  116638. * @param trigger defines the trigger to process
  116639. * @param evt defines the event details to be processed
  116640. */
  116641. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116642. /**
  116643. * Does this action manager handles actions of any of the given triggers
  116644. * @param triggers defines the triggers to be tested
  116645. * @return a boolean indicating whether one (or more) of the triggers is handled
  116646. */
  116647. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116648. /**
  116649. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116650. * speed.
  116651. * @param triggerA defines the trigger to be tested
  116652. * @param triggerB defines the trigger to be tested
  116653. * @return a boolean indicating whether one (or more) of the triggers is handled
  116654. */
  116655. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116656. /**
  116657. * Does this action manager handles actions of a given trigger
  116658. * @param trigger defines the trigger to be tested
  116659. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116660. * @return whether the trigger is handled
  116661. */
  116662. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116663. /**
  116664. * Serialize this manager to a JSON object
  116665. * @param name defines the property name to store this manager
  116666. * @returns a JSON representation of this manager
  116667. */
  116668. abstract serialize(name: string): any;
  116669. /**
  116670. * Registers an action to this action manager
  116671. * @param action defines the action to be registered
  116672. * @return the action amended (prepared) after registration
  116673. */
  116674. abstract registerAction(action: IAction): Nullable<IAction>;
  116675. /**
  116676. * Unregisters an action to this action manager
  116677. * @param action defines the action to be unregistered
  116678. * @return a boolean indicating whether the action has been unregistered
  116679. */
  116680. abstract unregisterAction(action: IAction): Boolean;
  116681. /**
  116682. * Does exist one action manager with at least one trigger
  116683. **/
  116684. static get HasTriggers(): boolean;
  116685. /**
  116686. * Does exist one action manager with at least one pick trigger
  116687. **/
  116688. static get HasPickTriggers(): boolean;
  116689. /**
  116690. * Does exist one action manager that handles actions of a given trigger
  116691. * @param trigger defines the trigger to be tested
  116692. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116693. **/
  116694. static HasSpecificTrigger(trigger: number): boolean;
  116695. }
  116696. }
  116697. declare module BABYLON {
  116698. /**
  116699. * Defines how a node can be built from a string name.
  116700. */
  116701. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116702. /**
  116703. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116704. */
  116705. export class Node implements IBehaviorAware<Node> {
  116706. /** @hidden */
  116707. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116708. private static _NodeConstructors;
  116709. /**
  116710. * Add a new node constructor
  116711. * @param type defines the type name of the node to construct
  116712. * @param constructorFunc defines the constructor function
  116713. */
  116714. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116715. /**
  116716. * Returns a node constructor based on type name
  116717. * @param type defines the type name
  116718. * @param name defines the new node name
  116719. * @param scene defines the hosting scene
  116720. * @param options defines optional options to transmit to constructors
  116721. * @returns the new constructor or null
  116722. */
  116723. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  116724. /**
  116725. * Gets or sets the name of the node
  116726. */
  116727. name: string;
  116728. /**
  116729. * Gets or sets the id of the node
  116730. */
  116731. id: string;
  116732. /**
  116733. * Gets or sets the unique id of the node
  116734. */
  116735. uniqueId: number;
  116736. /**
  116737. * Gets or sets a string used to store user defined state for the node
  116738. */
  116739. state: string;
  116740. /**
  116741. * Gets or sets an object used to store user defined information for the node
  116742. */
  116743. metadata: any;
  116744. /**
  116745. * For internal use only. Please do not use.
  116746. */
  116747. reservedDataStore: any;
  116748. /**
  116749. * List of inspectable custom properties (used by the Inspector)
  116750. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  116751. */
  116752. inspectableCustomProperties: IInspectable[];
  116753. private _doNotSerialize;
  116754. /**
  116755. * Gets or sets a boolean used to define if the node must be serialized
  116756. */
  116757. get doNotSerialize(): boolean;
  116758. set doNotSerialize(value: boolean);
  116759. /** @hidden */
  116760. _isDisposed: boolean;
  116761. /**
  116762. * Gets a list of Animations associated with the node
  116763. */
  116764. animations: Animation[];
  116765. protected _ranges: {
  116766. [name: string]: Nullable<AnimationRange>;
  116767. };
  116768. /**
  116769. * Callback raised when the node is ready to be used
  116770. */
  116771. onReady: Nullable<(node: Node) => void>;
  116772. private _isEnabled;
  116773. private _isParentEnabled;
  116774. private _isReady;
  116775. /** @hidden */
  116776. _currentRenderId: number;
  116777. private _parentUpdateId;
  116778. /** @hidden */
  116779. _childUpdateId: number;
  116780. /** @hidden */
  116781. _waitingParentId: Nullable<string>;
  116782. /** @hidden */
  116783. _scene: Scene;
  116784. /** @hidden */
  116785. _cache: any;
  116786. private _parentNode;
  116787. private _children;
  116788. /** @hidden */
  116789. _worldMatrix: Matrix;
  116790. /** @hidden */
  116791. _worldMatrixDeterminant: number;
  116792. /** @hidden */
  116793. _worldMatrixDeterminantIsDirty: boolean;
  116794. /** @hidden */
  116795. private _sceneRootNodesIndex;
  116796. /**
  116797. * Gets a boolean indicating if the node has been disposed
  116798. * @returns true if the node was disposed
  116799. */
  116800. isDisposed(): boolean;
  116801. /**
  116802. * Gets or sets the parent of the node (without keeping the current position in the scene)
  116803. * @see https://doc.babylonjs.com/how_to/parenting
  116804. */
  116805. set parent(parent: Nullable<Node>);
  116806. get parent(): Nullable<Node>;
  116807. /** @hidden */
  116808. _addToSceneRootNodes(): void;
  116809. /** @hidden */
  116810. _removeFromSceneRootNodes(): void;
  116811. private _animationPropertiesOverride;
  116812. /**
  116813. * Gets or sets the animation properties override
  116814. */
  116815. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116816. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116817. /**
  116818. * Gets a string identifying the name of the class
  116819. * @returns "Node" string
  116820. */
  116821. getClassName(): string;
  116822. /** @hidden */
  116823. readonly _isNode: boolean;
  116824. /**
  116825. * An event triggered when the mesh is disposed
  116826. */
  116827. onDisposeObservable: Observable<Node>;
  116828. private _onDisposeObserver;
  116829. /**
  116830. * Sets a callback that will be raised when the node will be disposed
  116831. */
  116832. set onDispose(callback: () => void);
  116833. /**
  116834. * Creates a new Node
  116835. * @param name the name and id to be given to this node
  116836. * @param scene the scene this node will be added to
  116837. */
  116838. constructor(name: string, scene?: Nullable<Scene>);
  116839. /**
  116840. * Gets the scene of the node
  116841. * @returns a scene
  116842. */
  116843. getScene(): Scene;
  116844. /**
  116845. * Gets the engine of the node
  116846. * @returns a Engine
  116847. */
  116848. getEngine(): Engine;
  116849. private _behaviors;
  116850. /**
  116851. * Attach a behavior to the node
  116852. * @see https://doc.babylonjs.com/features/behaviour
  116853. * @param behavior defines the behavior to attach
  116854. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  116855. * @returns the current Node
  116856. */
  116857. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  116858. /**
  116859. * Remove an attached behavior
  116860. * @see https://doc.babylonjs.com/features/behaviour
  116861. * @param behavior defines the behavior to attach
  116862. * @returns the current Node
  116863. */
  116864. removeBehavior(behavior: Behavior<Node>): Node;
  116865. /**
  116866. * Gets the list of attached behaviors
  116867. * @see https://doc.babylonjs.com/features/behaviour
  116868. */
  116869. get behaviors(): Behavior<Node>[];
  116870. /**
  116871. * Gets an attached behavior by name
  116872. * @param name defines the name of the behavior to look for
  116873. * @see https://doc.babylonjs.com/features/behaviour
  116874. * @returns null if behavior was not found else the requested behavior
  116875. */
  116876. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  116877. /**
  116878. * Returns the latest update of the World matrix
  116879. * @returns a Matrix
  116880. */
  116881. getWorldMatrix(): Matrix;
  116882. /** @hidden */
  116883. _getWorldMatrixDeterminant(): number;
  116884. /**
  116885. * Returns directly the latest state of the mesh World matrix.
  116886. * A Matrix is returned.
  116887. */
  116888. get worldMatrixFromCache(): Matrix;
  116889. /** @hidden */
  116890. _initCache(): void;
  116891. /** @hidden */
  116892. updateCache(force?: boolean): void;
  116893. /** @hidden */
  116894. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116895. /** @hidden */
  116896. _updateCache(ignoreParentClass?: boolean): void;
  116897. /** @hidden */
  116898. _isSynchronized(): boolean;
  116899. /** @hidden */
  116900. _markSyncedWithParent(): void;
  116901. /** @hidden */
  116902. isSynchronizedWithParent(): boolean;
  116903. /** @hidden */
  116904. isSynchronized(): boolean;
  116905. /**
  116906. * Is this node ready to be used/rendered
  116907. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  116908. * @return true if the node is ready
  116909. */
  116910. isReady(completeCheck?: boolean): boolean;
  116911. /**
  116912. * Is this node enabled?
  116913. * 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
  116914. * @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
  116915. * @return whether this node (and its parent) is enabled
  116916. */
  116917. isEnabled(checkAncestors?: boolean): boolean;
  116918. /** @hidden */
  116919. protected _syncParentEnabledState(): void;
  116920. /**
  116921. * Set the enabled state of this node
  116922. * @param value defines the new enabled state
  116923. */
  116924. setEnabled(value: boolean): void;
  116925. /**
  116926. * Is this node a descendant of the given node?
  116927. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  116928. * @param ancestor defines the parent node to inspect
  116929. * @returns a boolean indicating if this node is a descendant of the given node
  116930. */
  116931. isDescendantOf(ancestor: Node): boolean;
  116932. /** @hidden */
  116933. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  116934. /**
  116935. * Will return all nodes that have this node as ascendant
  116936. * @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
  116937. * @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
  116938. * @return all children nodes of all types
  116939. */
  116940. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  116941. /**
  116942. * Get all child-meshes of this node
  116943. * @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)
  116944. * @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
  116945. * @returns an array of AbstractMesh
  116946. */
  116947. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  116948. /**
  116949. * Get all direct children of this node
  116950. * @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
  116951. * @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)
  116952. * @returns an array of Node
  116953. */
  116954. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  116955. /** @hidden */
  116956. _setReady(state: boolean): void;
  116957. /**
  116958. * Get an animation by name
  116959. * @param name defines the name of the animation to look for
  116960. * @returns null if not found else the requested animation
  116961. */
  116962. getAnimationByName(name: string): Nullable<Animation>;
  116963. /**
  116964. * Creates an animation range for this node
  116965. * @param name defines the name of the range
  116966. * @param from defines the starting key
  116967. * @param to defines the end key
  116968. */
  116969. createAnimationRange(name: string, from: number, to: number): void;
  116970. /**
  116971. * Delete a specific animation range
  116972. * @param name defines the name of the range to delete
  116973. * @param deleteFrames defines if animation frames from the range must be deleted as well
  116974. */
  116975. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  116976. /**
  116977. * Get an animation range by name
  116978. * @param name defines the name of the animation range to look for
  116979. * @returns null if not found else the requested animation range
  116980. */
  116981. getAnimationRange(name: string): Nullable<AnimationRange>;
  116982. /**
  116983. * Gets the list of all animation ranges defined on this node
  116984. * @returns an array
  116985. */
  116986. getAnimationRanges(): Nullable<AnimationRange>[];
  116987. /**
  116988. * Will start the animation sequence
  116989. * @param name defines the range frames for animation sequence
  116990. * @param loop defines if the animation should loop (false by default)
  116991. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  116992. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  116993. * @returns the object created for this animation. If range does not exist, it will return null
  116994. */
  116995. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  116996. /**
  116997. * Serialize animation ranges into a JSON compatible object
  116998. * @returns serialization object
  116999. */
  117000. serializeAnimationRanges(): any;
  117001. /**
  117002. * Computes the world matrix of the node
  117003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117004. * @returns the world matrix
  117005. */
  117006. computeWorldMatrix(force?: boolean): Matrix;
  117007. /**
  117008. * Releases resources associated with this node.
  117009. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117010. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117011. */
  117012. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117013. /**
  117014. * Parse animation range data from a serialization object and store them into a given node
  117015. * @param node defines where to store the animation ranges
  117016. * @param parsedNode defines the serialization object to read data from
  117017. * @param scene defines the hosting scene
  117018. */
  117019. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117020. /**
  117021. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117022. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117023. * @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
  117024. * @returns the new bounding vectors
  117025. */
  117026. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117027. min: Vector3;
  117028. max: Vector3;
  117029. };
  117030. }
  117031. }
  117032. declare module BABYLON {
  117033. /**
  117034. * @hidden
  117035. */
  117036. export class _IAnimationState {
  117037. key: number;
  117038. repeatCount: number;
  117039. workValue?: any;
  117040. loopMode?: number;
  117041. offsetValue?: any;
  117042. highLimitValue?: any;
  117043. }
  117044. /**
  117045. * Class used to store any kind of animation
  117046. */
  117047. export class Animation {
  117048. /**Name of the animation */
  117049. name: string;
  117050. /**Property to animate */
  117051. targetProperty: string;
  117052. /**The frames per second of the animation */
  117053. framePerSecond: number;
  117054. /**The data type of the animation */
  117055. dataType: number;
  117056. /**The loop mode of the animation */
  117057. loopMode?: number | undefined;
  117058. /**Specifies if blending should be enabled */
  117059. enableBlending?: boolean | undefined;
  117060. /**
  117061. * Use matrix interpolation instead of using direct key value when animating matrices
  117062. */
  117063. static AllowMatricesInterpolation: boolean;
  117064. /**
  117065. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117066. */
  117067. static AllowMatrixDecomposeForInterpolation: boolean;
  117068. /** Define the Url to load snippets */
  117069. static SnippetUrl: string;
  117070. /** Snippet ID if the animation was created from the snippet server */
  117071. snippetId: string;
  117072. /**
  117073. * Stores the key frames of the animation
  117074. */
  117075. private _keys;
  117076. /**
  117077. * Stores the easing function of the animation
  117078. */
  117079. private _easingFunction;
  117080. /**
  117081. * @hidden Internal use only
  117082. */
  117083. _runtimeAnimations: RuntimeAnimation[];
  117084. /**
  117085. * The set of event that will be linked to this animation
  117086. */
  117087. private _events;
  117088. /**
  117089. * Stores an array of target property paths
  117090. */
  117091. targetPropertyPath: string[];
  117092. /**
  117093. * Stores the blending speed of the animation
  117094. */
  117095. blendingSpeed: number;
  117096. /**
  117097. * Stores the animation ranges for the animation
  117098. */
  117099. private _ranges;
  117100. /**
  117101. * @hidden Internal use
  117102. */
  117103. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117104. /**
  117105. * Sets up an animation
  117106. * @param property The property to animate
  117107. * @param animationType The animation type to apply
  117108. * @param framePerSecond The frames per second of the animation
  117109. * @param easingFunction The easing function used in the animation
  117110. * @returns The created animation
  117111. */
  117112. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117113. /**
  117114. * Create and start an animation on a node
  117115. * @param name defines the name of the global animation that will be run on all nodes
  117116. * @param node defines the root node where the animation will take place
  117117. * @param targetProperty defines property to animate
  117118. * @param framePerSecond defines the number of frame per second yo use
  117119. * @param totalFrame defines the number of frames in total
  117120. * @param from defines the initial value
  117121. * @param to defines the final value
  117122. * @param loopMode defines which loop mode you want to use (off by default)
  117123. * @param easingFunction defines the easing function to use (linear by default)
  117124. * @param onAnimationEnd defines the callback to call when animation end
  117125. * @returns the animatable created for this animation
  117126. */
  117127. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117128. /**
  117129. * Create and start an animation on a node and its descendants
  117130. * @param name defines the name of the global animation that will be run on all nodes
  117131. * @param node defines the root node where the animation will take place
  117132. * @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
  117133. * @param targetProperty defines property to animate
  117134. * @param framePerSecond defines the number of frame per second to use
  117135. * @param totalFrame defines the number of frames in total
  117136. * @param from defines the initial value
  117137. * @param to defines the final value
  117138. * @param loopMode defines which loop mode you want to use (off by default)
  117139. * @param easingFunction defines the easing function to use (linear by default)
  117140. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117141. * @returns the list of animatables created for all nodes
  117142. * @example https://www.babylonjs-playground.com/#MH0VLI
  117143. */
  117144. 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[]>;
  117145. /**
  117146. * Creates a new animation, merges it with the existing animations and starts it
  117147. * @param name Name of the animation
  117148. * @param node Node which contains the scene that begins the animations
  117149. * @param targetProperty Specifies which property to animate
  117150. * @param framePerSecond The frames per second of the animation
  117151. * @param totalFrame The total number of frames
  117152. * @param from The frame at the beginning of the animation
  117153. * @param to The frame at the end of the animation
  117154. * @param loopMode Specifies the loop mode of the animation
  117155. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117156. * @param onAnimationEnd Callback to run once the animation is complete
  117157. * @returns Nullable animation
  117158. */
  117159. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117160. /**
  117161. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117162. * @param sourceAnimation defines the Animation containing keyframes to convert
  117163. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117164. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117165. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117166. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117167. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117168. */
  117169. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117170. /**
  117171. * Transition property of an host to the target Value
  117172. * @param property The property to transition
  117173. * @param targetValue The target Value of the property
  117174. * @param host The object where the property to animate belongs
  117175. * @param scene Scene used to run the animation
  117176. * @param frameRate Framerate (in frame/s) to use
  117177. * @param transition The transition type we want to use
  117178. * @param duration The duration of the animation, in milliseconds
  117179. * @param onAnimationEnd Callback trigger at the end of the animation
  117180. * @returns Nullable animation
  117181. */
  117182. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117183. /**
  117184. * Return the array of runtime animations currently using this animation
  117185. */
  117186. get runtimeAnimations(): RuntimeAnimation[];
  117187. /**
  117188. * Specifies if any of the runtime animations are currently running
  117189. */
  117190. get hasRunningRuntimeAnimations(): boolean;
  117191. /**
  117192. * Initializes the animation
  117193. * @param name Name of the animation
  117194. * @param targetProperty Property to animate
  117195. * @param framePerSecond The frames per second of the animation
  117196. * @param dataType The data type of the animation
  117197. * @param loopMode The loop mode of the animation
  117198. * @param enableBlending Specifies if blending should be enabled
  117199. */
  117200. constructor(
  117201. /**Name of the animation */
  117202. name: string,
  117203. /**Property to animate */
  117204. targetProperty: string,
  117205. /**The frames per second of the animation */
  117206. framePerSecond: number,
  117207. /**The data type of the animation */
  117208. dataType: number,
  117209. /**The loop mode of the animation */
  117210. loopMode?: number | undefined,
  117211. /**Specifies if blending should be enabled */
  117212. enableBlending?: boolean | undefined);
  117213. /**
  117214. * Converts the animation to a string
  117215. * @param fullDetails support for multiple levels of logging within scene loading
  117216. * @returns String form of the animation
  117217. */
  117218. toString(fullDetails?: boolean): string;
  117219. /**
  117220. * Add an event to this animation
  117221. * @param event Event to add
  117222. */
  117223. addEvent(event: AnimationEvent): void;
  117224. /**
  117225. * Remove all events found at the given frame
  117226. * @param frame The frame to remove events from
  117227. */
  117228. removeEvents(frame: number): void;
  117229. /**
  117230. * Retrieves all the events from the animation
  117231. * @returns Events from the animation
  117232. */
  117233. getEvents(): AnimationEvent[];
  117234. /**
  117235. * Creates an animation range
  117236. * @param name Name of the animation range
  117237. * @param from Starting frame of the animation range
  117238. * @param to Ending frame of the animation
  117239. */
  117240. createRange(name: string, from: number, to: number): void;
  117241. /**
  117242. * Deletes an animation range by name
  117243. * @param name Name of the animation range to delete
  117244. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117245. */
  117246. deleteRange(name: string, deleteFrames?: boolean): void;
  117247. /**
  117248. * Gets the animation range by name, or null if not defined
  117249. * @param name Name of the animation range
  117250. * @returns Nullable animation range
  117251. */
  117252. getRange(name: string): Nullable<AnimationRange>;
  117253. /**
  117254. * Gets the key frames from the animation
  117255. * @returns The key frames of the animation
  117256. */
  117257. getKeys(): Array<IAnimationKey>;
  117258. /**
  117259. * Gets the highest frame rate of the animation
  117260. * @returns Highest frame rate of the animation
  117261. */
  117262. getHighestFrame(): number;
  117263. /**
  117264. * Gets the easing function of the animation
  117265. * @returns Easing function of the animation
  117266. */
  117267. getEasingFunction(): IEasingFunction;
  117268. /**
  117269. * Sets the easing function of the animation
  117270. * @param easingFunction A custom mathematical formula for animation
  117271. */
  117272. setEasingFunction(easingFunction: EasingFunction): void;
  117273. /**
  117274. * Interpolates a scalar linearly
  117275. * @param startValue Start value of the animation curve
  117276. * @param endValue End value of the animation curve
  117277. * @param gradient Scalar amount to interpolate
  117278. * @returns Interpolated scalar value
  117279. */
  117280. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117281. /**
  117282. * Interpolates a scalar cubically
  117283. * @param startValue Start value of the animation curve
  117284. * @param outTangent End tangent of the animation
  117285. * @param endValue End value of the animation curve
  117286. * @param inTangent Start tangent of the animation curve
  117287. * @param gradient Scalar amount to interpolate
  117288. * @returns Interpolated scalar value
  117289. */
  117290. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117291. /**
  117292. * Interpolates a quaternion using a spherical linear interpolation
  117293. * @param startValue Start value of the animation curve
  117294. * @param endValue End value of the animation curve
  117295. * @param gradient Scalar amount to interpolate
  117296. * @returns Interpolated quaternion value
  117297. */
  117298. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117299. /**
  117300. * Interpolates a quaternion cubically
  117301. * @param startValue Start value of the animation curve
  117302. * @param outTangent End tangent of the animation curve
  117303. * @param endValue End value of the animation curve
  117304. * @param inTangent Start tangent of the animation curve
  117305. * @param gradient Scalar amount to interpolate
  117306. * @returns Interpolated quaternion value
  117307. */
  117308. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117309. /**
  117310. * Interpolates a Vector3 linearl
  117311. * @param startValue Start value of the animation curve
  117312. * @param endValue End value of the animation curve
  117313. * @param gradient Scalar amount to interpolate
  117314. * @returns Interpolated scalar value
  117315. */
  117316. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117317. /**
  117318. * Interpolates a Vector3 cubically
  117319. * @param startValue Start value of the animation curve
  117320. * @param outTangent End tangent of the animation
  117321. * @param endValue End value of the animation curve
  117322. * @param inTangent Start tangent of the animation curve
  117323. * @param gradient Scalar amount to interpolate
  117324. * @returns InterpolatedVector3 value
  117325. */
  117326. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117327. /**
  117328. * Interpolates a Vector2 linearly
  117329. * @param startValue Start value of the animation curve
  117330. * @param endValue End value of the animation curve
  117331. * @param gradient Scalar amount to interpolate
  117332. * @returns Interpolated Vector2 value
  117333. */
  117334. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117335. /**
  117336. * Interpolates a Vector2 cubically
  117337. * @param startValue Start value of the animation curve
  117338. * @param outTangent End tangent of the animation
  117339. * @param endValue End value of the animation curve
  117340. * @param inTangent Start tangent of the animation curve
  117341. * @param gradient Scalar amount to interpolate
  117342. * @returns Interpolated Vector2 value
  117343. */
  117344. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117345. /**
  117346. * Interpolates a size linearly
  117347. * @param startValue Start value of the animation curve
  117348. * @param endValue End value of the animation curve
  117349. * @param gradient Scalar amount to interpolate
  117350. * @returns Interpolated Size value
  117351. */
  117352. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117353. /**
  117354. * Interpolates a Color3 linearly
  117355. * @param startValue Start value of the animation curve
  117356. * @param endValue End value of the animation curve
  117357. * @param gradient Scalar amount to interpolate
  117358. * @returns Interpolated Color3 value
  117359. */
  117360. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117361. /**
  117362. * Interpolates a Color4 linearly
  117363. * @param startValue Start value of the animation curve
  117364. * @param endValue End value of the animation curve
  117365. * @param gradient Scalar amount to interpolate
  117366. * @returns Interpolated Color3 value
  117367. */
  117368. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117369. /**
  117370. * @hidden Internal use only
  117371. */
  117372. _getKeyValue(value: any): any;
  117373. /**
  117374. * @hidden Internal use only
  117375. */
  117376. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117377. /**
  117378. * Defines the function to use to interpolate matrices
  117379. * @param startValue defines the start matrix
  117380. * @param endValue defines the end matrix
  117381. * @param gradient defines the gradient between both matrices
  117382. * @param result defines an optional target matrix where to store the interpolation
  117383. * @returns the interpolated matrix
  117384. */
  117385. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117386. /**
  117387. * Makes a copy of the animation
  117388. * @returns Cloned animation
  117389. */
  117390. clone(): Animation;
  117391. /**
  117392. * Sets the key frames of the animation
  117393. * @param values The animation key frames to set
  117394. */
  117395. setKeys(values: Array<IAnimationKey>): void;
  117396. /**
  117397. * Serializes the animation to an object
  117398. * @returns Serialized object
  117399. */
  117400. serialize(): any;
  117401. /**
  117402. * Float animation type
  117403. */
  117404. static readonly ANIMATIONTYPE_FLOAT: number;
  117405. /**
  117406. * Vector3 animation type
  117407. */
  117408. static readonly ANIMATIONTYPE_VECTOR3: number;
  117409. /**
  117410. * Quaternion animation type
  117411. */
  117412. static readonly ANIMATIONTYPE_QUATERNION: number;
  117413. /**
  117414. * Matrix animation type
  117415. */
  117416. static readonly ANIMATIONTYPE_MATRIX: number;
  117417. /**
  117418. * Color3 animation type
  117419. */
  117420. static readonly ANIMATIONTYPE_COLOR3: number;
  117421. /**
  117422. * Color3 animation type
  117423. */
  117424. static readonly ANIMATIONTYPE_COLOR4: number;
  117425. /**
  117426. * Vector2 animation type
  117427. */
  117428. static readonly ANIMATIONTYPE_VECTOR2: number;
  117429. /**
  117430. * Size animation type
  117431. */
  117432. static readonly ANIMATIONTYPE_SIZE: number;
  117433. /**
  117434. * Relative Loop Mode
  117435. */
  117436. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117437. /**
  117438. * Cycle Loop Mode
  117439. */
  117440. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117441. /**
  117442. * Constant Loop Mode
  117443. */
  117444. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117445. /** @hidden */
  117446. static _UniversalLerp(left: any, right: any, amount: number): any;
  117447. /**
  117448. * Parses an animation object and creates an animation
  117449. * @param parsedAnimation Parsed animation object
  117450. * @returns Animation object
  117451. */
  117452. static Parse(parsedAnimation: any): Animation;
  117453. /**
  117454. * Appends the serialized animations from the source animations
  117455. * @param source Source containing the animations
  117456. * @param destination Target to store the animations
  117457. */
  117458. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117459. /**
  117460. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117461. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117462. * @param url defines the url to load from
  117463. * @returns a promise that will resolve to the new animation or an array of animations
  117464. */
  117465. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117466. /**
  117467. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117468. * @param snippetId defines the snippet to load
  117469. * @returns a promise that will resolve to the new animation or a new array of animations
  117470. */
  117471. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117472. }
  117473. }
  117474. declare module BABYLON {
  117475. /**
  117476. * Interface containing an array of animations
  117477. */
  117478. export interface IAnimatable {
  117479. /**
  117480. * Array of animations
  117481. */
  117482. animations: Nullable<Array<Animation>>;
  117483. }
  117484. }
  117485. declare module BABYLON {
  117486. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117487. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117488. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117489. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117490. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117491. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117492. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117493. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117494. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117495. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117496. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117497. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117498. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117499. /**
  117500. * Decorator used to define property that can be serialized as reference to a camera
  117501. * @param sourceName defines the name of the property to decorate
  117502. */
  117503. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117504. /**
  117505. * Class used to help serialization objects
  117506. */
  117507. export class SerializationHelper {
  117508. /** @hidden */
  117509. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117510. /** @hidden */
  117511. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117512. /** @hidden */
  117513. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117514. /** @hidden */
  117515. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117516. /**
  117517. * Appends the serialized animations from the source animations
  117518. * @param source Source containing the animations
  117519. * @param destination Target to store the animations
  117520. */
  117521. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117522. /**
  117523. * Static function used to serialized a specific entity
  117524. * @param entity defines the entity to serialize
  117525. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117526. * @returns a JSON compatible object representing the serialization of the entity
  117527. */
  117528. static Serialize<T>(entity: T, serializationObject?: any): any;
  117529. /**
  117530. * Creates a new entity from a serialization data object
  117531. * @param creationFunction defines a function used to instanciated the new entity
  117532. * @param source defines the source serialization data
  117533. * @param scene defines the hosting scene
  117534. * @param rootUrl defines the root url for resources
  117535. * @returns a new entity
  117536. */
  117537. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117538. /**
  117539. * Clones an object
  117540. * @param creationFunction defines the function used to instanciate the new object
  117541. * @param source defines the source object
  117542. * @returns the cloned object
  117543. */
  117544. static Clone<T>(creationFunction: () => T, source: T): T;
  117545. /**
  117546. * Instanciates a new object based on a source one (some data will be shared between both object)
  117547. * @param creationFunction defines the function used to instanciate the new object
  117548. * @param source defines the source object
  117549. * @returns the new object
  117550. */
  117551. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117552. }
  117553. }
  117554. declare module BABYLON {
  117555. /**
  117556. * Base class of all the textures in babylon.
  117557. * It groups all the common properties the materials, post process, lights... might need
  117558. * in order to make a correct use of the texture.
  117559. */
  117560. export class BaseTexture implements IAnimatable {
  117561. /**
  117562. * Default anisotropic filtering level for the application.
  117563. * It is set to 4 as a good tradeoff between perf and quality.
  117564. */
  117565. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117566. /**
  117567. * Gets or sets the unique id of the texture
  117568. */
  117569. uniqueId: number;
  117570. /**
  117571. * Define the name of the texture.
  117572. */
  117573. name: string;
  117574. /**
  117575. * Gets or sets an object used to store user defined information.
  117576. */
  117577. metadata: any;
  117578. /**
  117579. * For internal use only. Please do not use.
  117580. */
  117581. reservedDataStore: any;
  117582. private _hasAlpha;
  117583. /**
  117584. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117585. */
  117586. set hasAlpha(value: boolean);
  117587. get hasAlpha(): boolean;
  117588. /**
  117589. * Defines if the alpha value should be determined via the rgb values.
  117590. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117591. */
  117592. getAlphaFromRGB: boolean;
  117593. /**
  117594. * Intensity or strength of the texture.
  117595. * It is commonly used by materials to fine tune the intensity of the texture
  117596. */
  117597. level: number;
  117598. /**
  117599. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117600. * This is part of the texture as textures usually maps to one uv set.
  117601. */
  117602. coordinatesIndex: number;
  117603. protected _coordinatesMode: number;
  117604. /**
  117605. * How a texture is mapped.
  117606. *
  117607. * | Value | Type | Description |
  117608. * | ----- | ----------------------------------- | ----------- |
  117609. * | 0 | EXPLICIT_MODE | |
  117610. * | 1 | SPHERICAL_MODE | |
  117611. * | 2 | PLANAR_MODE | |
  117612. * | 3 | CUBIC_MODE | |
  117613. * | 4 | PROJECTION_MODE | |
  117614. * | 5 | SKYBOX_MODE | |
  117615. * | 6 | INVCUBIC_MODE | |
  117616. * | 7 | EQUIRECTANGULAR_MODE | |
  117617. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117618. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117619. */
  117620. set coordinatesMode(value: number);
  117621. get coordinatesMode(): number;
  117622. private _wrapU;
  117623. /**
  117624. * | Value | Type | Description |
  117625. * | ----- | ------------------ | ----------- |
  117626. * | 0 | CLAMP_ADDRESSMODE | |
  117627. * | 1 | WRAP_ADDRESSMODE | |
  117628. * | 2 | MIRROR_ADDRESSMODE | |
  117629. */
  117630. get wrapU(): number;
  117631. set wrapU(value: number);
  117632. private _wrapV;
  117633. /**
  117634. * | Value | Type | Description |
  117635. * | ----- | ------------------ | ----------- |
  117636. * | 0 | CLAMP_ADDRESSMODE | |
  117637. * | 1 | WRAP_ADDRESSMODE | |
  117638. * | 2 | MIRROR_ADDRESSMODE | |
  117639. */
  117640. get wrapV(): number;
  117641. set wrapV(value: number);
  117642. /**
  117643. * | Value | Type | Description |
  117644. * | ----- | ------------------ | ----------- |
  117645. * | 0 | CLAMP_ADDRESSMODE | |
  117646. * | 1 | WRAP_ADDRESSMODE | |
  117647. * | 2 | MIRROR_ADDRESSMODE | |
  117648. */
  117649. wrapR: number;
  117650. /**
  117651. * With compliant hardware and browser (supporting anisotropic filtering)
  117652. * this defines the level of anisotropic filtering in the texture.
  117653. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117654. */
  117655. anisotropicFilteringLevel: number;
  117656. /**
  117657. * Define if the texture is a cube texture or if false a 2d texture.
  117658. */
  117659. get isCube(): boolean;
  117660. set isCube(value: boolean);
  117661. /**
  117662. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117663. */
  117664. get is3D(): boolean;
  117665. set is3D(value: boolean);
  117666. /**
  117667. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117668. */
  117669. get is2DArray(): boolean;
  117670. set is2DArray(value: boolean);
  117671. private _gammaSpace;
  117672. /**
  117673. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117674. * HDR texture are usually stored in linear space.
  117675. * This only impacts the PBR and Background materials
  117676. */
  117677. get gammaSpace(): boolean;
  117678. set gammaSpace(gamma: boolean);
  117679. /**
  117680. * Gets or sets whether or not the texture contains RGBD data.
  117681. */
  117682. get isRGBD(): boolean;
  117683. set isRGBD(value: boolean);
  117684. /**
  117685. * Is Z inverted in the texture (useful in a cube texture).
  117686. */
  117687. invertZ: boolean;
  117688. /**
  117689. * Are mip maps generated for this texture or not.
  117690. */
  117691. get noMipmap(): boolean;
  117692. /**
  117693. * @hidden
  117694. */
  117695. lodLevelInAlpha: boolean;
  117696. /**
  117697. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117698. */
  117699. get lodGenerationOffset(): number;
  117700. set lodGenerationOffset(value: number);
  117701. /**
  117702. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117703. */
  117704. get lodGenerationScale(): number;
  117705. set lodGenerationScale(value: number);
  117706. /**
  117707. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117708. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117709. * average roughness values.
  117710. */
  117711. get linearSpecularLOD(): boolean;
  117712. set linearSpecularLOD(value: boolean);
  117713. /**
  117714. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117715. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117716. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117717. */
  117718. get irradianceTexture(): Nullable<BaseTexture>;
  117719. set irradianceTexture(value: Nullable<BaseTexture>);
  117720. /**
  117721. * Define if the texture is a render target.
  117722. */
  117723. isRenderTarget: boolean;
  117724. /**
  117725. * Define the unique id of the texture in the scene.
  117726. */
  117727. get uid(): string;
  117728. /** @hidden */
  117729. _prefiltered: boolean;
  117730. /**
  117731. * Return a string representation of the texture.
  117732. * @returns the texture as a string
  117733. */
  117734. toString(): string;
  117735. /**
  117736. * Get the class name of the texture.
  117737. * @returns "BaseTexture"
  117738. */
  117739. getClassName(): string;
  117740. /**
  117741. * Define the list of animation attached to the texture.
  117742. */
  117743. animations: Animation[];
  117744. /**
  117745. * An event triggered when the texture is disposed.
  117746. */
  117747. onDisposeObservable: Observable<BaseTexture>;
  117748. private _onDisposeObserver;
  117749. /**
  117750. * Callback triggered when the texture has been disposed.
  117751. * Kept for back compatibility, you can use the onDisposeObservable instead.
  117752. */
  117753. set onDispose(callback: () => void);
  117754. /**
  117755. * Define the current state of the loading sequence when in delayed load mode.
  117756. */
  117757. delayLoadState: number;
  117758. protected _scene: Nullable<Scene>;
  117759. protected _engine: Nullable<ThinEngine>;
  117760. /** @hidden */
  117761. _texture: Nullable<InternalTexture>;
  117762. private _uid;
  117763. /**
  117764. * Define if the texture is preventinga material to render or not.
  117765. * If not and the texture is not ready, the engine will use a default black texture instead.
  117766. */
  117767. get isBlocking(): boolean;
  117768. /**
  117769. * Instantiates a new BaseTexture.
  117770. * Base class of all the textures in babylon.
  117771. * It groups all the common properties the materials, post process, lights... might need
  117772. * in order to make a correct use of the texture.
  117773. * @param sceneOrEngine Define the scene or engine the texture blongs to
  117774. */
  117775. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  117776. /**
  117777. * Get the scene the texture belongs to.
  117778. * @returns the scene or null if undefined
  117779. */
  117780. getScene(): Nullable<Scene>;
  117781. /** @hidden */
  117782. protected _getEngine(): Nullable<ThinEngine>;
  117783. /**
  117784. * Get the texture transform matrix used to offset tile the texture for istance.
  117785. * @returns the transformation matrix
  117786. */
  117787. getTextureMatrix(): Matrix;
  117788. /**
  117789. * Get the texture reflection matrix used to rotate/transform the reflection.
  117790. * @returns the reflection matrix
  117791. */
  117792. getReflectionTextureMatrix(): Matrix;
  117793. /**
  117794. * Get the underlying lower level texture from Babylon.
  117795. * @returns the insternal texture
  117796. */
  117797. getInternalTexture(): Nullable<InternalTexture>;
  117798. /**
  117799. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  117800. * @returns true if ready or not blocking
  117801. */
  117802. isReadyOrNotBlocking(): boolean;
  117803. /**
  117804. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  117805. * @returns true if fully ready
  117806. */
  117807. isReady(): boolean;
  117808. private _cachedSize;
  117809. /**
  117810. * Get the size of the texture.
  117811. * @returns the texture size.
  117812. */
  117813. getSize(): ISize;
  117814. /**
  117815. * Get the base size of the texture.
  117816. * It can be different from the size if the texture has been resized for POT for instance
  117817. * @returns the base size
  117818. */
  117819. getBaseSize(): ISize;
  117820. /**
  117821. * Update the sampling mode of the texture.
  117822. * Default is Trilinear mode.
  117823. *
  117824. * | Value | Type | Description |
  117825. * | ----- | ------------------ | ----------- |
  117826. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  117827. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  117828. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  117829. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  117830. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  117831. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  117832. * | 7 | NEAREST_LINEAR | |
  117833. * | 8 | NEAREST_NEAREST | |
  117834. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  117835. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  117836. * | 11 | LINEAR_LINEAR | |
  117837. * | 12 | LINEAR_NEAREST | |
  117838. *
  117839. * > _mag_: magnification filter (close to the viewer)
  117840. * > _min_: minification filter (far from the viewer)
  117841. * > _mip_: filter used between mip map levels
  117842. *@param samplingMode Define the new sampling mode of the texture
  117843. */
  117844. updateSamplingMode(samplingMode: number): void;
  117845. /**
  117846. * Scales the texture if is `canRescale()`
  117847. * @param ratio the resize factor we want to use to rescale
  117848. */
  117849. scale(ratio: number): void;
  117850. /**
  117851. * Get if the texture can rescale.
  117852. */
  117853. get canRescale(): boolean;
  117854. /** @hidden */
  117855. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  117856. /** @hidden */
  117857. _rebuild(): void;
  117858. /**
  117859. * Triggers the load sequence in delayed load mode.
  117860. */
  117861. delayLoad(): void;
  117862. /**
  117863. * Clones the texture.
  117864. * @returns the cloned texture
  117865. */
  117866. clone(): Nullable<BaseTexture>;
  117867. /**
  117868. * Get the texture underlying type (INT, FLOAT...)
  117869. */
  117870. get textureType(): number;
  117871. /**
  117872. * Get the texture underlying format (RGB, RGBA...)
  117873. */
  117874. get textureFormat(): number;
  117875. /**
  117876. * Indicates that textures need to be re-calculated for all materials
  117877. */
  117878. protected _markAllSubMeshesAsTexturesDirty(): void;
  117879. /**
  117880. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  117881. * This will returns an RGBA array buffer containing either in values (0-255) or
  117882. * float values (0-1) depending of the underlying buffer type.
  117883. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  117884. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  117885. * @param buffer defines a user defined buffer to fill with data (can be null)
  117886. * @returns The Array buffer containing the pixels data.
  117887. */
  117888. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  117889. /**
  117890. * Release and destroy the underlying lower level texture aka internalTexture.
  117891. */
  117892. releaseInternalTexture(): void;
  117893. /** @hidden */
  117894. get _lodTextureHigh(): Nullable<BaseTexture>;
  117895. /** @hidden */
  117896. get _lodTextureMid(): Nullable<BaseTexture>;
  117897. /** @hidden */
  117898. get _lodTextureLow(): Nullable<BaseTexture>;
  117899. /**
  117900. * Dispose the texture and release its associated resources.
  117901. */
  117902. dispose(): void;
  117903. /**
  117904. * Serialize the texture into a JSON representation that can be parsed later on.
  117905. * @returns the JSON representation of the texture
  117906. */
  117907. serialize(): any;
  117908. /**
  117909. * Helper function to be called back once a list of texture contains only ready textures.
  117910. * @param textures Define the list of textures to wait for
  117911. * @param callback Define the callback triggered once the entire list will be ready
  117912. */
  117913. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  117914. private static _isScene;
  117915. }
  117916. }
  117917. declare module BABYLON {
  117918. /**
  117919. * Options to be used when creating an effect.
  117920. */
  117921. export interface IEffectCreationOptions {
  117922. /**
  117923. * Atrributes that will be used in the shader.
  117924. */
  117925. attributes: string[];
  117926. /**
  117927. * Uniform varible names that will be set in the shader.
  117928. */
  117929. uniformsNames: string[];
  117930. /**
  117931. * Uniform buffer variable names that will be set in the shader.
  117932. */
  117933. uniformBuffersNames: string[];
  117934. /**
  117935. * Sampler texture variable names that will be set in the shader.
  117936. */
  117937. samplers: string[];
  117938. /**
  117939. * Define statements that will be set in the shader.
  117940. */
  117941. defines: any;
  117942. /**
  117943. * Possible fallbacks for this effect to improve performance when needed.
  117944. */
  117945. fallbacks: Nullable<IEffectFallbacks>;
  117946. /**
  117947. * Callback that will be called when the shader is compiled.
  117948. */
  117949. onCompiled: Nullable<(effect: Effect) => void>;
  117950. /**
  117951. * Callback that will be called if an error occurs during shader compilation.
  117952. */
  117953. onError: Nullable<(effect: Effect, errors: string) => void>;
  117954. /**
  117955. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  117956. */
  117957. indexParameters?: any;
  117958. /**
  117959. * Max number of lights that can be used in the shader.
  117960. */
  117961. maxSimultaneousLights?: number;
  117962. /**
  117963. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  117964. */
  117965. transformFeedbackVaryings?: Nullable<string[]>;
  117966. /**
  117967. * 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
  117968. */
  117969. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  117970. /**
  117971. * Is this effect rendering to several color attachments ?
  117972. */
  117973. multiTarget?: boolean;
  117974. }
  117975. /**
  117976. * Effect containing vertex and fragment shader that can be executed on an object.
  117977. */
  117978. export class Effect implements IDisposable {
  117979. /**
  117980. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  117981. */
  117982. static ShadersRepository: string;
  117983. /**
  117984. * Enable logging of the shader code when a compilation error occurs
  117985. */
  117986. static LogShaderCodeOnCompilationError: boolean;
  117987. /**
  117988. * Name of the effect.
  117989. */
  117990. name: any;
  117991. /**
  117992. * String container all the define statements that should be set on the shader.
  117993. */
  117994. defines: string;
  117995. /**
  117996. * Callback that will be called when the shader is compiled.
  117997. */
  117998. onCompiled: Nullable<(effect: Effect) => void>;
  117999. /**
  118000. * Callback that will be called if an error occurs during shader compilation.
  118001. */
  118002. onError: Nullable<(effect: Effect, errors: string) => void>;
  118003. /**
  118004. * Callback that will be called when effect is bound.
  118005. */
  118006. onBind: Nullable<(effect: Effect) => void>;
  118007. /**
  118008. * Unique ID of the effect.
  118009. */
  118010. uniqueId: number;
  118011. /**
  118012. * Observable that will be called when the shader is compiled.
  118013. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118014. */
  118015. onCompileObservable: Observable<Effect>;
  118016. /**
  118017. * Observable that will be called if an error occurs during shader compilation.
  118018. */
  118019. onErrorObservable: Observable<Effect>;
  118020. /** @hidden */
  118021. _onBindObservable: Nullable<Observable<Effect>>;
  118022. /**
  118023. * @hidden
  118024. * Specifies if the effect was previously ready
  118025. */
  118026. _wasPreviouslyReady: boolean;
  118027. /**
  118028. * Observable that will be called when effect is bound.
  118029. */
  118030. get onBindObservable(): Observable<Effect>;
  118031. /** @hidden */
  118032. _bonesComputationForcedToCPU: boolean;
  118033. /** @hidden */
  118034. _multiTarget: boolean;
  118035. private static _uniqueIdSeed;
  118036. private _engine;
  118037. private _uniformBuffersNames;
  118038. private _uniformBuffersNamesList;
  118039. private _uniformsNames;
  118040. private _samplerList;
  118041. private _samplers;
  118042. private _isReady;
  118043. private _compilationError;
  118044. private _allFallbacksProcessed;
  118045. private _attributesNames;
  118046. private _attributes;
  118047. private _attributeLocationByName;
  118048. private _uniforms;
  118049. /**
  118050. * Key for the effect.
  118051. * @hidden
  118052. */
  118053. _key: string;
  118054. private _indexParameters;
  118055. private _fallbacks;
  118056. private _vertexSourceCode;
  118057. private _fragmentSourceCode;
  118058. private _vertexSourceCodeOverride;
  118059. private _fragmentSourceCodeOverride;
  118060. private _transformFeedbackVaryings;
  118061. /**
  118062. * Compiled shader to webGL program.
  118063. * @hidden
  118064. */
  118065. _pipelineContext: Nullable<IPipelineContext>;
  118066. private _valueCache;
  118067. private static _baseCache;
  118068. /**
  118069. * Instantiates an effect.
  118070. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118071. * @param baseName Name of the effect.
  118072. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118073. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118074. * @param samplers List of sampler variables that will be passed to the shader.
  118075. * @param engine Engine to be used to render the effect
  118076. * @param defines Define statements to be added to the shader.
  118077. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118078. * @param onCompiled Callback that will be called when the shader is compiled.
  118079. * @param onError Callback that will be called if an error occurs during shader compilation.
  118080. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118081. */
  118082. 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);
  118083. private _useFinalCode;
  118084. /**
  118085. * Unique key for this effect
  118086. */
  118087. get key(): string;
  118088. /**
  118089. * If the effect has been compiled and prepared.
  118090. * @returns if the effect is compiled and prepared.
  118091. */
  118092. isReady(): boolean;
  118093. private _isReadyInternal;
  118094. /**
  118095. * The engine the effect was initialized with.
  118096. * @returns the engine.
  118097. */
  118098. getEngine(): Engine;
  118099. /**
  118100. * The pipeline context for this effect
  118101. * @returns the associated pipeline context
  118102. */
  118103. getPipelineContext(): Nullable<IPipelineContext>;
  118104. /**
  118105. * The set of names of attribute variables for the shader.
  118106. * @returns An array of attribute names.
  118107. */
  118108. getAttributesNames(): string[];
  118109. /**
  118110. * Returns the attribute at the given index.
  118111. * @param index The index of the attribute.
  118112. * @returns The location of the attribute.
  118113. */
  118114. getAttributeLocation(index: number): number;
  118115. /**
  118116. * Returns the attribute based on the name of the variable.
  118117. * @param name of the attribute to look up.
  118118. * @returns the attribute location.
  118119. */
  118120. getAttributeLocationByName(name: string): number;
  118121. /**
  118122. * The number of attributes.
  118123. * @returns the numnber of attributes.
  118124. */
  118125. getAttributesCount(): number;
  118126. /**
  118127. * Gets the index of a uniform variable.
  118128. * @param uniformName of the uniform to look up.
  118129. * @returns the index.
  118130. */
  118131. getUniformIndex(uniformName: string): number;
  118132. /**
  118133. * Returns the attribute based on the name of the variable.
  118134. * @param uniformName of the uniform to look up.
  118135. * @returns the location of the uniform.
  118136. */
  118137. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118138. /**
  118139. * Returns an array of sampler variable names
  118140. * @returns The array of sampler variable names.
  118141. */
  118142. getSamplers(): string[];
  118143. /**
  118144. * Returns an array of uniform variable names
  118145. * @returns The array of uniform variable names.
  118146. */
  118147. getUniformNames(): string[];
  118148. /**
  118149. * Returns an array of uniform buffer variable names
  118150. * @returns The array of uniform buffer variable names.
  118151. */
  118152. getUniformBuffersNames(): string[];
  118153. /**
  118154. * Returns the index parameters used to create the effect
  118155. * @returns The index parameters object
  118156. */
  118157. getIndexParameters(): any;
  118158. /**
  118159. * The error from the last compilation.
  118160. * @returns the error string.
  118161. */
  118162. getCompilationError(): string;
  118163. /**
  118164. * Gets a boolean indicating that all fallbacks were used during compilation
  118165. * @returns true if all fallbacks were used
  118166. */
  118167. allFallbacksProcessed(): boolean;
  118168. /**
  118169. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118170. * @param func The callback to be used.
  118171. */
  118172. executeWhenCompiled(func: (effect: Effect) => void): void;
  118173. private _checkIsReady;
  118174. private _loadShader;
  118175. /**
  118176. * Gets the vertex shader source code of this effect
  118177. */
  118178. get vertexSourceCode(): string;
  118179. /**
  118180. * Gets the fragment shader source code of this effect
  118181. */
  118182. get fragmentSourceCode(): string;
  118183. /**
  118184. * Recompiles the webGL program
  118185. * @param vertexSourceCode The source code for the vertex shader.
  118186. * @param fragmentSourceCode The source code for the fragment shader.
  118187. * @param onCompiled Callback called when completed.
  118188. * @param onError Callback called on error.
  118189. * @hidden
  118190. */
  118191. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118192. /**
  118193. * Prepares the effect
  118194. * @hidden
  118195. */
  118196. _prepareEffect(): void;
  118197. private _getShaderCodeAndErrorLine;
  118198. private _processCompilationErrors;
  118199. /**
  118200. * Checks if the effect is supported. (Must be called after compilation)
  118201. */
  118202. get isSupported(): boolean;
  118203. /**
  118204. * Binds a texture to the engine to be used as output of the shader.
  118205. * @param channel Name of the output variable.
  118206. * @param texture Texture to bind.
  118207. * @hidden
  118208. */
  118209. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118210. /**
  118211. * Sets a texture on the engine to be used in the shader.
  118212. * @param channel Name of the sampler variable.
  118213. * @param texture Texture to set.
  118214. */
  118215. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118216. /**
  118217. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118218. * @param channel Name of the sampler variable.
  118219. * @param texture Texture to set.
  118220. */
  118221. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118222. /**
  118223. * Sets an array of textures on the engine to be used in the shader.
  118224. * @param channel Name of the variable.
  118225. * @param textures Textures to set.
  118226. */
  118227. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118228. /**
  118229. * 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)
  118230. * @param channel Name of the sampler variable.
  118231. * @param postProcess Post process to get the input texture from.
  118232. */
  118233. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118234. /**
  118235. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118236. * 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)
  118237. * @param channel Name of the sampler variable.
  118238. * @param postProcess Post process to get the output texture from.
  118239. */
  118240. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118241. /** @hidden */
  118242. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118243. /** @hidden */
  118244. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118245. /** @hidden */
  118246. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118247. /** @hidden */
  118248. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118249. /**
  118250. * Binds a buffer to a uniform.
  118251. * @param buffer Buffer to bind.
  118252. * @param name Name of the uniform variable to bind to.
  118253. */
  118254. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118255. /**
  118256. * Binds block to a uniform.
  118257. * @param blockName Name of the block to bind.
  118258. * @param index Index to bind.
  118259. */
  118260. bindUniformBlock(blockName: string, index: number): void;
  118261. /**
  118262. * Sets an interger value on a uniform variable.
  118263. * @param uniformName Name of the variable.
  118264. * @param value Value to be set.
  118265. * @returns this effect.
  118266. */
  118267. setInt(uniformName: string, value: number): Effect;
  118268. /**
  118269. * Sets an int array on a uniform variable.
  118270. * @param uniformName Name of the variable.
  118271. * @param array array to be set.
  118272. * @returns this effect.
  118273. */
  118274. setIntArray(uniformName: string, array: Int32Array): Effect;
  118275. /**
  118276. * 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)
  118277. * @param uniformName Name of the variable.
  118278. * @param array array to be set.
  118279. * @returns this effect.
  118280. */
  118281. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118282. /**
  118283. * 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)
  118284. * @param uniformName Name of the variable.
  118285. * @param array array to be set.
  118286. * @returns this effect.
  118287. */
  118288. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118289. /**
  118290. * 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)
  118291. * @param uniformName Name of the variable.
  118292. * @param array array to be set.
  118293. * @returns this effect.
  118294. */
  118295. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118296. /**
  118297. * Sets an float array on a uniform variable.
  118298. * @param uniformName Name of the variable.
  118299. * @param array array to be set.
  118300. * @returns this effect.
  118301. */
  118302. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118303. /**
  118304. * 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)
  118305. * @param uniformName Name of the variable.
  118306. * @param array array to be set.
  118307. * @returns this effect.
  118308. */
  118309. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118310. /**
  118311. * 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)
  118312. * @param uniformName Name of the variable.
  118313. * @param array array to be set.
  118314. * @returns this effect.
  118315. */
  118316. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118317. /**
  118318. * 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)
  118319. * @param uniformName Name of the variable.
  118320. * @param array array to be set.
  118321. * @returns this effect.
  118322. */
  118323. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118324. /**
  118325. * Sets an array on a uniform variable.
  118326. * @param uniformName Name of the variable.
  118327. * @param array array to be set.
  118328. * @returns this effect.
  118329. */
  118330. setArray(uniformName: string, array: number[]): Effect;
  118331. /**
  118332. * 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)
  118333. * @param uniformName Name of the variable.
  118334. * @param array array to be set.
  118335. * @returns this effect.
  118336. */
  118337. setArray2(uniformName: string, array: number[]): Effect;
  118338. /**
  118339. * 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)
  118340. * @param uniformName Name of the variable.
  118341. * @param array array to be set.
  118342. * @returns this effect.
  118343. */
  118344. setArray3(uniformName: string, array: number[]): Effect;
  118345. /**
  118346. * 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)
  118347. * @param uniformName Name of the variable.
  118348. * @param array array to be set.
  118349. * @returns this effect.
  118350. */
  118351. setArray4(uniformName: string, array: number[]): Effect;
  118352. /**
  118353. * Sets matrices on a uniform variable.
  118354. * @param uniformName Name of the variable.
  118355. * @param matrices matrices to be set.
  118356. * @returns this effect.
  118357. */
  118358. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118359. /**
  118360. * Sets matrix on a uniform variable.
  118361. * @param uniformName Name of the variable.
  118362. * @param matrix matrix to be set.
  118363. * @returns this effect.
  118364. */
  118365. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118366. /**
  118367. * 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)
  118368. * @param uniformName Name of the variable.
  118369. * @param matrix matrix to be set.
  118370. * @returns this effect.
  118371. */
  118372. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118373. /**
  118374. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118375. * @param uniformName Name of the variable.
  118376. * @param matrix matrix to be set.
  118377. * @returns this effect.
  118378. */
  118379. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118380. /**
  118381. * Sets a float on a uniform variable.
  118382. * @param uniformName Name of the variable.
  118383. * @param value value to be set.
  118384. * @returns this effect.
  118385. */
  118386. setFloat(uniformName: string, value: number): Effect;
  118387. /**
  118388. * Sets a boolean on a uniform variable.
  118389. * @param uniformName Name of the variable.
  118390. * @param bool value to be set.
  118391. * @returns this effect.
  118392. */
  118393. setBool(uniformName: string, bool: boolean): Effect;
  118394. /**
  118395. * Sets a Vector2 on a uniform variable.
  118396. * @param uniformName Name of the variable.
  118397. * @param vector2 vector2 to be set.
  118398. * @returns this effect.
  118399. */
  118400. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118401. /**
  118402. * Sets a float2 on a uniform variable.
  118403. * @param uniformName Name of the variable.
  118404. * @param x First float in float2.
  118405. * @param y Second float in float2.
  118406. * @returns this effect.
  118407. */
  118408. setFloat2(uniformName: string, x: number, y: number): Effect;
  118409. /**
  118410. * Sets a Vector3 on a uniform variable.
  118411. * @param uniformName Name of the variable.
  118412. * @param vector3 Value to be set.
  118413. * @returns this effect.
  118414. */
  118415. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118416. /**
  118417. * Sets a float3 on a uniform variable.
  118418. * @param uniformName Name of the variable.
  118419. * @param x First float in float3.
  118420. * @param y Second float in float3.
  118421. * @param z Third float in float3.
  118422. * @returns this effect.
  118423. */
  118424. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118425. /**
  118426. * Sets a Vector4 on a uniform variable.
  118427. * @param uniformName Name of the variable.
  118428. * @param vector4 Value to be set.
  118429. * @returns this effect.
  118430. */
  118431. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118432. /**
  118433. * Sets a float4 on a uniform variable.
  118434. * @param uniformName Name of the variable.
  118435. * @param x First float in float4.
  118436. * @param y Second float in float4.
  118437. * @param z Third float in float4.
  118438. * @param w Fourth float in float4.
  118439. * @returns this effect.
  118440. */
  118441. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118442. /**
  118443. * Sets a Color3 on a uniform variable.
  118444. * @param uniformName Name of the variable.
  118445. * @param color3 Value to be set.
  118446. * @returns this effect.
  118447. */
  118448. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118449. /**
  118450. * Sets a Color4 on a uniform variable.
  118451. * @param uniformName Name of the variable.
  118452. * @param color3 Value to be set.
  118453. * @param alpha Alpha value to be set.
  118454. * @returns this effect.
  118455. */
  118456. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118457. /**
  118458. * Sets a Color4 on a uniform variable
  118459. * @param uniformName defines the name of the variable
  118460. * @param color4 defines the value to be set
  118461. * @returns this effect.
  118462. */
  118463. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118464. /** Release all associated resources */
  118465. dispose(): void;
  118466. /**
  118467. * This function will add a new shader to the shader store
  118468. * @param name the name of the shader
  118469. * @param pixelShader optional pixel shader content
  118470. * @param vertexShader optional vertex shader content
  118471. */
  118472. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118473. /**
  118474. * Store of each shader (The can be looked up using effect.key)
  118475. */
  118476. static ShadersStore: {
  118477. [key: string]: string;
  118478. };
  118479. /**
  118480. * Store of each included file for a shader (The can be looked up using effect.key)
  118481. */
  118482. static IncludesShadersStore: {
  118483. [key: string]: string;
  118484. };
  118485. /**
  118486. * Resets the cache of effects.
  118487. */
  118488. static ResetCache(): void;
  118489. }
  118490. }
  118491. declare module BABYLON {
  118492. /**
  118493. * Interface used to describe the capabilities of the engine relatively to the current browser
  118494. */
  118495. export interface EngineCapabilities {
  118496. /** Maximum textures units per fragment shader */
  118497. maxTexturesImageUnits: number;
  118498. /** Maximum texture units per vertex shader */
  118499. maxVertexTextureImageUnits: number;
  118500. /** Maximum textures units in the entire pipeline */
  118501. maxCombinedTexturesImageUnits: number;
  118502. /** Maximum texture size */
  118503. maxTextureSize: number;
  118504. /** Maximum texture samples */
  118505. maxSamples?: number;
  118506. /** Maximum cube texture size */
  118507. maxCubemapTextureSize: number;
  118508. /** Maximum render texture size */
  118509. maxRenderTextureSize: number;
  118510. /** Maximum number of vertex attributes */
  118511. maxVertexAttribs: number;
  118512. /** Maximum number of varyings */
  118513. maxVaryingVectors: number;
  118514. /** Maximum number of uniforms per vertex shader */
  118515. maxVertexUniformVectors: number;
  118516. /** Maximum number of uniforms per fragment shader */
  118517. maxFragmentUniformVectors: number;
  118518. /** Defines if standard derivates (dx/dy) are supported */
  118519. standardDerivatives: boolean;
  118520. /** Defines if s3tc texture compression is supported */
  118521. s3tc?: WEBGL_compressed_texture_s3tc;
  118522. /** Defines if pvrtc texture compression is supported */
  118523. pvrtc: any;
  118524. /** Defines if etc1 texture compression is supported */
  118525. etc1: any;
  118526. /** Defines if etc2 texture compression is supported */
  118527. etc2: any;
  118528. /** Defines if astc texture compression is supported */
  118529. astc: any;
  118530. /** Defines if bptc texture compression is supported */
  118531. bptc: any;
  118532. /** Defines if float textures are supported */
  118533. textureFloat: boolean;
  118534. /** Defines if vertex array objects are supported */
  118535. vertexArrayObject: boolean;
  118536. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118537. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118538. /** Gets the maximum level of anisotropy supported */
  118539. maxAnisotropy: number;
  118540. /** Defines if instancing is supported */
  118541. instancedArrays: boolean;
  118542. /** Defines if 32 bits indices are supported */
  118543. uintIndices: boolean;
  118544. /** Defines if high precision shaders are supported */
  118545. highPrecisionShaderSupported: boolean;
  118546. /** Defines if depth reading in the fragment shader is supported */
  118547. fragmentDepthSupported: boolean;
  118548. /** Defines if float texture linear filtering is supported*/
  118549. textureFloatLinearFiltering: boolean;
  118550. /** Defines if rendering to float textures is supported */
  118551. textureFloatRender: boolean;
  118552. /** Defines if half float textures are supported*/
  118553. textureHalfFloat: boolean;
  118554. /** Defines if half float texture linear filtering is supported*/
  118555. textureHalfFloatLinearFiltering: boolean;
  118556. /** Defines if rendering to half float textures is supported */
  118557. textureHalfFloatRender: boolean;
  118558. /** Defines if textureLOD shader command is supported */
  118559. textureLOD: boolean;
  118560. /** Defines if draw buffers extension is supported */
  118561. drawBuffersExtension: boolean;
  118562. /** Defines if depth textures are supported */
  118563. depthTextureExtension: boolean;
  118564. /** Defines if float color buffer are supported */
  118565. colorBufferFloat: boolean;
  118566. /** Gets disjoint timer query extension (null if not supported) */
  118567. timerQuery?: EXT_disjoint_timer_query;
  118568. /** Defines if timestamp can be used with timer query */
  118569. canUseTimestampForTimerQuery: boolean;
  118570. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118571. multiview?: any;
  118572. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118573. oculusMultiview?: any;
  118574. /** Function used to let the system compiles shaders in background */
  118575. parallelShaderCompile?: {
  118576. COMPLETION_STATUS_KHR: number;
  118577. };
  118578. /** Max number of texture samples for MSAA */
  118579. maxMSAASamples: number;
  118580. /** Defines if the blend min max extension is supported */
  118581. blendMinMax: boolean;
  118582. }
  118583. }
  118584. declare module BABYLON {
  118585. /**
  118586. * @hidden
  118587. **/
  118588. export class DepthCullingState {
  118589. private _isDepthTestDirty;
  118590. private _isDepthMaskDirty;
  118591. private _isDepthFuncDirty;
  118592. private _isCullFaceDirty;
  118593. private _isCullDirty;
  118594. private _isZOffsetDirty;
  118595. private _isFrontFaceDirty;
  118596. private _depthTest;
  118597. private _depthMask;
  118598. private _depthFunc;
  118599. private _cull;
  118600. private _cullFace;
  118601. private _zOffset;
  118602. private _frontFace;
  118603. /**
  118604. * Initializes the state.
  118605. */
  118606. constructor();
  118607. get isDirty(): boolean;
  118608. get zOffset(): number;
  118609. set zOffset(value: number);
  118610. get cullFace(): Nullable<number>;
  118611. set cullFace(value: Nullable<number>);
  118612. get cull(): Nullable<boolean>;
  118613. set cull(value: Nullable<boolean>);
  118614. get depthFunc(): Nullable<number>;
  118615. set depthFunc(value: Nullable<number>);
  118616. get depthMask(): boolean;
  118617. set depthMask(value: boolean);
  118618. get depthTest(): boolean;
  118619. set depthTest(value: boolean);
  118620. get frontFace(): Nullable<number>;
  118621. set frontFace(value: Nullable<number>);
  118622. reset(): void;
  118623. apply(gl: WebGLRenderingContext): void;
  118624. }
  118625. }
  118626. declare module BABYLON {
  118627. /**
  118628. * @hidden
  118629. **/
  118630. export class StencilState {
  118631. /** 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 */
  118632. static readonly ALWAYS: number;
  118633. /** Passed to stencilOperation to specify that stencil value must be kept */
  118634. static readonly KEEP: number;
  118635. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118636. static readonly REPLACE: number;
  118637. private _isStencilTestDirty;
  118638. private _isStencilMaskDirty;
  118639. private _isStencilFuncDirty;
  118640. private _isStencilOpDirty;
  118641. private _stencilTest;
  118642. private _stencilMask;
  118643. private _stencilFunc;
  118644. private _stencilFuncRef;
  118645. private _stencilFuncMask;
  118646. private _stencilOpStencilFail;
  118647. private _stencilOpDepthFail;
  118648. private _stencilOpStencilDepthPass;
  118649. get isDirty(): boolean;
  118650. get stencilFunc(): number;
  118651. set stencilFunc(value: number);
  118652. get stencilFuncRef(): number;
  118653. set stencilFuncRef(value: number);
  118654. get stencilFuncMask(): number;
  118655. set stencilFuncMask(value: number);
  118656. get stencilOpStencilFail(): number;
  118657. set stencilOpStencilFail(value: number);
  118658. get stencilOpDepthFail(): number;
  118659. set stencilOpDepthFail(value: number);
  118660. get stencilOpStencilDepthPass(): number;
  118661. set stencilOpStencilDepthPass(value: number);
  118662. get stencilMask(): number;
  118663. set stencilMask(value: number);
  118664. get stencilTest(): boolean;
  118665. set stencilTest(value: boolean);
  118666. constructor();
  118667. reset(): void;
  118668. apply(gl: WebGLRenderingContext): void;
  118669. }
  118670. }
  118671. declare module BABYLON {
  118672. /**
  118673. * @hidden
  118674. **/
  118675. export class AlphaState {
  118676. private _isAlphaBlendDirty;
  118677. private _isBlendFunctionParametersDirty;
  118678. private _isBlendEquationParametersDirty;
  118679. private _isBlendConstantsDirty;
  118680. private _alphaBlend;
  118681. private _blendFunctionParameters;
  118682. private _blendEquationParameters;
  118683. private _blendConstants;
  118684. /**
  118685. * Initializes the state.
  118686. */
  118687. constructor();
  118688. get isDirty(): boolean;
  118689. get alphaBlend(): boolean;
  118690. set alphaBlend(value: boolean);
  118691. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118692. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118693. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118694. reset(): void;
  118695. apply(gl: WebGLRenderingContext): void;
  118696. }
  118697. }
  118698. declare module BABYLON {
  118699. /** @hidden */
  118700. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118701. attributeProcessor(attribute: string): string;
  118702. varyingProcessor(varying: string, isFragment: boolean): string;
  118703. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118704. }
  118705. }
  118706. declare module BABYLON {
  118707. /**
  118708. * Interface for attribute information associated with buffer instanciation
  118709. */
  118710. export interface InstancingAttributeInfo {
  118711. /**
  118712. * Name of the GLSL attribute
  118713. * if attribute index is not specified, this is used to retrieve the index from the effect
  118714. */
  118715. attributeName: string;
  118716. /**
  118717. * Index/offset of the attribute in the vertex shader
  118718. * if not specified, this will be computes from the name.
  118719. */
  118720. index?: number;
  118721. /**
  118722. * size of the attribute, 1, 2, 3 or 4
  118723. */
  118724. attributeSize: number;
  118725. /**
  118726. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  118727. */
  118728. offset: number;
  118729. /**
  118730. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  118731. * default to 1
  118732. */
  118733. divisor?: number;
  118734. /**
  118735. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  118736. * default is FLOAT
  118737. */
  118738. attributeType?: number;
  118739. /**
  118740. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  118741. */
  118742. normalized?: boolean;
  118743. }
  118744. }
  118745. declare module BABYLON {
  118746. interface ThinEngine {
  118747. /**
  118748. * Update a video texture
  118749. * @param texture defines the texture to update
  118750. * @param video defines the video element to use
  118751. * @param invertY defines if data must be stored with Y axis inverted
  118752. */
  118753. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  118754. }
  118755. }
  118756. declare module BABYLON {
  118757. interface ThinEngine {
  118758. /**
  118759. * Creates a dynamic texture
  118760. * @param width defines the width of the texture
  118761. * @param height defines the height of the texture
  118762. * @param generateMipMaps defines if the engine should generate the mip levels
  118763. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  118764. * @returns the dynamic texture inside an InternalTexture
  118765. */
  118766. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  118767. /**
  118768. * Update the content of a dynamic texture
  118769. * @param texture defines the texture to update
  118770. * @param canvas defines the canvas containing the source
  118771. * @param invertY defines if data must be stored with Y axis inverted
  118772. * @param premulAlpha defines if alpha is stored as premultiplied
  118773. * @param format defines the format of the data
  118774. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  118775. */
  118776. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  118777. }
  118778. }
  118779. declare module BABYLON {
  118780. /**
  118781. * Settings for finer control over video usage
  118782. */
  118783. export interface VideoTextureSettings {
  118784. /**
  118785. * Applies `autoplay` to video, if specified
  118786. */
  118787. autoPlay?: boolean;
  118788. /**
  118789. * Applies `muted` to video, if specified
  118790. */
  118791. muted?: boolean;
  118792. /**
  118793. * Applies `loop` to video, if specified
  118794. */
  118795. loop?: boolean;
  118796. /**
  118797. * Automatically updates internal texture from video at every frame in the render loop
  118798. */
  118799. autoUpdateTexture: boolean;
  118800. /**
  118801. * Image src displayed during the video loading or until the user interacts with the video.
  118802. */
  118803. poster?: string;
  118804. }
  118805. /**
  118806. * If you want to display a video in your scene, this is the special texture for that.
  118807. * This special texture works similar to other textures, with the exception of a few parameters.
  118808. * @see https://doc.babylonjs.com/how_to/video_texture
  118809. */
  118810. export class VideoTexture extends Texture {
  118811. /**
  118812. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  118813. */
  118814. readonly autoUpdateTexture: boolean;
  118815. /**
  118816. * The video instance used by the texture internally
  118817. */
  118818. readonly video: HTMLVideoElement;
  118819. private _onUserActionRequestedObservable;
  118820. /**
  118821. * Event triggerd when a dom action is required by the user to play the video.
  118822. * This happens due to recent changes in browser policies preventing video to auto start.
  118823. */
  118824. get onUserActionRequestedObservable(): Observable<Texture>;
  118825. private _generateMipMaps;
  118826. private _stillImageCaptured;
  118827. private _displayingPosterTexture;
  118828. private _settings;
  118829. private _createInternalTextureOnEvent;
  118830. private _frameId;
  118831. private _currentSrc;
  118832. /**
  118833. * Creates a video texture.
  118834. * If you want to display a video in your scene, this is the special texture for that.
  118835. * This special texture works similar to other textures, with the exception of a few parameters.
  118836. * @see https://doc.babylonjs.com/how_to/video_texture
  118837. * @param name optional name, will detect from video source, if not defined
  118838. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  118839. * @param scene is obviously the current scene.
  118840. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  118841. * @param invertY is false by default but can be used to invert video on Y axis
  118842. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  118843. * @param settings allows finer control over video usage
  118844. */
  118845. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  118846. private _getName;
  118847. private _getVideo;
  118848. private _createInternalTexture;
  118849. private reset;
  118850. /**
  118851. * @hidden Internal method to initiate `update`.
  118852. */
  118853. _rebuild(): void;
  118854. /**
  118855. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  118856. */
  118857. update(): void;
  118858. /**
  118859. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  118860. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  118861. */
  118862. updateTexture(isVisible: boolean): void;
  118863. protected _updateInternalTexture: () => void;
  118864. /**
  118865. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  118866. * @param url New url.
  118867. */
  118868. updateURL(url: string): void;
  118869. /**
  118870. * Clones the texture.
  118871. * @returns the cloned texture
  118872. */
  118873. clone(): VideoTexture;
  118874. /**
  118875. * Dispose the texture and release its associated resources.
  118876. */
  118877. dispose(): void;
  118878. /**
  118879. * Creates a video texture straight from a stream.
  118880. * @param scene Define the scene the texture should be created in
  118881. * @param stream Define the stream the texture should be created from
  118882. * @returns The created video texture as a promise
  118883. */
  118884. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  118885. /**
  118886. * Creates a video texture straight from your WebCam video feed.
  118887. * @param scene Define the scene the texture should be created in
  118888. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  118889. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  118890. * @returns The created video texture as a promise
  118891. */
  118892. static CreateFromWebCamAsync(scene: Scene, constraints: {
  118893. minWidth: number;
  118894. maxWidth: number;
  118895. minHeight: number;
  118896. maxHeight: number;
  118897. deviceId: string;
  118898. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  118899. /**
  118900. * Creates a video texture straight from your WebCam video feed.
  118901. * @param scene Define the scene the texture should be created in
  118902. * @param onReady Define a callback to triggered once the texture will be ready
  118903. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  118904. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  118905. */
  118906. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  118907. minWidth: number;
  118908. maxWidth: number;
  118909. minHeight: number;
  118910. maxHeight: number;
  118911. deviceId: string;
  118912. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  118913. }
  118914. }
  118915. declare module BABYLON {
  118916. /**
  118917. * Defines the interface used by objects working like Scene
  118918. * @hidden
  118919. */
  118920. export interface ISceneLike {
  118921. _addPendingData(data: any): void;
  118922. _removePendingData(data: any): void;
  118923. offlineProvider: IOfflineProvider;
  118924. }
  118925. /**
  118926. * Information about the current host
  118927. */
  118928. export interface HostInformation {
  118929. /**
  118930. * Defines if the current host is a mobile
  118931. */
  118932. isMobile: boolean;
  118933. }
  118934. /** Interface defining initialization parameters for Engine class */
  118935. export interface EngineOptions extends WebGLContextAttributes {
  118936. /**
  118937. * Defines if the engine should no exceed a specified device ratio
  118938. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  118939. */
  118940. limitDeviceRatio?: number;
  118941. /**
  118942. * Defines if webvr should be enabled automatically
  118943. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118944. */
  118945. autoEnableWebVR?: boolean;
  118946. /**
  118947. * Defines if webgl2 should be turned off even if supported
  118948. * @see https://doc.babylonjs.com/features/webgl2
  118949. */
  118950. disableWebGL2Support?: boolean;
  118951. /**
  118952. * Defines if webaudio should be initialized as well
  118953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118954. */
  118955. audioEngine?: boolean;
  118956. /**
  118957. * Defines if animations should run using a deterministic lock step
  118958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118959. */
  118960. deterministicLockstep?: boolean;
  118961. /** Defines the maximum steps to use with deterministic lock step mode */
  118962. lockstepMaxSteps?: number;
  118963. /** Defines the seconds between each deterministic lock step */
  118964. timeStep?: number;
  118965. /**
  118966. * Defines that engine should ignore context lost events
  118967. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  118968. */
  118969. doNotHandleContextLost?: boolean;
  118970. /**
  118971. * Defines that engine should ignore modifying touch action attribute and style
  118972. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  118973. */
  118974. doNotHandleTouchAction?: boolean;
  118975. /**
  118976. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  118977. */
  118978. useHighPrecisionFloats?: boolean;
  118979. /**
  118980. * Make the canvas XR Compatible for XR sessions
  118981. */
  118982. xrCompatible?: boolean;
  118983. /**
  118984. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  118985. */
  118986. useHighPrecisionMatrix?: boolean;
  118987. /**
  118988. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  118989. */
  118990. failIfMajorPerformanceCaveat?: boolean;
  118991. }
  118992. /**
  118993. * The base engine class (root of all engines)
  118994. */
  118995. export class ThinEngine {
  118996. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  118997. static ExceptionList: ({
  118998. key: string;
  118999. capture: string;
  119000. captureConstraint: number;
  119001. targets: string[];
  119002. } | {
  119003. key: string;
  119004. capture: null;
  119005. captureConstraint: null;
  119006. targets: string[];
  119007. })[];
  119008. /** @hidden */
  119009. static _TextureLoaders: IInternalTextureLoader[];
  119010. /**
  119011. * Returns the current npm package of the sdk
  119012. */
  119013. static get NpmPackage(): string;
  119014. /**
  119015. * Returns the current version of the framework
  119016. */
  119017. static get Version(): string;
  119018. /**
  119019. * Returns a string describing the current engine
  119020. */
  119021. get description(): string;
  119022. /**
  119023. * Gets or sets the epsilon value used by collision engine
  119024. */
  119025. static CollisionsEpsilon: number;
  119026. /**
  119027. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119028. */
  119029. static get ShadersRepository(): string;
  119030. static set ShadersRepository(value: string);
  119031. /** @hidden */
  119032. _shaderProcessor: IShaderProcessor;
  119033. /**
  119034. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119035. */
  119036. forcePOTTextures: boolean;
  119037. /**
  119038. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119039. */
  119040. isFullscreen: boolean;
  119041. /**
  119042. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119043. */
  119044. cullBackFaces: boolean;
  119045. /**
  119046. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119047. */
  119048. renderEvenInBackground: boolean;
  119049. /**
  119050. * Gets or sets a boolean indicating that cache can be kept between frames
  119051. */
  119052. preventCacheWipeBetweenFrames: boolean;
  119053. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119054. validateShaderPrograms: boolean;
  119055. /**
  119056. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119057. * This can provide greater z depth for distant objects.
  119058. */
  119059. useReverseDepthBuffer: boolean;
  119060. /**
  119061. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119062. */
  119063. disableUniformBuffers: boolean;
  119064. /** @hidden */
  119065. _uniformBuffers: UniformBuffer[];
  119066. /**
  119067. * Gets a boolean indicating that the engine supports uniform buffers
  119068. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119069. */
  119070. get supportsUniformBuffers(): boolean;
  119071. /** @hidden */
  119072. _gl: WebGLRenderingContext;
  119073. /** @hidden */
  119074. _webGLVersion: number;
  119075. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119076. protected _windowIsBackground: boolean;
  119077. protected _creationOptions: EngineOptions;
  119078. protected _highPrecisionShadersAllowed: boolean;
  119079. /** @hidden */
  119080. get _shouldUseHighPrecisionShader(): boolean;
  119081. /**
  119082. * Gets a boolean indicating that only power of 2 textures are supported
  119083. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119084. */
  119085. get needPOTTextures(): boolean;
  119086. /** @hidden */
  119087. _badOS: boolean;
  119088. /** @hidden */
  119089. _badDesktopOS: boolean;
  119090. private _hardwareScalingLevel;
  119091. /** @hidden */
  119092. _caps: EngineCapabilities;
  119093. private _isStencilEnable;
  119094. private _glVersion;
  119095. private _glRenderer;
  119096. private _glVendor;
  119097. /** @hidden */
  119098. _videoTextureSupported: boolean;
  119099. protected _renderingQueueLaunched: boolean;
  119100. protected _activeRenderLoops: (() => void)[];
  119101. /**
  119102. * Observable signaled when a context lost event is raised
  119103. */
  119104. onContextLostObservable: Observable<ThinEngine>;
  119105. /**
  119106. * Observable signaled when a context restored event is raised
  119107. */
  119108. onContextRestoredObservable: Observable<ThinEngine>;
  119109. private _onContextLost;
  119110. private _onContextRestored;
  119111. protected _contextWasLost: boolean;
  119112. /** @hidden */
  119113. _doNotHandleContextLost: boolean;
  119114. /**
  119115. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119116. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119117. */
  119118. get doNotHandleContextLost(): boolean;
  119119. set doNotHandleContextLost(value: boolean);
  119120. /**
  119121. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119122. */
  119123. disableVertexArrayObjects: boolean;
  119124. /** @hidden */
  119125. protected _colorWrite: boolean;
  119126. /** @hidden */
  119127. protected _colorWriteChanged: boolean;
  119128. /** @hidden */
  119129. protected _depthCullingState: DepthCullingState;
  119130. /** @hidden */
  119131. protected _stencilState: StencilState;
  119132. /** @hidden */
  119133. _alphaState: AlphaState;
  119134. /** @hidden */
  119135. _alphaMode: number;
  119136. /** @hidden */
  119137. _alphaEquation: number;
  119138. /** @hidden */
  119139. _internalTexturesCache: InternalTexture[];
  119140. /** @hidden */
  119141. protected _activeChannel: number;
  119142. private _currentTextureChannel;
  119143. /** @hidden */
  119144. protected _boundTexturesCache: {
  119145. [key: string]: Nullable<InternalTexture>;
  119146. };
  119147. /** @hidden */
  119148. protected _currentEffect: Nullable<Effect>;
  119149. /** @hidden */
  119150. protected _currentProgram: Nullable<WebGLProgram>;
  119151. private _compiledEffects;
  119152. private _vertexAttribArraysEnabled;
  119153. /** @hidden */
  119154. protected _cachedViewport: Nullable<IViewportLike>;
  119155. private _cachedVertexArrayObject;
  119156. /** @hidden */
  119157. protected _cachedVertexBuffers: any;
  119158. /** @hidden */
  119159. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119160. /** @hidden */
  119161. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119162. /** @hidden */
  119163. _currentRenderTarget: Nullable<InternalTexture>;
  119164. private _uintIndicesCurrentlySet;
  119165. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119166. /** @hidden */
  119167. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119168. /** @hidden */
  119169. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119170. private _currentBufferPointers;
  119171. private _currentInstanceLocations;
  119172. private _currentInstanceBuffers;
  119173. private _textureUnits;
  119174. /** @hidden */
  119175. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119176. /** @hidden */
  119177. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119178. /** @hidden */
  119179. _boundRenderFunction: any;
  119180. private _vaoRecordInProgress;
  119181. private _mustWipeVertexAttributes;
  119182. private _emptyTexture;
  119183. private _emptyCubeTexture;
  119184. private _emptyTexture3D;
  119185. private _emptyTexture2DArray;
  119186. /** @hidden */
  119187. _frameHandler: number;
  119188. private _nextFreeTextureSlots;
  119189. private _maxSimultaneousTextures;
  119190. private _activeRequests;
  119191. /** @hidden */
  119192. _transformTextureUrl: Nullable<(url: string) => string>;
  119193. /**
  119194. * Gets information about the current host
  119195. */
  119196. hostInformation: HostInformation;
  119197. protected get _supportsHardwareTextureRescaling(): boolean;
  119198. private _framebufferDimensionsObject;
  119199. /**
  119200. * sets the object from which width and height will be taken from when getting render width and height
  119201. * Will fallback to the gl object
  119202. * @param dimensions the framebuffer width and height that will be used.
  119203. */
  119204. set framebufferDimensionsObject(dimensions: Nullable<{
  119205. framebufferWidth: number;
  119206. framebufferHeight: number;
  119207. }>);
  119208. /**
  119209. * Gets the current viewport
  119210. */
  119211. get currentViewport(): Nullable<IViewportLike>;
  119212. /**
  119213. * Gets the default empty texture
  119214. */
  119215. get emptyTexture(): InternalTexture;
  119216. /**
  119217. * Gets the default empty 3D texture
  119218. */
  119219. get emptyTexture3D(): InternalTexture;
  119220. /**
  119221. * Gets the default empty 2D array texture
  119222. */
  119223. get emptyTexture2DArray(): InternalTexture;
  119224. /**
  119225. * Gets the default empty cube texture
  119226. */
  119227. get emptyCubeTexture(): InternalTexture;
  119228. /**
  119229. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119230. */
  119231. readonly premultipliedAlpha: boolean;
  119232. /**
  119233. * Observable event triggered before each texture is initialized
  119234. */
  119235. onBeforeTextureInitObservable: Observable<Texture>;
  119236. /**
  119237. * Creates a new engine
  119238. * @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
  119239. * @param antialias defines enable antialiasing (default: false)
  119240. * @param options defines further options to be sent to the getContext() function
  119241. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119242. */
  119243. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119244. private _rebuildInternalTextures;
  119245. private _rebuildEffects;
  119246. /**
  119247. * Gets a boolean indicating if all created effects are ready
  119248. * @returns true if all effects are ready
  119249. */
  119250. areAllEffectsReady(): boolean;
  119251. protected _rebuildBuffers(): void;
  119252. protected _initGLContext(): void;
  119253. /**
  119254. * Gets version of the current webGL context
  119255. */
  119256. get webGLVersion(): number;
  119257. /**
  119258. * Gets a string identifying the name of the class
  119259. * @returns "Engine" string
  119260. */
  119261. getClassName(): string;
  119262. /**
  119263. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119264. */
  119265. get isStencilEnable(): boolean;
  119266. /** @hidden */
  119267. _prepareWorkingCanvas(): void;
  119268. /**
  119269. * Reset the texture cache to empty state
  119270. */
  119271. resetTextureCache(): void;
  119272. /**
  119273. * Gets an object containing information about the current webGL context
  119274. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119275. */
  119276. getGlInfo(): {
  119277. vendor: string;
  119278. renderer: string;
  119279. version: string;
  119280. };
  119281. /**
  119282. * Defines the hardware scaling level.
  119283. * By default the hardware scaling level is computed from the window device ratio.
  119284. * 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.
  119285. * @param level defines the level to use
  119286. */
  119287. setHardwareScalingLevel(level: number): void;
  119288. /**
  119289. * Gets the current hardware scaling level.
  119290. * By default the hardware scaling level is computed from the window device ratio.
  119291. * 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.
  119292. * @returns a number indicating the current hardware scaling level
  119293. */
  119294. getHardwareScalingLevel(): number;
  119295. /**
  119296. * Gets the list of loaded textures
  119297. * @returns an array containing all loaded textures
  119298. */
  119299. getLoadedTexturesCache(): InternalTexture[];
  119300. /**
  119301. * Gets the object containing all engine capabilities
  119302. * @returns the EngineCapabilities object
  119303. */
  119304. getCaps(): EngineCapabilities;
  119305. /**
  119306. * stop executing a render loop function and remove it from the execution array
  119307. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119308. */
  119309. stopRenderLoop(renderFunction?: () => void): void;
  119310. /** @hidden */
  119311. _renderLoop(): void;
  119312. /**
  119313. * Gets the HTML canvas attached with the current webGL context
  119314. * @returns a HTML canvas
  119315. */
  119316. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119317. /**
  119318. * Gets host window
  119319. * @returns the host window object
  119320. */
  119321. getHostWindow(): Nullable<Window>;
  119322. /**
  119323. * Gets the current render width
  119324. * @param useScreen defines if screen size must be used (or the current render target if any)
  119325. * @returns a number defining the current render width
  119326. */
  119327. getRenderWidth(useScreen?: boolean): number;
  119328. /**
  119329. * Gets the current render height
  119330. * @param useScreen defines if screen size must be used (or the current render target if any)
  119331. * @returns a number defining the current render height
  119332. */
  119333. getRenderHeight(useScreen?: boolean): number;
  119334. /**
  119335. * Can be used to override the current requestAnimationFrame requester.
  119336. * @hidden
  119337. */
  119338. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119339. /**
  119340. * Register and execute a render loop. The engine can have more than one render function
  119341. * @param renderFunction defines the function to continuously execute
  119342. */
  119343. runRenderLoop(renderFunction: () => void): void;
  119344. /**
  119345. * Clear the current render buffer or the current render target (if any is set up)
  119346. * @param color defines the color to use
  119347. * @param backBuffer defines if the back buffer must be cleared
  119348. * @param depth defines if the depth buffer must be cleared
  119349. * @param stencil defines if the stencil buffer must be cleared
  119350. */
  119351. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119352. private _viewportCached;
  119353. /** @hidden */
  119354. _viewport(x: number, y: number, width: number, height: number): void;
  119355. /**
  119356. * Set the WebGL's viewport
  119357. * @param viewport defines the viewport element to be used
  119358. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119359. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119360. */
  119361. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119362. /**
  119363. * Begin a new frame
  119364. */
  119365. beginFrame(): void;
  119366. /**
  119367. * Enf the current frame
  119368. */
  119369. endFrame(): void;
  119370. /**
  119371. * Resize the view according to the canvas' size
  119372. */
  119373. resize(): void;
  119374. /**
  119375. * Force a specific size of the canvas
  119376. * @param width defines the new canvas' width
  119377. * @param height defines the new canvas' height
  119378. * @returns true if the size was changed
  119379. */
  119380. setSize(width: number, height: number): boolean;
  119381. /**
  119382. * Binds the frame buffer to the specified texture.
  119383. * @param texture The texture to render to or null for the default canvas
  119384. * @param faceIndex The face of the texture to render to in case of cube texture
  119385. * @param requiredWidth The width of the target to render to
  119386. * @param requiredHeight The height of the target to render to
  119387. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119388. * @param lodLevel defines the lod level to bind to the frame buffer
  119389. * @param layer defines the 2d array index to bind to frame buffer to
  119390. */
  119391. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119392. /** @hidden */
  119393. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119394. /**
  119395. * Unbind the current render target texture from the webGL context
  119396. * @param texture defines the render target texture to unbind
  119397. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119398. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119399. */
  119400. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119401. /**
  119402. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119403. */
  119404. flushFramebuffer(): void;
  119405. /**
  119406. * Unbind the current render target and bind the default framebuffer
  119407. */
  119408. restoreDefaultFramebuffer(): void;
  119409. /** @hidden */
  119410. protected _resetVertexBufferBinding(): void;
  119411. /**
  119412. * Creates a vertex buffer
  119413. * @param data the data for the vertex buffer
  119414. * @returns the new WebGL static buffer
  119415. */
  119416. createVertexBuffer(data: DataArray): DataBuffer;
  119417. private _createVertexBuffer;
  119418. /**
  119419. * Creates a dynamic vertex buffer
  119420. * @param data the data for the dynamic vertex buffer
  119421. * @returns the new WebGL dynamic buffer
  119422. */
  119423. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119424. protected _resetIndexBufferBinding(): void;
  119425. /**
  119426. * Creates a new index buffer
  119427. * @param indices defines the content of the index buffer
  119428. * @param updatable defines if the index buffer must be updatable
  119429. * @returns a new webGL buffer
  119430. */
  119431. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119432. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119433. /**
  119434. * Bind a webGL buffer to the webGL context
  119435. * @param buffer defines the buffer to bind
  119436. */
  119437. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119438. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119439. private bindBuffer;
  119440. /**
  119441. * update the bound buffer with the given data
  119442. * @param data defines the data to update
  119443. */
  119444. updateArrayBuffer(data: Float32Array): void;
  119445. private _vertexAttribPointer;
  119446. /** @hidden */
  119447. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119448. private _bindVertexBuffersAttributes;
  119449. /**
  119450. * Records a vertex array object
  119451. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119452. * @param vertexBuffers defines the list of vertex buffers to store
  119453. * @param indexBuffer defines the index buffer to store
  119454. * @param effect defines the effect to store
  119455. * @returns the new vertex array object
  119456. */
  119457. recordVertexArrayObject(vertexBuffers: {
  119458. [key: string]: VertexBuffer;
  119459. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119460. /**
  119461. * Bind a specific vertex array object
  119462. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119463. * @param vertexArrayObject defines the vertex array object to bind
  119464. * @param indexBuffer defines the index buffer to bind
  119465. */
  119466. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119467. /**
  119468. * Bind webGl buffers directly to the webGL context
  119469. * @param vertexBuffer defines the vertex buffer to bind
  119470. * @param indexBuffer defines the index buffer to bind
  119471. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119472. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119473. * @param effect defines the effect associated with the vertex buffer
  119474. */
  119475. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119476. private _unbindVertexArrayObject;
  119477. /**
  119478. * Bind a list of vertex buffers to the webGL context
  119479. * @param vertexBuffers defines the list of vertex buffers to bind
  119480. * @param indexBuffer defines the index buffer to bind
  119481. * @param effect defines the effect associated with the vertex buffers
  119482. */
  119483. bindBuffers(vertexBuffers: {
  119484. [key: string]: Nullable<VertexBuffer>;
  119485. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119486. /**
  119487. * Unbind all instance attributes
  119488. */
  119489. unbindInstanceAttributes(): void;
  119490. /**
  119491. * Release and free the memory of a vertex array object
  119492. * @param vao defines the vertex array object to delete
  119493. */
  119494. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119495. /** @hidden */
  119496. _releaseBuffer(buffer: DataBuffer): boolean;
  119497. protected _deleteBuffer(buffer: DataBuffer): void;
  119498. /**
  119499. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119500. * @param instancesBuffer defines the webGL buffer to update and bind
  119501. * @param data defines the data to store in the buffer
  119502. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119503. */
  119504. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119505. /**
  119506. * Bind the content of a webGL buffer used with instantiation
  119507. * @param instancesBuffer defines the webGL buffer to bind
  119508. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119509. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119510. */
  119511. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119512. /**
  119513. * Disable the instance attribute corresponding to the name in parameter
  119514. * @param name defines the name of the attribute to disable
  119515. */
  119516. disableInstanceAttributeByName(name: string): void;
  119517. /**
  119518. * Disable the instance attribute corresponding to the location in parameter
  119519. * @param attributeLocation defines the attribute location of the attribute to disable
  119520. */
  119521. disableInstanceAttribute(attributeLocation: number): void;
  119522. /**
  119523. * Disable the attribute corresponding to the location in parameter
  119524. * @param attributeLocation defines the attribute location of the attribute to disable
  119525. */
  119526. disableAttributeByIndex(attributeLocation: number): void;
  119527. /**
  119528. * Send a draw order
  119529. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119530. * @param indexStart defines the starting index
  119531. * @param indexCount defines the number of index to draw
  119532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119533. */
  119534. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119535. /**
  119536. * Draw a list of points
  119537. * @param verticesStart defines the index of first vertex to draw
  119538. * @param verticesCount defines the count of vertices to draw
  119539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119540. */
  119541. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119542. /**
  119543. * Draw a list of unindexed primitives
  119544. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119545. * @param verticesStart defines the index of first vertex to draw
  119546. * @param verticesCount defines the count of vertices to draw
  119547. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119548. */
  119549. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119550. /**
  119551. * Draw a list of indexed primitives
  119552. * @param fillMode defines the primitive to use
  119553. * @param indexStart defines the starting index
  119554. * @param indexCount defines the number of index to draw
  119555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119556. */
  119557. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119558. /**
  119559. * Draw a list of unindexed primitives
  119560. * @param fillMode defines the primitive to use
  119561. * @param verticesStart defines the index of first vertex to draw
  119562. * @param verticesCount defines the count of vertices to draw
  119563. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119564. */
  119565. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119566. private _drawMode;
  119567. /** @hidden */
  119568. protected _reportDrawCall(): void;
  119569. /** @hidden */
  119570. _releaseEffect(effect: Effect): void;
  119571. /** @hidden */
  119572. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119573. /**
  119574. * Create a new effect (used to store vertex/fragment shaders)
  119575. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119576. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119577. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119578. * @param samplers defines an array of string used to represent textures
  119579. * @param defines defines the string containing the defines to use to compile the shaders
  119580. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119581. * @param onCompiled defines a function to call when the effect creation is successful
  119582. * @param onError defines a function to call when the effect creation has failed
  119583. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119584. * @returns the new Effect
  119585. */
  119586. 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;
  119587. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119588. private _compileShader;
  119589. private _compileRawShader;
  119590. /** @hidden */
  119591. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119592. /**
  119593. * Directly creates a webGL program
  119594. * @param pipelineContext defines the pipeline context to attach to
  119595. * @param vertexCode defines the vertex shader code to use
  119596. * @param fragmentCode defines the fragment shader code to use
  119597. * @param context defines the webGL context to use (if not set, the current one will be used)
  119598. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119599. * @returns the new webGL program
  119600. */
  119601. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119602. /**
  119603. * Creates a webGL program
  119604. * @param pipelineContext defines the pipeline context to attach to
  119605. * @param vertexCode defines the vertex shader code to use
  119606. * @param fragmentCode defines the fragment shader code to use
  119607. * @param defines defines the string containing the defines to use to compile the shaders
  119608. * @param context defines the webGL context to use (if not set, the current one will be used)
  119609. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119610. * @returns the new webGL program
  119611. */
  119612. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119613. /**
  119614. * Creates a new pipeline context
  119615. * @returns the new pipeline
  119616. */
  119617. createPipelineContext(): IPipelineContext;
  119618. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119619. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119620. /** @hidden */
  119621. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119622. /** @hidden */
  119623. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119624. /** @hidden */
  119625. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119626. /**
  119627. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119628. * @param pipelineContext defines the pipeline context to use
  119629. * @param uniformsNames defines the list of uniform names
  119630. * @returns an array of webGL uniform locations
  119631. */
  119632. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119633. /**
  119634. * Gets the lsit of active attributes for a given webGL program
  119635. * @param pipelineContext defines the pipeline context to use
  119636. * @param attributesNames defines the list of attribute names to get
  119637. * @returns an array of indices indicating the offset of each attribute
  119638. */
  119639. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119640. /**
  119641. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119642. * @param effect defines the effect to activate
  119643. */
  119644. enableEffect(effect: Nullable<Effect>): void;
  119645. /**
  119646. * Set the value of an uniform to a number (int)
  119647. * @param uniform defines the webGL uniform location where to store the value
  119648. * @param value defines the int number to store
  119649. * @returns true if the value was set
  119650. */
  119651. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119652. /**
  119653. * Set the value of an uniform to an array of int32
  119654. * @param uniform defines the webGL uniform location where to store the value
  119655. * @param array defines the array of int32 to store
  119656. * @returns true if the value was set
  119657. */
  119658. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119659. /**
  119660. * Set the value of an uniform to an array of int32 (stored as vec2)
  119661. * @param uniform defines the webGL uniform location where to store the value
  119662. * @param array defines the array of int32 to store
  119663. * @returns true if the value was set
  119664. */
  119665. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119666. /**
  119667. * Set the value of an uniform to an array of int32 (stored as vec3)
  119668. * @param uniform defines the webGL uniform location where to store the value
  119669. * @param array defines the array of int32 to store
  119670. * @returns true if the value was set
  119671. */
  119672. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119673. /**
  119674. * Set the value of an uniform to an array of int32 (stored as vec4)
  119675. * @param uniform defines the webGL uniform location where to store the value
  119676. * @param array defines the array of int32 to store
  119677. * @returns true if the value was set
  119678. */
  119679. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119680. /**
  119681. * Set the value of an uniform to an array of number
  119682. * @param uniform defines the webGL uniform location where to store the value
  119683. * @param array defines the array of number to store
  119684. * @returns true if the value was set
  119685. */
  119686. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119687. /**
  119688. * Set the value of an uniform to an array of number (stored as vec2)
  119689. * @param uniform defines the webGL uniform location where to store the value
  119690. * @param array defines the array of number to store
  119691. * @returns true if the value was set
  119692. */
  119693. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119694. /**
  119695. * Set the value of an uniform to an array of number (stored as vec3)
  119696. * @param uniform defines the webGL uniform location where to store the value
  119697. * @param array defines the array of number to store
  119698. * @returns true if the value was set
  119699. */
  119700. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119701. /**
  119702. * Set the value of an uniform to an array of number (stored as vec4)
  119703. * @param uniform defines the webGL uniform location where to store the value
  119704. * @param array defines the array of number to store
  119705. * @returns true if the value was set
  119706. */
  119707. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119708. /**
  119709. * Set the value of an uniform to an array of float32 (stored as matrices)
  119710. * @param uniform defines the webGL uniform location where to store the value
  119711. * @param matrices defines the array of float32 to store
  119712. * @returns true if the value was set
  119713. */
  119714. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  119715. /**
  119716. * Set the value of an uniform to a matrix (3x3)
  119717. * @param uniform defines the webGL uniform location where to store the value
  119718. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119719. * @returns true if the value was set
  119720. */
  119721. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119722. /**
  119723. * Set the value of an uniform to a matrix (2x2)
  119724. * @param uniform defines the webGL uniform location where to store the value
  119725. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119726. * @returns true if the value was set
  119727. */
  119728. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119729. /**
  119730. * Set the value of an uniform to a number (float)
  119731. * @param uniform defines the webGL uniform location where to store the value
  119732. * @param value defines the float number to store
  119733. * @returns true if the value was transfered
  119734. */
  119735. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119736. /**
  119737. * Set the value of an uniform to a vec2
  119738. * @param uniform defines the webGL uniform location where to store the value
  119739. * @param x defines the 1st component of the value
  119740. * @param y defines the 2nd component of the value
  119741. * @returns true if the value was set
  119742. */
  119743. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  119744. /**
  119745. * Set the value of an uniform to a vec3
  119746. * @param uniform defines the webGL uniform location where to store the value
  119747. * @param x defines the 1st component of the value
  119748. * @param y defines the 2nd component of the value
  119749. * @param z defines the 3rd component of the value
  119750. * @returns true if the value was set
  119751. */
  119752. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  119753. /**
  119754. * Set the value of an uniform to a vec4
  119755. * @param uniform defines the webGL uniform location where to store the value
  119756. * @param x defines the 1st component of the value
  119757. * @param y defines the 2nd component of the value
  119758. * @param z defines the 3rd component of the value
  119759. * @param w defines the 4th component of the value
  119760. * @returns true if the value was set
  119761. */
  119762. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  119763. /**
  119764. * Apply all cached states (depth, culling, stencil and alpha)
  119765. */
  119766. applyStates(): void;
  119767. /**
  119768. * Enable or disable color writing
  119769. * @param enable defines the state to set
  119770. */
  119771. setColorWrite(enable: boolean): void;
  119772. /**
  119773. * Gets a boolean indicating if color writing is enabled
  119774. * @returns the current color writing state
  119775. */
  119776. getColorWrite(): boolean;
  119777. /**
  119778. * Gets the depth culling state manager
  119779. */
  119780. get depthCullingState(): DepthCullingState;
  119781. /**
  119782. * Gets the alpha state manager
  119783. */
  119784. get alphaState(): AlphaState;
  119785. /**
  119786. * Gets the stencil state manager
  119787. */
  119788. get stencilState(): StencilState;
  119789. /**
  119790. * Clears the list of texture accessible through engine.
  119791. * This can help preventing texture load conflict due to name collision.
  119792. */
  119793. clearInternalTexturesCache(): void;
  119794. /**
  119795. * Force the entire cache to be cleared
  119796. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119797. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119798. */
  119799. wipeCaches(bruteForce?: boolean): void;
  119800. /** @hidden */
  119801. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  119802. min: number;
  119803. mag: number;
  119804. };
  119805. /** @hidden */
  119806. _createTexture(): WebGLTexture;
  119807. /**
  119808. * Usually called from Texture.ts.
  119809. * Passed information to create a WebGLTexture
  119810. * @param url defines a value which contains one of the following:
  119811. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119812. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119813. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119814. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119815. * @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)
  119816. * @param scene needed for loading to the correct scene
  119817. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119818. * @param onLoad optional callback to be called upon successful completion
  119819. * @param onError optional callback to be called upon failure
  119820. * @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
  119821. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119822. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119823. * @param forcedExtension defines the extension to use to pick the right loader
  119824. * @param mimeType defines an optional mime type
  119825. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119826. */
  119827. 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;
  119828. /**
  119829. * Loads an image as an HTMLImageElement.
  119830. * @param input url string, ArrayBuffer, or Blob to load
  119831. * @param onLoad callback called when the image successfully loads
  119832. * @param onError callback called when the image fails to load
  119833. * @param offlineProvider offline provider for caching
  119834. * @param mimeType optional mime type
  119835. * @returns the HTMLImageElement of the loaded image
  119836. * @hidden
  119837. */
  119838. 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>;
  119839. /**
  119840. * @hidden
  119841. */
  119842. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  119843. private _unpackFlipYCached;
  119844. /**
  119845. * In case you are sharing the context with other applications, it might
  119846. * be interested to not cache the unpack flip y state to ensure a consistent
  119847. * value would be set.
  119848. */
  119849. enableUnpackFlipYCached: boolean;
  119850. /** @hidden */
  119851. _unpackFlipY(value: boolean): void;
  119852. /** @hidden */
  119853. _getUnpackAlignement(): number;
  119854. private _getTextureTarget;
  119855. /**
  119856. * Update the sampling mode of a given texture
  119857. * @param samplingMode defines the required sampling mode
  119858. * @param texture defines the texture to update
  119859. * @param generateMipMaps defines whether to generate mipmaps for the texture
  119860. */
  119861. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  119862. /**
  119863. * Update the sampling mode of a given texture
  119864. * @param texture defines the texture to update
  119865. * @param wrapU defines the texture wrap mode of the u coordinates
  119866. * @param wrapV defines the texture wrap mode of the v coordinates
  119867. * @param wrapR defines the texture wrap mode of the r coordinates
  119868. */
  119869. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  119870. /** @hidden */
  119871. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  119872. width: number;
  119873. height: number;
  119874. layers?: number;
  119875. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  119876. /** @hidden */
  119877. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119878. /** @hidden */
  119879. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  119880. /**
  119881. * Update a portion of an internal texture
  119882. * @param texture defines the texture to update
  119883. * @param imageData defines the data to store into the texture
  119884. * @param xOffset defines the x coordinates of the update rectangle
  119885. * @param yOffset defines the y coordinates of the update rectangle
  119886. * @param width defines the width of the update rectangle
  119887. * @param height defines the height of the update rectangle
  119888. * @param faceIndex defines the face index if texture is a cube (0 by default)
  119889. * @param lod defines the lod level to update (0 by default)
  119890. */
  119891. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  119892. /** @hidden */
  119893. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119894. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  119895. private _prepareWebGLTexture;
  119896. /** @hidden */
  119897. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  119898. private _getDepthStencilBuffer;
  119899. /** @hidden */
  119900. _releaseFramebufferObjects(texture: InternalTexture): void;
  119901. /** @hidden */
  119902. _releaseTexture(texture: InternalTexture): void;
  119903. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  119904. protected _setProgram(program: WebGLProgram): void;
  119905. protected _boundUniforms: {
  119906. [key: number]: WebGLUniformLocation;
  119907. };
  119908. /**
  119909. * Binds an effect to the webGL context
  119910. * @param effect defines the effect to bind
  119911. */
  119912. bindSamplers(effect: Effect): void;
  119913. private _activateCurrentTexture;
  119914. /** @hidden */
  119915. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  119916. /** @hidden */
  119917. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  119918. /**
  119919. * Unbind all textures from the webGL context
  119920. */
  119921. unbindAllTextures(): void;
  119922. /**
  119923. * Sets a texture to the according uniform.
  119924. * @param channel The texture channel
  119925. * @param uniform The uniform to set
  119926. * @param texture The texture to apply
  119927. */
  119928. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  119929. private _bindSamplerUniformToChannel;
  119930. private _getTextureWrapMode;
  119931. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  119932. /**
  119933. * Sets an array of texture to the webGL context
  119934. * @param channel defines the channel where the texture array must be set
  119935. * @param uniform defines the associated uniform location
  119936. * @param textures defines the array of textures to bind
  119937. */
  119938. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  119939. /** @hidden */
  119940. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  119941. private _setTextureParameterFloat;
  119942. private _setTextureParameterInteger;
  119943. /**
  119944. * Unbind all vertex attributes from the webGL context
  119945. */
  119946. unbindAllAttributes(): void;
  119947. /**
  119948. * 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
  119949. */
  119950. releaseEffects(): void;
  119951. /**
  119952. * Dispose and release all associated resources
  119953. */
  119954. dispose(): void;
  119955. /**
  119956. * Attach a new callback raised when context lost event is fired
  119957. * @param callback defines the callback to call
  119958. */
  119959. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  119960. /**
  119961. * Attach a new callback raised when context restored event is fired
  119962. * @param callback defines the callback to call
  119963. */
  119964. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  119965. /**
  119966. * Get the current error code of the webGL context
  119967. * @returns the error code
  119968. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119969. */
  119970. getError(): number;
  119971. private _canRenderToFloatFramebuffer;
  119972. private _canRenderToHalfFloatFramebuffer;
  119973. private _canRenderToFramebuffer;
  119974. /** @hidden */
  119975. _getWebGLTextureType(type: number): number;
  119976. /** @hidden */
  119977. _getInternalFormat(format: number): number;
  119978. /** @hidden */
  119979. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  119980. /** @hidden */
  119981. _getRGBAMultiSampleBufferFormat(type: number): number;
  119982. /** @hidden */
  119983. _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;
  119984. /**
  119985. * Loads a file from a url
  119986. * @param url url to load
  119987. * @param onSuccess callback called when the file successfully loads
  119988. * @param onProgress callback called while file is loading (if the server supports this mode)
  119989. * @param offlineProvider defines the offline provider for caching
  119990. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119991. * @param onError callback called when the file fails to load
  119992. * @returns a file request object
  119993. * @hidden
  119994. */
  119995. 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;
  119996. /**
  119997. * Reads pixels from the current frame buffer. Please note that this function can be slow
  119998. * @param x defines the x coordinate of the rectangle where pixels must be read
  119999. * @param y defines the y coordinate of the rectangle where pixels must be read
  120000. * @param width defines the width of the rectangle where pixels must be read
  120001. * @param height defines the height of the rectangle where pixels must be read
  120002. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120003. * @returns a Uint8Array containing RGBA colors
  120004. */
  120005. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120006. private static _IsSupported;
  120007. private static _HasMajorPerformanceCaveat;
  120008. /**
  120009. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120010. */
  120011. static get IsSupported(): boolean;
  120012. /**
  120013. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120014. * @returns true if the engine can be created
  120015. * @ignorenaming
  120016. */
  120017. static isSupported(): boolean;
  120018. /**
  120019. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  120020. */
  120021. static get HasMajorPerformanceCaveat(): boolean;
  120022. /**
  120023. * Find the next highest power of two.
  120024. * @param x Number to start search from.
  120025. * @return Next highest power of two.
  120026. */
  120027. static CeilingPOT(x: number): number;
  120028. /**
  120029. * Find the next lowest power of two.
  120030. * @param x Number to start search from.
  120031. * @return Next lowest power of two.
  120032. */
  120033. static FloorPOT(x: number): number;
  120034. /**
  120035. * Find the nearest power of two.
  120036. * @param x Number to start search from.
  120037. * @return Next nearest power of two.
  120038. */
  120039. static NearestPOT(x: number): number;
  120040. /**
  120041. * Get the closest exponent of two
  120042. * @param value defines the value to approximate
  120043. * @param max defines the maximum value to return
  120044. * @param mode defines how to define the closest value
  120045. * @returns closest exponent of two of the given value
  120046. */
  120047. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120048. /**
  120049. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120050. * @param func - the function to be called
  120051. * @param requester - the object that will request the next frame. Falls back to window.
  120052. * @returns frame number
  120053. */
  120054. static QueueNewFrame(func: () => void, requester?: any): number;
  120055. /**
  120056. * Gets host document
  120057. * @returns the host document object
  120058. */
  120059. getHostDocument(): Nullable<Document>;
  120060. }
  120061. }
  120062. declare module BABYLON {
  120063. /**
  120064. * Defines the source of the internal texture
  120065. */
  120066. export enum InternalTextureSource {
  120067. /**
  120068. * The source of the texture data is unknown
  120069. */
  120070. Unknown = 0,
  120071. /**
  120072. * Texture data comes from an URL
  120073. */
  120074. Url = 1,
  120075. /**
  120076. * Texture data is only used for temporary storage
  120077. */
  120078. Temp = 2,
  120079. /**
  120080. * Texture data comes from raw data (ArrayBuffer)
  120081. */
  120082. Raw = 3,
  120083. /**
  120084. * Texture content is dynamic (video or dynamic texture)
  120085. */
  120086. Dynamic = 4,
  120087. /**
  120088. * Texture content is generated by rendering to it
  120089. */
  120090. RenderTarget = 5,
  120091. /**
  120092. * Texture content is part of a multi render target process
  120093. */
  120094. MultiRenderTarget = 6,
  120095. /**
  120096. * Texture data comes from a cube data file
  120097. */
  120098. Cube = 7,
  120099. /**
  120100. * Texture data comes from a raw cube data
  120101. */
  120102. CubeRaw = 8,
  120103. /**
  120104. * Texture data come from a prefiltered cube data file
  120105. */
  120106. CubePrefiltered = 9,
  120107. /**
  120108. * Texture content is raw 3D data
  120109. */
  120110. Raw3D = 10,
  120111. /**
  120112. * Texture content is raw 2D array data
  120113. */
  120114. Raw2DArray = 11,
  120115. /**
  120116. * Texture content is a depth texture
  120117. */
  120118. Depth = 12,
  120119. /**
  120120. * Texture data comes from a raw cube data encoded with RGBD
  120121. */
  120122. CubeRawRGBD = 13
  120123. }
  120124. /**
  120125. * Class used to store data associated with WebGL texture data for the engine
  120126. * This class should not be used directly
  120127. */
  120128. export class InternalTexture {
  120129. /** @hidden */
  120130. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120131. /**
  120132. * Defines if the texture is ready
  120133. */
  120134. isReady: boolean;
  120135. /**
  120136. * Defines if the texture is a cube texture
  120137. */
  120138. isCube: boolean;
  120139. /**
  120140. * Defines if the texture contains 3D data
  120141. */
  120142. is3D: boolean;
  120143. /**
  120144. * Defines if the texture contains 2D array data
  120145. */
  120146. is2DArray: boolean;
  120147. /**
  120148. * Defines if the texture contains multiview data
  120149. */
  120150. isMultiview: boolean;
  120151. /**
  120152. * Gets the URL used to load this texture
  120153. */
  120154. url: string;
  120155. /**
  120156. * Gets the sampling mode of the texture
  120157. */
  120158. samplingMode: number;
  120159. /**
  120160. * Gets a boolean indicating if the texture needs mipmaps generation
  120161. */
  120162. generateMipMaps: boolean;
  120163. /**
  120164. * Gets the number of samples used by the texture (WebGL2+ only)
  120165. */
  120166. samples: number;
  120167. /**
  120168. * Gets the type of the texture (int, float...)
  120169. */
  120170. type: number;
  120171. /**
  120172. * Gets the format of the texture (RGB, RGBA...)
  120173. */
  120174. format: number;
  120175. /**
  120176. * Observable called when the texture is loaded
  120177. */
  120178. onLoadedObservable: Observable<InternalTexture>;
  120179. /**
  120180. * Gets the width of the texture
  120181. */
  120182. width: number;
  120183. /**
  120184. * Gets the height of the texture
  120185. */
  120186. height: number;
  120187. /**
  120188. * Gets the depth of the texture
  120189. */
  120190. depth: number;
  120191. /**
  120192. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120193. */
  120194. baseWidth: number;
  120195. /**
  120196. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120197. */
  120198. baseHeight: number;
  120199. /**
  120200. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120201. */
  120202. baseDepth: number;
  120203. /**
  120204. * Gets a boolean indicating if the texture is inverted on Y axis
  120205. */
  120206. invertY: boolean;
  120207. /** @hidden */
  120208. _invertVScale: boolean;
  120209. /** @hidden */
  120210. _associatedChannel: number;
  120211. /** @hidden */
  120212. _source: InternalTextureSource;
  120213. /** @hidden */
  120214. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120215. /** @hidden */
  120216. _bufferView: Nullable<ArrayBufferView>;
  120217. /** @hidden */
  120218. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120219. /** @hidden */
  120220. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120221. /** @hidden */
  120222. _size: number;
  120223. /** @hidden */
  120224. _extension: string;
  120225. /** @hidden */
  120226. _files: Nullable<string[]>;
  120227. /** @hidden */
  120228. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120229. /** @hidden */
  120230. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120231. /** @hidden */
  120232. _framebuffer: Nullable<WebGLFramebuffer>;
  120233. /** @hidden */
  120234. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120235. /** @hidden */
  120236. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120237. /** @hidden */
  120238. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120239. /** @hidden */
  120240. _attachments: Nullable<number[]>;
  120241. /** @hidden */
  120242. _textureArray: Nullable<InternalTexture[]>;
  120243. /** @hidden */
  120244. _cachedCoordinatesMode: Nullable<number>;
  120245. /** @hidden */
  120246. _cachedWrapU: Nullable<number>;
  120247. /** @hidden */
  120248. _cachedWrapV: Nullable<number>;
  120249. /** @hidden */
  120250. _cachedWrapR: Nullable<number>;
  120251. /** @hidden */
  120252. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120253. /** @hidden */
  120254. _isDisabled: boolean;
  120255. /** @hidden */
  120256. _compression: Nullable<string>;
  120257. /** @hidden */
  120258. _generateStencilBuffer: boolean;
  120259. /** @hidden */
  120260. _generateDepthBuffer: boolean;
  120261. /** @hidden */
  120262. _comparisonFunction: number;
  120263. /** @hidden */
  120264. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120265. /** @hidden */
  120266. _lodGenerationScale: number;
  120267. /** @hidden */
  120268. _lodGenerationOffset: number;
  120269. /** @hidden */
  120270. _depthStencilTexture: Nullable<InternalTexture>;
  120271. /** @hidden */
  120272. _colorTextureArray: Nullable<WebGLTexture>;
  120273. /** @hidden */
  120274. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120275. /** @hidden */
  120276. _lodTextureHigh: Nullable<BaseTexture>;
  120277. /** @hidden */
  120278. _lodTextureMid: Nullable<BaseTexture>;
  120279. /** @hidden */
  120280. _lodTextureLow: Nullable<BaseTexture>;
  120281. /** @hidden */
  120282. _isRGBD: boolean;
  120283. /** @hidden */
  120284. _linearSpecularLOD: boolean;
  120285. /** @hidden */
  120286. _irradianceTexture: Nullable<BaseTexture>;
  120287. /** @hidden */
  120288. _webGLTexture: Nullable<WebGLTexture>;
  120289. /** @hidden */
  120290. _references: number;
  120291. /** @hidden */
  120292. _gammaSpace: Nullable<boolean>;
  120293. private _engine;
  120294. /**
  120295. * Gets the Engine the texture belongs to.
  120296. * @returns The babylon engine
  120297. */
  120298. getEngine(): ThinEngine;
  120299. /**
  120300. * Gets the data source type of the texture
  120301. */
  120302. get source(): InternalTextureSource;
  120303. /**
  120304. * Creates a new InternalTexture
  120305. * @param engine defines the engine to use
  120306. * @param source defines the type of data that will be used
  120307. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120308. */
  120309. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120310. /**
  120311. * Increments the number of references (ie. the number of Texture that point to it)
  120312. */
  120313. incrementReferences(): void;
  120314. /**
  120315. * Change the size of the texture (not the size of the content)
  120316. * @param width defines the new width
  120317. * @param height defines the new height
  120318. * @param depth defines the new depth (1 by default)
  120319. */
  120320. updateSize(width: int, height: int, depth?: int): void;
  120321. /** @hidden */
  120322. _rebuild(): void;
  120323. /** @hidden */
  120324. _swapAndDie(target: InternalTexture): void;
  120325. /**
  120326. * Dispose the current allocated resources
  120327. */
  120328. dispose(): void;
  120329. }
  120330. }
  120331. declare module BABYLON {
  120332. /**
  120333. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120335. */
  120336. export class Analyser {
  120337. /**
  120338. * Gets or sets the smoothing
  120339. * @ignorenaming
  120340. */
  120341. SMOOTHING: number;
  120342. /**
  120343. * Gets or sets the FFT table size
  120344. * @ignorenaming
  120345. */
  120346. FFT_SIZE: number;
  120347. /**
  120348. * Gets or sets the bar graph amplitude
  120349. * @ignorenaming
  120350. */
  120351. BARGRAPHAMPLITUDE: number;
  120352. /**
  120353. * Gets or sets the position of the debug canvas
  120354. * @ignorenaming
  120355. */
  120356. DEBUGCANVASPOS: {
  120357. x: number;
  120358. y: number;
  120359. };
  120360. /**
  120361. * Gets or sets the debug canvas size
  120362. * @ignorenaming
  120363. */
  120364. DEBUGCANVASSIZE: {
  120365. width: number;
  120366. height: number;
  120367. };
  120368. private _byteFreqs;
  120369. private _byteTime;
  120370. private _floatFreqs;
  120371. private _webAudioAnalyser;
  120372. private _debugCanvas;
  120373. private _debugCanvasContext;
  120374. private _scene;
  120375. private _registerFunc;
  120376. private _audioEngine;
  120377. /**
  120378. * Creates a new analyser
  120379. * @param scene defines hosting scene
  120380. */
  120381. constructor(scene: Scene);
  120382. /**
  120383. * Get the number of data values you will have to play with for the visualization
  120384. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120385. * @returns a number
  120386. */
  120387. getFrequencyBinCount(): number;
  120388. /**
  120389. * Gets the current frequency data as a byte array
  120390. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120391. * @returns a Uint8Array
  120392. */
  120393. getByteFrequencyData(): Uint8Array;
  120394. /**
  120395. * Gets the current waveform as a byte array
  120396. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120397. * @returns a Uint8Array
  120398. */
  120399. getByteTimeDomainData(): Uint8Array;
  120400. /**
  120401. * Gets the current frequency data as a float array
  120402. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120403. * @returns a Float32Array
  120404. */
  120405. getFloatFrequencyData(): Float32Array;
  120406. /**
  120407. * Renders the debug canvas
  120408. */
  120409. drawDebugCanvas(): void;
  120410. /**
  120411. * Stops rendering the debug canvas and removes it
  120412. */
  120413. stopDebugCanvas(): void;
  120414. /**
  120415. * Connects two audio nodes
  120416. * @param inputAudioNode defines first node to connect
  120417. * @param outputAudioNode defines second node to connect
  120418. */
  120419. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120420. /**
  120421. * Releases all associated resources
  120422. */
  120423. dispose(): void;
  120424. }
  120425. }
  120426. declare module BABYLON {
  120427. /**
  120428. * This represents an audio engine and it is responsible
  120429. * to play, synchronize and analyse sounds throughout the application.
  120430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120431. */
  120432. export interface IAudioEngine extends IDisposable {
  120433. /**
  120434. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120435. */
  120436. readonly canUseWebAudio: boolean;
  120437. /**
  120438. * Gets the current AudioContext if available.
  120439. */
  120440. readonly audioContext: Nullable<AudioContext>;
  120441. /**
  120442. * The master gain node defines the global audio volume of your audio engine.
  120443. */
  120444. readonly masterGain: GainNode;
  120445. /**
  120446. * Gets whether or not mp3 are supported by your browser.
  120447. */
  120448. readonly isMP3supported: boolean;
  120449. /**
  120450. * Gets whether or not ogg are supported by your browser.
  120451. */
  120452. readonly isOGGsupported: boolean;
  120453. /**
  120454. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120455. * @ignoreNaming
  120456. */
  120457. WarnedWebAudioUnsupported: boolean;
  120458. /**
  120459. * Defines if the audio engine relies on a custom unlocked button.
  120460. * In this case, the embedded button will not be displayed.
  120461. */
  120462. useCustomUnlockedButton: boolean;
  120463. /**
  120464. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120465. */
  120466. readonly unlocked: boolean;
  120467. /**
  120468. * Event raised when audio has been unlocked on the browser.
  120469. */
  120470. onAudioUnlockedObservable: Observable<AudioEngine>;
  120471. /**
  120472. * Event raised when audio has been locked on the browser.
  120473. */
  120474. onAudioLockedObservable: Observable<AudioEngine>;
  120475. /**
  120476. * Flags the audio engine in Locked state.
  120477. * This happens due to new browser policies preventing audio to autoplay.
  120478. */
  120479. lock(): void;
  120480. /**
  120481. * Unlocks the audio engine once a user action has been done on the dom.
  120482. * This is helpful to resume play once browser policies have been satisfied.
  120483. */
  120484. unlock(): void;
  120485. /**
  120486. * Gets the global volume sets on the master gain.
  120487. * @returns the global volume if set or -1 otherwise
  120488. */
  120489. getGlobalVolume(): number;
  120490. /**
  120491. * Sets the global volume of your experience (sets on the master gain).
  120492. * @param newVolume Defines the new global volume of the application
  120493. */
  120494. setGlobalVolume(newVolume: number): void;
  120495. /**
  120496. * Connect the audio engine to an audio analyser allowing some amazing
  120497. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120498. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120499. * @param analyser The analyser to connect to the engine
  120500. */
  120501. connectToAnalyser(analyser: Analyser): void;
  120502. }
  120503. /**
  120504. * This represents the default audio engine used in babylon.
  120505. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120506. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120507. */
  120508. export class AudioEngine implements IAudioEngine {
  120509. private _audioContext;
  120510. private _audioContextInitialized;
  120511. private _muteButton;
  120512. private _hostElement;
  120513. /**
  120514. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120515. */
  120516. canUseWebAudio: boolean;
  120517. /**
  120518. * The master gain node defines the global audio volume of your audio engine.
  120519. */
  120520. masterGain: GainNode;
  120521. /**
  120522. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120523. * @ignoreNaming
  120524. */
  120525. WarnedWebAudioUnsupported: boolean;
  120526. /**
  120527. * Gets whether or not mp3 are supported by your browser.
  120528. */
  120529. isMP3supported: boolean;
  120530. /**
  120531. * Gets whether or not ogg are supported by your browser.
  120532. */
  120533. isOGGsupported: boolean;
  120534. /**
  120535. * Gets whether audio has been unlocked on the device.
  120536. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120537. * a user interaction has happened.
  120538. */
  120539. unlocked: boolean;
  120540. /**
  120541. * Defines if the audio engine relies on a custom unlocked button.
  120542. * In this case, the embedded button will not be displayed.
  120543. */
  120544. useCustomUnlockedButton: boolean;
  120545. /**
  120546. * Event raised when audio has been unlocked on the browser.
  120547. */
  120548. onAudioUnlockedObservable: Observable<AudioEngine>;
  120549. /**
  120550. * Event raised when audio has been locked on the browser.
  120551. */
  120552. onAudioLockedObservable: Observable<AudioEngine>;
  120553. /**
  120554. * Gets the current AudioContext if available.
  120555. */
  120556. get audioContext(): Nullable<AudioContext>;
  120557. private _connectedAnalyser;
  120558. /**
  120559. * Instantiates a new audio engine.
  120560. *
  120561. * There should be only one per page as some browsers restrict the number
  120562. * of audio contexts you can create.
  120563. * @param hostElement defines the host element where to display the mute icon if necessary
  120564. */
  120565. constructor(hostElement?: Nullable<HTMLElement>);
  120566. /**
  120567. * Flags the audio engine in Locked state.
  120568. * This happens due to new browser policies preventing audio to autoplay.
  120569. */
  120570. lock(): void;
  120571. /**
  120572. * Unlocks the audio engine once a user action has been done on the dom.
  120573. * This is helpful to resume play once browser policies have been satisfied.
  120574. */
  120575. unlock(): void;
  120576. private _resumeAudioContext;
  120577. private _initializeAudioContext;
  120578. private _tryToRun;
  120579. private _triggerRunningState;
  120580. private _triggerSuspendedState;
  120581. private _displayMuteButton;
  120582. private _moveButtonToTopLeft;
  120583. private _onResize;
  120584. private _hideMuteButton;
  120585. /**
  120586. * Destroy and release the resources associated with the audio ccontext.
  120587. */
  120588. dispose(): void;
  120589. /**
  120590. * Gets the global volume sets on the master gain.
  120591. * @returns the global volume if set or -1 otherwise
  120592. */
  120593. getGlobalVolume(): number;
  120594. /**
  120595. * Sets the global volume of your experience (sets on the master gain).
  120596. * @param newVolume Defines the new global volume of the application
  120597. */
  120598. setGlobalVolume(newVolume: number): void;
  120599. /**
  120600. * Connect the audio engine to an audio analyser allowing some amazing
  120601. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120602. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120603. * @param analyser The analyser to connect to the engine
  120604. */
  120605. connectToAnalyser(analyser: Analyser): void;
  120606. }
  120607. }
  120608. declare module BABYLON {
  120609. /**
  120610. * Interface used to present a loading screen while loading a scene
  120611. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120612. */
  120613. export interface ILoadingScreen {
  120614. /**
  120615. * Function called to display the loading screen
  120616. */
  120617. displayLoadingUI: () => void;
  120618. /**
  120619. * Function called to hide the loading screen
  120620. */
  120621. hideLoadingUI: () => void;
  120622. /**
  120623. * Gets or sets the color to use for the background
  120624. */
  120625. loadingUIBackgroundColor: string;
  120626. /**
  120627. * Gets or sets the text to display while loading
  120628. */
  120629. loadingUIText: string;
  120630. }
  120631. /**
  120632. * Class used for the default loading screen
  120633. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120634. */
  120635. export class DefaultLoadingScreen implements ILoadingScreen {
  120636. private _renderingCanvas;
  120637. private _loadingText;
  120638. private _loadingDivBackgroundColor;
  120639. private _loadingDiv;
  120640. private _loadingTextDiv;
  120641. /** Gets or sets the logo url to use for the default loading screen */
  120642. static DefaultLogoUrl: string;
  120643. /** Gets or sets the spinner url to use for the default loading screen */
  120644. static DefaultSpinnerUrl: string;
  120645. /**
  120646. * Creates a new default loading screen
  120647. * @param _renderingCanvas defines the canvas used to render the scene
  120648. * @param _loadingText defines the default text to display
  120649. * @param _loadingDivBackgroundColor defines the default background color
  120650. */
  120651. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120652. /**
  120653. * Function called to display the loading screen
  120654. */
  120655. displayLoadingUI(): void;
  120656. /**
  120657. * Function called to hide the loading screen
  120658. */
  120659. hideLoadingUI(): void;
  120660. /**
  120661. * Gets or sets the text to display while loading
  120662. */
  120663. set loadingUIText(text: string);
  120664. get loadingUIText(): string;
  120665. /**
  120666. * Gets or sets the color to use for the background
  120667. */
  120668. get loadingUIBackgroundColor(): string;
  120669. set loadingUIBackgroundColor(color: string);
  120670. private _resizeLoadingUI;
  120671. }
  120672. }
  120673. declare module BABYLON {
  120674. /**
  120675. * Interface for any object that can request an animation frame
  120676. */
  120677. export interface ICustomAnimationFrameRequester {
  120678. /**
  120679. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120680. */
  120681. renderFunction?: Function;
  120682. /**
  120683. * Called to request the next frame to render to
  120684. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120685. */
  120686. requestAnimationFrame: Function;
  120687. /**
  120688. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120689. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120690. */
  120691. requestID?: number;
  120692. }
  120693. }
  120694. declare module BABYLON {
  120695. /**
  120696. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120697. */
  120698. export class PerformanceMonitor {
  120699. private _enabled;
  120700. private _rollingFrameTime;
  120701. private _lastFrameTimeMs;
  120702. /**
  120703. * constructor
  120704. * @param frameSampleSize The number of samples required to saturate the sliding window
  120705. */
  120706. constructor(frameSampleSize?: number);
  120707. /**
  120708. * Samples current frame
  120709. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120710. */
  120711. sampleFrame(timeMs?: number): void;
  120712. /**
  120713. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120714. */
  120715. get averageFrameTime(): number;
  120716. /**
  120717. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120718. */
  120719. get averageFrameTimeVariance(): number;
  120720. /**
  120721. * Returns the frame time of the most recent frame
  120722. */
  120723. get instantaneousFrameTime(): number;
  120724. /**
  120725. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  120726. */
  120727. get averageFPS(): number;
  120728. /**
  120729. * Returns the average framerate in frames per second using the most recent frame time
  120730. */
  120731. get instantaneousFPS(): number;
  120732. /**
  120733. * Returns true if enough samples have been taken to completely fill the sliding window
  120734. */
  120735. get isSaturated(): boolean;
  120736. /**
  120737. * Enables contributions to the sliding window sample set
  120738. */
  120739. enable(): void;
  120740. /**
  120741. * Disables contributions to the sliding window sample set
  120742. * Samples will not be interpolated over the disabled period
  120743. */
  120744. disable(): void;
  120745. /**
  120746. * Returns true if sampling is enabled
  120747. */
  120748. get isEnabled(): boolean;
  120749. /**
  120750. * Resets performance monitor
  120751. */
  120752. reset(): void;
  120753. }
  120754. /**
  120755. * RollingAverage
  120756. *
  120757. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  120758. */
  120759. export class RollingAverage {
  120760. /**
  120761. * Current average
  120762. */
  120763. average: number;
  120764. /**
  120765. * Current variance
  120766. */
  120767. variance: number;
  120768. protected _samples: Array<number>;
  120769. protected _sampleCount: number;
  120770. protected _pos: number;
  120771. protected _m2: number;
  120772. /**
  120773. * constructor
  120774. * @param length The number of samples required to saturate the sliding window
  120775. */
  120776. constructor(length: number);
  120777. /**
  120778. * Adds a sample to the sample set
  120779. * @param v The sample value
  120780. */
  120781. add(v: number): void;
  120782. /**
  120783. * Returns previously added values or null if outside of history or outside the sliding window domain
  120784. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  120785. * @return Value previously recorded with add() or null if outside of range
  120786. */
  120787. history(i: number): number;
  120788. /**
  120789. * Returns true if enough samples have been taken to completely fill the sliding window
  120790. * @return true if sample-set saturated
  120791. */
  120792. isSaturated(): boolean;
  120793. /**
  120794. * Resets the rolling average (equivalent to 0 samples taken so far)
  120795. */
  120796. reset(): void;
  120797. /**
  120798. * Wraps a value around the sample range boundaries
  120799. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  120800. * @return Wrapped position in sample range
  120801. */
  120802. protected _wrapPosition(i: number): number;
  120803. }
  120804. }
  120805. declare module BABYLON {
  120806. /**
  120807. * This class is used to track a performance counter which is number based.
  120808. * The user has access to many properties which give statistics of different nature.
  120809. *
  120810. * The implementer can track two kinds of Performance Counter: time and count.
  120811. * 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.
  120812. * 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.
  120813. */
  120814. export class PerfCounter {
  120815. /**
  120816. * Gets or sets a global boolean to turn on and off all the counters
  120817. */
  120818. static Enabled: boolean;
  120819. /**
  120820. * Returns the smallest value ever
  120821. */
  120822. get min(): number;
  120823. /**
  120824. * Returns the biggest value ever
  120825. */
  120826. get max(): number;
  120827. /**
  120828. * Returns the average value since the performance counter is running
  120829. */
  120830. get average(): number;
  120831. /**
  120832. * Returns the average value of the last second the counter was monitored
  120833. */
  120834. get lastSecAverage(): number;
  120835. /**
  120836. * Returns the current value
  120837. */
  120838. get current(): number;
  120839. /**
  120840. * Gets the accumulated total
  120841. */
  120842. get total(): number;
  120843. /**
  120844. * Gets the total value count
  120845. */
  120846. get count(): number;
  120847. /**
  120848. * Creates a new counter
  120849. */
  120850. constructor();
  120851. /**
  120852. * Call this method to start monitoring a new frame.
  120853. * 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.
  120854. */
  120855. fetchNewFrame(): void;
  120856. /**
  120857. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  120858. * @param newCount the count value to add to the monitored count
  120859. * @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.
  120860. */
  120861. addCount(newCount: number, fetchResult: boolean): void;
  120862. /**
  120863. * Start monitoring this performance counter
  120864. */
  120865. beginMonitoring(): void;
  120866. /**
  120867. * Compute the time lapsed since the previous beginMonitoring() call.
  120868. * @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
  120869. */
  120870. endMonitoring(newFrame?: boolean): void;
  120871. private _fetchResult;
  120872. private _startMonitoringTime;
  120873. private _min;
  120874. private _max;
  120875. private _average;
  120876. private _current;
  120877. private _totalValueCount;
  120878. private _totalAccumulated;
  120879. private _lastSecAverage;
  120880. private _lastSecAccumulated;
  120881. private _lastSecTime;
  120882. private _lastSecValueCount;
  120883. }
  120884. }
  120885. declare module BABYLON {
  120886. interface ThinEngine {
  120887. /** @hidden */
  120888. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  120889. }
  120890. }
  120891. declare module BABYLON {
  120892. /**
  120893. * Defines the interface used by display changed events
  120894. */
  120895. export interface IDisplayChangedEventArgs {
  120896. /** Gets the vrDisplay object (if any) */
  120897. vrDisplay: Nullable<any>;
  120898. /** Gets a boolean indicating if webVR is supported */
  120899. vrSupported: boolean;
  120900. }
  120901. /**
  120902. * Defines the interface used by objects containing a viewport (like a camera)
  120903. */
  120904. interface IViewportOwnerLike {
  120905. /**
  120906. * Gets or sets the viewport
  120907. */
  120908. viewport: IViewportLike;
  120909. }
  120910. /**
  120911. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  120912. */
  120913. export class Engine extends ThinEngine {
  120914. /** Defines that alpha blending is disabled */
  120915. static readonly ALPHA_DISABLE: number;
  120916. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  120917. static readonly ALPHA_ADD: number;
  120918. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  120919. static readonly ALPHA_COMBINE: number;
  120920. /** Defines that alpha blending to DEST - SRC * DEST */
  120921. static readonly ALPHA_SUBTRACT: number;
  120922. /** Defines that alpha blending to SRC * DEST */
  120923. static readonly ALPHA_MULTIPLY: number;
  120924. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  120925. static readonly ALPHA_MAXIMIZED: number;
  120926. /** Defines that alpha blending to SRC + DEST */
  120927. static readonly ALPHA_ONEONE: number;
  120928. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  120929. static readonly ALPHA_PREMULTIPLIED: number;
  120930. /**
  120931. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  120932. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  120933. */
  120934. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  120935. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  120936. static readonly ALPHA_INTERPOLATE: number;
  120937. /**
  120938. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  120939. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  120940. */
  120941. static readonly ALPHA_SCREENMODE: number;
  120942. /** Defines that the ressource is not delayed*/
  120943. static readonly DELAYLOADSTATE_NONE: number;
  120944. /** Defines that the ressource was successfully delay loaded */
  120945. static readonly DELAYLOADSTATE_LOADED: number;
  120946. /** Defines that the ressource is currently delay loading */
  120947. static readonly DELAYLOADSTATE_LOADING: number;
  120948. /** Defines that the ressource is delayed and has not started loading */
  120949. static readonly DELAYLOADSTATE_NOTLOADED: number;
  120950. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  120951. static readonly NEVER: number;
  120952. /** 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 */
  120953. static readonly ALWAYS: number;
  120954. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  120955. static readonly LESS: number;
  120956. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  120957. static readonly EQUAL: number;
  120958. /** 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 */
  120959. static readonly LEQUAL: number;
  120960. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  120961. static readonly GREATER: number;
  120962. /** 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 */
  120963. static readonly GEQUAL: number;
  120964. /** 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 */
  120965. static readonly NOTEQUAL: number;
  120966. /** Passed to stencilOperation to specify that stencil value must be kept */
  120967. static readonly KEEP: number;
  120968. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120969. static readonly REPLACE: number;
  120970. /** Passed to stencilOperation to specify that stencil value must be incremented */
  120971. static readonly INCR: number;
  120972. /** Passed to stencilOperation to specify that stencil value must be decremented */
  120973. static readonly DECR: number;
  120974. /** Passed to stencilOperation to specify that stencil value must be inverted */
  120975. static readonly INVERT: number;
  120976. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  120977. static readonly INCR_WRAP: number;
  120978. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  120979. static readonly DECR_WRAP: number;
  120980. /** Texture is not repeating outside of 0..1 UVs */
  120981. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  120982. /** Texture is repeating outside of 0..1 UVs */
  120983. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  120984. /** Texture is repeating and mirrored */
  120985. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  120986. /** ALPHA */
  120987. static readonly TEXTUREFORMAT_ALPHA: number;
  120988. /** LUMINANCE */
  120989. static readonly TEXTUREFORMAT_LUMINANCE: number;
  120990. /** LUMINANCE_ALPHA */
  120991. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  120992. /** RGB */
  120993. static readonly TEXTUREFORMAT_RGB: number;
  120994. /** RGBA */
  120995. static readonly TEXTUREFORMAT_RGBA: number;
  120996. /** RED */
  120997. static readonly TEXTUREFORMAT_RED: number;
  120998. /** RED (2nd reference) */
  120999. static readonly TEXTUREFORMAT_R: number;
  121000. /** RG */
  121001. static readonly TEXTUREFORMAT_RG: number;
  121002. /** RED_INTEGER */
  121003. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121004. /** RED_INTEGER (2nd reference) */
  121005. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121006. /** RG_INTEGER */
  121007. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121008. /** RGB_INTEGER */
  121009. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121010. /** RGBA_INTEGER */
  121011. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121012. /** UNSIGNED_BYTE */
  121013. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121014. /** UNSIGNED_BYTE (2nd reference) */
  121015. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121016. /** FLOAT */
  121017. static readonly TEXTURETYPE_FLOAT: number;
  121018. /** HALF_FLOAT */
  121019. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121020. /** BYTE */
  121021. static readonly TEXTURETYPE_BYTE: number;
  121022. /** SHORT */
  121023. static readonly TEXTURETYPE_SHORT: number;
  121024. /** UNSIGNED_SHORT */
  121025. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121026. /** INT */
  121027. static readonly TEXTURETYPE_INT: number;
  121028. /** UNSIGNED_INT */
  121029. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121030. /** UNSIGNED_SHORT_4_4_4_4 */
  121031. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121032. /** UNSIGNED_SHORT_5_5_5_1 */
  121033. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121034. /** UNSIGNED_SHORT_5_6_5 */
  121035. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121036. /** UNSIGNED_INT_2_10_10_10_REV */
  121037. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121038. /** UNSIGNED_INT_24_8 */
  121039. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121040. /** UNSIGNED_INT_10F_11F_11F_REV */
  121041. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121042. /** UNSIGNED_INT_5_9_9_9_REV */
  121043. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121044. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121045. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121046. /** nearest is mag = nearest and min = nearest and mip = linear */
  121047. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121048. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121049. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121050. /** Trilinear is mag = linear and min = linear and mip = linear */
  121051. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121052. /** nearest is mag = nearest and min = nearest and mip = linear */
  121053. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121054. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121055. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121056. /** Trilinear is mag = linear and min = linear and mip = linear */
  121057. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121058. /** mag = nearest and min = nearest and mip = nearest */
  121059. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121060. /** mag = nearest and min = linear and mip = nearest */
  121061. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121062. /** mag = nearest and min = linear and mip = linear */
  121063. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121064. /** mag = nearest and min = linear and mip = none */
  121065. static readonly TEXTURE_NEAREST_LINEAR: number;
  121066. /** mag = nearest and min = nearest and mip = none */
  121067. static readonly TEXTURE_NEAREST_NEAREST: number;
  121068. /** mag = linear and min = nearest and mip = nearest */
  121069. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121070. /** mag = linear and min = nearest and mip = linear */
  121071. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121072. /** mag = linear and min = linear and mip = none */
  121073. static readonly TEXTURE_LINEAR_LINEAR: number;
  121074. /** mag = linear and min = nearest and mip = none */
  121075. static readonly TEXTURE_LINEAR_NEAREST: number;
  121076. /** Explicit coordinates mode */
  121077. static readonly TEXTURE_EXPLICIT_MODE: number;
  121078. /** Spherical coordinates mode */
  121079. static readonly TEXTURE_SPHERICAL_MODE: number;
  121080. /** Planar coordinates mode */
  121081. static readonly TEXTURE_PLANAR_MODE: number;
  121082. /** Cubic coordinates mode */
  121083. static readonly TEXTURE_CUBIC_MODE: number;
  121084. /** Projection coordinates mode */
  121085. static readonly TEXTURE_PROJECTION_MODE: number;
  121086. /** Skybox coordinates mode */
  121087. static readonly TEXTURE_SKYBOX_MODE: number;
  121088. /** Inverse Cubic coordinates mode */
  121089. static readonly TEXTURE_INVCUBIC_MODE: number;
  121090. /** Equirectangular coordinates mode */
  121091. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121092. /** Equirectangular Fixed coordinates mode */
  121093. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121094. /** Equirectangular Fixed Mirrored coordinates mode */
  121095. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121096. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121097. static readonly SCALEMODE_FLOOR: number;
  121098. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121099. static readonly SCALEMODE_NEAREST: number;
  121100. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121101. static readonly SCALEMODE_CEILING: number;
  121102. /**
  121103. * Returns the current npm package of the sdk
  121104. */
  121105. static get NpmPackage(): string;
  121106. /**
  121107. * Returns the current version of the framework
  121108. */
  121109. static get Version(): string;
  121110. /** Gets the list of created engines */
  121111. static get Instances(): Engine[];
  121112. /**
  121113. * Gets the latest created engine
  121114. */
  121115. static get LastCreatedEngine(): Nullable<Engine>;
  121116. /**
  121117. * Gets the latest created scene
  121118. */
  121119. static get LastCreatedScene(): Nullable<Scene>;
  121120. /**
  121121. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121122. * @param flag defines which part of the materials must be marked as dirty
  121123. * @param predicate defines a predicate used to filter which materials should be affected
  121124. */
  121125. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121126. /**
  121127. * Method called to create the default loading screen.
  121128. * This can be overriden in your own app.
  121129. * @param canvas The rendering canvas element
  121130. * @returns The loading screen
  121131. */
  121132. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121133. /**
  121134. * Method called to create the default rescale post process on each engine.
  121135. */
  121136. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121137. /**
  121138. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121139. **/
  121140. enableOfflineSupport: boolean;
  121141. /**
  121142. * 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)
  121143. **/
  121144. disableManifestCheck: boolean;
  121145. /**
  121146. * Gets the list of created scenes
  121147. */
  121148. scenes: Scene[];
  121149. /**
  121150. * Event raised when a new scene is created
  121151. */
  121152. onNewSceneAddedObservable: Observable<Scene>;
  121153. /**
  121154. * Gets the list of created postprocesses
  121155. */
  121156. postProcesses: PostProcess[];
  121157. /**
  121158. * Gets a boolean indicating if the pointer is currently locked
  121159. */
  121160. isPointerLock: boolean;
  121161. /**
  121162. * Observable event triggered each time the rendering canvas is resized
  121163. */
  121164. onResizeObservable: Observable<Engine>;
  121165. /**
  121166. * Observable event triggered each time the canvas loses focus
  121167. */
  121168. onCanvasBlurObservable: Observable<Engine>;
  121169. /**
  121170. * Observable event triggered each time the canvas gains focus
  121171. */
  121172. onCanvasFocusObservable: Observable<Engine>;
  121173. /**
  121174. * Observable event triggered each time the canvas receives pointerout event
  121175. */
  121176. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121177. /**
  121178. * Observable raised when the engine begins a new frame
  121179. */
  121180. onBeginFrameObservable: Observable<Engine>;
  121181. /**
  121182. * If set, will be used to request the next animation frame for the render loop
  121183. */
  121184. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121185. /**
  121186. * Observable raised when the engine ends the current frame
  121187. */
  121188. onEndFrameObservable: Observable<Engine>;
  121189. /**
  121190. * Observable raised when the engine is about to compile a shader
  121191. */
  121192. onBeforeShaderCompilationObservable: Observable<Engine>;
  121193. /**
  121194. * Observable raised when the engine has jsut compiled a shader
  121195. */
  121196. onAfterShaderCompilationObservable: Observable<Engine>;
  121197. /**
  121198. * Gets the audio engine
  121199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121200. * @ignorenaming
  121201. */
  121202. static audioEngine: IAudioEngine;
  121203. /**
  121204. * Default AudioEngine factory responsible of creating the Audio Engine.
  121205. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121206. */
  121207. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121208. /**
  121209. * Default offline support factory responsible of creating a tool used to store data locally.
  121210. * By default, this will create a Database object if the workload has been embedded.
  121211. */
  121212. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121213. private _loadingScreen;
  121214. private _pointerLockRequested;
  121215. private _rescalePostProcess;
  121216. private _deterministicLockstep;
  121217. private _lockstepMaxSteps;
  121218. private _timeStep;
  121219. protected get _supportsHardwareTextureRescaling(): boolean;
  121220. private _fps;
  121221. private _deltaTime;
  121222. /** @hidden */
  121223. _drawCalls: PerfCounter;
  121224. /** 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 */
  121225. canvasTabIndex: number;
  121226. /**
  121227. * Turn this value on if you want to pause FPS computation when in background
  121228. */
  121229. disablePerformanceMonitorInBackground: boolean;
  121230. private _performanceMonitor;
  121231. /**
  121232. * Gets the performance monitor attached to this engine
  121233. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121234. */
  121235. get performanceMonitor(): PerformanceMonitor;
  121236. private _onFocus;
  121237. private _onBlur;
  121238. private _onCanvasPointerOut;
  121239. private _onCanvasBlur;
  121240. private _onCanvasFocus;
  121241. private _onFullscreenChange;
  121242. private _onPointerLockChange;
  121243. /**
  121244. * Gets the HTML element used to attach event listeners
  121245. * @returns a HTML element
  121246. */
  121247. getInputElement(): Nullable<HTMLElement>;
  121248. /**
  121249. * Creates a new engine
  121250. * @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
  121251. * @param antialias defines enable antialiasing (default: false)
  121252. * @param options defines further options to be sent to the getContext() function
  121253. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121254. */
  121255. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121256. /**
  121257. * Gets current aspect ratio
  121258. * @param viewportOwner defines the camera to use to get the aspect ratio
  121259. * @param useScreen defines if screen size must be used (or the current render target if any)
  121260. * @returns a number defining the aspect ratio
  121261. */
  121262. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121263. /**
  121264. * Gets current screen aspect ratio
  121265. * @returns a number defining the aspect ratio
  121266. */
  121267. getScreenAspectRatio(): number;
  121268. /**
  121269. * Gets the client rect of the HTML canvas attached with the current webGL context
  121270. * @returns a client rectanglee
  121271. */
  121272. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121273. /**
  121274. * Gets the client rect of the HTML element used for events
  121275. * @returns a client rectanglee
  121276. */
  121277. getInputElementClientRect(): Nullable<ClientRect>;
  121278. /**
  121279. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121280. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121281. * @returns true if engine is in deterministic lock step mode
  121282. */
  121283. isDeterministicLockStep(): boolean;
  121284. /**
  121285. * Gets the max steps when engine is running in deterministic lock step
  121286. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121287. * @returns the max steps
  121288. */
  121289. getLockstepMaxSteps(): number;
  121290. /**
  121291. * Returns the time in ms between steps when using deterministic lock step.
  121292. * @returns time step in (ms)
  121293. */
  121294. getTimeStep(): number;
  121295. /**
  121296. * Force the mipmap generation for the given render target texture
  121297. * @param texture defines the render target texture to use
  121298. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121299. */
  121300. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121301. /** States */
  121302. /**
  121303. * Set various states to the webGL context
  121304. * @param culling defines backface culling state
  121305. * @param zOffset defines the value to apply to zOffset (0 by default)
  121306. * @param force defines if states must be applied even if cache is up to date
  121307. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121308. */
  121309. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121310. /**
  121311. * Set the z offset to apply to current rendering
  121312. * @param value defines the offset to apply
  121313. */
  121314. setZOffset(value: number): void;
  121315. /**
  121316. * Gets the current value of the zOffset
  121317. * @returns the current zOffset state
  121318. */
  121319. getZOffset(): number;
  121320. /**
  121321. * Enable or disable depth buffering
  121322. * @param enable defines the state to set
  121323. */
  121324. setDepthBuffer(enable: boolean): void;
  121325. /**
  121326. * Gets a boolean indicating if depth writing is enabled
  121327. * @returns the current depth writing state
  121328. */
  121329. getDepthWrite(): boolean;
  121330. /**
  121331. * Enable or disable depth writing
  121332. * @param enable defines the state to set
  121333. */
  121334. setDepthWrite(enable: boolean): void;
  121335. /**
  121336. * Gets a boolean indicating if stencil buffer is enabled
  121337. * @returns the current stencil buffer state
  121338. */
  121339. getStencilBuffer(): boolean;
  121340. /**
  121341. * Enable or disable the stencil buffer
  121342. * @param enable defines if the stencil buffer must be enabled or disabled
  121343. */
  121344. setStencilBuffer(enable: boolean): void;
  121345. /**
  121346. * Gets the current stencil mask
  121347. * @returns a number defining the new stencil mask to use
  121348. */
  121349. getStencilMask(): number;
  121350. /**
  121351. * Sets the current stencil mask
  121352. * @param mask defines the new stencil mask to use
  121353. */
  121354. setStencilMask(mask: number): void;
  121355. /**
  121356. * Gets the current stencil function
  121357. * @returns a number defining the stencil function to use
  121358. */
  121359. getStencilFunction(): number;
  121360. /**
  121361. * Gets the current stencil reference value
  121362. * @returns a number defining the stencil reference value to use
  121363. */
  121364. getStencilFunctionReference(): number;
  121365. /**
  121366. * Gets the current stencil mask
  121367. * @returns a number defining the stencil mask to use
  121368. */
  121369. getStencilFunctionMask(): number;
  121370. /**
  121371. * Sets the current stencil function
  121372. * @param stencilFunc defines the new stencil function to use
  121373. */
  121374. setStencilFunction(stencilFunc: number): void;
  121375. /**
  121376. * Sets the current stencil reference
  121377. * @param reference defines the new stencil reference to use
  121378. */
  121379. setStencilFunctionReference(reference: number): void;
  121380. /**
  121381. * Sets the current stencil mask
  121382. * @param mask defines the new stencil mask to use
  121383. */
  121384. setStencilFunctionMask(mask: number): void;
  121385. /**
  121386. * Gets the current stencil operation when stencil fails
  121387. * @returns a number defining stencil operation to use when stencil fails
  121388. */
  121389. getStencilOperationFail(): number;
  121390. /**
  121391. * Gets the current stencil operation when depth fails
  121392. * @returns a number defining stencil operation to use when depth fails
  121393. */
  121394. getStencilOperationDepthFail(): number;
  121395. /**
  121396. * Gets the current stencil operation when stencil passes
  121397. * @returns a number defining stencil operation to use when stencil passes
  121398. */
  121399. getStencilOperationPass(): number;
  121400. /**
  121401. * Sets the stencil operation to use when stencil fails
  121402. * @param operation defines the stencil operation to use when stencil fails
  121403. */
  121404. setStencilOperationFail(operation: number): void;
  121405. /**
  121406. * Sets the stencil operation to use when depth fails
  121407. * @param operation defines the stencil operation to use when depth fails
  121408. */
  121409. setStencilOperationDepthFail(operation: number): void;
  121410. /**
  121411. * Sets the stencil operation to use when stencil passes
  121412. * @param operation defines the stencil operation to use when stencil passes
  121413. */
  121414. setStencilOperationPass(operation: number): void;
  121415. /**
  121416. * Sets a boolean indicating if the dithering state is enabled or disabled
  121417. * @param value defines the dithering state
  121418. */
  121419. setDitheringState(value: boolean): void;
  121420. /**
  121421. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121422. * @param value defines the rasterizer state
  121423. */
  121424. setRasterizerState(value: boolean): void;
  121425. /**
  121426. * Gets the current depth function
  121427. * @returns a number defining the depth function
  121428. */
  121429. getDepthFunction(): Nullable<number>;
  121430. /**
  121431. * Sets the current depth function
  121432. * @param depthFunc defines the function to use
  121433. */
  121434. setDepthFunction(depthFunc: number): void;
  121435. /**
  121436. * Sets the current depth function to GREATER
  121437. */
  121438. setDepthFunctionToGreater(): void;
  121439. /**
  121440. * Sets the current depth function to GEQUAL
  121441. */
  121442. setDepthFunctionToGreaterOrEqual(): void;
  121443. /**
  121444. * Sets the current depth function to LESS
  121445. */
  121446. setDepthFunctionToLess(): void;
  121447. /**
  121448. * Sets the current depth function to LEQUAL
  121449. */
  121450. setDepthFunctionToLessOrEqual(): void;
  121451. private _cachedStencilBuffer;
  121452. private _cachedStencilFunction;
  121453. private _cachedStencilMask;
  121454. private _cachedStencilOperationPass;
  121455. private _cachedStencilOperationFail;
  121456. private _cachedStencilOperationDepthFail;
  121457. private _cachedStencilReference;
  121458. /**
  121459. * Caches the the state of the stencil buffer
  121460. */
  121461. cacheStencilState(): void;
  121462. /**
  121463. * Restores the state of the stencil buffer
  121464. */
  121465. restoreStencilState(): void;
  121466. /**
  121467. * Directly set the WebGL Viewport
  121468. * @param x defines the x coordinate of the viewport (in screen space)
  121469. * @param y defines the y coordinate of the viewport (in screen space)
  121470. * @param width defines the width of the viewport (in screen space)
  121471. * @param height defines the height of the viewport (in screen space)
  121472. * @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
  121473. */
  121474. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121475. /**
  121476. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121477. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121478. * @param y defines the y-coordinate of the corner of the clear rectangle
  121479. * @param width defines the width of the clear rectangle
  121480. * @param height defines the height of the clear rectangle
  121481. * @param clearColor defines the clear color
  121482. */
  121483. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121484. /**
  121485. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121486. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121487. * @param y defines the y-coordinate of the corner of the clear rectangle
  121488. * @param width defines the width of the clear rectangle
  121489. * @param height defines the height of the clear rectangle
  121490. */
  121491. enableScissor(x: number, y: number, width: number, height: number): void;
  121492. /**
  121493. * Disable previously set scissor test rectangle
  121494. */
  121495. disableScissor(): void;
  121496. protected _reportDrawCall(): void;
  121497. /**
  121498. * Initializes a webVR display and starts listening to display change events
  121499. * The onVRDisplayChangedObservable will be notified upon these changes
  121500. * @returns The onVRDisplayChangedObservable
  121501. */
  121502. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121503. /** @hidden */
  121504. _prepareVRComponent(): void;
  121505. /** @hidden */
  121506. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121507. /** @hidden */
  121508. _submitVRFrame(): void;
  121509. /**
  121510. * Call this function to leave webVR mode
  121511. * Will do nothing if webVR is not supported or if there is no webVR device
  121512. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121513. */
  121514. disableVR(): void;
  121515. /**
  121516. * Gets a boolean indicating that the system is in VR mode and is presenting
  121517. * @returns true if VR mode is engaged
  121518. */
  121519. isVRPresenting(): boolean;
  121520. /** @hidden */
  121521. _requestVRFrame(): void;
  121522. /** @hidden */
  121523. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121524. /**
  121525. * Gets the source code of the vertex shader associated with a specific webGL program
  121526. * @param program defines the program to use
  121527. * @returns a string containing the source code of the vertex shader associated with the program
  121528. */
  121529. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121530. /**
  121531. * Gets the source code of the fragment shader associated with a specific webGL program
  121532. * @param program defines the program to use
  121533. * @returns a string containing the source code of the fragment shader associated with the program
  121534. */
  121535. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121536. /**
  121537. * Sets a depth stencil texture from a render target to the according uniform.
  121538. * @param channel The texture channel
  121539. * @param uniform The uniform to set
  121540. * @param texture The render target texture containing the depth stencil texture to apply
  121541. */
  121542. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121543. /**
  121544. * Sets a texture to the webGL context from a postprocess
  121545. * @param channel defines the channel to use
  121546. * @param postProcess defines the source postprocess
  121547. */
  121548. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121549. /**
  121550. * Binds the output of the passed in post process to the texture channel specified
  121551. * @param channel The channel the texture should be bound to
  121552. * @param postProcess The post process which's output should be bound
  121553. */
  121554. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121555. protected _rebuildBuffers(): void;
  121556. /** @hidden */
  121557. _renderFrame(): void;
  121558. _renderLoop(): void;
  121559. /** @hidden */
  121560. _renderViews(): boolean;
  121561. /**
  121562. * Toggle full screen mode
  121563. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121564. */
  121565. switchFullscreen(requestPointerLock: boolean): void;
  121566. /**
  121567. * Enters full screen mode
  121568. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121569. */
  121570. enterFullscreen(requestPointerLock: boolean): void;
  121571. /**
  121572. * Exits full screen mode
  121573. */
  121574. exitFullscreen(): void;
  121575. /**
  121576. * Enters Pointerlock mode
  121577. */
  121578. enterPointerlock(): void;
  121579. /**
  121580. * Exits Pointerlock mode
  121581. */
  121582. exitPointerlock(): void;
  121583. /**
  121584. * Begin a new frame
  121585. */
  121586. beginFrame(): void;
  121587. /**
  121588. * Enf the current frame
  121589. */
  121590. endFrame(): void;
  121591. resize(): void;
  121592. /**
  121593. * Force a specific size of the canvas
  121594. * @param width defines the new canvas' width
  121595. * @param height defines the new canvas' height
  121596. * @returns true if the size was changed
  121597. */
  121598. setSize(width: number, height: number): boolean;
  121599. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121600. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121601. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121602. _releaseTexture(texture: InternalTexture): void;
  121603. /**
  121604. * @hidden
  121605. * Rescales a texture
  121606. * @param source input texutre
  121607. * @param destination destination texture
  121608. * @param scene scene to use to render the resize
  121609. * @param internalFormat format to use when resizing
  121610. * @param onComplete callback to be called when resize has completed
  121611. */
  121612. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121613. /**
  121614. * Gets the current framerate
  121615. * @returns a number representing the framerate
  121616. */
  121617. getFps(): number;
  121618. /**
  121619. * Gets the time spent between current and previous frame
  121620. * @returns a number representing the delta time in ms
  121621. */
  121622. getDeltaTime(): number;
  121623. private _measureFps;
  121624. /** @hidden */
  121625. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121626. /**
  121627. * Updates the sample count of a render target texture
  121628. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121629. * @param texture defines the texture to update
  121630. * @param samples defines the sample count to set
  121631. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121632. */
  121633. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121634. /**
  121635. * Updates a depth texture Comparison Mode and Function.
  121636. * If the comparison Function is equal to 0, the mode will be set to none.
  121637. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121638. * @param texture The texture to set the comparison function for
  121639. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121640. */
  121641. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121642. /**
  121643. * Creates a webGL buffer to use with instanciation
  121644. * @param capacity defines the size of the buffer
  121645. * @returns the webGL buffer
  121646. */
  121647. createInstancesBuffer(capacity: number): DataBuffer;
  121648. /**
  121649. * Delete a webGL buffer used with instanciation
  121650. * @param buffer defines the webGL buffer to delete
  121651. */
  121652. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121653. private _clientWaitAsync;
  121654. /** @hidden */
  121655. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121656. dispose(): void;
  121657. private _disableTouchAction;
  121658. /**
  121659. * Display the loading screen
  121660. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121661. */
  121662. displayLoadingUI(): void;
  121663. /**
  121664. * Hide the loading screen
  121665. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121666. */
  121667. hideLoadingUI(): void;
  121668. /**
  121669. * Gets the current loading screen object
  121670. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121671. */
  121672. get loadingScreen(): ILoadingScreen;
  121673. /**
  121674. * Sets the current loading screen object
  121675. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121676. */
  121677. set loadingScreen(loadingScreen: ILoadingScreen);
  121678. /**
  121679. * Sets the current loading screen text
  121680. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121681. */
  121682. set loadingUIText(text: string);
  121683. /**
  121684. * Sets the current loading screen background color
  121685. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121686. */
  121687. set loadingUIBackgroundColor(color: string);
  121688. /** Pointerlock and fullscreen */
  121689. /**
  121690. * Ask the browser to promote the current element to pointerlock mode
  121691. * @param element defines the DOM element to promote
  121692. */
  121693. static _RequestPointerlock(element: HTMLElement): void;
  121694. /**
  121695. * Asks the browser to exit pointerlock mode
  121696. */
  121697. static _ExitPointerlock(): void;
  121698. /**
  121699. * Ask the browser to promote the current element to fullscreen rendering mode
  121700. * @param element defines the DOM element to promote
  121701. */
  121702. static _RequestFullscreen(element: HTMLElement): void;
  121703. /**
  121704. * Asks the browser to exit fullscreen mode
  121705. */
  121706. static _ExitFullscreen(): void;
  121707. }
  121708. }
  121709. declare module BABYLON {
  121710. /**
  121711. * The engine store class is responsible to hold all the instances of Engine and Scene created
  121712. * during the life time of the application.
  121713. */
  121714. export class EngineStore {
  121715. /** Gets the list of created engines */
  121716. static Instances: Engine[];
  121717. /** @hidden */
  121718. static _LastCreatedScene: Nullable<Scene>;
  121719. /**
  121720. * Gets the latest created engine
  121721. */
  121722. static get LastCreatedEngine(): Nullable<Engine>;
  121723. /**
  121724. * Gets the latest created scene
  121725. */
  121726. static get LastCreatedScene(): Nullable<Scene>;
  121727. /**
  121728. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121729. * @ignorenaming
  121730. */
  121731. static UseFallbackTexture: boolean;
  121732. /**
  121733. * Texture content used if a texture cannot loaded
  121734. * @ignorenaming
  121735. */
  121736. static FallbackTexture: string;
  121737. }
  121738. }
  121739. declare module BABYLON {
  121740. /**
  121741. * Helper class that provides a small promise polyfill
  121742. */
  121743. export class PromisePolyfill {
  121744. /**
  121745. * Static function used to check if the polyfill is required
  121746. * If this is the case then the function will inject the polyfill to window.Promise
  121747. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  121748. */
  121749. static Apply(force?: boolean): void;
  121750. }
  121751. }
  121752. declare module BABYLON {
  121753. /**
  121754. * Interface for screenshot methods with describe argument called `size` as object with options
  121755. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  121756. */
  121757. export interface IScreenshotSize {
  121758. /**
  121759. * number in pixels for canvas height
  121760. */
  121761. height?: number;
  121762. /**
  121763. * multiplier allowing render at a higher or lower resolution
  121764. * If value is defined then height and width will be ignored and taken from camera
  121765. */
  121766. precision?: number;
  121767. /**
  121768. * number in pixels for canvas width
  121769. */
  121770. width?: number;
  121771. }
  121772. }
  121773. declare module BABYLON {
  121774. interface IColor4Like {
  121775. r: float;
  121776. g: float;
  121777. b: float;
  121778. a: float;
  121779. }
  121780. /**
  121781. * Class containing a set of static utilities functions
  121782. */
  121783. export class Tools {
  121784. /**
  121785. * Gets or sets the base URL to use to load assets
  121786. */
  121787. static get BaseUrl(): string;
  121788. static set BaseUrl(value: string);
  121789. /**
  121790. * Enable/Disable Custom HTTP Request Headers globally.
  121791. * default = false
  121792. * @see CustomRequestHeaders
  121793. */
  121794. static UseCustomRequestHeaders: boolean;
  121795. /**
  121796. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  121797. * i.e. when loading files, where the server/service expects an Authorization header
  121798. */
  121799. static CustomRequestHeaders: {
  121800. [key: string]: string;
  121801. };
  121802. /**
  121803. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  121804. */
  121805. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  121806. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  121807. /**
  121808. * Default behaviour for cors in the application.
  121809. * It can be a string if the expected behavior is identical in the entire app.
  121810. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  121811. */
  121812. static get CorsBehavior(): string | ((url: string | string[]) => string);
  121813. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  121814. /**
  121815. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121816. * @ignorenaming
  121817. */
  121818. static get UseFallbackTexture(): boolean;
  121819. static set UseFallbackTexture(value: boolean);
  121820. /**
  121821. * Use this object to register external classes like custom textures or material
  121822. * to allow the laoders to instantiate them
  121823. */
  121824. static get RegisteredExternalClasses(): {
  121825. [key: string]: Object;
  121826. };
  121827. static set RegisteredExternalClasses(classes: {
  121828. [key: string]: Object;
  121829. });
  121830. /**
  121831. * Texture content used if a texture cannot loaded
  121832. * @ignorenaming
  121833. */
  121834. static get fallbackTexture(): string;
  121835. static set fallbackTexture(value: string);
  121836. /**
  121837. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  121838. * @param u defines the coordinate on X axis
  121839. * @param v defines the coordinate on Y axis
  121840. * @param width defines the width of the source data
  121841. * @param height defines the height of the source data
  121842. * @param pixels defines the source byte array
  121843. * @param color defines the output color
  121844. */
  121845. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  121846. /**
  121847. * Interpolates between a and b via alpha
  121848. * @param a The lower value (returned when alpha = 0)
  121849. * @param b The upper value (returned when alpha = 1)
  121850. * @param alpha The interpolation-factor
  121851. * @return The mixed value
  121852. */
  121853. static Mix(a: number, b: number, alpha: number): number;
  121854. /**
  121855. * Tries to instantiate a new object from a given class name
  121856. * @param className defines the class name to instantiate
  121857. * @returns the new object or null if the system was not able to do the instantiation
  121858. */
  121859. static Instantiate(className: string): any;
  121860. /**
  121861. * Provides a slice function that will work even on IE
  121862. * @param data defines the array to slice
  121863. * @param start defines the start of the data (optional)
  121864. * @param end defines the end of the data (optional)
  121865. * @returns the new sliced array
  121866. */
  121867. static Slice<T>(data: T, start?: number, end?: number): T;
  121868. /**
  121869. * Polyfill for setImmediate
  121870. * @param action defines the action to execute after the current execution block
  121871. */
  121872. static SetImmediate(action: () => void): void;
  121873. /**
  121874. * Function indicating if a number is an exponent of 2
  121875. * @param value defines the value to test
  121876. * @returns true if the value is an exponent of 2
  121877. */
  121878. static IsExponentOfTwo(value: number): boolean;
  121879. private static _tmpFloatArray;
  121880. /**
  121881. * Returns the nearest 32-bit single precision float representation of a Number
  121882. * @param value A Number. If the parameter is of a different type, it will get converted
  121883. * to a number or to NaN if it cannot be converted
  121884. * @returns number
  121885. */
  121886. static FloatRound(value: number): number;
  121887. /**
  121888. * Extracts the filename from a path
  121889. * @param path defines the path to use
  121890. * @returns the filename
  121891. */
  121892. static GetFilename(path: string): string;
  121893. /**
  121894. * Extracts the "folder" part of a path (everything before the filename).
  121895. * @param uri The URI to extract the info from
  121896. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  121897. * @returns The "folder" part of the path
  121898. */
  121899. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  121900. /**
  121901. * Extracts text content from a DOM element hierarchy
  121902. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  121903. */
  121904. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  121905. /**
  121906. * Convert an angle in radians to degrees
  121907. * @param angle defines the angle to convert
  121908. * @returns the angle in degrees
  121909. */
  121910. static ToDegrees(angle: number): number;
  121911. /**
  121912. * Convert an angle in degrees to radians
  121913. * @param angle defines the angle to convert
  121914. * @returns the angle in radians
  121915. */
  121916. static ToRadians(angle: number): number;
  121917. /**
  121918. * Returns an array if obj is not an array
  121919. * @param obj defines the object to evaluate as an array
  121920. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  121921. * @returns either obj directly if obj is an array or a new array containing obj
  121922. */
  121923. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  121924. /**
  121925. * Gets the pointer prefix to use
  121926. * @param engine defines the engine we are finding the prefix for
  121927. * @returns "pointer" if touch is enabled. Else returns "mouse"
  121928. */
  121929. static GetPointerPrefix(engine: Engine): string;
  121930. /**
  121931. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  121932. * @param url define the url we are trying
  121933. * @param element define the dom element where to configure the cors policy
  121934. */
  121935. static SetCorsBehavior(url: string | string[], element: {
  121936. crossOrigin: string | null;
  121937. }): void;
  121938. /**
  121939. * Removes unwanted characters from an url
  121940. * @param url defines the url to clean
  121941. * @returns the cleaned url
  121942. */
  121943. static CleanUrl(url: string): string;
  121944. /**
  121945. * Gets or sets a function used to pre-process url before using them to load assets
  121946. */
  121947. static get PreprocessUrl(): (url: string) => string;
  121948. static set PreprocessUrl(processor: (url: string) => string);
  121949. /**
  121950. * Loads an image as an HTMLImageElement.
  121951. * @param input url string, ArrayBuffer, or Blob to load
  121952. * @param onLoad callback called when the image successfully loads
  121953. * @param onError callback called when the image fails to load
  121954. * @param offlineProvider offline provider for caching
  121955. * @param mimeType optional mime type
  121956. * @returns the HTMLImageElement of the loaded image
  121957. */
  121958. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  121959. /**
  121960. * Loads a file from a url
  121961. * @param url url string, ArrayBuffer, or Blob to load
  121962. * @param onSuccess callback called when the file successfully loads
  121963. * @param onProgress callback called while file is loading (if the server supports this mode)
  121964. * @param offlineProvider defines the offline provider for caching
  121965. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121966. * @param onError callback called when the file fails to load
  121967. * @returns a file request object
  121968. */
  121969. 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;
  121970. /**
  121971. * Loads a file from a url
  121972. * @param url the file url to load
  121973. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121974. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  121975. */
  121976. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  121977. /**
  121978. * Load a script (identified by an url). When the url returns, the
  121979. * content of this file is added into a new script element, attached to the DOM (body element)
  121980. * @param scriptUrl defines the url of the script to laod
  121981. * @param onSuccess defines the callback called when the script is loaded
  121982. * @param onError defines the callback to call if an error occurs
  121983. * @param scriptId defines the id of the script element
  121984. */
  121985. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  121986. /**
  121987. * Load an asynchronous script (identified by an url). When the url returns, the
  121988. * content of this file is added into a new script element, attached to the DOM (body element)
  121989. * @param scriptUrl defines the url of the script to laod
  121990. * @param scriptId defines the id of the script element
  121991. * @returns a promise request object
  121992. */
  121993. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  121994. /**
  121995. * Loads a file from a blob
  121996. * @param fileToLoad defines the blob to use
  121997. * @param callback defines the callback to call when data is loaded
  121998. * @param progressCallback defines the callback to call during loading process
  121999. * @returns a file request object
  122000. */
  122001. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122002. /**
  122003. * Reads a file from a File object
  122004. * @param file defines the file to load
  122005. * @param onSuccess defines the callback to call when data is loaded
  122006. * @param onProgress defines the callback to call during loading process
  122007. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122008. * @param onError defines the callback to call when an error occurs
  122009. * @returns a file request object
  122010. */
  122011. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122012. /**
  122013. * Creates a data url from a given string content
  122014. * @param content defines the content to convert
  122015. * @returns the new data url link
  122016. */
  122017. static FileAsURL(content: string): string;
  122018. /**
  122019. * Format the given number to a specific decimal format
  122020. * @param value defines the number to format
  122021. * @param decimals defines the number of decimals to use
  122022. * @returns the formatted string
  122023. */
  122024. static Format(value: number, decimals?: number): string;
  122025. /**
  122026. * Tries to copy an object by duplicating every property
  122027. * @param source defines the source object
  122028. * @param destination defines the target object
  122029. * @param doNotCopyList defines a list of properties to avoid
  122030. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122031. */
  122032. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122033. /**
  122034. * Gets a boolean indicating if the given object has no own property
  122035. * @param obj defines the object to test
  122036. * @returns true if object has no own property
  122037. */
  122038. static IsEmpty(obj: any): boolean;
  122039. /**
  122040. * Function used to register events at window level
  122041. * @param windowElement defines the Window object to use
  122042. * @param events defines the events to register
  122043. */
  122044. static RegisterTopRootEvents(windowElement: Window, events: {
  122045. name: string;
  122046. handler: Nullable<(e: FocusEvent) => any>;
  122047. }[]): void;
  122048. /**
  122049. * Function used to unregister events from window level
  122050. * @param windowElement defines the Window object to use
  122051. * @param events defines the events to unregister
  122052. */
  122053. static UnregisterTopRootEvents(windowElement: Window, events: {
  122054. name: string;
  122055. handler: Nullable<(e: FocusEvent) => any>;
  122056. }[]): void;
  122057. /**
  122058. * @ignore
  122059. */
  122060. static _ScreenshotCanvas: HTMLCanvasElement;
  122061. /**
  122062. * Dumps the current bound framebuffer
  122063. * @param width defines the rendering width
  122064. * @param height defines the rendering height
  122065. * @param engine defines the hosting engine
  122066. * @param successCallback defines the callback triggered once the data are available
  122067. * @param mimeType defines the mime type of the result
  122068. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122069. */
  122070. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122071. /**
  122072. * Converts the canvas data to blob.
  122073. * This acts as a polyfill for browsers not supporting the to blob function.
  122074. * @param canvas Defines the canvas to extract the data from
  122075. * @param successCallback Defines the callback triggered once the data are available
  122076. * @param mimeType Defines the mime type of the result
  122077. */
  122078. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122079. /**
  122080. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122081. * @param successCallback defines the callback triggered once the data are available
  122082. * @param mimeType defines the mime type of the result
  122083. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122084. */
  122085. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122086. /**
  122087. * Downloads a blob in the browser
  122088. * @param blob defines the blob to download
  122089. * @param fileName defines the name of the downloaded file
  122090. */
  122091. static Download(blob: Blob, fileName: string): void;
  122092. /**
  122093. * Captures a screenshot of the current rendering
  122094. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122095. * @param engine defines the rendering engine
  122096. * @param camera defines the source camera
  122097. * @param size This parameter can be set to a single number or to an object with the
  122098. * following (optional) properties: precision, width, height. If a single number is passed,
  122099. * it will be used for both width and height. If an object is passed, the screenshot size
  122100. * will be derived from the parameters. The precision property is a multiplier allowing
  122101. * rendering at a higher or lower resolution
  122102. * @param successCallback defines the callback receives a single parameter which contains the
  122103. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122104. * src parameter of an <img> to display it
  122105. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122106. * Check your browser for supported MIME types
  122107. */
  122108. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122109. /**
  122110. * Captures a screenshot of the current rendering
  122111. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122112. * @param engine defines the rendering engine
  122113. * @param camera defines the source camera
  122114. * @param size This parameter can be set to a single number or to an object with the
  122115. * following (optional) properties: precision, width, height. If a single number is passed,
  122116. * it will be used for both width and height. If an object is passed, the screenshot size
  122117. * will be derived from the parameters. The precision property is a multiplier allowing
  122118. * rendering at a higher or lower resolution
  122119. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122120. * Check your browser for supported MIME types
  122121. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122122. * to the src parameter of an <img> to display it
  122123. */
  122124. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122125. /**
  122126. * Generates an image screenshot from the specified camera.
  122127. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122128. * @param engine The engine to use for rendering
  122129. * @param camera The camera to use for rendering
  122130. * @param size This parameter can be set to a single number or to an object with the
  122131. * following (optional) properties: precision, width, height. If a single number is passed,
  122132. * it will be used for both width and height. If an object is passed, the screenshot size
  122133. * will be derived from the parameters. The precision property is a multiplier allowing
  122134. * rendering at a higher or lower resolution
  122135. * @param successCallback The callback receives a single parameter which contains the
  122136. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122137. * src parameter of an <img> to display it
  122138. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122139. * Check your browser for supported MIME types
  122140. * @param samples Texture samples (default: 1)
  122141. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122142. * @param fileName A name for for the downloaded file.
  122143. */
  122144. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122145. /**
  122146. * Generates an image screenshot from the specified camera.
  122147. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122148. * @param engine The engine to use for rendering
  122149. * @param camera The camera to use for rendering
  122150. * @param size This parameter can be set to a single number or to an object with the
  122151. * following (optional) properties: precision, width, height. If a single number is passed,
  122152. * it will be used for both width and height. If an object is passed, the screenshot size
  122153. * will be derived from the parameters. The precision property is a multiplier allowing
  122154. * rendering at a higher or lower resolution
  122155. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122156. * Check your browser for supported MIME types
  122157. * @param samples Texture samples (default: 1)
  122158. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122159. * @param fileName A name for for the downloaded file.
  122160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122161. * to the src parameter of an <img> to display it
  122162. */
  122163. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122164. /**
  122165. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122166. * Be aware Math.random() could cause collisions, but:
  122167. * "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"
  122168. * @returns a pseudo random id
  122169. */
  122170. static RandomId(): string;
  122171. /**
  122172. * Test if the given uri is a base64 string
  122173. * @param uri The uri to test
  122174. * @return True if the uri is a base64 string or false otherwise
  122175. */
  122176. static IsBase64(uri: string): boolean;
  122177. /**
  122178. * Decode the given base64 uri.
  122179. * @param uri The uri to decode
  122180. * @return The decoded base64 data.
  122181. */
  122182. static DecodeBase64(uri: string): ArrayBuffer;
  122183. /**
  122184. * Gets the absolute url.
  122185. * @param url the input url
  122186. * @return the absolute url
  122187. */
  122188. static GetAbsoluteUrl(url: string): string;
  122189. /**
  122190. * No log
  122191. */
  122192. static readonly NoneLogLevel: number;
  122193. /**
  122194. * Only message logs
  122195. */
  122196. static readonly MessageLogLevel: number;
  122197. /**
  122198. * Only warning logs
  122199. */
  122200. static readonly WarningLogLevel: number;
  122201. /**
  122202. * Only error logs
  122203. */
  122204. static readonly ErrorLogLevel: number;
  122205. /**
  122206. * All logs
  122207. */
  122208. static readonly AllLogLevel: number;
  122209. /**
  122210. * Gets a value indicating the number of loading errors
  122211. * @ignorenaming
  122212. */
  122213. static get errorsCount(): number;
  122214. /**
  122215. * Callback called when a new log is added
  122216. */
  122217. static OnNewCacheEntry: (entry: string) => void;
  122218. /**
  122219. * Log a message to the console
  122220. * @param message defines the message to log
  122221. */
  122222. static Log(message: string): void;
  122223. /**
  122224. * Write a warning message to the console
  122225. * @param message defines the message to log
  122226. */
  122227. static Warn(message: string): void;
  122228. /**
  122229. * Write an error message to the console
  122230. * @param message defines the message to log
  122231. */
  122232. static Error(message: string): void;
  122233. /**
  122234. * Gets current log cache (list of logs)
  122235. */
  122236. static get LogCache(): string;
  122237. /**
  122238. * Clears the log cache
  122239. */
  122240. static ClearLogCache(): void;
  122241. /**
  122242. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122243. */
  122244. static set LogLevels(level: number);
  122245. /**
  122246. * Checks if the window object exists
  122247. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122248. */
  122249. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122250. /**
  122251. * No performance log
  122252. */
  122253. static readonly PerformanceNoneLogLevel: number;
  122254. /**
  122255. * Use user marks to log performance
  122256. */
  122257. static readonly PerformanceUserMarkLogLevel: number;
  122258. /**
  122259. * Log performance to the console
  122260. */
  122261. static readonly PerformanceConsoleLogLevel: number;
  122262. private static _performance;
  122263. /**
  122264. * Sets the current performance log level
  122265. */
  122266. static set PerformanceLogLevel(level: number);
  122267. private static _StartPerformanceCounterDisabled;
  122268. private static _EndPerformanceCounterDisabled;
  122269. private static _StartUserMark;
  122270. private static _EndUserMark;
  122271. private static _StartPerformanceConsole;
  122272. private static _EndPerformanceConsole;
  122273. /**
  122274. * Starts a performance counter
  122275. */
  122276. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122277. /**
  122278. * Ends a specific performance coutner
  122279. */
  122280. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122281. /**
  122282. * Gets either window.performance.now() if supported or Date.now() else
  122283. */
  122284. static get Now(): number;
  122285. /**
  122286. * This method will return the name of the class used to create the instance of the given object.
  122287. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122288. * @param object the object to get the class name from
  122289. * @param isType defines if the object is actually a type
  122290. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122291. */
  122292. static GetClassName(object: any, isType?: boolean): string;
  122293. /**
  122294. * Gets the first element of an array satisfying a given predicate
  122295. * @param array defines the array to browse
  122296. * @param predicate defines the predicate to use
  122297. * @returns null if not found or the element
  122298. */
  122299. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122300. /**
  122301. * This method will return the name of the full name of the class, including its owning module (if any).
  122302. * 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).
  122303. * @param object the object to get the class name from
  122304. * @param isType defines if the object is actually a type
  122305. * @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.
  122306. * @ignorenaming
  122307. */
  122308. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122309. /**
  122310. * Returns a promise that resolves after the given amount of time.
  122311. * @param delay Number of milliseconds to delay
  122312. * @returns Promise that resolves after the given amount of time
  122313. */
  122314. static DelayAsync(delay: number): Promise<void>;
  122315. /**
  122316. * Utility function to detect if the current user agent is Safari
  122317. * @returns whether or not the current user agent is safari
  122318. */
  122319. static IsSafari(): boolean;
  122320. }
  122321. /**
  122322. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122323. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122324. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122325. * @param name The name of the class, case should be preserved
  122326. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122327. */
  122328. export function className(name: string, module?: string): (target: Object) => void;
  122329. /**
  122330. * An implementation of a loop for asynchronous functions.
  122331. */
  122332. export class AsyncLoop {
  122333. /**
  122334. * Defines the number of iterations for the loop
  122335. */
  122336. iterations: number;
  122337. /**
  122338. * Defines the current index of the loop.
  122339. */
  122340. index: number;
  122341. private _done;
  122342. private _fn;
  122343. private _successCallback;
  122344. /**
  122345. * Constructor.
  122346. * @param iterations the number of iterations.
  122347. * @param func the function to run each iteration
  122348. * @param successCallback the callback that will be called upon succesful execution
  122349. * @param offset starting offset.
  122350. */
  122351. constructor(
  122352. /**
  122353. * Defines the number of iterations for the loop
  122354. */
  122355. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122356. /**
  122357. * Execute the next iteration. Must be called after the last iteration was finished.
  122358. */
  122359. executeNext(): void;
  122360. /**
  122361. * Break the loop and run the success callback.
  122362. */
  122363. breakLoop(): void;
  122364. /**
  122365. * Create and run an async loop.
  122366. * @param iterations the number of iterations.
  122367. * @param fn the function to run each iteration
  122368. * @param successCallback the callback that will be called upon succesful execution
  122369. * @param offset starting offset.
  122370. * @returns the created async loop object
  122371. */
  122372. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122373. /**
  122374. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122375. * @param iterations total number of iterations
  122376. * @param syncedIterations number of synchronous iterations in each async iteration.
  122377. * @param fn the function to call each iteration.
  122378. * @param callback a success call back that will be called when iterating stops.
  122379. * @param breakFunction a break condition (optional)
  122380. * @param timeout timeout settings for the setTimeout function. default - 0.
  122381. * @returns the created async loop object
  122382. */
  122383. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122384. }
  122385. }
  122386. declare module BABYLON {
  122387. /**
  122388. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122389. * The underlying implementation relies on an associative array to ensure the best performances.
  122390. * The value can be anything including 'null' but except 'undefined'
  122391. */
  122392. export class StringDictionary<T> {
  122393. /**
  122394. * This will clear this dictionary and copy the content from the 'source' one.
  122395. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122396. * @param source the dictionary to take the content from and copy to this dictionary
  122397. */
  122398. copyFrom(source: StringDictionary<T>): void;
  122399. /**
  122400. * Get a value based from its key
  122401. * @param key the given key to get the matching value from
  122402. * @return the value if found, otherwise undefined is returned
  122403. */
  122404. get(key: string): T | undefined;
  122405. /**
  122406. * Get a value from its key or add it if it doesn't exist.
  122407. * This method will ensure you that a given key/data will be present in the dictionary.
  122408. * @param key the given key to get the matching value from
  122409. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122410. * The factory will only be invoked if there's no data for the given key.
  122411. * @return the value corresponding to the key.
  122412. */
  122413. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122414. /**
  122415. * Get a value from its key if present in the dictionary otherwise add it
  122416. * @param key the key to get the value from
  122417. * @param val if there's no such key/value pair in the dictionary add it with this value
  122418. * @return the value corresponding to the key
  122419. */
  122420. getOrAdd(key: string, val: T): T;
  122421. /**
  122422. * Check if there's a given key in the dictionary
  122423. * @param key the key to check for
  122424. * @return true if the key is present, false otherwise
  122425. */
  122426. contains(key: string): boolean;
  122427. /**
  122428. * Add a new key and its corresponding value
  122429. * @param key the key to add
  122430. * @param value the value corresponding to the key
  122431. * @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
  122432. */
  122433. add(key: string, value: T): boolean;
  122434. /**
  122435. * Update a specific value associated to a key
  122436. * @param key defines the key to use
  122437. * @param value defines the value to store
  122438. * @returns true if the value was updated (or false if the key was not found)
  122439. */
  122440. set(key: string, value: T): boolean;
  122441. /**
  122442. * Get the element of the given key and remove it from the dictionary
  122443. * @param key defines the key to search
  122444. * @returns the value associated with the key or null if not found
  122445. */
  122446. getAndRemove(key: string): Nullable<T>;
  122447. /**
  122448. * Remove a key/value from the dictionary.
  122449. * @param key the key to remove
  122450. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122451. */
  122452. remove(key: string): boolean;
  122453. /**
  122454. * Clear the whole content of the dictionary
  122455. */
  122456. clear(): void;
  122457. /**
  122458. * Gets the current count
  122459. */
  122460. get count(): number;
  122461. /**
  122462. * Execute a callback on each key/val of the dictionary.
  122463. * Note that you can remove any element in this dictionary in the callback implementation
  122464. * @param callback the callback to execute on a given key/value pair
  122465. */
  122466. forEach(callback: (key: string, val: T) => void): void;
  122467. /**
  122468. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122469. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122470. * Note that you can remove any element in this dictionary in the callback implementation
  122471. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122472. * @returns the first item
  122473. */
  122474. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122475. private _count;
  122476. private _data;
  122477. }
  122478. }
  122479. declare module BABYLON {
  122480. /** @hidden */
  122481. export interface ICollisionCoordinator {
  122482. createCollider(): Collider;
  122483. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122484. init(scene: Scene): void;
  122485. }
  122486. /** @hidden */
  122487. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122488. private _scene;
  122489. private _scaledPosition;
  122490. private _scaledVelocity;
  122491. private _finalPosition;
  122492. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122493. createCollider(): Collider;
  122494. init(scene: Scene): void;
  122495. private _collideWithWorld;
  122496. }
  122497. }
  122498. declare module BABYLON {
  122499. /**
  122500. * Class used to manage all inputs for the scene.
  122501. */
  122502. export class InputManager {
  122503. /** The distance in pixel that you have to move to prevent some events */
  122504. static DragMovementThreshold: number;
  122505. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122506. static LongPressDelay: number;
  122507. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122508. static DoubleClickDelay: number;
  122509. /** If you need to check double click without raising a single click at first click, enable this flag */
  122510. static ExclusiveDoubleClickMode: boolean;
  122511. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  122512. private _alreadyAttached;
  122513. private _wheelEventName;
  122514. private _onPointerMove;
  122515. private _onPointerDown;
  122516. private _onPointerUp;
  122517. private _initClickEvent;
  122518. private _initActionManager;
  122519. private _delayedSimpleClick;
  122520. private _delayedSimpleClickTimeout;
  122521. private _previousDelayedSimpleClickTimeout;
  122522. private _meshPickProceed;
  122523. private _previousButtonPressed;
  122524. private _currentPickResult;
  122525. private _previousPickResult;
  122526. private _totalPointersPressed;
  122527. private _doubleClickOccured;
  122528. private _pointerOverMesh;
  122529. private _pickedDownMesh;
  122530. private _pickedUpMesh;
  122531. private _pointerX;
  122532. private _pointerY;
  122533. private _unTranslatedPointerX;
  122534. private _unTranslatedPointerY;
  122535. private _startingPointerPosition;
  122536. private _previousStartingPointerPosition;
  122537. private _startingPointerTime;
  122538. private _previousStartingPointerTime;
  122539. private _pointerCaptures;
  122540. private _meshUnderPointerId;
  122541. private _onKeyDown;
  122542. private _onKeyUp;
  122543. private _onCanvasFocusObserver;
  122544. private _onCanvasBlurObserver;
  122545. private _scene;
  122546. /**
  122547. * Creates a new InputManager
  122548. * @param scene defines the hosting scene
  122549. */
  122550. constructor(scene: Scene);
  122551. /**
  122552. * Gets the mesh that is currently under the pointer
  122553. */
  122554. get meshUnderPointer(): Nullable<AbstractMesh>;
  122555. /**
  122556. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122557. * @param pointerId the pointer id to use
  122558. * @returns The mesh under this pointer id or null if not found
  122559. */
  122560. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122561. /**
  122562. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122563. */
  122564. get unTranslatedPointer(): Vector2;
  122565. /**
  122566. * Gets or sets the current on-screen X position of the pointer
  122567. */
  122568. get pointerX(): number;
  122569. set pointerX(value: number);
  122570. /**
  122571. * Gets or sets the current on-screen Y position of the pointer
  122572. */
  122573. get pointerY(): number;
  122574. set pointerY(value: number);
  122575. private _updatePointerPosition;
  122576. private _processPointerMove;
  122577. private _setRayOnPointerInfo;
  122578. private _checkPrePointerObservable;
  122579. /**
  122580. * Use this method to simulate a pointer move on a mesh
  122581. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122582. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122583. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122584. */
  122585. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122586. /**
  122587. * Use this method to simulate a pointer down on a mesh
  122588. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122589. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122590. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122591. */
  122592. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122593. private _processPointerDown;
  122594. /** @hidden */
  122595. _isPointerSwiping(): boolean;
  122596. /**
  122597. * Use this method to simulate a pointer up on a mesh
  122598. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122599. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122600. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122601. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122602. */
  122603. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122604. private _processPointerUp;
  122605. /**
  122606. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122607. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122608. * @returns true if the pointer was captured
  122609. */
  122610. isPointerCaptured(pointerId?: number): boolean;
  122611. /**
  122612. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122613. * @param attachUp defines if you want to attach events to pointerup
  122614. * @param attachDown defines if you want to attach events to pointerdown
  122615. * @param attachMove defines if you want to attach events to pointermove
  122616. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122617. */
  122618. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122619. /**
  122620. * Detaches all event handlers
  122621. */
  122622. detachControl(): void;
  122623. /**
  122624. * Force the value of meshUnderPointer
  122625. * @param mesh defines the mesh to use
  122626. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122627. */
  122628. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122629. /**
  122630. * Gets the mesh under the pointer
  122631. * @returns a Mesh or null if no mesh is under the pointer
  122632. */
  122633. getPointerOverMesh(): Nullable<AbstractMesh>;
  122634. }
  122635. }
  122636. declare module BABYLON {
  122637. /**
  122638. * This class defines the direct association between an animation and a target
  122639. */
  122640. export class TargetedAnimation {
  122641. /**
  122642. * Animation to perform
  122643. */
  122644. animation: Animation;
  122645. /**
  122646. * Target to animate
  122647. */
  122648. target: any;
  122649. /**
  122650. * Returns the string "TargetedAnimation"
  122651. * @returns "TargetedAnimation"
  122652. */
  122653. getClassName(): string;
  122654. /**
  122655. * Serialize the object
  122656. * @returns the JSON object representing the current entity
  122657. */
  122658. serialize(): any;
  122659. }
  122660. /**
  122661. * Use this class to create coordinated animations on multiple targets
  122662. */
  122663. export class AnimationGroup implements IDisposable {
  122664. /** The name of the animation group */
  122665. name: string;
  122666. private _scene;
  122667. private _targetedAnimations;
  122668. private _animatables;
  122669. private _from;
  122670. private _to;
  122671. private _isStarted;
  122672. private _isPaused;
  122673. private _speedRatio;
  122674. private _loopAnimation;
  122675. private _isAdditive;
  122676. /**
  122677. * Gets or sets the unique id of the node
  122678. */
  122679. uniqueId: number;
  122680. /**
  122681. * This observable will notify when one animation have ended
  122682. */
  122683. onAnimationEndObservable: Observable<TargetedAnimation>;
  122684. /**
  122685. * Observer raised when one animation loops
  122686. */
  122687. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122688. /**
  122689. * Observer raised when all animations have looped
  122690. */
  122691. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122692. /**
  122693. * This observable will notify when all animations have ended.
  122694. */
  122695. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122696. /**
  122697. * This observable will notify when all animations have paused.
  122698. */
  122699. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122700. /**
  122701. * This observable will notify when all animations are playing.
  122702. */
  122703. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122704. /**
  122705. * Gets the first frame
  122706. */
  122707. get from(): number;
  122708. /**
  122709. * Gets the last frame
  122710. */
  122711. get to(): number;
  122712. /**
  122713. * Define if the animations are started
  122714. */
  122715. get isStarted(): boolean;
  122716. /**
  122717. * Gets a value indicating that the current group is playing
  122718. */
  122719. get isPlaying(): boolean;
  122720. /**
  122721. * Gets or sets the speed ratio to use for all animations
  122722. */
  122723. get speedRatio(): number;
  122724. /**
  122725. * Gets or sets the speed ratio to use for all animations
  122726. */
  122727. set speedRatio(value: number);
  122728. /**
  122729. * Gets or sets if all animations should loop or not
  122730. */
  122731. get loopAnimation(): boolean;
  122732. set loopAnimation(value: boolean);
  122733. /**
  122734. * Gets or sets if all animations should be evaluated additively
  122735. */
  122736. get isAdditive(): boolean;
  122737. set isAdditive(value: boolean);
  122738. /**
  122739. * Gets the targeted animations for this animation group
  122740. */
  122741. get targetedAnimations(): Array<TargetedAnimation>;
  122742. /**
  122743. * returning the list of animatables controlled by this animation group.
  122744. */
  122745. get animatables(): Array<Animatable>;
  122746. /**
  122747. * Gets the list of target animations
  122748. */
  122749. get children(): TargetedAnimation[];
  122750. /**
  122751. * Instantiates a new Animation Group.
  122752. * This helps managing several animations at once.
  122753. * @see https://doc.babylonjs.com/how_to/group
  122754. * @param name Defines the name of the group
  122755. * @param scene Defines the scene the group belongs to
  122756. */
  122757. constructor(
  122758. /** The name of the animation group */
  122759. name: string, scene?: Nullable<Scene>);
  122760. /**
  122761. * Add an animation (with its target) in the group
  122762. * @param animation defines the animation we want to add
  122763. * @param target defines the target of the animation
  122764. * @returns the TargetedAnimation object
  122765. */
  122766. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  122767. /**
  122768. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  122769. * It can add constant keys at begin or end
  122770. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  122771. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  122772. * @returns the animation group
  122773. */
  122774. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  122775. private _animationLoopCount;
  122776. private _animationLoopFlags;
  122777. private _processLoop;
  122778. /**
  122779. * Start all animations on given targets
  122780. * @param loop defines if animations must loop
  122781. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  122782. * @param from defines the from key (optional)
  122783. * @param to defines the to key (optional)
  122784. * @param isAdditive defines the additive state for the resulting animatables (optional)
  122785. * @returns the current animation group
  122786. */
  122787. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  122788. /**
  122789. * Pause all animations
  122790. * @returns the animation group
  122791. */
  122792. pause(): AnimationGroup;
  122793. /**
  122794. * Play all animations to initial state
  122795. * This function will start() the animations if they were not started or will restart() them if they were paused
  122796. * @param loop defines if animations must loop
  122797. * @returns the animation group
  122798. */
  122799. play(loop?: boolean): AnimationGroup;
  122800. /**
  122801. * Reset all animations to initial state
  122802. * @returns the animation group
  122803. */
  122804. reset(): AnimationGroup;
  122805. /**
  122806. * Restart animations from key 0
  122807. * @returns the animation group
  122808. */
  122809. restart(): AnimationGroup;
  122810. /**
  122811. * Stop all animations
  122812. * @returns the animation group
  122813. */
  122814. stop(): AnimationGroup;
  122815. /**
  122816. * Set animation weight for all animatables
  122817. * @param weight defines the weight to use
  122818. * @return the animationGroup
  122819. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122820. */
  122821. setWeightForAllAnimatables(weight: number): AnimationGroup;
  122822. /**
  122823. * Synchronize and normalize all animatables with a source animatable
  122824. * @param root defines the root animatable to synchronize with
  122825. * @return the animationGroup
  122826. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122827. */
  122828. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  122829. /**
  122830. * Goes to a specific frame in this animation group
  122831. * @param frame the frame number to go to
  122832. * @return the animationGroup
  122833. */
  122834. goToFrame(frame: number): AnimationGroup;
  122835. /**
  122836. * Dispose all associated resources
  122837. */
  122838. dispose(): void;
  122839. private _checkAnimationGroupEnded;
  122840. /**
  122841. * Clone the current animation group and returns a copy
  122842. * @param newName defines the name of the new group
  122843. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  122844. * @returns the new aniamtion group
  122845. */
  122846. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  122847. /**
  122848. * Serializes the animationGroup to an object
  122849. * @returns Serialized object
  122850. */
  122851. serialize(): any;
  122852. /**
  122853. * Returns a new AnimationGroup object parsed from the source provided.
  122854. * @param parsedAnimationGroup defines the source
  122855. * @param scene defines the scene that will receive the animationGroup
  122856. * @returns a new AnimationGroup
  122857. */
  122858. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  122859. /**
  122860. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  122861. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  122862. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  122863. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  122864. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  122865. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  122866. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  122867. */
  122868. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  122869. /**
  122870. * Returns the string "AnimationGroup"
  122871. * @returns "AnimationGroup"
  122872. */
  122873. getClassName(): string;
  122874. /**
  122875. * Creates a detailled string about the object
  122876. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  122877. * @returns a string representing the object
  122878. */
  122879. toString(fullDetails?: boolean): string;
  122880. }
  122881. }
  122882. declare module BABYLON {
  122883. /**
  122884. * Define an interface for all classes that will hold resources
  122885. */
  122886. export interface IDisposable {
  122887. /**
  122888. * Releases all held resources
  122889. */
  122890. dispose(): void;
  122891. }
  122892. /** Interface defining initialization parameters for Scene class */
  122893. export interface SceneOptions {
  122894. /**
  122895. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  122896. * It will improve performance when the number of geometries becomes important.
  122897. */
  122898. useGeometryUniqueIdsMap?: boolean;
  122899. /**
  122900. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  122901. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  122902. */
  122903. useMaterialMeshMap?: boolean;
  122904. /**
  122905. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  122906. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  122907. */
  122908. useClonedMeshMap?: boolean;
  122909. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  122910. virtual?: boolean;
  122911. }
  122912. /**
  122913. * Represents a scene to be rendered by the engine.
  122914. * @see https://doc.babylonjs.com/features/scene
  122915. */
  122916. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  122917. /** The fog is deactivated */
  122918. static readonly FOGMODE_NONE: number;
  122919. /** The fog density is following an exponential function */
  122920. static readonly FOGMODE_EXP: number;
  122921. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  122922. static readonly FOGMODE_EXP2: number;
  122923. /** The fog density is following a linear function. */
  122924. static readonly FOGMODE_LINEAR: number;
  122925. /**
  122926. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  122927. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122928. */
  122929. static MinDeltaTime: number;
  122930. /**
  122931. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  122932. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122933. */
  122934. static MaxDeltaTime: number;
  122935. /**
  122936. * Factory used to create the default material.
  122937. * @param name The name of the material to create
  122938. * @param scene The scene to create the material for
  122939. * @returns The default material
  122940. */
  122941. static DefaultMaterialFactory(scene: Scene): Material;
  122942. /**
  122943. * Factory used to create the a collision coordinator.
  122944. * @returns The collision coordinator
  122945. */
  122946. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  122947. /** @hidden */
  122948. _inputManager: InputManager;
  122949. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  122950. cameraToUseForPointers: Nullable<Camera>;
  122951. /** @hidden */
  122952. readonly _isScene: boolean;
  122953. /** @hidden */
  122954. _blockEntityCollection: boolean;
  122955. /**
  122956. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  122957. */
  122958. autoClear: boolean;
  122959. /**
  122960. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  122961. */
  122962. autoClearDepthAndStencil: boolean;
  122963. /**
  122964. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  122965. */
  122966. clearColor: Color4;
  122967. /**
  122968. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  122969. */
  122970. ambientColor: Color3;
  122971. /**
  122972. * This is use to store the default BRDF lookup for PBR materials in your scene.
  122973. * It should only be one of the following (if not the default embedded one):
  122974. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  122975. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  122976. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  122977. * The material properties need to be setup according to the type of texture in use.
  122978. */
  122979. environmentBRDFTexture: BaseTexture;
  122980. /**
  122981. * Texture used in all pbr material as the reflection texture.
  122982. * As in the majority of the scene they are the same (exception for multi room and so on),
  122983. * this is easier to reference from here than from all the materials.
  122984. */
  122985. get environmentTexture(): Nullable<BaseTexture>;
  122986. /**
  122987. * Texture used in all pbr material as the reflection texture.
  122988. * As in the majority of the scene they are the same (exception for multi room and so on),
  122989. * this is easier to set here than in all the materials.
  122990. */
  122991. set environmentTexture(value: Nullable<BaseTexture>);
  122992. /** @hidden */
  122993. protected _environmentIntensity: number;
  122994. /**
  122995. * Intensity of the environment in all pbr material.
  122996. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  122997. * As in the majority of the scene they are the same (exception for multi room and so on),
  122998. * this is easier to reference from here than from all the materials.
  122999. */
  123000. get environmentIntensity(): number;
  123001. /**
  123002. * Intensity of the environment in all pbr material.
  123003. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123004. * As in the majority of the scene they are the same (exception for multi room and so on),
  123005. * this is easier to set here than in all the materials.
  123006. */
  123007. set environmentIntensity(value: number);
  123008. /** @hidden */
  123009. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123010. /**
  123011. * Default image processing configuration used either in the rendering
  123012. * Forward main pass or through the imageProcessingPostProcess if present.
  123013. * As in the majority of the scene they are the same (exception for multi camera),
  123014. * this is easier to reference from here than from all the materials and post process.
  123015. *
  123016. * No setter as we it is a shared configuration, you can set the values instead.
  123017. */
  123018. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123019. private _forceWireframe;
  123020. /**
  123021. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123022. */
  123023. set forceWireframe(value: boolean);
  123024. get forceWireframe(): boolean;
  123025. private _skipFrustumClipping;
  123026. /**
  123027. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123028. */
  123029. set skipFrustumClipping(value: boolean);
  123030. get skipFrustumClipping(): boolean;
  123031. private _forcePointsCloud;
  123032. /**
  123033. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123034. */
  123035. set forcePointsCloud(value: boolean);
  123036. get forcePointsCloud(): boolean;
  123037. /**
  123038. * Gets or sets the active clipplane 1
  123039. */
  123040. clipPlane: Nullable<Plane>;
  123041. /**
  123042. * Gets or sets the active clipplane 2
  123043. */
  123044. clipPlane2: Nullable<Plane>;
  123045. /**
  123046. * Gets or sets the active clipplane 3
  123047. */
  123048. clipPlane3: Nullable<Plane>;
  123049. /**
  123050. * Gets or sets the active clipplane 4
  123051. */
  123052. clipPlane4: Nullable<Plane>;
  123053. /**
  123054. * Gets or sets the active clipplane 5
  123055. */
  123056. clipPlane5: Nullable<Plane>;
  123057. /**
  123058. * Gets or sets the active clipplane 6
  123059. */
  123060. clipPlane6: Nullable<Plane>;
  123061. /**
  123062. * Gets or sets a boolean indicating if animations are enabled
  123063. */
  123064. animationsEnabled: boolean;
  123065. private _animationPropertiesOverride;
  123066. /**
  123067. * Gets or sets the animation properties override
  123068. */
  123069. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123070. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123071. /**
  123072. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123073. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123074. */
  123075. useConstantAnimationDeltaTime: boolean;
  123076. /**
  123077. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123078. * Please note that it requires to run a ray cast through the scene on every frame
  123079. */
  123080. constantlyUpdateMeshUnderPointer: boolean;
  123081. /**
  123082. * Defines the HTML cursor to use when hovering over interactive elements
  123083. */
  123084. hoverCursor: string;
  123085. /**
  123086. * Defines the HTML default cursor to use (empty by default)
  123087. */
  123088. defaultCursor: string;
  123089. /**
  123090. * Defines whether cursors are handled by the scene.
  123091. */
  123092. doNotHandleCursors: boolean;
  123093. /**
  123094. * This is used to call preventDefault() on pointer down
  123095. * in order to block unwanted artifacts like system double clicks
  123096. */
  123097. preventDefaultOnPointerDown: boolean;
  123098. /**
  123099. * This is used to call preventDefault() on pointer up
  123100. * in order to block unwanted artifacts like system double clicks
  123101. */
  123102. preventDefaultOnPointerUp: boolean;
  123103. /**
  123104. * Gets or sets user defined metadata
  123105. */
  123106. metadata: any;
  123107. /**
  123108. * For internal use only. Please do not use.
  123109. */
  123110. reservedDataStore: any;
  123111. /**
  123112. * Gets the name of the plugin used to load this scene (null by default)
  123113. */
  123114. loadingPluginName: string;
  123115. /**
  123116. * Use this array to add regular expressions used to disable offline support for specific urls
  123117. */
  123118. disableOfflineSupportExceptionRules: RegExp[];
  123119. /**
  123120. * An event triggered when the scene is disposed.
  123121. */
  123122. onDisposeObservable: Observable<Scene>;
  123123. private _onDisposeObserver;
  123124. /** Sets a function to be executed when this scene is disposed. */
  123125. set onDispose(callback: () => void);
  123126. /**
  123127. * An event triggered before rendering the scene (right after animations and physics)
  123128. */
  123129. onBeforeRenderObservable: Observable<Scene>;
  123130. private _onBeforeRenderObserver;
  123131. /** Sets a function to be executed before rendering this scene */
  123132. set beforeRender(callback: Nullable<() => void>);
  123133. /**
  123134. * An event triggered after rendering the scene
  123135. */
  123136. onAfterRenderObservable: Observable<Scene>;
  123137. /**
  123138. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123139. */
  123140. onAfterRenderCameraObservable: Observable<Camera>;
  123141. private _onAfterRenderObserver;
  123142. /** Sets a function to be executed after rendering this scene */
  123143. set afterRender(callback: Nullable<() => void>);
  123144. /**
  123145. * An event triggered before animating the scene
  123146. */
  123147. onBeforeAnimationsObservable: Observable<Scene>;
  123148. /**
  123149. * An event triggered after animations processing
  123150. */
  123151. onAfterAnimationsObservable: Observable<Scene>;
  123152. /**
  123153. * An event triggered before draw calls are ready to be sent
  123154. */
  123155. onBeforeDrawPhaseObservable: Observable<Scene>;
  123156. /**
  123157. * An event triggered after draw calls have been sent
  123158. */
  123159. onAfterDrawPhaseObservable: Observable<Scene>;
  123160. /**
  123161. * An event triggered when the scene is ready
  123162. */
  123163. onReadyObservable: Observable<Scene>;
  123164. /**
  123165. * An event triggered before rendering a camera
  123166. */
  123167. onBeforeCameraRenderObservable: Observable<Camera>;
  123168. private _onBeforeCameraRenderObserver;
  123169. /** Sets a function to be executed before rendering a camera*/
  123170. set beforeCameraRender(callback: () => void);
  123171. /**
  123172. * An event triggered after rendering a camera
  123173. */
  123174. onAfterCameraRenderObservable: Observable<Camera>;
  123175. private _onAfterCameraRenderObserver;
  123176. /** Sets a function to be executed after rendering a camera*/
  123177. set afterCameraRender(callback: () => void);
  123178. /**
  123179. * An event triggered when active meshes evaluation is about to start
  123180. */
  123181. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123182. /**
  123183. * An event triggered when active meshes evaluation is done
  123184. */
  123185. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123186. /**
  123187. * An event triggered when particles rendering is about to start
  123188. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123189. */
  123190. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123191. /**
  123192. * An event triggered when particles rendering is done
  123193. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123194. */
  123195. onAfterParticlesRenderingObservable: Observable<Scene>;
  123196. /**
  123197. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123198. */
  123199. onDataLoadedObservable: Observable<Scene>;
  123200. /**
  123201. * An event triggered when a camera is created
  123202. */
  123203. onNewCameraAddedObservable: Observable<Camera>;
  123204. /**
  123205. * An event triggered when a camera is removed
  123206. */
  123207. onCameraRemovedObservable: Observable<Camera>;
  123208. /**
  123209. * An event triggered when a light is created
  123210. */
  123211. onNewLightAddedObservable: Observable<Light>;
  123212. /**
  123213. * An event triggered when a light is removed
  123214. */
  123215. onLightRemovedObservable: Observable<Light>;
  123216. /**
  123217. * An event triggered when a geometry is created
  123218. */
  123219. onNewGeometryAddedObservable: Observable<Geometry>;
  123220. /**
  123221. * An event triggered when a geometry is removed
  123222. */
  123223. onGeometryRemovedObservable: Observable<Geometry>;
  123224. /**
  123225. * An event triggered when a transform node is created
  123226. */
  123227. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123228. /**
  123229. * An event triggered when a transform node is removed
  123230. */
  123231. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123232. /**
  123233. * An event triggered when a mesh is created
  123234. */
  123235. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123236. /**
  123237. * An event triggered when a mesh is removed
  123238. */
  123239. onMeshRemovedObservable: Observable<AbstractMesh>;
  123240. /**
  123241. * An event triggered when a skeleton is created
  123242. */
  123243. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123244. /**
  123245. * An event triggered when a skeleton is removed
  123246. */
  123247. onSkeletonRemovedObservable: Observable<Skeleton>;
  123248. /**
  123249. * An event triggered when a material is created
  123250. */
  123251. onNewMaterialAddedObservable: Observable<Material>;
  123252. /**
  123253. * An event triggered when a material is removed
  123254. */
  123255. onMaterialRemovedObservable: Observable<Material>;
  123256. /**
  123257. * An event triggered when a texture is created
  123258. */
  123259. onNewTextureAddedObservable: Observable<BaseTexture>;
  123260. /**
  123261. * An event triggered when a texture is removed
  123262. */
  123263. onTextureRemovedObservable: Observable<BaseTexture>;
  123264. /**
  123265. * An event triggered when render targets are about to be rendered
  123266. * Can happen multiple times per frame.
  123267. */
  123268. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123269. /**
  123270. * An event triggered when render targets were rendered.
  123271. * Can happen multiple times per frame.
  123272. */
  123273. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123274. /**
  123275. * An event triggered before calculating deterministic simulation step
  123276. */
  123277. onBeforeStepObservable: Observable<Scene>;
  123278. /**
  123279. * An event triggered after calculating deterministic simulation step
  123280. */
  123281. onAfterStepObservable: Observable<Scene>;
  123282. /**
  123283. * An event triggered when the activeCamera property is updated
  123284. */
  123285. onActiveCameraChanged: Observable<Scene>;
  123286. /**
  123287. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123288. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123289. * 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)
  123290. */
  123291. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123292. /**
  123293. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123294. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123295. * 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)
  123296. */
  123297. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123298. /**
  123299. * This Observable will when a mesh has been imported into the scene.
  123300. */
  123301. onMeshImportedObservable: Observable<AbstractMesh>;
  123302. /**
  123303. * This Observable will when an animation file has been imported into the scene.
  123304. */
  123305. onAnimationFileImportedObservable: Observable<Scene>;
  123306. /**
  123307. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123308. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123309. */
  123310. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123311. /** @hidden */
  123312. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123313. /**
  123314. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123315. */
  123316. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123317. /**
  123318. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123319. */
  123320. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123321. /**
  123322. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123323. */
  123324. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123325. /** Callback called when a pointer move is detected */
  123326. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123327. /** Callback called when a pointer down is detected */
  123328. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123329. /** Callback called when a pointer up is detected */
  123330. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123331. /** Callback called when a pointer pick is detected */
  123332. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123333. /**
  123334. * 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).
  123335. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123336. */
  123337. onPrePointerObservable: Observable<PointerInfoPre>;
  123338. /**
  123339. * Observable event triggered each time an input event is received from the rendering canvas
  123340. */
  123341. onPointerObservable: Observable<PointerInfo>;
  123342. /**
  123343. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123344. */
  123345. get unTranslatedPointer(): Vector2;
  123346. /**
  123347. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123348. */
  123349. static get DragMovementThreshold(): number;
  123350. static set DragMovementThreshold(value: number);
  123351. /**
  123352. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123353. */
  123354. static get LongPressDelay(): number;
  123355. static set LongPressDelay(value: number);
  123356. /**
  123357. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123358. */
  123359. static get DoubleClickDelay(): number;
  123360. static set DoubleClickDelay(value: number);
  123361. /** If you need to check double click without raising a single click at first click, enable this flag */
  123362. static get ExclusiveDoubleClickMode(): boolean;
  123363. static set ExclusiveDoubleClickMode(value: boolean);
  123364. /** @hidden */
  123365. _mirroredCameraPosition: Nullable<Vector3>;
  123366. /**
  123367. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123368. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123369. */
  123370. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123371. /**
  123372. * Observable event triggered each time an keyboard event is received from the hosting window
  123373. */
  123374. onKeyboardObservable: Observable<KeyboardInfo>;
  123375. private _useRightHandedSystem;
  123376. /**
  123377. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123378. */
  123379. set useRightHandedSystem(value: boolean);
  123380. get useRightHandedSystem(): boolean;
  123381. private _timeAccumulator;
  123382. private _currentStepId;
  123383. private _currentInternalStep;
  123384. /**
  123385. * Sets the step Id used by deterministic lock step
  123386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123387. * @param newStepId defines the step Id
  123388. */
  123389. setStepId(newStepId: number): void;
  123390. /**
  123391. * Gets the step Id used by deterministic lock step
  123392. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123393. * @returns the step Id
  123394. */
  123395. getStepId(): number;
  123396. /**
  123397. * Gets the internal step used by deterministic lock step
  123398. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123399. * @returns the internal step
  123400. */
  123401. getInternalStep(): number;
  123402. private _fogEnabled;
  123403. /**
  123404. * Gets or sets a boolean indicating if fog is enabled on this scene
  123405. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123406. * (Default is true)
  123407. */
  123408. set fogEnabled(value: boolean);
  123409. get fogEnabled(): boolean;
  123410. private _fogMode;
  123411. /**
  123412. * Gets or sets the fog mode to use
  123413. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123414. * | mode | value |
  123415. * | --- | --- |
  123416. * | FOGMODE_NONE | 0 |
  123417. * | FOGMODE_EXP | 1 |
  123418. * | FOGMODE_EXP2 | 2 |
  123419. * | FOGMODE_LINEAR | 3 |
  123420. */
  123421. set fogMode(value: number);
  123422. get fogMode(): number;
  123423. /**
  123424. * Gets or sets the fog color to use
  123425. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123426. * (Default is Color3(0.2, 0.2, 0.3))
  123427. */
  123428. fogColor: Color3;
  123429. /**
  123430. * Gets or sets the fog density to use
  123431. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123432. * (Default is 0.1)
  123433. */
  123434. fogDensity: number;
  123435. /**
  123436. * Gets or sets the fog start distance to use
  123437. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123438. * (Default is 0)
  123439. */
  123440. fogStart: number;
  123441. /**
  123442. * Gets or sets the fog end distance to use
  123443. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123444. * (Default is 1000)
  123445. */
  123446. fogEnd: number;
  123447. /**
  123448. * Flag indicating that the frame buffer binding is handled by another component
  123449. */
  123450. prePass: boolean;
  123451. private _shadowsEnabled;
  123452. /**
  123453. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123454. */
  123455. set shadowsEnabled(value: boolean);
  123456. get shadowsEnabled(): boolean;
  123457. private _lightsEnabled;
  123458. /**
  123459. * Gets or sets a boolean indicating if lights are enabled on this scene
  123460. */
  123461. set lightsEnabled(value: boolean);
  123462. get lightsEnabled(): boolean;
  123463. /** All of the active cameras added to this scene. */
  123464. activeCameras: Camera[];
  123465. /** @hidden */
  123466. _activeCamera: Nullable<Camera>;
  123467. /** Gets or sets the current active camera */
  123468. get activeCamera(): Nullable<Camera>;
  123469. set activeCamera(value: Nullable<Camera>);
  123470. private _defaultMaterial;
  123471. /** The default material used on meshes when no material is affected */
  123472. get defaultMaterial(): Material;
  123473. /** The default material used on meshes when no material is affected */
  123474. set defaultMaterial(value: Material);
  123475. private _texturesEnabled;
  123476. /**
  123477. * Gets or sets a boolean indicating if textures are enabled on this scene
  123478. */
  123479. set texturesEnabled(value: boolean);
  123480. get texturesEnabled(): boolean;
  123481. /**
  123482. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123483. */
  123484. physicsEnabled: boolean;
  123485. /**
  123486. * Gets or sets a boolean indicating if particles are enabled on this scene
  123487. */
  123488. particlesEnabled: boolean;
  123489. /**
  123490. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123491. */
  123492. spritesEnabled: boolean;
  123493. private _skeletonsEnabled;
  123494. /**
  123495. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123496. */
  123497. set skeletonsEnabled(value: boolean);
  123498. get skeletonsEnabled(): boolean;
  123499. /**
  123500. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123501. */
  123502. lensFlaresEnabled: boolean;
  123503. /**
  123504. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123505. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123506. */
  123507. collisionsEnabled: boolean;
  123508. private _collisionCoordinator;
  123509. /** @hidden */
  123510. get collisionCoordinator(): ICollisionCoordinator;
  123511. /**
  123512. * Defines the gravity applied to this scene (used only for collisions)
  123513. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123514. */
  123515. gravity: Vector3;
  123516. /**
  123517. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123518. */
  123519. postProcessesEnabled: boolean;
  123520. /**
  123521. * Gets the current postprocess manager
  123522. */
  123523. postProcessManager: PostProcessManager;
  123524. /**
  123525. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123526. */
  123527. renderTargetsEnabled: boolean;
  123528. /**
  123529. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123530. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123531. */
  123532. dumpNextRenderTargets: boolean;
  123533. /**
  123534. * The list of user defined render targets added to the scene
  123535. */
  123536. customRenderTargets: RenderTargetTexture[];
  123537. /**
  123538. * Defines if texture loading must be delayed
  123539. * If true, textures will only be loaded when they need to be rendered
  123540. */
  123541. useDelayedTextureLoading: boolean;
  123542. /**
  123543. * Gets the list of meshes imported to the scene through SceneLoader
  123544. */
  123545. importedMeshesFiles: String[];
  123546. /**
  123547. * Gets or sets a boolean indicating if probes are enabled on this scene
  123548. */
  123549. probesEnabled: boolean;
  123550. /**
  123551. * Gets or sets the current offline provider to use to store scene data
  123552. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123553. */
  123554. offlineProvider: IOfflineProvider;
  123555. /**
  123556. * Gets or sets the action manager associated with the scene
  123557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123558. */
  123559. actionManager: AbstractActionManager;
  123560. private _meshesForIntersections;
  123561. /**
  123562. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123563. */
  123564. proceduralTexturesEnabled: boolean;
  123565. private _engine;
  123566. private _totalVertices;
  123567. /** @hidden */
  123568. _activeIndices: PerfCounter;
  123569. /** @hidden */
  123570. _activeParticles: PerfCounter;
  123571. /** @hidden */
  123572. _activeBones: PerfCounter;
  123573. private _animationRatio;
  123574. /** @hidden */
  123575. _animationTimeLast: number;
  123576. /** @hidden */
  123577. _animationTime: number;
  123578. /**
  123579. * Gets or sets a general scale for animation speed
  123580. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123581. */
  123582. animationTimeScale: number;
  123583. /** @hidden */
  123584. _cachedMaterial: Nullable<Material>;
  123585. /** @hidden */
  123586. _cachedEffect: Nullable<Effect>;
  123587. /** @hidden */
  123588. _cachedVisibility: Nullable<number>;
  123589. private _renderId;
  123590. private _frameId;
  123591. private _executeWhenReadyTimeoutId;
  123592. private _intermediateRendering;
  123593. private _viewUpdateFlag;
  123594. private _projectionUpdateFlag;
  123595. /** @hidden */
  123596. _toBeDisposed: Nullable<IDisposable>[];
  123597. private _activeRequests;
  123598. /** @hidden */
  123599. _pendingData: any[];
  123600. private _isDisposed;
  123601. /**
  123602. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123603. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123604. */
  123605. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123606. private _activeMeshes;
  123607. private _processedMaterials;
  123608. private _renderTargets;
  123609. /** @hidden */
  123610. _activeParticleSystems: SmartArray<IParticleSystem>;
  123611. private _activeSkeletons;
  123612. private _softwareSkinnedMeshes;
  123613. private _renderingManager;
  123614. /** @hidden */
  123615. _activeAnimatables: Animatable[];
  123616. private _transformMatrix;
  123617. private _sceneUbo;
  123618. /** @hidden */
  123619. _viewMatrix: Matrix;
  123620. private _projectionMatrix;
  123621. /** @hidden */
  123622. _forcedViewPosition: Nullable<Vector3>;
  123623. /** @hidden */
  123624. _frustumPlanes: Plane[];
  123625. /**
  123626. * Gets the list of frustum planes (built from the active camera)
  123627. */
  123628. get frustumPlanes(): Plane[];
  123629. /**
  123630. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123631. * This is useful if there are more lights that the maximum simulteanous authorized
  123632. */
  123633. requireLightSorting: boolean;
  123634. /** @hidden */
  123635. readonly useMaterialMeshMap: boolean;
  123636. /** @hidden */
  123637. readonly useClonedMeshMap: boolean;
  123638. private _externalData;
  123639. private _uid;
  123640. /**
  123641. * @hidden
  123642. * Backing store of defined scene components.
  123643. */
  123644. _components: ISceneComponent[];
  123645. /**
  123646. * @hidden
  123647. * Backing store of defined scene components.
  123648. */
  123649. _serializableComponents: ISceneSerializableComponent[];
  123650. /**
  123651. * List of components to register on the next registration step.
  123652. */
  123653. private _transientComponents;
  123654. /**
  123655. * Registers the transient components if needed.
  123656. */
  123657. private _registerTransientComponents;
  123658. /**
  123659. * @hidden
  123660. * Add a component to the scene.
  123661. * Note that the ccomponent could be registered on th next frame if this is called after
  123662. * the register component stage.
  123663. * @param component Defines the component to add to the scene
  123664. */
  123665. _addComponent(component: ISceneComponent): void;
  123666. /**
  123667. * @hidden
  123668. * Gets a component from the scene.
  123669. * @param name defines the name of the component to retrieve
  123670. * @returns the component or null if not present
  123671. */
  123672. _getComponent(name: string): Nullable<ISceneComponent>;
  123673. /**
  123674. * @hidden
  123675. * Defines the actions happening before camera updates.
  123676. */
  123677. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123678. /**
  123679. * @hidden
  123680. * Defines the actions happening before clear the canvas.
  123681. */
  123682. _beforeClearStage: Stage<SimpleStageAction>;
  123683. /**
  123684. * @hidden
  123685. * Defines the actions when collecting render targets for the frame.
  123686. */
  123687. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123688. /**
  123689. * @hidden
  123690. * Defines the actions happening for one camera in the frame.
  123691. */
  123692. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123693. /**
  123694. * @hidden
  123695. * Defines the actions happening during the per mesh ready checks.
  123696. */
  123697. _isReadyForMeshStage: Stage<MeshStageAction>;
  123698. /**
  123699. * @hidden
  123700. * Defines the actions happening before evaluate active mesh checks.
  123701. */
  123702. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123703. /**
  123704. * @hidden
  123705. * Defines the actions happening during the evaluate sub mesh checks.
  123706. */
  123707. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123708. /**
  123709. * @hidden
  123710. * Defines the actions happening during the active mesh stage.
  123711. */
  123712. _activeMeshStage: Stage<ActiveMeshStageAction>;
  123713. /**
  123714. * @hidden
  123715. * Defines the actions happening during the per camera render target step.
  123716. */
  123717. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  123718. /**
  123719. * @hidden
  123720. * Defines the actions happening just before the active camera is drawing.
  123721. */
  123722. _beforeCameraDrawStage: Stage<CameraStageAction>;
  123723. /**
  123724. * @hidden
  123725. * Defines the actions happening just before a render target is drawing.
  123726. */
  123727. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123728. /**
  123729. * @hidden
  123730. * Defines the actions happening just before a rendering group is drawing.
  123731. */
  123732. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123733. /**
  123734. * @hidden
  123735. * Defines the actions happening just before a mesh is drawing.
  123736. */
  123737. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123738. /**
  123739. * @hidden
  123740. * Defines the actions happening just after a mesh has been drawn.
  123741. */
  123742. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123743. /**
  123744. * @hidden
  123745. * Defines the actions happening just after a rendering group has been drawn.
  123746. */
  123747. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123748. /**
  123749. * @hidden
  123750. * Defines the actions happening just after the active camera has been drawn.
  123751. */
  123752. _afterCameraDrawStage: Stage<CameraStageAction>;
  123753. /**
  123754. * @hidden
  123755. * Defines the actions happening just after a render target has been drawn.
  123756. */
  123757. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123758. /**
  123759. * @hidden
  123760. * Defines the actions happening just after rendering all cameras and computing intersections.
  123761. */
  123762. _afterRenderStage: Stage<SimpleStageAction>;
  123763. /**
  123764. * @hidden
  123765. * Defines the actions happening when a pointer move event happens.
  123766. */
  123767. _pointerMoveStage: Stage<PointerMoveStageAction>;
  123768. /**
  123769. * @hidden
  123770. * Defines the actions happening when a pointer down event happens.
  123771. */
  123772. _pointerDownStage: Stage<PointerUpDownStageAction>;
  123773. /**
  123774. * @hidden
  123775. * Defines the actions happening when a pointer up event happens.
  123776. */
  123777. _pointerUpStage: Stage<PointerUpDownStageAction>;
  123778. /**
  123779. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  123780. */
  123781. private geometriesByUniqueId;
  123782. /**
  123783. * Creates a new Scene
  123784. * @param engine defines the engine to use to render this scene
  123785. * @param options defines the scene options
  123786. */
  123787. constructor(engine: Engine, options?: SceneOptions);
  123788. /**
  123789. * Gets a string identifying the name of the class
  123790. * @returns "Scene" string
  123791. */
  123792. getClassName(): string;
  123793. private _defaultMeshCandidates;
  123794. /**
  123795. * @hidden
  123796. */
  123797. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  123798. private _defaultSubMeshCandidates;
  123799. /**
  123800. * @hidden
  123801. */
  123802. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  123803. /**
  123804. * Sets the default candidate providers for the scene.
  123805. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  123806. * and getCollidingSubMeshCandidates to their default function
  123807. */
  123808. setDefaultCandidateProviders(): void;
  123809. /**
  123810. * Gets the mesh that is currently under the pointer
  123811. */
  123812. get meshUnderPointer(): Nullable<AbstractMesh>;
  123813. /**
  123814. * Gets or sets the current on-screen X position of the pointer
  123815. */
  123816. get pointerX(): number;
  123817. set pointerX(value: number);
  123818. /**
  123819. * Gets or sets the current on-screen Y position of the pointer
  123820. */
  123821. get pointerY(): number;
  123822. set pointerY(value: number);
  123823. /**
  123824. * Gets the cached material (ie. the latest rendered one)
  123825. * @returns the cached material
  123826. */
  123827. getCachedMaterial(): Nullable<Material>;
  123828. /**
  123829. * Gets the cached effect (ie. the latest rendered one)
  123830. * @returns the cached effect
  123831. */
  123832. getCachedEffect(): Nullable<Effect>;
  123833. /**
  123834. * Gets the cached visibility state (ie. the latest rendered one)
  123835. * @returns the cached visibility state
  123836. */
  123837. getCachedVisibility(): Nullable<number>;
  123838. /**
  123839. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  123840. * @param material defines the current material
  123841. * @param effect defines the current effect
  123842. * @param visibility defines the current visibility state
  123843. * @returns true if one parameter is not cached
  123844. */
  123845. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  123846. /**
  123847. * Gets the engine associated with the scene
  123848. * @returns an Engine
  123849. */
  123850. getEngine(): Engine;
  123851. /**
  123852. * Gets the total number of vertices rendered per frame
  123853. * @returns the total number of vertices rendered per frame
  123854. */
  123855. getTotalVertices(): number;
  123856. /**
  123857. * Gets the performance counter for total vertices
  123858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123859. */
  123860. get totalVerticesPerfCounter(): PerfCounter;
  123861. /**
  123862. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  123863. * @returns the total number of active indices rendered per frame
  123864. */
  123865. getActiveIndices(): number;
  123866. /**
  123867. * Gets the performance counter for active indices
  123868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123869. */
  123870. get totalActiveIndicesPerfCounter(): PerfCounter;
  123871. /**
  123872. * Gets the total number of active particles rendered per frame
  123873. * @returns the total number of active particles rendered per frame
  123874. */
  123875. getActiveParticles(): number;
  123876. /**
  123877. * Gets the performance counter for active particles
  123878. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123879. */
  123880. get activeParticlesPerfCounter(): PerfCounter;
  123881. /**
  123882. * Gets the total number of active bones rendered per frame
  123883. * @returns the total number of active bones rendered per frame
  123884. */
  123885. getActiveBones(): number;
  123886. /**
  123887. * Gets the performance counter for active bones
  123888. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123889. */
  123890. get activeBonesPerfCounter(): PerfCounter;
  123891. /**
  123892. * Gets the array of active meshes
  123893. * @returns an array of AbstractMesh
  123894. */
  123895. getActiveMeshes(): SmartArray<AbstractMesh>;
  123896. /**
  123897. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  123898. * @returns a number
  123899. */
  123900. getAnimationRatio(): number;
  123901. /**
  123902. * Gets an unique Id for the current render phase
  123903. * @returns a number
  123904. */
  123905. getRenderId(): number;
  123906. /**
  123907. * Gets an unique Id for the current frame
  123908. * @returns a number
  123909. */
  123910. getFrameId(): number;
  123911. /** Call this function if you want to manually increment the render Id*/
  123912. incrementRenderId(): void;
  123913. private _createUbo;
  123914. /**
  123915. * Use this method to simulate a pointer move on a mesh
  123916. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123917. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123918. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123919. * @returns the current scene
  123920. */
  123921. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  123922. /**
  123923. * Use this method to simulate a pointer down on a mesh
  123924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123927. * @returns the current scene
  123928. */
  123929. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  123930. /**
  123931. * Use this method to simulate a pointer up on a mesh
  123932. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123933. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123934. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123935. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123936. * @returns the current scene
  123937. */
  123938. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  123939. /**
  123940. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123941. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123942. * @returns true if the pointer was captured
  123943. */
  123944. isPointerCaptured(pointerId?: number): boolean;
  123945. /**
  123946. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123947. * @param attachUp defines if you want to attach events to pointerup
  123948. * @param attachDown defines if you want to attach events to pointerdown
  123949. * @param attachMove defines if you want to attach events to pointermove
  123950. */
  123951. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  123952. /** Detaches all event handlers*/
  123953. detachControl(): void;
  123954. /**
  123955. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  123956. * Delay loaded resources are not taking in account
  123957. * @return true if all required resources are ready
  123958. */
  123959. isReady(): boolean;
  123960. /** Resets all cached information relative to material (including effect and visibility) */
  123961. resetCachedMaterial(): void;
  123962. /**
  123963. * Registers a function to be called before every frame render
  123964. * @param func defines the function to register
  123965. */
  123966. registerBeforeRender(func: () => void): void;
  123967. /**
  123968. * Unregisters a function called before every frame render
  123969. * @param func defines the function to unregister
  123970. */
  123971. unregisterBeforeRender(func: () => void): void;
  123972. /**
  123973. * Registers a function to be called after every frame render
  123974. * @param func defines the function to register
  123975. */
  123976. registerAfterRender(func: () => void): void;
  123977. /**
  123978. * Unregisters a function called after every frame render
  123979. * @param func defines the function to unregister
  123980. */
  123981. unregisterAfterRender(func: () => void): void;
  123982. private _executeOnceBeforeRender;
  123983. /**
  123984. * The provided function will run before render once and will be disposed afterwards.
  123985. * A timeout delay can be provided so that the function will be executed in N ms.
  123986. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  123987. * @param func The function to be executed.
  123988. * @param timeout optional delay in ms
  123989. */
  123990. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  123991. /** @hidden */
  123992. _addPendingData(data: any): void;
  123993. /** @hidden */
  123994. _removePendingData(data: any): void;
  123995. /**
  123996. * Returns the number of items waiting to be loaded
  123997. * @returns the number of items waiting to be loaded
  123998. */
  123999. getWaitingItemsCount(): number;
  124000. /**
  124001. * Returns a boolean indicating if the scene is still loading data
  124002. */
  124003. get isLoading(): boolean;
  124004. /**
  124005. * Registers a function to be executed when the scene is ready
  124006. * @param {Function} func - the function to be executed
  124007. */
  124008. executeWhenReady(func: () => void): void;
  124009. /**
  124010. * Returns a promise that resolves when the scene is ready
  124011. * @returns A promise that resolves when the scene is ready
  124012. */
  124013. whenReadyAsync(): Promise<void>;
  124014. /** @hidden */
  124015. _checkIsReady(): void;
  124016. /**
  124017. * Gets all animatable attached to the scene
  124018. */
  124019. get animatables(): Animatable[];
  124020. /**
  124021. * Resets the last animation time frame.
  124022. * Useful to override when animations start running when loading a scene for the first time.
  124023. */
  124024. resetLastAnimationTimeFrame(): void;
  124025. /**
  124026. * Gets the current view matrix
  124027. * @returns a Matrix
  124028. */
  124029. getViewMatrix(): Matrix;
  124030. /**
  124031. * Gets the current projection matrix
  124032. * @returns a Matrix
  124033. */
  124034. getProjectionMatrix(): Matrix;
  124035. /**
  124036. * Gets the current transform matrix
  124037. * @returns a Matrix made of View * Projection
  124038. */
  124039. getTransformMatrix(): Matrix;
  124040. /**
  124041. * Sets the current transform matrix
  124042. * @param viewL defines the View matrix to use
  124043. * @param projectionL defines the Projection matrix to use
  124044. * @param viewR defines the right View matrix to use (if provided)
  124045. * @param projectionR defines the right Projection matrix to use (if provided)
  124046. */
  124047. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124048. /**
  124049. * Gets the uniform buffer used to store scene data
  124050. * @returns a UniformBuffer
  124051. */
  124052. getSceneUniformBuffer(): UniformBuffer;
  124053. /**
  124054. * Gets an unique (relatively to the current scene) Id
  124055. * @returns an unique number for the scene
  124056. */
  124057. getUniqueId(): number;
  124058. /**
  124059. * Add a mesh to the list of scene's meshes
  124060. * @param newMesh defines the mesh to add
  124061. * @param recursive if all child meshes should also be added to the scene
  124062. */
  124063. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124064. /**
  124065. * Remove a mesh for the list of scene's meshes
  124066. * @param toRemove defines the mesh to remove
  124067. * @param recursive if all child meshes should also be removed from the scene
  124068. * @returns the index where the mesh was in the mesh list
  124069. */
  124070. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124071. /**
  124072. * Add a transform node to the list of scene's transform nodes
  124073. * @param newTransformNode defines the transform node to add
  124074. */
  124075. addTransformNode(newTransformNode: TransformNode): void;
  124076. /**
  124077. * Remove a transform node for the list of scene's transform nodes
  124078. * @param toRemove defines the transform node to remove
  124079. * @returns the index where the transform node was in the transform node list
  124080. */
  124081. removeTransformNode(toRemove: TransformNode): number;
  124082. /**
  124083. * Remove a skeleton for the list of scene's skeletons
  124084. * @param toRemove defines the skeleton to remove
  124085. * @returns the index where the skeleton was in the skeleton list
  124086. */
  124087. removeSkeleton(toRemove: Skeleton): number;
  124088. /**
  124089. * Remove a morph target for the list of scene's morph targets
  124090. * @param toRemove defines the morph target to remove
  124091. * @returns the index where the morph target was in the morph target list
  124092. */
  124093. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124094. /**
  124095. * Remove a light for the list of scene's lights
  124096. * @param toRemove defines the light to remove
  124097. * @returns the index where the light was in the light list
  124098. */
  124099. removeLight(toRemove: Light): number;
  124100. /**
  124101. * Remove a camera for the list of scene's cameras
  124102. * @param toRemove defines the camera to remove
  124103. * @returns the index where the camera was in the camera list
  124104. */
  124105. removeCamera(toRemove: Camera): number;
  124106. /**
  124107. * Remove a particle system for the list of scene's particle systems
  124108. * @param toRemove defines the particle system to remove
  124109. * @returns the index where the particle system was in the particle system list
  124110. */
  124111. removeParticleSystem(toRemove: IParticleSystem): number;
  124112. /**
  124113. * Remove a animation for the list of scene's animations
  124114. * @param toRemove defines the animation to remove
  124115. * @returns the index where the animation was in the animation list
  124116. */
  124117. removeAnimation(toRemove: Animation): number;
  124118. /**
  124119. * Will stop the animation of the given target
  124120. * @param target - the target
  124121. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124122. * @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)
  124123. */
  124124. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124125. /**
  124126. * Removes the given animation group from this scene.
  124127. * @param toRemove The animation group to remove
  124128. * @returns The index of the removed animation group
  124129. */
  124130. removeAnimationGroup(toRemove: AnimationGroup): number;
  124131. /**
  124132. * Removes the given multi-material from this scene.
  124133. * @param toRemove The multi-material to remove
  124134. * @returns The index of the removed multi-material
  124135. */
  124136. removeMultiMaterial(toRemove: MultiMaterial): number;
  124137. /**
  124138. * Removes the given material from this scene.
  124139. * @param toRemove The material to remove
  124140. * @returns The index of the removed material
  124141. */
  124142. removeMaterial(toRemove: Material): number;
  124143. /**
  124144. * Removes the given action manager from this scene.
  124145. * @param toRemove The action manager to remove
  124146. * @returns The index of the removed action manager
  124147. */
  124148. removeActionManager(toRemove: AbstractActionManager): number;
  124149. /**
  124150. * Removes the given texture from this scene.
  124151. * @param toRemove The texture to remove
  124152. * @returns The index of the removed texture
  124153. */
  124154. removeTexture(toRemove: BaseTexture): number;
  124155. /**
  124156. * Adds the given light to this scene
  124157. * @param newLight The light to add
  124158. */
  124159. addLight(newLight: Light): void;
  124160. /**
  124161. * Sorts the list list based on light priorities
  124162. */
  124163. sortLightsByPriority(): void;
  124164. /**
  124165. * Adds the given camera to this scene
  124166. * @param newCamera The camera to add
  124167. */
  124168. addCamera(newCamera: Camera): void;
  124169. /**
  124170. * Adds the given skeleton to this scene
  124171. * @param newSkeleton The skeleton to add
  124172. */
  124173. addSkeleton(newSkeleton: Skeleton): void;
  124174. /**
  124175. * Adds the given particle system to this scene
  124176. * @param newParticleSystem The particle system to add
  124177. */
  124178. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124179. /**
  124180. * Adds the given animation to this scene
  124181. * @param newAnimation The animation to add
  124182. */
  124183. addAnimation(newAnimation: Animation): void;
  124184. /**
  124185. * Adds the given animation group to this scene.
  124186. * @param newAnimationGroup The animation group to add
  124187. */
  124188. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124189. /**
  124190. * Adds the given multi-material to this scene
  124191. * @param newMultiMaterial The multi-material to add
  124192. */
  124193. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124194. /**
  124195. * Adds the given material to this scene
  124196. * @param newMaterial The material to add
  124197. */
  124198. addMaterial(newMaterial: Material): void;
  124199. /**
  124200. * Adds the given morph target to this scene
  124201. * @param newMorphTargetManager The morph target to add
  124202. */
  124203. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124204. /**
  124205. * Adds the given geometry to this scene
  124206. * @param newGeometry The geometry to add
  124207. */
  124208. addGeometry(newGeometry: Geometry): void;
  124209. /**
  124210. * Adds the given action manager to this scene
  124211. * @param newActionManager The action manager to add
  124212. */
  124213. addActionManager(newActionManager: AbstractActionManager): void;
  124214. /**
  124215. * Adds the given texture to this scene.
  124216. * @param newTexture The texture to add
  124217. */
  124218. addTexture(newTexture: BaseTexture): void;
  124219. /**
  124220. * Switch active camera
  124221. * @param newCamera defines the new active camera
  124222. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124223. */
  124224. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124225. /**
  124226. * sets the active camera of the scene using its ID
  124227. * @param id defines the camera's ID
  124228. * @return the new active camera or null if none found.
  124229. */
  124230. setActiveCameraByID(id: string): Nullable<Camera>;
  124231. /**
  124232. * sets the active camera of the scene using its name
  124233. * @param name defines the camera's name
  124234. * @returns the new active camera or null if none found.
  124235. */
  124236. setActiveCameraByName(name: string): Nullable<Camera>;
  124237. /**
  124238. * get an animation group using its name
  124239. * @param name defines the material's name
  124240. * @return the animation group or null if none found.
  124241. */
  124242. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124243. /**
  124244. * Get a material using its unique id
  124245. * @param uniqueId defines the material's unique id
  124246. * @return the material or null if none found.
  124247. */
  124248. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124249. /**
  124250. * get a material using its id
  124251. * @param id defines the material's ID
  124252. * @return the material or null if none found.
  124253. */
  124254. getMaterialByID(id: string): Nullable<Material>;
  124255. /**
  124256. * Gets a the last added material using a given id
  124257. * @param id defines the material's ID
  124258. * @return the last material with the given id or null if none found.
  124259. */
  124260. getLastMaterialByID(id: string): Nullable<Material>;
  124261. /**
  124262. * Gets a material using its name
  124263. * @param name defines the material's name
  124264. * @return the material or null if none found.
  124265. */
  124266. getMaterialByName(name: string): Nullable<Material>;
  124267. /**
  124268. * Get a texture using its unique id
  124269. * @param uniqueId defines the texture's unique id
  124270. * @return the texture or null if none found.
  124271. */
  124272. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124273. /**
  124274. * Gets a camera using its id
  124275. * @param id defines the id to look for
  124276. * @returns the camera or null if not found
  124277. */
  124278. getCameraByID(id: string): Nullable<Camera>;
  124279. /**
  124280. * Gets a camera using its unique id
  124281. * @param uniqueId defines the unique id to look for
  124282. * @returns the camera or null if not found
  124283. */
  124284. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124285. /**
  124286. * Gets a camera using its name
  124287. * @param name defines the camera's name
  124288. * @return the camera or null if none found.
  124289. */
  124290. getCameraByName(name: string): Nullable<Camera>;
  124291. /**
  124292. * Gets a bone using its id
  124293. * @param id defines the bone's id
  124294. * @return the bone or null if not found
  124295. */
  124296. getBoneByID(id: string): Nullable<Bone>;
  124297. /**
  124298. * Gets a bone using its id
  124299. * @param name defines the bone's name
  124300. * @return the bone or null if not found
  124301. */
  124302. getBoneByName(name: string): Nullable<Bone>;
  124303. /**
  124304. * Gets a light node using its name
  124305. * @param name defines the the light's name
  124306. * @return the light or null if none found.
  124307. */
  124308. getLightByName(name: string): Nullable<Light>;
  124309. /**
  124310. * Gets a light node using its id
  124311. * @param id defines the light's id
  124312. * @return the light or null if none found.
  124313. */
  124314. getLightByID(id: string): Nullable<Light>;
  124315. /**
  124316. * Gets a light node using its scene-generated unique ID
  124317. * @param uniqueId defines the light's unique id
  124318. * @return the light or null if none found.
  124319. */
  124320. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124321. /**
  124322. * Gets a particle system by id
  124323. * @param id defines the particle system id
  124324. * @return the corresponding system or null if none found
  124325. */
  124326. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124327. /**
  124328. * Gets a geometry using its ID
  124329. * @param id defines the geometry's id
  124330. * @return the geometry or null if none found.
  124331. */
  124332. getGeometryByID(id: string): Nullable<Geometry>;
  124333. private _getGeometryByUniqueID;
  124334. /**
  124335. * Add a new geometry to this scene
  124336. * @param geometry defines the geometry to be added to the scene.
  124337. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124338. * @return a boolean defining if the geometry was added or not
  124339. */
  124340. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124341. /**
  124342. * Removes an existing geometry
  124343. * @param geometry defines the geometry to be removed from the scene
  124344. * @return a boolean defining if the geometry was removed or not
  124345. */
  124346. removeGeometry(geometry: Geometry): boolean;
  124347. /**
  124348. * Gets the list of geometries attached to the scene
  124349. * @returns an array of Geometry
  124350. */
  124351. getGeometries(): Geometry[];
  124352. /**
  124353. * Gets the first added mesh found of a given ID
  124354. * @param id defines the id to search for
  124355. * @return the mesh found or null if not found at all
  124356. */
  124357. getMeshByID(id: string): Nullable<AbstractMesh>;
  124358. /**
  124359. * Gets a list of meshes using their id
  124360. * @param id defines the id to search for
  124361. * @returns a list of meshes
  124362. */
  124363. getMeshesByID(id: string): Array<AbstractMesh>;
  124364. /**
  124365. * Gets the first added transform node found of a given ID
  124366. * @param id defines the id to search for
  124367. * @return the found transform node or null if not found at all.
  124368. */
  124369. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124370. /**
  124371. * Gets a transform node with its auto-generated unique id
  124372. * @param uniqueId efines the unique id to search for
  124373. * @return the found transform node or null if not found at all.
  124374. */
  124375. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124376. /**
  124377. * Gets a list of transform nodes using their id
  124378. * @param id defines the id to search for
  124379. * @returns a list of transform nodes
  124380. */
  124381. getTransformNodesByID(id: string): Array<TransformNode>;
  124382. /**
  124383. * Gets a mesh with its auto-generated unique id
  124384. * @param uniqueId defines the unique id to search for
  124385. * @return the found mesh or null if not found at all.
  124386. */
  124387. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124388. /**
  124389. * Gets a the last added mesh using a given id
  124390. * @param id defines the id to search for
  124391. * @return the found mesh or null if not found at all.
  124392. */
  124393. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124394. /**
  124395. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124396. * @param id defines the id to search for
  124397. * @return the found node or null if not found at all
  124398. */
  124399. getLastEntryByID(id: string): Nullable<Node>;
  124400. /**
  124401. * Gets a node (Mesh, Camera, Light) using a given id
  124402. * @param id defines the id to search for
  124403. * @return the found node or null if not found at all
  124404. */
  124405. getNodeByID(id: string): Nullable<Node>;
  124406. /**
  124407. * Gets a node (Mesh, Camera, Light) using a given name
  124408. * @param name defines the name to search for
  124409. * @return the found node or null if not found at all.
  124410. */
  124411. getNodeByName(name: string): Nullable<Node>;
  124412. /**
  124413. * Gets a mesh using a given name
  124414. * @param name defines the name to search for
  124415. * @return the found mesh or null if not found at all.
  124416. */
  124417. getMeshByName(name: string): Nullable<AbstractMesh>;
  124418. /**
  124419. * Gets a transform node using a given name
  124420. * @param name defines the name to search for
  124421. * @return the found transform node or null if not found at all.
  124422. */
  124423. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124424. /**
  124425. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124426. * @param id defines the id to search for
  124427. * @return the found skeleton or null if not found at all.
  124428. */
  124429. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124430. /**
  124431. * Gets a skeleton using a given auto generated unique id
  124432. * @param uniqueId defines the unique id to search for
  124433. * @return the found skeleton or null if not found at all.
  124434. */
  124435. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124436. /**
  124437. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124438. * @param id defines the id to search for
  124439. * @return the found skeleton or null if not found at all.
  124440. */
  124441. getSkeletonById(id: string): Nullable<Skeleton>;
  124442. /**
  124443. * Gets a skeleton using a given name
  124444. * @param name defines the name to search for
  124445. * @return the found skeleton or null if not found at all.
  124446. */
  124447. getSkeletonByName(name: string): Nullable<Skeleton>;
  124448. /**
  124449. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124450. * @param id defines the id to search for
  124451. * @return the found morph target manager or null if not found at all.
  124452. */
  124453. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124454. /**
  124455. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124456. * @param id defines the id to search for
  124457. * @return the found morph target or null if not found at all.
  124458. */
  124459. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124460. /**
  124461. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124462. * @param name defines the name to search for
  124463. * @return the found morph target or null if not found at all.
  124464. */
  124465. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124466. /**
  124467. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124468. * @param name defines the name to search for
  124469. * @return the found post process or null if not found at all.
  124470. */
  124471. getPostProcessByName(name: string): Nullable<PostProcess>;
  124472. /**
  124473. * Gets a boolean indicating if the given mesh is active
  124474. * @param mesh defines the mesh to look for
  124475. * @returns true if the mesh is in the active list
  124476. */
  124477. isActiveMesh(mesh: AbstractMesh): boolean;
  124478. /**
  124479. * Return a unique id as a string which can serve as an identifier for the scene
  124480. */
  124481. get uid(): string;
  124482. /**
  124483. * Add an externaly attached data from its key.
  124484. * This method call will fail and return false, if such key already exists.
  124485. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124486. * @param key the unique key that identifies the data
  124487. * @param data the data object to associate to the key for this Engine instance
  124488. * @return true if no such key were already present and the data was added successfully, false otherwise
  124489. */
  124490. addExternalData<T>(key: string, data: T): boolean;
  124491. /**
  124492. * Get an externaly attached data from its key
  124493. * @param key the unique key that identifies the data
  124494. * @return the associated data, if present (can be null), or undefined if not present
  124495. */
  124496. getExternalData<T>(key: string): Nullable<T>;
  124497. /**
  124498. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124499. * @param key the unique key that identifies the data
  124500. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124501. * @return the associated data, can be null if the factory returned null.
  124502. */
  124503. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124504. /**
  124505. * Remove an externaly attached data from the Engine instance
  124506. * @param key the unique key that identifies the data
  124507. * @return true if the data was successfully removed, false if it doesn't exist
  124508. */
  124509. removeExternalData(key: string): boolean;
  124510. private _evaluateSubMesh;
  124511. /**
  124512. * Clear the processed materials smart array preventing retention point in material dispose.
  124513. */
  124514. freeProcessedMaterials(): void;
  124515. private _preventFreeActiveMeshesAndRenderingGroups;
  124516. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124517. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124518. * when disposing several meshes in a row or a hierarchy of meshes.
  124519. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124520. */
  124521. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124522. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124523. /**
  124524. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124525. */
  124526. freeActiveMeshes(): void;
  124527. /**
  124528. * Clear the info related to rendering groups preventing retention points during dispose.
  124529. */
  124530. freeRenderingGroups(): void;
  124531. /** @hidden */
  124532. _isInIntermediateRendering(): boolean;
  124533. /**
  124534. * Lambda returning the list of potentially active meshes.
  124535. */
  124536. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124537. /**
  124538. * Lambda returning the list of potentially active sub meshes.
  124539. */
  124540. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124541. /**
  124542. * Lambda returning the list of potentially intersecting sub meshes.
  124543. */
  124544. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124545. /**
  124546. * Lambda returning the list of potentially colliding sub meshes.
  124547. */
  124548. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124549. private _activeMeshesFrozen;
  124550. private _skipEvaluateActiveMeshesCompletely;
  124551. /**
  124552. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124553. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124554. * @param onSuccess optional success callback
  124555. * @param onError optional error callback
  124556. * @returns the current scene
  124557. */
  124558. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124559. /**
  124560. * Use this function to restart evaluating active meshes on every frame
  124561. * @returns the current scene
  124562. */
  124563. unfreezeActiveMeshes(): Scene;
  124564. private _evaluateActiveMeshes;
  124565. private _activeMesh;
  124566. /**
  124567. * Update the transform matrix to update from the current active camera
  124568. * @param force defines a boolean used to force the update even if cache is up to date
  124569. */
  124570. updateTransformMatrix(force?: boolean): void;
  124571. private _bindFrameBuffer;
  124572. /** @hidden */
  124573. _allowPostProcessClearColor: boolean;
  124574. /** @hidden */
  124575. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124576. private _processSubCameras;
  124577. private _checkIntersections;
  124578. /** @hidden */
  124579. _advancePhysicsEngineStep(step: number): void;
  124580. /**
  124581. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124582. */
  124583. getDeterministicFrameTime: () => number;
  124584. /** @hidden */
  124585. _animate(): void;
  124586. /** Execute all animations (for a frame) */
  124587. animate(): void;
  124588. /**
  124589. * Render the scene
  124590. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124591. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124592. */
  124593. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124594. /**
  124595. * Freeze all materials
  124596. * A frozen material will not be updatable but should be faster to render
  124597. */
  124598. freezeMaterials(): void;
  124599. /**
  124600. * Unfreeze all materials
  124601. * A frozen material will not be updatable but should be faster to render
  124602. */
  124603. unfreezeMaterials(): void;
  124604. /**
  124605. * Releases all held ressources
  124606. */
  124607. dispose(): void;
  124608. /**
  124609. * Gets if the scene is already disposed
  124610. */
  124611. get isDisposed(): boolean;
  124612. /**
  124613. * Call this function to reduce memory footprint of the scene.
  124614. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124615. */
  124616. clearCachedVertexData(): void;
  124617. /**
  124618. * This function will remove the local cached buffer data from texture.
  124619. * It will save memory but will prevent the texture from being rebuilt
  124620. */
  124621. cleanCachedTextureBuffer(): void;
  124622. /**
  124623. * Get the world extend vectors with an optional filter
  124624. *
  124625. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124626. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124627. */
  124628. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124629. min: Vector3;
  124630. max: Vector3;
  124631. };
  124632. /**
  124633. * Creates a ray that can be used to pick in the scene
  124634. * @param x defines the x coordinate of the origin (on-screen)
  124635. * @param y defines the y coordinate of the origin (on-screen)
  124636. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124637. * @param camera defines the camera to use for the picking
  124638. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124639. * @returns a Ray
  124640. */
  124641. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124642. /**
  124643. * Creates a ray that can be used to pick in the scene
  124644. * @param x defines the x coordinate of the origin (on-screen)
  124645. * @param y defines the y coordinate of the origin (on-screen)
  124646. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124647. * @param result defines the ray where to store the picking ray
  124648. * @param camera defines the camera to use for the picking
  124649. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124650. * @returns the current scene
  124651. */
  124652. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124653. /**
  124654. * Creates a ray that can be used to pick in the scene
  124655. * @param x defines the x coordinate of the origin (on-screen)
  124656. * @param y defines the y coordinate of the origin (on-screen)
  124657. * @param camera defines the camera to use for the picking
  124658. * @returns a Ray
  124659. */
  124660. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124661. /**
  124662. * Creates a ray that can be used to pick in the scene
  124663. * @param x defines the x coordinate of the origin (on-screen)
  124664. * @param y defines the y coordinate of the origin (on-screen)
  124665. * @param result defines the ray where to store the picking ray
  124666. * @param camera defines the camera to use for the picking
  124667. * @returns the current scene
  124668. */
  124669. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124670. /** Launch a ray to try to pick a mesh in the scene
  124671. * @param x position on screen
  124672. * @param y position on screen
  124673. * @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
  124674. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124675. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124677. * @returns a PickingInfo
  124678. */
  124679. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124680. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124681. * @param x position on screen
  124682. * @param y position on screen
  124683. * @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
  124684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124685. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124686. * @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)
  124687. */
  124688. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124689. /** Use the given ray to pick a mesh in the scene
  124690. * @param ray The ray to use to pick meshes
  124691. * @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
  124692. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124694. * @returns a PickingInfo
  124695. */
  124696. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124697. /**
  124698. * Launch a ray to try to pick a mesh in the scene
  124699. * @param x X position on screen
  124700. * @param y Y position on screen
  124701. * @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
  124702. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124704. * @returns an array of PickingInfo
  124705. */
  124706. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124707. /**
  124708. * Launch a ray to try to pick a mesh in the scene
  124709. * @param ray Ray to use
  124710. * @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
  124711. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124712. * @returns an array of PickingInfo
  124713. */
  124714. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124715. /**
  124716. * Force the value of meshUnderPointer
  124717. * @param mesh defines the mesh to use
  124718. * @param pointerId optional pointer id when using more than one pointer
  124719. */
  124720. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124721. /**
  124722. * Gets the mesh under the pointer
  124723. * @returns a Mesh or null if no mesh is under the pointer
  124724. */
  124725. getPointerOverMesh(): Nullable<AbstractMesh>;
  124726. /** @hidden */
  124727. _rebuildGeometries(): void;
  124728. /** @hidden */
  124729. _rebuildTextures(): void;
  124730. private _getByTags;
  124731. /**
  124732. * Get a list of meshes by tags
  124733. * @param tagsQuery defines the tags query to use
  124734. * @param forEach defines a predicate used to filter results
  124735. * @returns an array of Mesh
  124736. */
  124737. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  124738. /**
  124739. * Get a list of cameras by tags
  124740. * @param tagsQuery defines the tags query to use
  124741. * @param forEach defines a predicate used to filter results
  124742. * @returns an array of Camera
  124743. */
  124744. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  124745. /**
  124746. * Get a list of lights by tags
  124747. * @param tagsQuery defines the tags query to use
  124748. * @param forEach defines a predicate used to filter results
  124749. * @returns an array of Light
  124750. */
  124751. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  124752. /**
  124753. * Get a list of materials by tags
  124754. * @param tagsQuery defines the tags query to use
  124755. * @param forEach defines a predicate used to filter results
  124756. * @returns an array of Material
  124757. */
  124758. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  124759. /**
  124760. * Get a list of transform nodes by tags
  124761. * @param tagsQuery defines the tags query to use
  124762. * @param forEach defines a predicate used to filter results
  124763. * @returns an array of TransformNode
  124764. */
  124765. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  124766. /**
  124767. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  124768. * This allowed control for front to back rendering or reversly depending of the special needs.
  124769. *
  124770. * @param renderingGroupId The rendering group id corresponding to its index
  124771. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  124772. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  124773. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  124774. */
  124775. 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;
  124776. /**
  124777. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  124778. *
  124779. * @param renderingGroupId The rendering group id corresponding to its index
  124780. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124781. * @param depth Automatically clears depth between groups if true and autoClear is true.
  124782. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  124783. */
  124784. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  124785. /**
  124786. * Gets the current auto clear configuration for one rendering group of the rendering
  124787. * manager.
  124788. * @param index the rendering group index to get the information for
  124789. * @returns The auto clear setup for the requested rendering group
  124790. */
  124791. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  124792. private _blockMaterialDirtyMechanism;
  124793. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  124794. get blockMaterialDirtyMechanism(): boolean;
  124795. set blockMaterialDirtyMechanism(value: boolean);
  124796. /**
  124797. * Will flag all materials as dirty to trigger new shader compilation
  124798. * @param flag defines the flag used to specify which material part must be marked as dirty
  124799. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  124800. */
  124801. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  124802. /** @hidden */
  124803. _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;
  124804. /** @hidden */
  124805. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124806. /** @hidden */
  124807. _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;
  124808. /** @hidden */
  124809. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  124810. /** @hidden */
  124811. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  124812. /** @hidden */
  124813. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124814. }
  124815. }
  124816. declare module BABYLON {
  124817. /**
  124818. * Set of assets to keep when moving a scene into an asset container.
  124819. */
  124820. export class KeepAssets extends AbstractScene {
  124821. }
  124822. /**
  124823. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  124824. */
  124825. export class InstantiatedEntries {
  124826. /**
  124827. * List of new root nodes (eg. nodes with no parent)
  124828. */
  124829. rootNodes: TransformNode[];
  124830. /**
  124831. * List of new skeletons
  124832. */
  124833. skeletons: Skeleton[];
  124834. /**
  124835. * List of new animation groups
  124836. */
  124837. animationGroups: AnimationGroup[];
  124838. }
  124839. /**
  124840. * Container with a set of assets that can be added or removed from a scene.
  124841. */
  124842. export class AssetContainer extends AbstractScene {
  124843. private _wasAddedToScene;
  124844. /**
  124845. * The scene the AssetContainer belongs to.
  124846. */
  124847. scene: Scene;
  124848. /**
  124849. * Instantiates an AssetContainer.
  124850. * @param scene The scene the AssetContainer belongs to.
  124851. */
  124852. constructor(scene: Scene);
  124853. /**
  124854. * Instantiate or clone all meshes and add the new ones to the scene.
  124855. * Skeletons and animation groups will all be cloned
  124856. * @param nameFunction defines an optional function used to get new names for clones
  124857. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  124858. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  124859. */
  124860. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  124861. /**
  124862. * Adds all the assets from the container to the scene.
  124863. */
  124864. addAllToScene(): void;
  124865. /**
  124866. * Removes all the assets in the container from the scene
  124867. */
  124868. removeAllFromScene(): void;
  124869. /**
  124870. * Disposes all the assets in the container
  124871. */
  124872. dispose(): void;
  124873. private _moveAssets;
  124874. /**
  124875. * Removes all the assets contained in the scene and adds them to the container.
  124876. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  124877. */
  124878. moveAllFromScene(keepAssets?: KeepAssets): void;
  124879. /**
  124880. * 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.
  124881. * @returns the root mesh
  124882. */
  124883. createRootMesh(): Mesh;
  124884. /**
  124885. * Merge animations (direct and animation groups) from this asset container into a scene
  124886. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124887. * @param animatables set of animatables to retarget to a node from the scene
  124888. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  124889. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  124890. */
  124891. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  124892. }
  124893. }
  124894. declare module BABYLON {
  124895. /**
  124896. * Defines how the parser contract is defined.
  124897. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  124898. */
  124899. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  124900. /**
  124901. * Defines how the individual parser contract is defined.
  124902. * These parser can parse an individual asset
  124903. */
  124904. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  124905. /**
  124906. * Base class of the scene acting as a container for the different elements composing a scene.
  124907. * This class is dynamically extended by the different components of the scene increasing
  124908. * flexibility and reducing coupling
  124909. */
  124910. export abstract class AbstractScene {
  124911. /**
  124912. * Stores the list of available parsers in the application.
  124913. */
  124914. private static _BabylonFileParsers;
  124915. /**
  124916. * Stores the list of available individual parsers in the application.
  124917. */
  124918. private static _IndividualBabylonFileParsers;
  124919. /**
  124920. * Adds a parser in the list of available ones
  124921. * @param name Defines the name of the parser
  124922. * @param parser Defines the parser to add
  124923. */
  124924. static AddParser(name: string, parser: BabylonFileParser): void;
  124925. /**
  124926. * Gets a general parser from the list of avaialble ones
  124927. * @param name Defines the name of the parser
  124928. * @returns the requested parser or null
  124929. */
  124930. static GetParser(name: string): Nullable<BabylonFileParser>;
  124931. /**
  124932. * Adds n individual parser in the list of available ones
  124933. * @param name Defines the name of the parser
  124934. * @param parser Defines the parser to add
  124935. */
  124936. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  124937. /**
  124938. * Gets an individual parser from the list of avaialble ones
  124939. * @param name Defines the name of the parser
  124940. * @returns the requested parser or null
  124941. */
  124942. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  124943. /**
  124944. * Parser json data and populate both a scene and its associated container object
  124945. * @param jsonData Defines the data to parse
  124946. * @param scene Defines the scene to parse the data for
  124947. * @param container Defines the container attached to the parsing sequence
  124948. * @param rootUrl Defines the root url of the data
  124949. */
  124950. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  124951. /**
  124952. * Gets the list of root nodes (ie. nodes with no parent)
  124953. */
  124954. rootNodes: Node[];
  124955. /** All of the cameras added to this scene
  124956. * @see https://doc.babylonjs.com/babylon101/cameras
  124957. */
  124958. cameras: Camera[];
  124959. /**
  124960. * All of the lights added to this scene
  124961. * @see https://doc.babylonjs.com/babylon101/lights
  124962. */
  124963. lights: Light[];
  124964. /**
  124965. * All of the (abstract) meshes added to this scene
  124966. */
  124967. meshes: AbstractMesh[];
  124968. /**
  124969. * The list of skeletons added to the scene
  124970. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  124971. */
  124972. skeletons: Skeleton[];
  124973. /**
  124974. * All of the particle systems added to this scene
  124975. * @see https://doc.babylonjs.com/babylon101/particles
  124976. */
  124977. particleSystems: IParticleSystem[];
  124978. /**
  124979. * Gets a list of Animations associated with the scene
  124980. */
  124981. animations: Animation[];
  124982. /**
  124983. * All of the animation groups added to this scene
  124984. * @see https://doc.babylonjs.com/how_to/group
  124985. */
  124986. animationGroups: AnimationGroup[];
  124987. /**
  124988. * All of the multi-materials added to this scene
  124989. * @see https://doc.babylonjs.com/how_to/multi_materials
  124990. */
  124991. multiMaterials: MultiMaterial[];
  124992. /**
  124993. * All of the materials added to this scene
  124994. * In the context of a Scene, it is not supposed to be modified manually.
  124995. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  124996. * Note also that the order of the Material within the array is not significant and might change.
  124997. * @see https://doc.babylonjs.com/babylon101/materials
  124998. */
  124999. materials: Material[];
  125000. /**
  125001. * The list of morph target managers added to the scene
  125002. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125003. */
  125004. morphTargetManagers: MorphTargetManager[];
  125005. /**
  125006. * The list of geometries used in the scene.
  125007. */
  125008. geometries: Geometry[];
  125009. /**
  125010. * All of the tranform nodes added to this scene
  125011. * In the context of a Scene, it is not supposed to be modified manually.
  125012. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125013. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125014. * @see https://doc.babylonjs.com/how_to/transformnode
  125015. */
  125016. transformNodes: TransformNode[];
  125017. /**
  125018. * ActionManagers available on the scene.
  125019. */
  125020. actionManagers: AbstractActionManager[];
  125021. /**
  125022. * Textures to keep.
  125023. */
  125024. textures: BaseTexture[];
  125025. /** @hidden */
  125026. protected _environmentTexture: Nullable<BaseTexture>;
  125027. /**
  125028. * Texture used in all pbr material as the reflection texture.
  125029. * As in the majority of the scene they are the same (exception for multi room and so on),
  125030. * this is easier to reference from here than from all the materials.
  125031. */
  125032. get environmentTexture(): Nullable<BaseTexture>;
  125033. set environmentTexture(value: Nullable<BaseTexture>);
  125034. /**
  125035. * The list of postprocesses added to the scene
  125036. */
  125037. postProcesses: PostProcess[];
  125038. /**
  125039. * @returns all meshes, lights, cameras, transformNodes and bones
  125040. */
  125041. getNodes(): Array<Node>;
  125042. }
  125043. }
  125044. declare module BABYLON {
  125045. /**
  125046. * Interface used to define options for Sound class
  125047. */
  125048. export interface ISoundOptions {
  125049. /**
  125050. * Does the sound autoplay once loaded.
  125051. */
  125052. autoplay?: boolean;
  125053. /**
  125054. * Does the sound loop after it finishes playing once.
  125055. */
  125056. loop?: boolean;
  125057. /**
  125058. * Sound's volume
  125059. */
  125060. volume?: number;
  125061. /**
  125062. * Is it a spatial sound?
  125063. */
  125064. spatialSound?: boolean;
  125065. /**
  125066. * Maximum distance to hear that sound
  125067. */
  125068. maxDistance?: number;
  125069. /**
  125070. * Uses user defined attenuation function
  125071. */
  125072. useCustomAttenuation?: boolean;
  125073. /**
  125074. * Define the roll off factor of spatial sounds.
  125075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125076. */
  125077. rolloffFactor?: number;
  125078. /**
  125079. * Define the reference distance the sound should be heard perfectly.
  125080. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125081. */
  125082. refDistance?: number;
  125083. /**
  125084. * Define the distance attenuation model the sound will follow.
  125085. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125086. */
  125087. distanceModel?: string;
  125088. /**
  125089. * Defines the playback speed (1 by default)
  125090. */
  125091. playbackRate?: number;
  125092. /**
  125093. * Defines if the sound is from a streaming source
  125094. */
  125095. streaming?: boolean;
  125096. /**
  125097. * Defines an optional length (in seconds) inside the sound file
  125098. */
  125099. length?: number;
  125100. /**
  125101. * Defines an optional offset (in seconds) inside the sound file
  125102. */
  125103. offset?: number;
  125104. /**
  125105. * If true, URLs will not be required to state the audio file codec to use.
  125106. */
  125107. skipCodecCheck?: boolean;
  125108. }
  125109. /**
  125110. * Defines a sound that can be played in the application.
  125111. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125112. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125113. */
  125114. export class Sound {
  125115. /**
  125116. * The name of the sound in the scene.
  125117. */
  125118. name: string;
  125119. /**
  125120. * Does the sound autoplay once loaded.
  125121. */
  125122. autoplay: boolean;
  125123. /**
  125124. * Does the sound loop after it finishes playing once.
  125125. */
  125126. loop: boolean;
  125127. /**
  125128. * Does the sound use a custom attenuation curve to simulate the falloff
  125129. * happening when the source gets further away from the camera.
  125130. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125131. */
  125132. useCustomAttenuation: boolean;
  125133. /**
  125134. * The sound track id this sound belongs to.
  125135. */
  125136. soundTrackId: number;
  125137. /**
  125138. * Is this sound currently played.
  125139. */
  125140. isPlaying: boolean;
  125141. /**
  125142. * Is this sound currently paused.
  125143. */
  125144. isPaused: boolean;
  125145. /**
  125146. * Does this sound enables spatial sound.
  125147. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125148. */
  125149. spatialSound: boolean;
  125150. /**
  125151. * Define the reference distance the sound should be heard perfectly.
  125152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125153. */
  125154. refDistance: number;
  125155. /**
  125156. * Define the roll off factor of spatial sounds.
  125157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125158. */
  125159. rolloffFactor: number;
  125160. /**
  125161. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125163. */
  125164. maxDistance: number;
  125165. /**
  125166. * Define the distance attenuation model the sound will follow.
  125167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125168. */
  125169. distanceModel: string;
  125170. /**
  125171. * @hidden
  125172. * Back Compat
  125173. **/
  125174. onended: () => any;
  125175. /**
  125176. * Gets or sets an object used to store user defined information for the sound.
  125177. */
  125178. metadata: any;
  125179. /**
  125180. * Observable event when the current playing sound finishes.
  125181. */
  125182. onEndedObservable: Observable<Sound>;
  125183. private _panningModel;
  125184. private _playbackRate;
  125185. private _streaming;
  125186. private _startTime;
  125187. private _startOffset;
  125188. private _position;
  125189. /** @hidden */
  125190. _positionInEmitterSpace: boolean;
  125191. private _localDirection;
  125192. private _volume;
  125193. private _isReadyToPlay;
  125194. private _isDirectional;
  125195. private _readyToPlayCallback;
  125196. private _audioBuffer;
  125197. private _soundSource;
  125198. private _streamingSource;
  125199. private _soundPanner;
  125200. private _soundGain;
  125201. private _inputAudioNode;
  125202. private _outputAudioNode;
  125203. private _coneInnerAngle;
  125204. private _coneOuterAngle;
  125205. private _coneOuterGain;
  125206. private _scene;
  125207. private _connectedTransformNode;
  125208. private _customAttenuationFunction;
  125209. private _registerFunc;
  125210. private _isOutputConnected;
  125211. private _htmlAudioElement;
  125212. private _urlType;
  125213. private _length?;
  125214. private _offset?;
  125215. /** @hidden */
  125216. static _SceneComponentInitialization: (scene: Scene) => void;
  125217. /**
  125218. * Create a sound and attach it to a scene
  125219. * @param name Name of your sound
  125220. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125221. * @param scene defines the scene the sound belongs to
  125222. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125223. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125224. */
  125225. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125226. /**
  125227. * Release the sound and its associated resources
  125228. */
  125229. dispose(): void;
  125230. /**
  125231. * Gets if the sounds is ready to be played or not.
  125232. * @returns true if ready, otherwise false
  125233. */
  125234. isReady(): boolean;
  125235. private _soundLoaded;
  125236. /**
  125237. * Sets the data of the sound from an audiobuffer
  125238. * @param audioBuffer The audioBuffer containing the data
  125239. */
  125240. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125241. /**
  125242. * Updates the current sounds options such as maxdistance, loop...
  125243. * @param options A JSON object containing values named as the object properties
  125244. */
  125245. updateOptions(options: ISoundOptions): void;
  125246. private _createSpatialParameters;
  125247. private _updateSpatialParameters;
  125248. /**
  125249. * Switch the panning model to HRTF:
  125250. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125251. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125252. */
  125253. switchPanningModelToHRTF(): void;
  125254. /**
  125255. * Switch the panning model to Equal Power:
  125256. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125258. */
  125259. switchPanningModelToEqualPower(): void;
  125260. private _switchPanningModel;
  125261. /**
  125262. * Connect this sound to a sound track audio node like gain...
  125263. * @param soundTrackAudioNode the sound track audio node to connect to
  125264. */
  125265. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125266. /**
  125267. * Transform this sound into a directional source
  125268. * @param coneInnerAngle Size of the inner cone in degree
  125269. * @param coneOuterAngle Size of the outer cone in degree
  125270. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125271. */
  125272. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125273. /**
  125274. * Gets or sets the inner angle for the directional cone.
  125275. */
  125276. get directionalConeInnerAngle(): number;
  125277. /**
  125278. * Gets or sets the inner angle for the directional cone.
  125279. */
  125280. set directionalConeInnerAngle(value: number);
  125281. /**
  125282. * Gets or sets the outer angle for the directional cone.
  125283. */
  125284. get directionalConeOuterAngle(): number;
  125285. /**
  125286. * Gets or sets the outer angle for the directional cone.
  125287. */
  125288. set directionalConeOuterAngle(value: number);
  125289. /**
  125290. * Sets the position of the emitter if spatial sound is enabled
  125291. * @param newPosition Defines the new posisiton
  125292. */
  125293. setPosition(newPosition: Vector3): void;
  125294. /**
  125295. * Sets the local direction of the emitter if spatial sound is enabled
  125296. * @param newLocalDirection Defines the new local direction
  125297. */
  125298. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125299. private _updateDirection;
  125300. /** @hidden */
  125301. updateDistanceFromListener(): void;
  125302. /**
  125303. * Sets a new custom attenuation function for the sound.
  125304. * @param callback Defines the function used for the attenuation
  125305. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125306. */
  125307. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125308. /**
  125309. * Play the sound
  125310. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125311. * @param offset (optional) Start the sound at a specific time in seconds
  125312. * @param length (optional) Sound duration (in seconds)
  125313. */
  125314. play(time?: number, offset?: number, length?: number): void;
  125315. private _onended;
  125316. /**
  125317. * Stop the sound
  125318. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125319. */
  125320. stop(time?: number): void;
  125321. /**
  125322. * Put the sound in pause
  125323. */
  125324. pause(): void;
  125325. /**
  125326. * Sets a dedicated volume for this sounds
  125327. * @param newVolume Define the new volume of the sound
  125328. * @param time Define time for gradual change to new volume
  125329. */
  125330. setVolume(newVolume: number, time?: number): void;
  125331. /**
  125332. * Set the sound play back rate
  125333. * @param newPlaybackRate Define the playback rate the sound should be played at
  125334. */
  125335. setPlaybackRate(newPlaybackRate: number): void;
  125336. /**
  125337. * Gets the volume of the sound.
  125338. * @returns the volume of the sound
  125339. */
  125340. getVolume(): number;
  125341. /**
  125342. * Attach the sound to a dedicated mesh
  125343. * @param transformNode The transform node to connect the sound with
  125344. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125345. */
  125346. attachToMesh(transformNode: TransformNode): void;
  125347. /**
  125348. * Detach the sound from the previously attached mesh
  125349. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125350. */
  125351. detachFromMesh(): void;
  125352. private _onRegisterAfterWorldMatrixUpdate;
  125353. /**
  125354. * Clone the current sound in the scene.
  125355. * @returns the new sound clone
  125356. */
  125357. clone(): Nullable<Sound>;
  125358. /**
  125359. * Gets the current underlying audio buffer containing the data
  125360. * @returns the audio buffer
  125361. */
  125362. getAudioBuffer(): Nullable<AudioBuffer>;
  125363. /**
  125364. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125365. * @returns the source node
  125366. */
  125367. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125368. /**
  125369. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125370. * @returns the gain node
  125371. */
  125372. getSoundGain(): Nullable<GainNode>;
  125373. /**
  125374. * Serializes the Sound in a JSON representation
  125375. * @returns the JSON representation of the sound
  125376. */
  125377. serialize(): any;
  125378. /**
  125379. * Parse a JSON representation of a sound to innstantiate in a given scene
  125380. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125381. * @param scene Define the scene the new parsed sound should be created in
  125382. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125383. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125384. * @returns the newly parsed sound
  125385. */
  125386. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125387. }
  125388. }
  125389. declare module BABYLON {
  125390. /**
  125391. * This defines an action helpful to play a defined sound on a triggered action.
  125392. */
  125393. export class PlaySoundAction extends Action {
  125394. private _sound;
  125395. /**
  125396. * Instantiate the action
  125397. * @param triggerOptions defines the trigger options
  125398. * @param sound defines the sound to play
  125399. * @param condition defines the trigger related conditions
  125400. */
  125401. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125402. /** @hidden */
  125403. _prepare(): void;
  125404. /**
  125405. * Execute the action and play the sound.
  125406. */
  125407. execute(): void;
  125408. /**
  125409. * Serializes the actions and its related information.
  125410. * @param parent defines the object to serialize in
  125411. * @returns the serialized object
  125412. */
  125413. serialize(parent: any): any;
  125414. }
  125415. /**
  125416. * This defines an action helpful to stop a defined sound on a triggered action.
  125417. */
  125418. export class StopSoundAction extends Action {
  125419. private _sound;
  125420. /**
  125421. * Instantiate the action
  125422. * @param triggerOptions defines the trigger options
  125423. * @param sound defines the sound to stop
  125424. * @param condition defines the trigger related conditions
  125425. */
  125426. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125427. /** @hidden */
  125428. _prepare(): void;
  125429. /**
  125430. * Execute the action and stop the sound.
  125431. */
  125432. execute(): void;
  125433. /**
  125434. * Serializes the actions and its related information.
  125435. * @param parent defines the object to serialize in
  125436. * @returns the serialized object
  125437. */
  125438. serialize(parent: any): any;
  125439. }
  125440. }
  125441. declare module BABYLON {
  125442. /**
  125443. * This defines an action responsible to change the value of a property
  125444. * by interpolating between its current value and the newly set one once triggered.
  125445. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125446. */
  125447. export class InterpolateValueAction extends Action {
  125448. /**
  125449. * Defines the path of the property where the value should be interpolated
  125450. */
  125451. propertyPath: string;
  125452. /**
  125453. * Defines the target value at the end of the interpolation.
  125454. */
  125455. value: any;
  125456. /**
  125457. * Defines the time it will take for the property to interpolate to the value.
  125458. */
  125459. duration: number;
  125460. /**
  125461. * Defines if the other scene animations should be stopped when the action has been triggered
  125462. */
  125463. stopOtherAnimations?: boolean;
  125464. /**
  125465. * Defines a callback raised once the interpolation animation has been done.
  125466. */
  125467. onInterpolationDone?: () => void;
  125468. /**
  125469. * Observable triggered once the interpolation animation has been done.
  125470. */
  125471. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125472. private _target;
  125473. private _effectiveTarget;
  125474. private _property;
  125475. /**
  125476. * Instantiate the action
  125477. * @param triggerOptions defines the trigger options
  125478. * @param target defines the object containing the value to interpolate
  125479. * @param propertyPath defines the path to the property in the target object
  125480. * @param value defines the target value at the end of the interpolation
  125481. * @param duration deines the time it will take for the property to interpolate to the value.
  125482. * @param condition defines the trigger related conditions
  125483. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125484. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125485. */
  125486. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125487. /** @hidden */
  125488. _prepare(): void;
  125489. /**
  125490. * Execute the action starts the value interpolation.
  125491. */
  125492. execute(): void;
  125493. /**
  125494. * Serializes the actions and its related information.
  125495. * @param parent defines the object to serialize in
  125496. * @returns the serialized object
  125497. */
  125498. serialize(parent: any): any;
  125499. }
  125500. }
  125501. declare module BABYLON {
  125502. /**
  125503. * Options allowed during the creation of a sound track.
  125504. */
  125505. export interface ISoundTrackOptions {
  125506. /**
  125507. * The volume the sound track should take during creation
  125508. */
  125509. volume?: number;
  125510. /**
  125511. * Define if the sound track is the main sound track of the scene
  125512. */
  125513. mainTrack?: boolean;
  125514. }
  125515. /**
  125516. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125517. * It will be also used in a future release to apply effects on a specific track.
  125518. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125519. */
  125520. export class SoundTrack {
  125521. /**
  125522. * The unique identifier of the sound track in the scene.
  125523. */
  125524. id: number;
  125525. /**
  125526. * The list of sounds included in the sound track.
  125527. */
  125528. soundCollection: Array<Sound>;
  125529. private _outputAudioNode;
  125530. private _scene;
  125531. private _connectedAnalyser;
  125532. private _options;
  125533. private _isInitialized;
  125534. /**
  125535. * Creates a new sound track.
  125536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125537. * @param scene Define the scene the sound track belongs to
  125538. * @param options
  125539. */
  125540. constructor(scene: Scene, options?: ISoundTrackOptions);
  125541. private _initializeSoundTrackAudioGraph;
  125542. /**
  125543. * Release the sound track and its associated resources
  125544. */
  125545. dispose(): void;
  125546. /**
  125547. * Adds a sound to this sound track
  125548. * @param sound define the cound to add
  125549. * @ignoreNaming
  125550. */
  125551. AddSound(sound: Sound): void;
  125552. /**
  125553. * Removes a sound to this sound track
  125554. * @param sound define the cound to remove
  125555. * @ignoreNaming
  125556. */
  125557. RemoveSound(sound: Sound): void;
  125558. /**
  125559. * Set a global volume for the full sound track.
  125560. * @param newVolume Define the new volume of the sound track
  125561. */
  125562. setVolume(newVolume: number): void;
  125563. /**
  125564. * Switch the panning model to HRTF:
  125565. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125566. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125567. */
  125568. switchPanningModelToHRTF(): void;
  125569. /**
  125570. * Switch the panning model to Equal Power:
  125571. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125572. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125573. */
  125574. switchPanningModelToEqualPower(): void;
  125575. /**
  125576. * Connect the sound track to an audio analyser allowing some amazing
  125577. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125579. * @param analyser The analyser to connect to the engine
  125580. */
  125581. connectToAnalyser(analyser: Analyser): void;
  125582. }
  125583. }
  125584. declare module BABYLON {
  125585. interface AbstractScene {
  125586. /**
  125587. * The list of sounds used in the scene.
  125588. */
  125589. sounds: Nullable<Array<Sound>>;
  125590. }
  125591. interface Scene {
  125592. /**
  125593. * @hidden
  125594. * Backing field
  125595. */
  125596. _mainSoundTrack: SoundTrack;
  125597. /**
  125598. * The main sound track played by the scene.
  125599. * It cotains your primary collection of sounds.
  125600. */
  125601. mainSoundTrack: SoundTrack;
  125602. /**
  125603. * The list of sound tracks added to the scene
  125604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125605. */
  125606. soundTracks: Nullable<Array<SoundTrack>>;
  125607. /**
  125608. * Gets a sound using a given name
  125609. * @param name defines the name to search for
  125610. * @return the found sound or null if not found at all.
  125611. */
  125612. getSoundByName(name: string): Nullable<Sound>;
  125613. /**
  125614. * Gets or sets if audio support is enabled
  125615. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125616. */
  125617. audioEnabled: boolean;
  125618. /**
  125619. * Gets or sets if audio will be output to headphones
  125620. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125621. */
  125622. headphone: boolean;
  125623. /**
  125624. * Gets or sets custom audio listener position provider
  125625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125626. */
  125627. audioListenerPositionProvider: Nullable<() => Vector3>;
  125628. /**
  125629. * Gets or sets a refresh rate when using 3D audio positioning
  125630. */
  125631. audioPositioningRefreshRate: number;
  125632. }
  125633. /**
  125634. * Defines the sound scene component responsible to manage any sounds
  125635. * in a given scene.
  125636. */
  125637. export class AudioSceneComponent implements ISceneSerializableComponent {
  125638. private static _CameraDirectionLH;
  125639. private static _CameraDirectionRH;
  125640. /**
  125641. * The component name helpfull to identify the component in the list of scene components.
  125642. */
  125643. readonly name: string;
  125644. /**
  125645. * The scene the component belongs to.
  125646. */
  125647. scene: Scene;
  125648. private _audioEnabled;
  125649. /**
  125650. * Gets whether audio is enabled or not.
  125651. * Please use related enable/disable method to switch state.
  125652. */
  125653. get audioEnabled(): boolean;
  125654. private _headphone;
  125655. /**
  125656. * Gets whether audio is outputing to headphone or not.
  125657. * Please use the according Switch methods to change output.
  125658. */
  125659. get headphone(): boolean;
  125660. /**
  125661. * Gets or sets a refresh rate when using 3D audio positioning
  125662. */
  125663. audioPositioningRefreshRate: number;
  125664. private _audioListenerPositionProvider;
  125665. /**
  125666. * Gets the current audio listener position provider
  125667. */
  125668. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125669. /**
  125670. * Sets a custom listener position for all sounds in the scene
  125671. * By default, this is the position of the first active camera
  125672. */
  125673. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125674. /**
  125675. * Creates a new instance of the component for the given scene
  125676. * @param scene Defines the scene to register the component in
  125677. */
  125678. constructor(scene: Scene);
  125679. /**
  125680. * Registers the component in a given scene
  125681. */
  125682. register(): void;
  125683. /**
  125684. * Rebuilds the elements related to this component in case of
  125685. * context lost for instance.
  125686. */
  125687. rebuild(): void;
  125688. /**
  125689. * Serializes the component data to the specified json object
  125690. * @param serializationObject The object to serialize to
  125691. */
  125692. serialize(serializationObject: any): void;
  125693. /**
  125694. * Adds all the elements from the container to the scene
  125695. * @param container the container holding the elements
  125696. */
  125697. addFromContainer(container: AbstractScene): void;
  125698. /**
  125699. * Removes all the elements in the container from the scene
  125700. * @param container contains the elements to remove
  125701. * @param dispose if the removed element should be disposed (default: false)
  125702. */
  125703. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125704. /**
  125705. * Disposes the component and the associated ressources.
  125706. */
  125707. dispose(): void;
  125708. /**
  125709. * Disables audio in the associated scene.
  125710. */
  125711. disableAudio(): void;
  125712. /**
  125713. * Enables audio in the associated scene.
  125714. */
  125715. enableAudio(): void;
  125716. /**
  125717. * Switch audio to headphone output.
  125718. */
  125719. switchAudioModeForHeadphones(): void;
  125720. /**
  125721. * Switch audio to normal speakers.
  125722. */
  125723. switchAudioModeForNormalSpeakers(): void;
  125724. private _cachedCameraDirection;
  125725. private _cachedCameraPosition;
  125726. private _lastCheck;
  125727. private _afterRender;
  125728. }
  125729. }
  125730. declare module BABYLON {
  125731. /**
  125732. * Wraps one or more Sound objects and selects one with random weight for playback.
  125733. */
  125734. export class WeightedSound {
  125735. /** When true a Sound will be selected and played when the current playing Sound completes. */
  125736. loop: boolean;
  125737. private _coneInnerAngle;
  125738. private _coneOuterAngle;
  125739. private _volume;
  125740. /** A Sound is currently playing. */
  125741. isPlaying: boolean;
  125742. /** A Sound is currently paused. */
  125743. isPaused: boolean;
  125744. private _sounds;
  125745. private _weights;
  125746. private _currentIndex?;
  125747. /**
  125748. * Creates a new WeightedSound from the list of sounds given.
  125749. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  125750. * @param sounds Array of Sounds that will be selected from.
  125751. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  125752. */
  125753. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  125754. /**
  125755. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  125756. */
  125757. get directionalConeInnerAngle(): number;
  125758. /**
  125759. * The size of cone in degress for a directional sound in which there will be no attenuation.
  125760. */
  125761. set directionalConeInnerAngle(value: number);
  125762. /**
  125763. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125764. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125765. */
  125766. get directionalConeOuterAngle(): number;
  125767. /**
  125768. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125769. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125770. */
  125771. set directionalConeOuterAngle(value: number);
  125772. /**
  125773. * Playback volume.
  125774. */
  125775. get volume(): number;
  125776. /**
  125777. * Playback volume.
  125778. */
  125779. set volume(value: number);
  125780. private _onended;
  125781. /**
  125782. * Suspend playback
  125783. */
  125784. pause(): void;
  125785. /**
  125786. * Stop playback
  125787. */
  125788. stop(): void;
  125789. /**
  125790. * Start playback.
  125791. * @param startOffset Position the clip head at a specific time in seconds.
  125792. */
  125793. play(startOffset?: number): void;
  125794. }
  125795. }
  125796. declare module BABYLON {
  125797. /**
  125798. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  125799. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  125800. */
  125801. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  125802. /**
  125803. * Gets the name of the behavior.
  125804. */
  125805. get name(): string;
  125806. /**
  125807. * The easing function used by animations
  125808. */
  125809. static EasingFunction: BackEase;
  125810. /**
  125811. * The easing mode used by animations
  125812. */
  125813. static EasingMode: number;
  125814. /**
  125815. * The duration of the animation, in milliseconds
  125816. */
  125817. transitionDuration: number;
  125818. /**
  125819. * Length of the distance animated by the transition when lower radius is reached
  125820. */
  125821. lowerRadiusTransitionRange: number;
  125822. /**
  125823. * Length of the distance animated by the transition when upper radius is reached
  125824. */
  125825. upperRadiusTransitionRange: number;
  125826. private _autoTransitionRange;
  125827. /**
  125828. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125829. */
  125830. get autoTransitionRange(): boolean;
  125831. /**
  125832. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125833. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  125834. */
  125835. set autoTransitionRange(value: boolean);
  125836. private _attachedCamera;
  125837. private _onAfterCheckInputsObserver;
  125838. private _onMeshTargetChangedObserver;
  125839. /**
  125840. * Initializes the behavior.
  125841. */
  125842. init(): void;
  125843. /**
  125844. * Attaches the behavior to its arc rotate camera.
  125845. * @param camera Defines the camera to attach the behavior to
  125846. */
  125847. attach(camera: ArcRotateCamera): void;
  125848. /**
  125849. * Detaches the behavior from its current arc rotate camera.
  125850. */
  125851. detach(): void;
  125852. private _radiusIsAnimating;
  125853. private _radiusBounceTransition;
  125854. private _animatables;
  125855. private _cachedWheelPrecision;
  125856. /**
  125857. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  125858. * @param radiusLimit The limit to check against.
  125859. * @return Bool to indicate if at limit.
  125860. */
  125861. private _isRadiusAtLimit;
  125862. /**
  125863. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  125864. * @param radiusDelta The delta by which to animate to. Can be negative.
  125865. */
  125866. private _applyBoundRadiusAnimation;
  125867. /**
  125868. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  125869. */
  125870. protected _clearAnimationLocks(): void;
  125871. /**
  125872. * Stops and removes all animations that have been applied to the camera
  125873. */
  125874. stopAllAnimations(): void;
  125875. }
  125876. }
  125877. declare module BABYLON {
  125878. /**
  125879. * 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.
  125880. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  125881. */
  125882. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  125883. /**
  125884. * Gets the name of the behavior.
  125885. */
  125886. get name(): string;
  125887. private _mode;
  125888. private _radiusScale;
  125889. private _positionScale;
  125890. private _defaultElevation;
  125891. private _elevationReturnTime;
  125892. private _elevationReturnWaitTime;
  125893. private _zoomStopsAnimation;
  125894. private _framingTime;
  125895. /**
  125896. * The easing function used by animations
  125897. */
  125898. static EasingFunction: ExponentialEase;
  125899. /**
  125900. * The easing mode used by animations
  125901. */
  125902. static EasingMode: number;
  125903. /**
  125904. * Sets the current mode used by the behavior
  125905. */
  125906. set mode(mode: number);
  125907. /**
  125908. * Gets current mode used by the behavior.
  125909. */
  125910. get mode(): number;
  125911. /**
  125912. * Sets the scale applied to the radius (1 by default)
  125913. */
  125914. set radiusScale(radius: number);
  125915. /**
  125916. * Gets the scale applied to the radius
  125917. */
  125918. get radiusScale(): number;
  125919. /**
  125920. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  125921. */
  125922. set positionScale(scale: number);
  125923. /**
  125924. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  125925. */
  125926. get positionScale(): number;
  125927. /**
  125928. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  125929. * behaviour is triggered, in radians.
  125930. */
  125931. set defaultElevation(elevation: number);
  125932. /**
  125933. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  125934. * behaviour is triggered, in radians.
  125935. */
  125936. get defaultElevation(): number;
  125937. /**
  125938. * Sets the time (in milliseconds) taken to return to the default beta position.
  125939. * Negative value indicates camera should not return to default.
  125940. */
  125941. set elevationReturnTime(speed: number);
  125942. /**
  125943. * Gets the time (in milliseconds) taken to return to the default beta position.
  125944. * Negative value indicates camera should not return to default.
  125945. */
  125946. get elevationReturnTime(): number;
  125947. /**
  125948. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  125949. */
  125950. set elevationReturnWaitTime(time: number);
  125951. /**
  125952. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  125953. */
  125954. get elevationReturnWaitTime(): number;
  125955. /**
  125956. * Sets the flag that indicates if user zooming should stop animation.
  125957. */
  125958. set zoomStopsAnimation(flag: boolean);
  125959. /**
  125960. * Gets the flag that indicates if user zooming should stop animation.
  125961. */
  125962. get zoomStopsAnimation(): boolean;
  125963. /**
  125964. * Sets the transition time when framing the mesh, in milliseconds
  125965. */
  125966. set framingTime(time: number);
  125967. /**
  125968. * Gets the transition time when framing the mesh, in milliseconds
  125969. */
  125970. get framingTime(): number;
  125971. /**
  125972. * Define if the behavior should automatically change the configured
  125973. * camera limits and sensibilities.
  125974. */
  125975. autoCorrectCameraLimitsAndSensibility: boolean;
  125976. private _onPrePointerObservableObserver;
  125977. private _onAfterCheckInputsObserver;
  125978. private _onMeshTargetChangedObserver;
  125979. private _attachedCamera;
  125980. private _isPointerDown;
  125981. private _lastInteractionTime;
  125982. /**
  125983. * Initializes the behavior.
  125984. */
  125985. init(): void;
  125986. /**
  125987. * Attaches the behavior to its arc rotate camera.
  125988. * @param camera Defines the camera to attach the behavior to
  125989. */
  125990. attach(camera: ArcRotateCamera): void;
  125991. /**
  125992. * Detaches the behavior from its current arc rotate camera.
  125993. */
  125994. detach(): void;
  125995. private _animatables;
  125996. private _betaIsAnimating;
  125997. private _betaTransition;
  125998. private _radiusTransition;
  125999. private _vectorTransition;
  126000. /**
  126001. * Targets the given mesh and updates zoom level accordingly.
  126002. * @param mesh The mesh to target.
  126003. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126004. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126005. */
  126006. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126007. /**
  126008. * Targets the given mesh with its children and updates zoom level accordingly.
  126009. * @param mesh The mesh to target.
  126010. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126011. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126012. */
  126013. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126014. /**
  126015. * Targets the given meshes with their children and updates zoom level accordingly.
  126016. * @param meshes The mesh to target.
  126017. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126018. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126019. */
  126020. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126021. /**
  126022. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126023. * @param minimumWorld Determines the smaller position of the bounding box extend
  126024. * @param maximumWorld Determines the bigger position of the bounding box extend
  126025. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126026. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126027. */
  126028. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126029. /**
  126030. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126031. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126032. * frustum width.
  126033. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126034. * to fully enclose the mesh in the viewing frustum.
  126035. */
  126036. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126037. /**
  126038. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126039. * is automatically returned to its default position (expected to be above ground plane).
  126040. */
  126041. private _maintainCameraAboveGround;
  126042. /**
  126043. * Returns the frustum slope based on the canvas ratio and camera FOV
  126044. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126045. */
  126046. private _getFrustumSlope;
  126047. /**
  126048. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126049. */
  126050. private _clearAnimationLocks;
  126051. /**
  126052. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126053. */
  126054. private _applyUserInteraction;
  126055. /**
  126056. * Stops and removes all animations that have been applied to the camera
  126057. */
  126058. stopAllAnimations(): void;
  126059. /**
  126060. * Gets a value indicating if the user is moving the camera
  126061. */
  126062. get isUserIsMoving(): boolean;
  126063. /**
  126064. * The camera can move all the way towards the mesh.
  126065. */
  126066. static IgnoreBoundsSizeMode: number;
  126067. /**
  126068. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126069. */
  126070. static FitFrustumSidesMode: number;
  126071. }
  126072. }
  126073. declare module BABYLON {
  126074. /**
  126075. * Base class for Camera Pointer Inputs.
  126076. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126077. * for example usage.
  126078. */
  126079. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126080. /**
  126081. * Defines the camera the input is attached to.
  126082. */
  126083. abstract camera: Camera;
  126084. /**
  126085. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126086. */
  126087. protected _altKey: boolean;
  126088. protected _ctrlKey: boolean;
  126089. protected _metaKey: boolean;
  126090. protected _shiftKey: boolean;
  126091. /**
  126092. * Which mouse buttons were pressed at time of last mouse event.
  126093. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126094. */
  126095. protected _buttonsPressed: number;
  126096. /**
  126097. * Defines the buttons associated with the input to handle camera move.
  126098. */
  126099. buttons: number[];
  126100. /**
  126101. * Attach the input controls to a specific dom element to get the input from.
  126102. * @param element Defines the element the controls should be listened from
  126103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126104. */
  126105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126106. /**
  126107. * Detach the current controls from the specified dom element.
  126108. * @param element Defines the element to stop listening the inputs from
  126109. */
  126110. detachControl(element: Nullable<HTMLElement>): void;
  126111. /**
  126112. * Gets the class name of the current input.
  126113. * @returns the class name
  126114. */
  126115. getClassName(): string;
  126116. /**
  126117. * Get the friendly name associated with the input class.
  126118. * @returns the input friendly name
  126119. */
  126120. getSimpleName(): string;
  126121. /**
  126122. * Called on pointer POINTERDOUBLETAP event.
  126123. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126124. */
  126125. protected onDoubleTap(type: string): void;
  126126. /**
  126127. * Called on pointer POINTERMOVE event if only a single touch is active.
  126128. * Override this method to provide functionality.
  126129. */
  126130. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126131. /**
  126132. * Called on pointer POINTERMOVE event if multiple touches are active.
  126133. * Override this method to provide functionality.
  126134. */
  126135. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126136. /**
  126137. * Called on JS contextmenu event.
  126138. * Override this method to provide functionality.
  126139. */
  126140. protected onContextMenu(evt: PointerEvent): void;
  126141. /**
  126142. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126143. * press.
  126144. * Override this method to provide functionality.
  126145. */
  126146. protected onButtonDown(evt: PointerEvent): void;
  126147. /**
  126148. * Called each time a new POINTERUP event occurs. Ie, for each button
  126149. * release.
  126150. * Override this method to provide functionality.
  126151. */
  126152. protected onButtonUp(evt: PointerEvent): void;
  126153. /**
  126154. * Called when window becomes inactive.
  126155. * Override this method to provide functionality.
  126156. */
  126157. protected onLostFocus(): void;
  126158. private _pointerInput;
  126159. private _observer;
  126160. private _onLostFocus;
  126161. private pointA;
  126162. private pointB;
  126163. }
  126164. }
  126165. declare module BABYLON {
  126166. /**
  126167. * Manage the pointers inputs to control an arc rotate camera.
  126168. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126169. */
  126170. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126171. /**
  126172. * Defines the camera the input is attached to.
  126173. */
  126174. camera: ArcRotateCamera;
  126175. /**
  126176. * Gets the class name of the current input.
  126177. * @returns the class name
  126178. */
  126179. getClassName(): string;
  126180. /**
  126181. * Defines the buttons associated with the input to handle camera move.
  126182. */
  126183. buttons: number[];
  126184. /**
  126185. * Defines the pointer angular sensibility along the X axis or how fast is
  126186. * the camera rotating.
  126187. */
  126188. angularSensibilityX: number;
  126189. /**
  126190. * Defines the pointer angular sensibility along the Y axis or how fast is
  126191. * the camera rotating.
  126192. */
  126193. angularSensibilityY: number;
  126194. /**
  126195. * Defines the pointer pinch precision or how fast is the camera zooming.
  126196. */
  126197. pinchPrecision: number;
  126198. /**
  126199. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126200. * from 0.
  126201. * It defines the percentage of current camera.radius to use as delta when
  126202. * pinch zoom is used.
  126203. */
  126204. pinchDeltaPercentage: number;
  126205. /**
  126206. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126207. * that any object in the plane at the camera's target point will scale
  126208. * perfectly with finger motion.
  126209. * Overrides pinchDeltaPercentage and pinchPrecision.
  126210. */
  126211. useNaturalPinchZoom: boolean;
  126212. /**
  126213. * Defines the pointer panning sensibility or how fast is the camera moving.
  126214. */
  126215. panningSensibility: number;
  126216. /**
  126217. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126218. */
  126219. multiTouchPanning: boolean;
  126220. /**
  126221. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126222. * zoom (pinch) through multitouch.
  126223. */
  126224. multiTouchPanAndZoom: boolean;
  126225. /**
  126226. * Revers pinch action direction.
  126227. */
  126228. pinchInwards: boolean;
  126229. private _isPanClick;
  126230. private _twoFingerActivityCount;
  126231. private _isPinching;
  126232. /**
  126233. * Called on pointer POINTERMOVE event if only a single touch is active.
  126234. */
  126235. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126236. /**
  126237. * Called on pointer POINTERDOUBLETAP event.
  126238. */
  126239. protected onDoubleTap(type: string): void;
  126240. /**
  126241. * Called on pointer POINTERMOVE event if multiple touches are active.
  126242. */
  126243. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126244. /**
  126245. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126246. * press.
  126247. */
  126248. protected onButtonDown(evt: PointerEvent): void;
  126249. /**
  126250. * Called each time a new POINTERUP event occurs. Ie, for each button
  126251. * release.
  126252. */
  126253. protected onButtonUp(evt: PointerEvent): void;
  126254. /**
  126255. * Called when window becomes inactive.
  126256. */
  126257. protected onLostFocus(): void;
  126258. }
  126259. }
  126260. declare module BABYLON {
  126261. /**
  126262. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126263. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126264. */
  126265. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126266. /**
  126267. * Defines the camera the input is attached to.
  126268. */
  126269. camera: ArcRotateCamera;
  126270. /**
  126271. * Defines the list of key codes associated with the up action (increase alpha)
  126272. */
  126273. keysUp: number[];
  126274. /**
  126275. * Defines the list of key codes associated with the down action (decrease alpha)
  126276. */
  126277. keysDown: number[];
  126278. /**
  126279. * Defines the list of key codes associated with the left action (increase beta)
  126280. */
  126281. keysLeft: number[];
  126282. /**
  126283. * Defines the list of key codes associated with the right action (decrease beta)
  126284. */
  126285. keysRight: number[];
  126286. /**
  126287. * Defines the list of key codes associated with the reset action.
  126288. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126289. */
  126290. keysReset: number[];
  126291. /**
  126292. * Defines the panning sensibility of the inputs.
  126293. * (How fast is the camera panning)
  126294. */
  126295. panningSensibility: number;
  126296. /**
  126297. * Defines the zooming sensibility of the inputs.
  126298. * (How fast is the camera zooming)
  126299. */
  126300. zoomingSensibility: number;
  126301. /**
  126302. * Defines whether maintaining the alt key down switch the movement mode from
  126303. * orientation to zoom.
  126304. */
  126305. useAltToZoom: boolean;
  126306. /**
  126307. * Rotation speed of the camera
  126308. */
  126309. angularSpeed: number;
  126310. private _keys;
  126311. private _ctrlPressed;
  126312. private _altPressed;
  126313. private _onCanvasBlurObserver;
  126314. private _onKeyboardObserver;
  126315. private _engine;
  126316. private _scene;
  126317. /**
  126318. * Attach the input controls to a specific dom element to get the input from.
  126319. * @param element Defines the element the controls should be listened from
  126320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126321. */
  126322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126323. /**
  126324. * Detach the current controls from the specified dom element.
  126325. * @param element Defines the element to stop listening the inputs from
  126326. */
  126327. detachControl(element: Nullable<HTMLElement>): void;
  126328. /**
  126329. * Update the current camera state depending on the inputs that have been used this frame.
  126330. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126331. */
  126332. checkInputs(): void;
  126333. /**
  126334. * Gets the class name of the current intput.
  126335. * @returns the class name
  126336. */
  126337. getClassName(): string;
  126338. /**
  126339. * Get the friendly name associated with the input class.
  126340. * @returns the input friendly name
  126341. */
  126342. getSimpleName(): string;
  126343. }
  126344. }
  126345. declare module BABYLON {
  126346. /**
  126347. * Manage the mouse wheel inputs to control an arc rotate camera.
  126348. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126349. */
  126350. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126351. /**
  126352. * Defines the camera the input is attached to.
  126353. */
  126354. camera: ArcRotateCamera;
  126355. /**
  126356. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126357. */
  126358. wheelPrecision: number;
  126359. /**
  126360. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126361. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126362. */
  126363. wheelDeltaPercentage: number;
  126364. private _wheel;
  126365. private _observer;
  126366. private computeDeltaFromMouseWheelLegacyEvent;
  126367. /**
  126368. * Attach the input controls to a specific dom element to get the input from.
  126369. * @param element Defines the element the controls should be listened from
  126370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126371. */
  126372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126373. /**
  126374. * Detach the current controls from the specified dom element.
  126375. * @param element Defines the element to stop listening the inputs from
  126376. */
  126377. detachControl(element: Nullable<HTMLElement>): void;
  126378. /**
  126379. * Gets the class name of the current intput.
  126380. * @returns the class name
  126381. */
  126382. getClassName(): string;
  126383. /**
  126384. * Get the friendly name associated with the input class.
  126385. * @returns the input friendly name
  126386. */
  126387. getSimpleName(): string;
  126388. }
  126389. }
  126390. declare module BABYLON {
  126391. /**
  126392. * Default Inputs manager for the ArcRotateCamera.
  126393. * It groups all the default supported inputs for ease of use.
  126394. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126395. */
  126396. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126397. /**
  126398. * Instantiates a new ArcRotateCameraInputsManager.
  126399. * @param camera Defines the camera the inputs belong to
  126400. */
  126401. constructor(camera: ArcRotateCamera);
  126402. /**
  126403. * Add mouse wheel input support to the input manager.
  126404. * @returns the current input manager
  126405. */
  126406. addMouseWheel(): ArcRotateCameraInputsManager;
  126407. /**
  126408. * Add pointers input support to the input manager.
  126409. * @returns the current input manager
  126410. */
  126411. addPointers(): ArcRotateCameraInputsManager;
  126412. /**
  126413. * Add keyboard input support to the input manager.
  126414. * @returns the current input manager
  126415. */
  126416. addKeyboard(): ArcRotateCameraInputsManager;
  126417. }
  126418. }
  126419. declare module BABYLON {
  126420. /**
  126421. * This represents an orbital type of camera.
  126422. *
  126423. * 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.
  126424. * 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.
  126425. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126426. */
  126427. export class ArcRotateCamera extends TargetCamera {
  126428. /**
  126429. * Defines the rotation angle of the camera along the longitudinal axis.
  126430. */
  126431. alpha: number;
  126432. /**
  126433. * Defines the rotation angle of the camera along the latitudinal axis.
  126434. */
  126435. beta: number;
  126436. /**
  126437. * Defines the radius of the camera from it s target point.
  126438. */
  126439. radius: number;
  126440. protected _target: Vector3;
  126441. protected _targetHost: Nullable<AbstractMesh>;
  126442. /**
  126443. * Defines the target point of the camera.
  126444. * The camera looks towards it form the radius distance.
  126445. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126446. */
  126447. get target(): Vector3;
  126448. set target(value: Vector3);
  126449. /**
  126450. * Define the current local position of the camera in the scene
  126451. */
  126452. get position(): Vector3;
  126453. set position(newPosition: Vector3);
  126454. protected _upToYMatrix: Matrix;
  126455. protected _YToUpMatrix: Matrix;
  126456. /**
  126457. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126458. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126459. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126460. */
  126461. set upVector(vec: Vector3);
  126462. get upVector(): Vector3;
  126463. /**
  126464. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126465. */
  126466. setMatUp(): void;
  126467. /**
  126468. * Current inertia value on the longitudinal axis.
  126469. * The bigger this number the longer it will take for the camera to stop.
  126470. */
  126471. inertialAlphaOffset: number;
  126472. /**
  126473. * Current inertia value on the latitudinal axis.
  126474. * The bigger this number the longer it will take for the camera to stop.
  126475. */
  126476. inertialBetaOffset: number;
  126477. /**
  126478. * Current inertia value on the radius axis.
  126479. * The bigger this number the longer it will take for the camera to stop.
  126480. */
  126481. inertialRadiusOffset: number;
  126482. /**
  126483. * Minimum allowed angle on the longitudinal axis.
  126484. * This can help limiting how the Camera is able to move in the scene.
  126485. */
  126486. lowerAlphaLimit: Nullable<number>;
  126487. /**
  126488. * Maximum allowed angle on the longitudinal axis.
  126489. * This can help limiting how the Camera is able to move in the scene.
  126490. */
  126491. upperAlphaLimit: Nullable<number>;
  126492. /**
  126493. * Minimum allowed angle on the latitudinal axis.
  126494. * This can help limiting how the Camera is able to move in the scene.
  126495. */
  126496. lowerBetaLimit: number;
  126497. /**
  126498. * Maximum allowed angle on the latitudinal axis.
  126499. * This can help limiting how the Camera is able to move in the scene.
  126500. */
  126501. upperBetaLimit: number;
  126502. /**
  126503. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126504. * This can help limiting how the Camera is able to move in the scene.
  126505. */
  126506. lowerRadiusLimit: Nullable<number>;
  126507. /**
  126508. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126509. * This can help limiting how the Camera is able to move in the scene.
  126510. */
  126511. upperRadiusLimit: Nullable<number>;
  126512. /**
  126513. * Defines the current inertia value used during panning of the camera along the X axis.
  126514. */
  126515. inertialPanningX: number;
  126516. /**
  126517. * Defines the current inertia value used during panning of the camera along the Y axis.
  126518. */
  126519. inertialPanningY: number;
  126520. /**
  126521. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126522. * Basically if your fingers moves away from more than this distance you will be considered
  126523. * in pinch mode.
  126524. */
  126525. pinchToPanMaxDistance: number;
  126526. /**
  126527. * Defines the maximum distance the camera can pan.
  126528. * This could help keeping the cammera always in your scene.
  126529. */
  126530. panningDistanceLimit: Nullable<number>;
  126531. /**
  126532. * Defines the target of the camera before paning.
  126533. */
  126534. panningOriginTarget: Vector3;
  126535. /**
  126536. * Defines the value of the inertia used during panning.
  126537. * 0 would mean stop inertia and one would mean no decelleration at all.
  126538. */
  126539. panningInertia: number;
  126540. /**
  126541. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126542. */
  126543. get angularSensibilityX(): number;
  126544. set angularSensibilityX(value: number);
  126545. /**
  126546. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126547. */
  126548. get angularSensibilityY(): number;
  126549. set angularSensibilityY(value: number);
  126550. /**
  126551. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126552. */
  126553. get pinchPrecision(): number;
  126554. set pinchPrecision(value: number);
  126555. /**
  126556. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126557. * It will be used instead of pinchDeltaPrecision if different from 0.
  126558. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126559. */
  126560. get pinchDeltaPercentage(): number;
  126561. set pinchDeltaPercentage(value: number);
  126562. /**
  126563. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126564. * and pinch delta percentage.
  126565. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126566. * that any object in the plane at the camera's target point will scale
  126567. * perfectly with finger motion.
  126568. */
  126569. get useNaturalPinchZoom(): boolean;
  126570. set useNaturalPinchZoom(value: boolean);
  126571. /**
  126572. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126573. */
  126574. get panningSensibility(): number;
  126575. set panningSensibility(value: number);
  126576. /**
  126577. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126578. */
  126579. get keysUp(): number[];
  126580. set keysUp(value: number[]);
  126581. /**
  126582. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126583. */
  126584. get keysDown(): number[];
  126585. set keysDown(value: number[]);
  126586. /**
  126587. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126588. */
  126589. get keysLeft(): number[];
  126590. set keysLeft(value: number[]);
  126591. /**
  126592. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126593. */
  126594. get keysRight(): number[];
  126595. set keysRight(value: number[]);
  126596. /**
  126597. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126598. */
  126599. get wheelPrecision(): number;
  126600. set wheelPrecision(value: number);
  126601. /**
  126602. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126603. * It will be used instead of pinchDeltaPrecision if different from 0.
  126604. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126605. */
  126606. get wheelDeltaPercentage(): number;
  126607. set wheelDeltaPercentage(value: number);
  126608. /**
  126609. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126610. */
  126611. zoomOnFactor: number;
  126612. /**
  126613. * Defines a screen offset for the camera position.
  126614. */
  126615. targetScreenOffset: Vector2;
  126616. /**
  126617. * Allows the camera to be completely reversed.
  126618. * If false the camera can not arrive upside down.
  126619. */
  126620. allowUpsideDown: boolean;
  126621. /**
  126622. * Define if double tap/click is used to restore the previously saved state of the camera.
  126623. */
  126624. useInputToRestoreState: boolean;
  126625. /** @hidden */
  126626. _viewMatrix: Matrix;
  126627. /** @hidden */
  126628. _useCtrlForPanning: boolean;
  126629. /** @hidden */
  126630. _panningMouseButton: number;
  126631. /**
  126632. * Defines the input associated to the camera.
  126633. */
  126634. inputs: ArcRotateCameraInputsManager;
  126635. /** @hidden */
  126636. _reset: () => void;
  126637. /**
  126638. * Defines the allowed panning axis.
  126639. */
  126640. panningAxis: Vector3;
  126641. protected _localDirection: Vector3;
  126642. protected _transformedDirection: Vector3;
  126643. private _bouncingBehavior;
  126644. /**
  126645. * Gets the bouncing behavior of the camera if it has been enabled.
  126646. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126647. */
  126648. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126649. /**
  126650. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126651. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126652. */
  126653. get useBouncingBehavior(): boolean;
  126654. set useBouncingBehavior(value: boolean);
  126655. private _framingBehavior;
  126656. /**
  126657. * Gets the framing behavior of the camera if it has been enabled.
  126658. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126659. */
  126660. get framingBehavior(): Nullable<FramingBehavior>;
  126661. /**
  126662. * Defines if the framing behavior of the camera is enabled on the camera.
  126663. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126664. */
  126665. get useFramingBehavior(): boolean;
  126666. set useFramingBehavior(value: boolean);
  126667. private _autoRotationBehavior;
  126668. /**
  126669. * Gets the auto rotation behavior of the camera if it has been enabled.
  126670. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126671. */
  126672. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126673. /**
  126674. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126675. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126676. */
  126677. get useAutoRotationBehavior(): boolean;
  126678. set useAutoRotationBehavior(value: boolean);
  126679. /**
  126680. * Observable triggered when the mesh target has been changed on the camera.
  126681. */
  126682. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126683. /**
  126684. * Event raised when the camera is colliding with a mesh.
  126685. */
  126686. onCollide: (collidedMesh: AbstractMesh) => void;
  126687. /**
  126688. * Defines whether the camera should check collision with the objects oh the scene.
  126689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126690. */
  126691. checkCollisions: boolean;
  126692. /**
  126693. * Defines the collision radius of the camera.
  126694. * This simulates a sphere around the camera.
  126695. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126696. */
  126697. collisionRadius: Vector3;
  126698. protected _collider: Collider;
  126699. protected _previousPosition: Vector3;
  126700. protected _collisionVelocity: Vector3;
  126701. protected _newPosition: Vector3;
  126702. protected _previousAlpha: number;
  126703. protected _previousBeta: number;
  126704. protected _previousRadius: number;
  126705. protected _collisionTriggered: boolean;
  126706. protected _targetBoundingCenter: Nullable<Vector3>;
  126707. private _computationVector;
  126708. /**
  126709. * Instantiates a new ArcRotateCamera in a given scene
  126710. * @param name Defines the name of the camera
  126711. * @param alpha Defines the camera rotation along the logitudinal axis
  126712. * @param beta Defines the camera rotation along the latitudinal axis
  126713. * @param radius Defines the camera distance from its target
  126714. * @param target Defines the camera target
  126715. * @param scene Defines the scene the camera belongs to
  126716. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  126717. */
  126718. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  126719. /** @hidden */
  126720. _initCache(): void;
  126721. /** @hidden */
  126722. _updateCache(ignoreParentClass?: boolean): void;
  126723. protected _getTargetPosition(): Vector3;
  126724. private _storedAlpha;
  126725. private _storedBeta;
  126726. private _storedRadius;
  126727. private _storedTarget;
  126728. private _storedTargetScreenOffset;
  126729. /**
  126730. * Stores the current state of the camera (alpha, beta, radius and target)
  126731. * @returns the camera itself
  126732. */
  126733. storeState(): Camera;
  126734. /**
  126735. * @hidden
  126736. * Restored camera state. You must call storeState() first
  126737. */
  126738. _restoreStateValues(): boolean;
  126739. /** @hidden */
  126740. _isSynchronizedViewMatrix(): boolean;
  126741. /**
  126742. * Attached controls to the current camera.
  126743. * @param element Defines the element the controls should be listened from
  126744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126745. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  126746. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  126747. */
  126748. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  126749. /**
  126750. * Detach the current controls from the camera.
  126751. * The camera will stop reacting to inputs.
  126752. * @param element Defines the element to stop listening the inputs from
  126753. */
  126754. detachControl(element: HTMLElement): void;
  126755. /** @hidden */
  126756. _checkInputs(): void;
  126757. protected _checkLimits(): void;
  126758. /**
  126759. * Rebuilds angles (alpha, beta) and radius from the give position and target
  126760. */
  126761. rebuildAnglesAndRadius(): void;
  126762. /**
  126763. * Use a position to define the current camera related information like alpha, beta and radius
  126764. * @param position Defines the position to set the camera at
  126765. */
  126766. setPosition(position: Vector3): void;
  126767. /**
  126768. * Defines the target the camera should look at.
  126769. * This will automatically adapt alpha beta and radius to fit within the new target.
  126770. * @param target Defines the new target as a Vector or a mesh
  126771. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  126772. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  126773. */
  126774. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  126775. /** @hidden */
  126776. _getViewMatrix(): Matrix;
  126777. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  126778. /**
  126779. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  126780. * @param meshes Defines the mesh to zoom on
  126781. * @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)
  126782. */
  126783. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  126784. /**
  126785. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  126786. * The target will be changed but the radius
  126787. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  126788. * @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)
  126789. */
  126790. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  126791. min: Vector3;
  126792. max: Vector3;
  126793. distance: number;
  126794. }, doNotUpdateMaxZ?: boolean): void;
  126795. /**
  126796. * @override
  126797. * Override Camera.createRigCamera
  126798. */
  126799. createRigCamera(name: string, cameraIndex: number): Camera;
  126800. /**
  126801. * @hidden
  126802. * @override
  126803. * Override Camera._updateRigCameras
  126804. */
  126805. _updateRigCameras(): void;
  126806. /**
  126807. * Destroy the camera and release the current resources hold by it.
  126808. */
  126809. dispose(): void;
  126810. /**
  126811. * Gets the current object class name.
  126812. * @return the class name
  126813. */
  126814. getClassName(): string;
  126815. }
  126816. }
  126817. declare module BABYLON {
  126818. /**
  126819. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  126820. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126821. */
  126822. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  126823. /**
  126824. * Gets the name of the behavior.
  126825. */
  126826. get name(): string;
  126827. private _zoomStopsAnimation;
  126828. private _idleRotationSpeed;
  126829. private _idleRotationWaitTime;
  126830. private _idleRotationSpinupTime;
  126831. /**
  126832. * Sets the flag that indicates if user zooming should stop animation.
  126833. */
  126834. set zoomStopsAnimation(flag: boolean);
  126835. /**
  126836. * Gets the flag that indicates if user zooming should stop animation.
  126837. */
  126838. get zoomStopsAnimation(): boolean;
  126839. /**
  126840. * Sets the default speed at which the camera rotates around the model.
  126841. */
  126842. set idleRotationSpeed(speed: number);
  126843. /**
  126844. * Gets the default speed at which the camera rotates around the model.
  126845. */
  126846. get idleRotationSpeed(): number;
  126847. /**
  126848. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  126849. */
  126850. set idleRotationWaitTime(time: number);
  126851. /**
  126852. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  126853. */
  126854. get idleRotationWaitTime(): number;
  126855. /**
  126856. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  126857. */
  126858. set idleRotationSpinupTime(time: number);
  126859. /**
  126860. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  126861. */
  126862. get idleRotationSpinupTime(): number;
  126863. /**
  126864. * Gets a value indicating if the camera is currently rotating because of this behavior
  126865. */
  126866. get rotationInProgress(): boolean;
  126867. private _onPrePointerObservableObserver;
  126868. private _onAfterCheckInputsObserver;
  126869. private _attachedCamera;
  126870. private _isPointerDown;
  126871. private _lastFrameTime;
  126872. private _lastInteractionTime;
  126873. private _cameraRotationSpeed;
  126874. /**
  126875. * Initializes the behavior.
  126876. */
  126877. init(): void;
  126878. /**
  126879. * Attaches the behavior to its arc rotate camera.
  126880. * @param camera Defines the camera to attach the behavior to
  126881. */
  126882. attach(camera: ArcRotateCamera): void;
  126883. /**
  126884. * Detaches the behavior from its current arc rotate camera.
  126885. */
  126886. detach(): void;
  126887. /**
  126888. * Returns true if user is scrolling.
  126889. * @return true if user is scrolling.
  126890. */
  126891. private _userIsZooming;
  126892. private _lastFrameRadius;
  126893. private _shouldAnimationStopForInteraction;
  126894. /**
  126895. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126896. */
  126897. private _applyUserInteraction;
  126898. private _userIsMoving;
  126899. }
  126900. }
  126901. declare module BABYLON {
  126902. /**
  126903. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  126904. */
  126905. export class AttachToBoxBehavior implements Behavior<Mesh> {
  126906. private ui;
  126907. /**
  126908. * The name of the behavior
  126909. */
  126910. name: string;
  126911. /**
  126912. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  126913. */
  126914. distanceAwayFromFace: number;
  126915. /**
  126916. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  126917. */
  126918. distanceAwayFromBottomOfFace: number;
  126919. private _faceVectors;
  126920. private _target;
  126921. private _scene;
  126922. private _onRenderObserver;
  126923. private _tmpMatrix;
  126924. private _tmpVector;
  126925. /**
  126926. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  126927. * @param ui The transform node that should be attched to the mesh
  126928. */
  126929. constructor(ui: TransformNode);
  126930. /**
  126931. * Initializes the behavior
  126932. */
  126933. init(): void;
  126934. private _closestFace;
  126935. private _zeroVector;
  126936. private _lookAtTmpMatrix;
  126937. private _lookAtToRef;
  126938. /**
  126939. * Attaches the AttachToBoxBehavior to the passed in mesh
  126940. * @param target The mesh that the specified node will be attached to
  126941. */
  126942. attach(target: Mesh): void;
  126943. /**
  126944. * Detaches the behavior from the mesh
  126945. */
  126946. detach(): void;
  126947. }
  126948. }
  126949. declare module BABYLON {
  126950. /**
  126951. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  126952. */
  126953. export class FadeInOutBehavior implements Behavior<Mesh> {
  126954. /**
  126955. * Time in milliseconds to delay before fading in (Default: 0)
  126956. */
  126957. delay: number;
  126958. /**
  126959. * Time in milliseconds for the mesh to fade in (Default: 300)
  126960. */
  126961. fadeInTime: number;
  126962. private _millisecondsPerFrame;
  126963. private _hovered;
  126964. private _hoverValue;
  126965. private _ownerNode;
  126966. /**
  126967. * Instatiates the FadeInOutBehavior
  126968. */
  126969. constructor();
  126970. /**
  126971. * The name of the behavior
  126972. */
  126973. get name(): string;
  126974. /**
  126975. * Initializes the behavior
  126976. */
  126977. init(): void;
  126978. /**
  126979. * Attaches the fade behavior on the passed in mesh
  126980. * @param ownerNode The mesh that will be faded in/out once attached
  126981. */
  126982. attach(ownerNode: Mesh): void;
  126983. /**
  126984. * Detaches the behavior from the mesh
  126985. */
  126986. detach(): void;
  126987. /**
  126988. * Triggers the mesh to begin fading in or out
  126989. * @param value if the object should fade in or out (true to fade in)
  126990. */
  126991. fadeIn(value: boolean): void;
  126992. private _update;
  126993. private _setAllVisibility;
  126994. }
  126995. }
  126996. declare module BABYLON {
  126997. /**
  126998. * Class containing a set of static utilities functions for managing Pivots
  126999. * @hidden
  127000. */
  127001. export class PivotTools {
  127002. private static _PivotCached;
  127003. private static _OldPivotPoint;
  127004. private static _PivotTranslation;
  127005. private static _PivotTmpVector;
  127006. private static _PivotPostMultiplyPivotMatrix;
  127007. /** @hidden */
  127008. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127009. /** @hidden */
  127010. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127011. }
  127012. }
  127013. declare module BABYLON {
  127014. /**
  127015. * Class containing static functions to help procedurally build meshes
  127016. */
  127017. export class PlaneBuilder {
  127018. /**
  127019. * Creates a plane mesh
  127020. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127021. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127022. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127026. * @param name defines the name of the mesh
  127027. * @param options defines the options used to create the mesh
  127028. * @param scene defines the hosting scene
  127029. * @returns the plane mesh
  127030. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127031. */
  127032. static CreatePlane(name: string, options: {
  127033. size?: number;
  127034. width?: number;
  127035. height?: number;
  127036. sideOrientation?: number;
  127037. frontUVs?: Vector4;
  127038. backUVs?: Vector4;
  127039. updatable?: boolean;
  127040. sourcePlane?: Plane;
  127041. }, scene?: Nullable<Scene>): Mesh;
  127042. }
  127043. }
  127044. declare module BABYLON {
  127045. /**
  127046. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127047. */
  127048. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127049. private static _AnyMouseID;
  127050. /**
  127051. * Abstract mesh the behavior is set on
  127052. */
  127053. attachedNode: AbstractMesh;
  127054. private _dragPlane;
  127055. private _scene;
  127056. private _pointerObserver;
  127057. private _beforeRenderObserver;
  127058. private static _planeScene;
  127059. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127060. /**
  127061. * 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)
  127062. */
  127063. maxDragAngle: number;
  127064. /**
  127065. * @hidden
  127066. */
  127067. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127068. /**
  127069. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127070. */
  127071. currentDraggingPointerID: number;
  127072. /**
  127073. * The last position where the pointer hit the drag plane in world space
  127074. */
  127075. lastDragPosition: Vector3;
  127076. /**
  127077. * If the behavior is currently in a dragging state
  127078. */
  127079. dragging: boolean;
  127080. /**
  127081. * 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)
  127082. */
  127083. dragDeltaRatio: number;
  127084. /**
  127085. * If the drag plane orientation should be updated during the dragging (Default: true)
  127086. */
  127087. updateDragPlane: boolean;
  127088. private _debugMode;
  127089. private _moving;
  127090. /**
  127091. * Fires each time the attached mesh is dragged with the pointer
  127092. * * delta between last drag position and current drag position in world space
  127093. * * dragDistance along the drag axis
  127094. * * dragPlaneNormal normal of the current drag plane used during the drag
  127095. * * dragPlanePoint in world space where the drag intersects the drag plane
  127096. */
  127097. onDragObservable: Observable<{
  127098. delta: Vector3;
  127099. dragPlanePoint: Vector3;
  127100. dragPlaneNormal: Vector3;
  127101. dragDistance: number;
  127102. pointerId: number;
  127103. }>;
  127104. /**
  127105. * Fires each time a drag begins (eg. mouse down on mesh)
  127106. */
  127107. onDragStartObservable: Observable<{
  127108. dragPlanePoint: Vector3;
  127109. pointerId: number;
  127110. }>;
  127111. /**
  127112. * Fires each time a drag ends (eg. mouse release after drag)
  127113. */
  127114. onDragEndObservable: Observable<{
  127115. dragPlanePoint: Vector3;
  127116. pointerId: number;
  127117. }>;
  127118. /**
  127119. * If the attached mesh should be moved when dragged
  127120. */
  127121. moveAttached: boolean;
  127122. /**
  127123. * If the drag behavior will react to drag events (Default: true)
  127124. */
  127125. enabled: boolean;
  127126. /**
  127127. * If pointer events should start and release the drag (Default: true)
  127128. */
  127129. startAndReleaseDragOnPointerEvents: boolean;
  127130. /**
  127131. * If camera controls should be detached during the drag
  127132. */
  127133. detachCameraControls: boolean;
  127134. /**
  127135. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127136. */
  127137. useObjectOrientationForDragging: boolean;
  127138. private _options;
  127139. /**
  127140. * Gets the options used by the behavior
  127141. */
  127142. get options(): {
  127143. dragAxis?: Vector3;
  127144. dragPlaneNormal?: Vector3;
  127145. };
  127146. /**
  127147. * Sets the options used by the behavior
  127148. */
  127149. set options(options: {
  127150. dragAxis?: Vector3;
  127151. dragPlaneNormal?: Vector3;
  127152. });
  127153. /**
  127154. * Creates a pointer drag behavior that can be attached to a mesh
  127155. * @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)
  127156. */
  127157. constructor(options?: {
  127158. dragAxis?: Vector3;
  127159. dragPlaneNormal?: Vector3;
  127160. });
  127161. /**
  127162. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127163. */
  127164. validateDrag: (targetPosition: Vector3) => boolean;
  127165. /**
  127166. * The name of the behavior
  127167. */
  127168. get name(): string;
  127169. /**
  127170. * Initializes the behavior
  127171. */
  127172. init(): void;
  127173. private _tmpVector;
  127174. private _alternatePickedPoint;
  127175. private _worldDragAxis;
  127176. private _targetPosition;
  127177. private _attachedElement;
  127178. /**
  127179. * Attaches the drag behavior the passed in mesh
  127180. * @param ownerNode The mesh that will be dragged around once attached
  127181. * @param predicate Predicate to use for pick filtering
  127182. */
  127183. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127184. /**
  127185. * Force relase the drag action by code.
  127186. */
  127187. releaseDrag(): void;
  127188. private _startDragRay;
  127189. private _lastPointerRay;
  127190. /**
  127191. * Simulates the start of a pointer drag event on the behavior
  127192. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127193. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127194. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127195. */
  127196. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127197. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127198. private _dragDelta;
  127199. protected _moveDrag(ray: Ray): void;
  127200. private _pickWithRayOnDragPlane;
  127201. private _pointA;
  127202. private _pointC;
  127203. private _localAxis;
  127204. private _lookAt;
  127205. private _updateDragPlanePosition;
  127206. /**
  127207. * Detaches the behavior from the mesh
  127208. */
  127209. detach(): void;
  127210. }
  127211. }
  127212. declare module BABYLON {
  127213. /**
  127214. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127215. */
  127216. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127217. private _dragBehaviorA;
  127218. private _dragBehaviorB;
  127219. private _startDistance;
  127220. private _initialScale;
  127221. private _targetScale;
  127222. private _ownerNode;
  127223. private _sceneRenderObserver;
  127224. /**
  127225. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127226. */
  127227. constructor();
  127228. /**
  127229. * The name of the behavior
  127230. */
  127231. get name(): string;
  127232. /**
  127233. * Initializes the behavior
  127234. */
  127235. init(): void;
  127236. private _getCurrentDistance;
  127237. /**
  127238. * Attaches the scale behavior the passed in mesh
  127239. * @param ownerNode The mesh that will be scaled around once attached
  127240. */
  127241. attach(ownerNode: Mesh): void;
  127242. /**
  127243. * Detaches the behavior from the mesh
  127244. */
  127245. detach(): void;
  127246. }
  127247. }
  127248. declare module BABYLON {
  127249. /**
  127250. * 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
  127251. */
  127252. export class SixDofDragBehavior implements Behavior<Mesh> {
  127253. private static _virtualScene;
  127254. private _ownerNode;
  127255. private _sceneRenderObserver;
  127256. private _scene;
  127257. private _targetPosition;
  127258. private _virtualOriginMesh;
  127259. private _virtualDragMesh;
  127260. private _pointerObserver;
  127261. private _moving;
  127262. private _startingOrientation;
  127263. private _attachedElement;
  127264. /**
  127265. * 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)
  127266. */
  127267. private zDragFactor;
  127268. /**
  127269. * If the object should rotate to face the drag origin
  127270. */
  127271. rotateDraggedObject: boolean;
  127272. /**
  127273. * If the behavior is currently in a dragging state
  127274. */
  127275. dragging: boolean;
  127276. /**
  127277. * 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)
  127278. */
  127279. dragDeltaRatio: number;
  127280. /**
  127281. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127282. */
  127283. currentDraggingPointerID: number;
  127284. /**
  127285. * If camera controls should be detached during the drag
  127286. */
  127287. detachCameraControls: boolean;
  127288. /**
  127289. * Fires each time a drag starts
  127290. */
  127291. onDragStartObservable: Observable<{}>;
  127292. /**
  127293. * Fires each time a drag ends (eg. mouse release after drag)
  127294. */
  127295. onDragEndObservable: Observable<{}>;
  127296. /**
  127297. * 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
  127298. */
  127299. constructor();
  127300. /**
  127301. * The name of the behavior
  127302. */
  127303. get name(): string;
  127304. /**
  127305. * Initializes the behavior
  127306. */
  127307. init(): void;
  127308. /**
  127309. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127310. */
  127311. private get _pointerCamera();
  127312. /**
  127313. * Attaches the scale behavior the passed in mesh
  127314. * @param ownerNode The mesh that will be scaled around once attached
  127315. */
  127316. attach(ownerNode: Mesh): void;
  127317. /**
  127318. * Detaches the behavior from the mesh
  127319. */
  127320. detach(): void;
  127321. }
  127322. }
  127323. declare module BABYLON {
  127324. /**
  127325. * Class used to apply inverse kinematics to bones
  127326. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127327. */
  127328. export class BoneIKController {
  127329. private static _tmpVecs;
  127330. private static _tmpQuat;
  127331. private static _tmpMats;
  127332. /**
  127333. * Gets or sets the target mesh
  127334. */
  127335. targetMesh: AbstractMesh;
  127336. /** Gets or sets the mesh used as pole */
  127337. poleTargetMesh: AbstractMesh;
  127338. /**
  127339. * Gets or sets the bone used as pole
  127340. */
  127341. poleTargetBone: Nullable<Bone>;
  127342. /**
  127343. * Gets or sets the target position
  127344. */
  127345. targetPosition: Vector3;
  127346. /**
  127347. * Gets or sets the pole target position
  127348. */
  127349. poleTargetPosition: Vector3;
  127350. /**
  127351. * Gets or sets the pole target local offset
  127352. */
  127353. poleTargetLocalOffset: Vector3;
  127354. /**
  127355. * Gets or sets the pole angle
  127356. */
  127357. poleAngle: number;
  127358. /**
  127359. * Gets or sets the mesh associated with the controller
  127360. */
  127361. mesh: AbstractMesh;
  127362. /**
  127363. * 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)
  127364. */
  127365. slerpAmount: number;
  127366. private _bone1Quat;
  127367. private _bone1Mat;
  127368. private _bone2Ang;
  127369. private _bone1;
  127370. private _bone2;
  127371. private _bone1Length;
  127372. private _bone2Length;
  127373. private _maxAngle;
  127374. private _maxReach;
  127375. private _rightHandedSystem;
  127376. private _bendAxis;
  127377. private _slerping;
  127378. private _adjustRoll;
  127379. /**
  127380. * Gets or sets maximum allowed angle
  127381. */
  127382. get maxAngle(): number;
  127383. set maxAngle(value: number);
  127384. /**
  127385. * Creates a new BoneIKController
  127386. * @param mesh defines the mesh to control
  127387. * @param bone defines the bone to control
  127388. * @param options defines options to set up the controller
  127389. */
  127390. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127391. targetMesh?: AbstractMesh;
  127392. poleTargetMesh?: AbstractMesh;
  127393. poleTargetBone?: Bone;
  127394. poleTargetLocalOffset?: Vector3;
  127395. poleAngle?: number;
  127396. bendAxis?: Vector3;
  127397. maxAngle?: number;
  127398. slerpAmount?: number;
  127399. });
  127400. private _setMaxAngle;
  127401. /**
  127402. * Force the controller to update the bones
  127403. */
  127404. update(): void;
  127405. }
  127406. }
  127407. declare module BABYLON {
  127408. /**
  127409. * Class used to make a bone look toward a point in space
  127410. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127411. */
  127412. export class BoneLookController {
  127413. private static _tmpVecs;
  127414. private static _tmpQuat;
  127415. private static _tmpMats;
  127416. /**
  127417. * The target Vector3 that the bone will look at
  127418. */
  127419. target: Vector3;
  127420. /**
  127421. * The mesh that the bone is attached to
  127422. */
  127423. mesh: AbstractMesh;
  127424. /**
  127425. * The bone that will be looking to the target
  127426. */
  127427. bone: Bone;
  127428. /**
  127429. * The up axis of the coordinate system that is used when the bone is rotated
  127430. */
  127431. upAxis: Vector3;
  127432. /**
  127433. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127434. */
  127435. upAxisSpace: Space;
  127436. /**
  127437. * Used to make an adjustment to the yaw of the bone
  127438. */
  127439. adjustYaw: number;
  127440. /**
  127441. * Used to make an adjustment to the pitch of the bone
  127442. */
  127443. adjustPitch: number;
  127444. /**
  127445. * Used to make an adjustment to the roll of the bone
  127446. */
  127447. adjustRoll: number;
  127448. /**
  127449. * 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)
  127450. */
  127451. slerpAmount: number;
  127452. private _minYaw;
  127453. private _maxYaw;
  127454. private _minPitch;
  127455. private _maxPitch;
  127456. private _minYawSin;
  127457. private _minYawCos;
  127458. private _maxYawSin;
  127459. private _maxYawCos;
  127460. private _midYawConstraint;
  127461. private _minPitchTan;
  127462. private _maxPitchTan;
  127463. private _boneQuat;
  127464. private _slerping;
  127465. private _transformYawPitch;
  127466. private _transformYawPitchInv;
  127467. private _firstFrameSkipped;
  127468. private _yawRange;
  127469. private _fowardAxis;
  127470. /**
  127471. * Gets or sets the minimum yaw angle that the bone can look to
  127472. */
  127473. get minYaw(): number;
  127474. set minYaw(value: number);
  127475. /**
  127476. * Gets or sets the maximum yaw angle that the bone can look to
  127477. */
  127478. get maxYaw(): number;
  127479. set maxYaw(value: number);
  127480. /**
  127481. * Gets or sets the minimum pitch angle that the bone can look to
  127482. */
  127483. get minPitch(): number;
  127484. set minPitch(value: number);
  127485. /**
  127486. * Gets or sets the maximum pitch angle that the bone can look to
  127487. */
  127488. get maxPitch(): number;
  127489. set maxPitch(value: number);
  127490. /**
  127491. * Create a BoneLookController
  127492. * @param mesh the mesh that the bone belongs to
  127493. * @param bone the bone that will be looking to the target
  127494. * @param target the target Vector3 to look at
  127495. * @param options optional settings:
  127496. * * maxYaw: the maximum angle the bone will yaw to
  127497. * * minYaw: the minimum angle the bone will yaw to
  127498. * * maxPitch: the maximum angle the bone will pitch to
  127499. * * minPitch: the minimum angle the bone will yaw to
  127500. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127501. * * upAxis: the up axis of the coordinate system
  127502. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127503. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127504. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127505. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127506. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127507. * * adjustRoll: used to make an adjustment to the roll of the bone
  127508. **/
  127509. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127510. maxYaw?: number;
  127511. minYaw?: number;
  127512. maxPitch?: number;
  127513. minPitch?: number;
  127514. slerpAmount?: number;
  127515. upAxis?: Vector3;
  127516. upAxisSpace?: Space;
  127517. yawAxis?: Vector3;
  127518. pitchAxis?: Vector3;
  127519. adjustYaw?: number;
  127520. adjustPitch?: number;
  127521. adjustRoll?: number;
  127522. });
  127523. /**
  127524. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127525. */
  127526. update(): void;
  127527. private _getAngleDiff;
  127528. private _getAngleBetween;
  127529. private _isAngleBetween;
  127530. }
  127531. }
  127532. declare module BABYLON {
  127533. /**
  127534. * Manage the gamepad inputs to control an arc rotate camera.
  127535. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127536. */
  127537. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127538. /**
  127539. * Defines the camera the input is attached to.
  127540. */
  127541. camera: ArcRotateCamera;
  127542. /**
  127543. * Defines the gamepad the input is gathering event from.
  127544. */
  127545. gamepad: Nullable<Gamepad>;
  127546. /**
  127547. * Defines the gamepad rotation sensiblity.
  127548. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127549. */
  127550. gamepadRotationSensibility: number;
  127551. /**
  127552. * Defines the gamepad move sensiblity.
  127553. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127554. */
  127555. gamepadMoveSensibility: number;
  127556. private _yAxisScale;
  127557. /**
  127558. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127559. */
  127560. get invertYAxis(): boolean;
  127561. set invertYAxis(value: boolean);
  127562. private _onGamepadConnectedObserver;
  127563. private _onGamepadDisconnectedObserver;
  127564. /**
  127565. * Attach the input controls to a specific dom element to get the input from.
  127566. * @param element Defines the element the controls should be listened from
  127567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127568. */
  127569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127570. /**
  127571. * Detach the current controls from the specified dom element.
  127572. * @param element Defines the element to stop listening the inputs from
  127573. */
  127574. detachControl(element: Nullable<HTMLElement>): void;
  127575. /**
  127576. * Update the current camera state depending on the inputs that have been used this frame.
  127577. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127578. */
  127579. checkInputs(): void;
  127580. /**
  127581. * Gets the class name of the current intput.
  127582. * @returns the class name
  127583. */
  127584. getClassName(): string;
  127585. /**
  127586. * Get the friendly name associated with the input class.
  127587. * @returns the input friendly name
  127588. */
  127589. getSimpleName(): string;
  127590. }
  127591. }
  127592. declare module BABYLON {
  127593. interface ArcRotateCameraInputsManager {
  127594. /**
  127595. * Add orientation input support to the input manager.
  127596. * @returns the current input manager
  127597. */
  127598. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127599. }
  127600. /**
  127601. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127602. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127603. */
  127604. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127605. /**
  127606. * Defines the camera the input is attached to.
  127607. */
  127608. camera: ArcRotateCamera;
  127609. /**
  127610. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127611. */
  127612. alphaCorrection: number;
  127613. /**
  127614. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127615. */
  127616. gammaCorrection: number;
  127617. private _alpha;
  127618. private _gamma;
  127619. private _dirty;
  127620. private _deviceOrientationHandler;
  127621. /**
  127622. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127623. */
  127624. constructor();
  127625. /**
  127626. * Attach the input controls to a specific dom element to get the input from.
  127627. * @param element Defines the element the controls should be listened from
  127628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127629. */
  127630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127631. /** @hidden */
  127632. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127633. /**
  127634. * Update the current camera state depending on the inputs that have been used this frame.
  127635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127636. */
  127637. checkInputs(): void;
  127638. /**
  127639. * Detach the current controls from the specified dom element.
  127640. * @param element Defines the element to stop listening the inputs from
  127641. */
  127642. detachControl(element: Nullable<HTMLElement>): void;
  127643. /**
  127644. * Gets the class name of the current intput.
  127645. * @returns the class name
  127646. */
  127647. getClassName(): string;
  127648. /**
  127649. * Get the friendly name associated with the input class.
  127650. * @returns the input friendly name
  127651. */
  127652. getSimpleName(): string;
  127653. }
  127654. }
  127655. declare module BABYLON {
  127656. /**
  127657. * Listen to mouse events to control the camera.
  127658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127659. */
  127660. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127661. /**
  127662. * Defines the camera the input is attached to.
  127663. */
  127664. camera: FlyCamera;
  127665. /**
  127666. * Defines if touch is enabled. (Default is true.)
  127667. */
  127668. touchEnabled: boolean;
  127669. /**
  127670. * Defines the buttons associated with the input to handle camera rotation.
  127671. */
  127672. buttons: number[];
  127673. /**
  127674. * Assign buttons for Yaw control.
  127675. */
  127676. buttonsYaw: number[];
  127677. /**
  127678. * Assign buttons for Pitch control.
  127679. */
  127680. buttonsPitch: number[];
  127681. /**
  127682. * Assign buttons for Roll control.
  127683. */
  127684. buttonsRoll: number[];
  127685. /**
  127686. * Detect if any button is being pressed while mouse is moved.
  127687. * -1 = Mouse locked.
  127688. * 0 = Left button.
  127689. * 1 = Middle Button.
  127690. * 2 = Right Button.
  127691. */
  127692. activeButton: number;
  127693. /**
  127694. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127695. * Higher values reduce its sensitivity.
  127696. */
  127697. angularSensibility: number;
  127698. private _observer;
  127699. private _rollObserver;
  127700. private previousPosition;
  127701. private noPreventDefault;
  127702. private element;
  127703. /**
  127704. * Listen to mouse events to control the camera.
  127705. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127706. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127707. */
  127708. constructor(touchEnabled?: boolean);
  127709. /**
  127710. * Attach the mouse control to the HTML DOM element.
  127711. * @param element Defines the element that listens to the input events.
  127712. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  127713. */
  127714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127715. /**
  127716. * Detach the current controls from the specified dom element.
  127717. * @param element Defines the element to stop listening the inputs from
  127718. */
  127719. detachControl(element: Nullable<HTMLElement>): void;
  127720. /**
  127721. * Gets the class name of the current input.
  127722. * @returns the class name.
  127723. */
  127724. getClassName(): string;
  127725. /**
  127726. * Get the friendly name associated with the input class.
  127727. * @returns the input's friendly name.
  127728. */
  127729. getSimpleName(): string;
  127730. private _pointerInput;
  127731. private _onMouseMove;
  127732. /**
  127733. * Rotate camera by mouse offset.
  127734. */
  127735. private rotateCamera;
  127736. }
  127737. }
  127738. declare module BABYLON {
  127739. /**
  127740. * Default Inputs manager for the FlyCamera.
  127741. * It groups all the default supported inputs for ease of use.
  127742. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127743. */
  127744. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  127745. /**
  127746. * Instantiates a new FlyCameraInputsManager.
  127747. * @param camera Defines the camera the inputs belong to.
  127748. */
  127749. constructor(camera: FlyCamera);
  127750. /**
  127751. * Add keyboard input support to the input manager.
  127752. * @returns the new FlyCameraKeyboardMoveInput().
  127753. */
  127754. addKeyboard(): FlyCameraInputsManager;
  127755. /**
  127756. * Add mouse input support to the input manager.
  127757. * @param touchEnabled Enable touch screen support.
  127758. * @returns the new FlyCameraMouseInput().
  127759. */
  127760. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  127761. }
  127762. }
  127763. declare module BABYLON {
  127764. /**
  127765. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127766. * such as in a 3D Space Shooter or a Flight Simulator.
  127767. */
  127768. export class FlyCamera extends TargetCamera {
  127769. /**
  127770. * Define the collision ellipsoid of the camera.
  127771. * This is helpful for simulating a camera body, like a player's body.
  127772. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127773. */
  127774. ellipsoid: Vector3;
  127775. /**
  127776. * Define an offset for the position of the ellipsoid around the camera.
  127777. * This can be helpful if the camera is attached away from the player's body center,
  127778. * such as at its head.
  127779. */
  127780. ellipsoidOffset: Vector3;
  127781. /**
  127782. * Enable or disable collisions of the camera with the rest of the scene objects.
  127783. */
  127784. checkCollisions: boolean;
  127785. /**
  127786. * Enable or disable gravity on the camera.
  127787. */
  127788. applyGravity: boolean;
  127789. /**
  127790. * Define the current direction the camera is moving to.
  127791. */
  127792. cameraDirection: Vector3;
  127793. /**
  127794. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  127795. * This overrides and empties cameraRotation.
  127796. */
  127797. rotationQuaternion: Quaternion;
  127798. /**
  127799. * Track Roll to maintain the wanted Rolling when looking around.
  127800. */
  127801. _trackRoll: number;
  127802. /**
  127803. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  127804. */
  127805. rollCorrect: number;
  127806. /**
  127807. * Mimic a banked turn, Rolling the camera when Yawing.
  127808. * It's recommended to use rollCorrect = 10 for faster banking correction.
  127809. */
  127810. bankedTurn: boolean;
  127811. /**
  127812. * Limit in radians for how much Roll banking will add. (Default: 90°)
  127813. */
  127814. bankedTurnLimit: number;
  127815. /**
  127816. * Value of 0 disables the banked Roll.
  127817. * Value of 1 is equal to the Yaw angle in radians.
  127818. */
  127819. bankedTurnMultiplier: number;
  127820. /**
  127821. * The inputs manager loads all the input sources, such as keyboard and mouse.
  127822. */
  127823. inputs: FlyCameraInputsManager;
  127824. /**
  127825. * Gets the input sensibility for mouse input.
  127826. * Higher values reduce sensitivity.
  127827. */
  127828. get angularSensibility(): number;
  127829. /**
  127830. * Sets the input sensibility for a mouse input.
  127831. * Higher values reduce sensitivity.
  127832. */
  127833. set angularSensibility(value: number);
  127834. /**
  127835. * Get the keys for camera movement forward.
  127836. */
  127837. get keysForward(): number[];
  127838. /**
  127839. * Set the keys for camera movement forward.
  127840. */
  127841. set keysForward(value: number[]);
  127842. /**
  127843. * Get the keys for camera movement backward.
  127844. */
  127845. get keysBackward(): number[];
  127846. set keysBackward(value: number[]);
  127847. /**
  127848. * Get the keys for camera movement up.
  127849. */
  127850. get keysUp(): number[];
  127851. /**
  127852. * Set the keys for camera movement up.
  127853. */
  127854. set keysUp(value: number[]);
  127855. /**
  127856. * Get the keys for camera movement down.
  127857. */
  127858. get keysDown(): number[];
  127859. /**
  127860. * Set the keys for camera movement down.
  127861. */
  127862. set keysDown(value: number[]);
  127863. /**
  127864. * Get the keys for camera movement left.
  127865. */
  127866. get keysLeft(): number[];
  127867. /**
  127868. * Set the keys for camera movement left.
  127869. */
  127870. set keysLeft(value: number[]);
  127871. /**
  127872. * Set the keys for camera movement right.
  127873. */
  127874. get keysRight(): number[];
  127875. /**
  127876. * Set the keys for camera movement right.
  127877. */
  127878. set keysRight(value: number[]);
  127879. /**
  127880. * Event raised when the camera collides with a mesh in the scene.
  127881. */
  127882. onCollide: (collidedMesh: AbstractMesh) => void;
  127883. private _collider;
  127884. private _needMoveForGravity;
  127885. private _oldPosition;
  127886. private _diffPosition;
  127887. private _newPosition;
  127888. /** @hidden */
  127889. _localDirection: Vector3;
  127890. /** @hidden */
  127891. _transformedDirection: Vector3;
  127892. /**
  127893. * Instantiates a FlyCamera.
  127894. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127895. * such as in a 3D Space Shooter or a Flight Simulator.
  127896. * @param name Define the name of the camera in the scene.
  127897. * @param position Define the starting position of the camera in the scene.
  127898. * @param scene Define the scene the camera belongs to.
  127899. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  127900. */
  127901. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127902. /**
  127903. * Attach a control to the HTML DOM element.
  127904. * @param element Defines the element that listens to the input events.
  127905. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  127906. */
  127907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127908. /**
  127909. * Detach a control from the HTML DOM element.
  127910. * The camera will stop reacting to that input.
  127911. * @param element Defines the element that listens to the input events.
  127912. */
  127913. detachControl(element: HTMLElement): void;
  127914. private _collisionMask;
  127915. /**
  127916. * Get the mask that the camera ignores in collision events.
  127917. */
  127918. get collisionMask(): number;
  127919. /**
  127920. * Set the mask that the camera ignores in collision events.
  127921. */
  127922. set collisionMask(mask: number);
  127923. /** @hidden */
  127924. _collideWithWorld(displacement: Vector3): void;
  127925. /** @hidden */
  127926. private _onCollisionPositionChange;
  127927. /** @hidden */
  127928. _checkInputs(): void;
  127929. /** @hidden */
  127930. _decideIfNeedsToMove(): boolean;
  127931. /** @hidden */
  127932. _updatePosition(): void;
  127933. /**
  127934. * Restore the Roll to its target value at the rate specified.
  127935. * @param rate - Higher means slower restoring.
  127936. * @hidden
  127937. */
  127938. restoreRoll(rate: number): void;
  127939. /**
  127940. * Destroy the camera and release the current resources held by it.
  127941. */
  127942. dispose(): void;
  127943. /**
  127944. * Get the current object class name.
  127945. * @returns the class name.
  127946. */
  127947. getClassName(): string;
  127948. }
  127949. }
  127950. declare module BABYLON {
  127951. /**
  127952. * Listen to keyboard events to control the camera.
  127953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127954. */
  127955. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  127956. /**
  127957. * Defines the camera the input is attached to.
  127958. */
  127959. camera: FlyCamera;
  127960. /**
  127961. * The list of keyboard keys used to control the forward move of the camera.
  127962. */
  127963. keysForward: number[];
  127964. /**
  127965. * The list of keyboard keys used to control the backward move of the camera.
  127966. */
  127967. keysBackward: number[];
  127968. /**
  127969. * The list of keyboard keys used to control the forward move of the camera.
  127970. */
  127971. keysUp: number[];
  127972. /**
  127973. * The list of keyboard keys used to control the backward move of the camera.
  127974. */
  127975. keysDown: number[];
  127976. /**
  127977. * The list of keyboard keys used to control the right strafe move of the camera.
  127978. */
  127979. keysRight: number[];
  127980. /**
  127981. * The list of keyboard keys used to control the left strafe move of the camera.
  127982. */
  127983. keysLeft: number[];
  127984. private _keys;
  127985. private _onCanvasBlurObserver;
  127986. private _onKeyboardObserver;
  127987. private _engine;
  127988. private _scene;
  127989. /**
  127990. * Attach the input controls to a specific dom element to get the input from.
  127991. * @param element Defines the element the controls should be listened from
  127992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127993. */
  127994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127995. /**
  127996. * Detach the current controls from the specified dom element.
  127997. * @param element Defines the element to stop listening the inputs from
  127998. */
  127999. detachControl(element: Nullable<HTMLElement>): void;
  128000. /**
  128001. * Gets the class name of the current intput.
  128002. * @returns the class name
  128003. */
  128004. getClassName(): string;
  128005. /** @hidden */
  128006. _onLostFocus(e: FocusEvent): void;
  128007. /**
  128008. * Get the friendly name associated with the input class.
  128009. * @returns the input friendly name
  128010. */
  128011. getSimpleName(): string;
  128012. /**
  128013. * Update the current camera state depending on the inputs that have been used this frame.
  128014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128015. */
  128016. checkInputs(): void;
  128017. }
  128018. }
  128019. declare module BABYLON {
  128020. /**
  128021. * Manage the mouse wheel inputs to control a follow camera.
  128022. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128023. */
  128024. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128025. /**
  128026. * Defines the camera the input is attached to.
  128027. */
  128028. camera: FollowCamera;
  128029. /**
  128030. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128031. */
  128032. axisControlRadius: boolean;
  128033. /**
  128034. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128035. */
  128036. axisControlHeight: boolean;
  128037. /**
  128038. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128039. */
  128040. axisControlRotation: boolean;
  128041. /**
  128042. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128043. * relation to mouseWheel events.
  128044. */
  128045. wheelPrecision: number;
  128046. /**
  128047. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128048. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128049. */
  128050. wheelDeltaPercentage: number;
  128051. private _wheel;
  128052. private _observer;
  128053. /**
  128054. * Attach the input controls to a specific dom element to get the input from.
  128055. * @param element Defines the element the controls should be listened from
  128056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128057. */
  128058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128059. /**
  128060. * Detach the current controls from the specified dom element.
  128061. * @param element Defines the element to stop listening the inputs from
  128062. */
  128063. detachControl(element: Nullable<HTMLElement>): void;
  128064. /**
  128065. * Gets the class name of the current intput.
  128066. * @returns the class name
  128067. */
  128068. getClassName(): string;
  128069. /**
  128070. * Get the friendly name associated with the input class.
  128071. * @returns the input friendly name
  128072. */
  128073. getSimpleName(): string;
  128074. }
  128075. }
  128076. declare module BABYLON {
  128077. /**
  128078. * Manage the pointers inputs to control an follow camera.
  128079. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128080. */
  128081. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128082. /**
  128083. * Defines the camera the input is attached to.
  128084. */
  128085. camera: FollowCamera;
  128086. /**
  128087. * Gets the class name of the current input.
  128088. * @returns the class name
  128089. */
  128090. getClassName(): string;
  128091. /**
  128092. * Defines the pointer angular sensibility along the X axis or how fast is
  128093. * the camera rotating.
  128094. * A negative number will reverse the axis direction.
  128095. */
  128096. angularSensibilityX: number;
  128097. /**
  128098. * Defines the pointer angular sensibility along the Y axis or how fast is
  128099. * the camera rotating.
  128100. * A negative number will reverse the axis direction.
  128101. */
  128102. angularSensibilityY: number;
  128103. /**
  128104. * Defines the pointer pinch precision or how fast is the camera zooming.
  128105. * A negative number will reverse the axis direction.
  128106. */
  128107. pinchPrecision: number;
  128108. /**
  128109. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128110. * from 0.
  128111. * It defines the percentage of current camera.radius to use as delta when
  128112. * pinch zoom is used.
  128113. */
  128114. pinchDeltaPercentage: number;
  128115. /**
  128116. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128117. */
  128118. axisXControlRadius: boolean;
  128119. /**
  128120. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128121. */
  128122. axisXControlHeight: boolean;
  128123. /**
  128124. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128125. */
  128126. axisXControlRotation: boolean;
  128127. /**
  128128. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128129. */
  128130. axisYControlRadius: boolean;
  128131. /**
  128132. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128133. */
  128134. axisYControlHeight: boolean;
  128135. /**
  128136. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128137. */
  128138. axisYControlRotation: boolean;
  128139. /**
  128140. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128141. */
  128142. axisPinchControlRadius: boolean;
  128143. /**
  128144. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128145. */
  128146. axisPinchControlHeight: boolean;
  128147. /**
  128148. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128149. */
  128150. axisPinchControlRotation: boolean;
  128151. /**
  128152. * Log error messages if basic misconfiguration has occurred.
  128153. */
  128154. warningEnable: boolean;
  128155. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128156. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128157. private _warningCounter;
  128158. private _warning;
  128159. }
  128160. }
  128161. declare module BABYLON {
  128162. /**
  128163. * Default Inputs manager for the FollowCamera.
  128164. * It groups all the default supported inputs for ease of use.
  128165. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128166. */
  128167. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128168. /**
  128169. * Instantiates a new FollowCameraInputsManager.
  128170. * @param camera Defines the camera the inputs belong to
  128171. */
  128172. constructor(camera: FollowCamera);
  128173. /**
  128174. * Add keyboard input support to the input manager.
  128175. * @returns the current input manager
  128176. */
  128177. addKeyboard(): FollowCameraInputsManager;
  128178. /**
  128179. * Add mouse wheel input support to the input manager.
  128180. * @returns the current input manager
  128181. */
  128182. addMouseWheel(): FollowCameraInputsManager;
  128183. /**
  128184. * Add pointers input support to the input manager.
  128185. * @returns the current input manager
  128186. */
  128187. addPointers(): FollowCameraInputsManager;
  128188. /**
  128189. * Add orientation input support to the input manager.
  128190. * @returns the current input manager
  128191. */
  128192. addVRDeviceOrientation(): FollowCameraInputsManager;
  128193. }
  128194. }
  128195. declare module BABYLON {
  128196. /**
  128197. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128198. * an arc rotate version arcFollowCamera are available.
  128199. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128200. */
  128201. export class FollowCamera extends TargetCamera {
  128202. /**
  128203. * Distance the follow camera should follow an object at
  128204. */
  128205. radius: number;
  128206. /**
  128207. * Minimum allowed distance of the camera to the axis of rotation
  128208. * (The camera can not get closer).
  128209. * This can help limiting how the Camera is able to move in the scene.
  128210. */
  128211. lowerRadiusLimit: Nullable<number>;
  128212. /**
  128213. * Maximum allowed distance of the camera to the axis of rotation
  128214. * (The camera can not get further).
  128215. * This can help limiting how the Camera is able to move in the scene.
  128216. */
  128217. upperRadiusLimit: Nullable<number>;
  128218. /**
  128219. * Define a rotation offset between the camera and the object it follows
  128220. */
  128221. rotationOffset: number;
  128222. /**
  128223. * Minimum allowed angle to camera position relative to target object.
  128224. * This can help limiting how the Camera is able to move in the scene.
  128225. */
  128226. lowerRotationOffsetLimit: Nullable<number>;
  128227. /**
  128228. * Maximum allowed angle to camera position relative to target object.
  128229. * This can help limiting how the Camera is able to move in the scene.
  128230. */
  128231. upperRotationOffsetLimit: Nullable<number>;
  128232. /**
  128233. * Define a height offset between the camera and the object it follows.
  128234. * It can help following an object from the top (like a car chaing a plane)
  128235. */
  128236. heightOffset: number;
  128237. /**
  128238. * Minimum allowed height of camera position relative to target object.
  128239. * This can help limiting how the Camera is able to move in the scene.
  128240. */
  128241. lowerHeightOffsetLimit: Nullable<number>;
  128242. /**
  128243. * Maximum allowed height of camera position relative to target object.
  128244. * This can help limiting how the Camera is able to move in the scene.
  128245. */
  128246. upperHeightOffsetLimit: Nullable<number>;
  128247. /**
  128248. * Define how fast the camera can accelerate to follow it s target.
  128249. */
  128250. cameraAcceleration: number;
  128251. /**
  128252. * Define the speed limit of the camera following an object.
  128253. */
  128254. maxCameraSpeed: number;
  128255. /**
  128256. * Define the target of the camera.
  128257. */
  128258. lockedTarget: Nullable<AbstractMesh>;
  128259. /**
  128260. * Defines the input associated with the camera.
  128261. */
  128262. inputs: FollowCameraInputsManager;
  128263. /**
  128264. * Instantiates the follow camera.
  128265. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128266. * @param name Define the name of the camera in the scene
  128267. * @param position Define the position of the camera
  128268. * @param scene Define the scene the camera belong to
  128269. * @param lockedTarget Define the target of the camera
  128270. */
  128271. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128272. private _follow;
  128273. /**
  128274. * Attached controls to the current camera.
  128275. * @param element Defines the element the controls should be listened from
  128276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128277. */
  128278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128279. /**
  128280. * Detach the current controls from the camera.
  128281. * The camera will stop reacting to inputs.
  128282. * @param element Defines the element to stop listening the inputs from
  128283. */
  128284. detachControl(element: HTMLElement): void;
  128285. /** @hidden */
  128286. _checkInputs(): void;
  128287. private _checkLimits;
  128288. /**
  128289. * Gets the camera class name.
  128290. * @returns the class name
  128291. */
  128292. getClassName(): string;
  128293. }
  128294. /**
  128295. * Arc Rotate version of the follow camera.
  128296. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128297. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128298. */
  128299. export class ArcFollowCamera extends TargetCamera {
  128300. /** The longitudinal angle of the camera */
  128301. alpha: number;
  128302. /** The latitudinal angle of the camera */
  128303. beta: number;
  128304. /** The radius of the camera from its target */
  128305. radius: number;
  128306. private _cartesianCoordinates;
  128307. /** Define the camera target (the mesh it should follow) */
  128308. private _meshTarget;
  128309. /**
  128310. * Instantiates a new ArcFollowCamera
  128311. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128312. * @param name Define the name of the camera
  128313. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128314. * @param beta Define the rotation angle of the camera around the elevation axis
  128315. * @param radius Define the radius of the camera from its target point
  128316. * @param target Define the target of the camera
  128317. * @param scene Define the scene the camera belongs to
  128318. */
  128319. constructor(name: string,
  128320. /** The longitudinal angle of the camera */
  128321. alpha: number,
  128322. /** The latitudinal angle of the camera */
  128323. beta: number,
  128324. /** The radius of the camera from its target */
  128325. radius: number,
  128326. /** Define the camera target (the mesh it should follow) */
  128327. target: Nullable<AbstractMesh>, scene: Scene);
  128328. private _follow;
  128329. /** @hidden */
  128330. _checkInputs(): void;
  128331. /**
  128332. * Returns the class name of the object.
  128333. * It is mostly used internally for serialization purposes.
  128334. */
  128335. getClassName(): string;
  128336. }
  128337. }
  128338. declare module BABYLON {
  128339. /**
  128340. * Manage the keyboard inputs to control the movement of a follow camera.
  128341. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128342. */
  128343. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128344. /**
  128345. * Defines the camera the input is attached to.
  128346. */
  128347. camera: FollowCamera;
  128348. /**
  128349. * Defines the list of key codes associated with the up action (increase heightOffset)
  128350. */
  128351. keysHeightOffsetIncr: number[];
  128352. /**
  128353. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128354. */
  128355. keysHeightOffsetDecr: number[];
  128356. /**
  128357. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128358. */
  128359. keysHeightOffsetModifierAlt: boolean;
  128360. /**
  128361. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128362. */
  128363. keysHeightOffsetModifierCtrl: boolean;
  128364. /**
  128365. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128366. */
  128367. keysHeightOffsetModifierShift: boolean;
  128368. /**
  128369. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128370. */
  128371. keysRotationOffsetIncr: number[];
  128372. /**
  128373. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128374. */
  128375. keysRotationOffsetDecr: number[];
  128376. /**
  128377. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128378. */
  128379. keysRotationOffsetModifierAlt: boolean;
  128380. /**
  128381. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128382. */
  128383. keysRotationOffsetModifierCtrl: boolean;
  128384. /**
  128385. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128386. */
  128387. keysRotationOffsetModifierShift: boolean;
  128388. /**
  128389. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128390. */
  128391. keysRadiusIncr: number[];
  128392. /**
  128393. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128394. */
  128395. keysRadiusDecr: number[];
  128396. /**
  128397. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128398. */
  128399. keysRadiusModifierAlt: boolean;
  128400. /**
  128401. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128402. */
  128403. keysRadiusModifierCtrl: boolean;
  128404. /**
  128405. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128406. */
  128407. keysRadiusModifierShift: boolean;
  128408. /**
  128409. * Defines the rate of change of heightOffset.
  128410. */
  128411. heightSensibility: number;
  128412. /**
  128413. * Defines the rate of change of rotationOffset.
  128414. */
  128415. rotationSensibility: number;
  128416. /**
  128417. * Defines the rate of change of radius.
  128418. */
  128419. radiusSensibility: number;
  128420. private _keys;
  128421. private _ctrlPressed;
  128422. private _altPressed;
  128423. private _shiftPressed;
  128424. private _onCanvasBlurObserver;
  128425. private _onKeyboardObserver;
  128426. private _engine;
  128427. private _scene;
  128428. /**
  128429. * Attach the input controls to a specific dom element to get the input from.
  128430. * @param element Defines the element the controls should be listened from
  128431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128432. */
  128433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128434. /**
  128435. * Detach the current controls from the specified dom element.
  128436. * @param element Defines the element to stop listening the inputs from
  128437. */
  128438. detachControl(element: Nullable<HTMLElement>): void;
  128439. /**
  128440. * Update the current camera state depending on the inputs that have been used this frame.
  128441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128442. */
  128443. checkInputs(): void;
  128444. /**
  128445. * Gets the class name of the current input.
  128446. * @returns the class name
  128447. */
  128448. getClassName(): string;
  128449. /**
  128450. * Get the friendly name associated with the input class.
  128451. * @returns the input friendly name
  128452. */
  128453. getSimpleName(): string;
  128454. /**
  128455. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128456. * allow modification of the heightOffset value.
  128457. */
  128458. private _modifierHeightOffset;
  128459. /**
  128460. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128461. * allow modification of the rotationOffset value.
  128462. */
  128463. private _modifierRotationOffset;
  128464. /**
  128465. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128466. * allow modification of the radius value.
  128467. */
  128468. private _modifierRadius;
  128469. }
  128470. }
  128471. declare module BABYLON {
  128472. interface FreeCameraInputsManager {
  128473. /**
  128474. * @hidden
  128475. */
  128476. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128477. /**
  128478. * Add orientation input support to the input manager.
  128479. * @returns the current input manager
  128480. */
  128481. addDeviceOrientation(): FreeCameraInputsManager;
  128482. }
  128483. /**
  128484. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128485. * Screen rotation is taken into account.
  128486. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128487. */
  128488. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128489. private _camera;
  128490. private _screenOrientationAngle;
  128491. private _constantTranform;
  128492. private _screenQuaternion;
  128493. private _alpha;
  128494. private _beta;
  128495. private _gamma;
  128496. /**
  128497. * Can be used to detect if a device orientation sensor is available on a device
  128498. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128499. * @returns a promise that will resolve on orientation change
  128500. */
  128501. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128502. /**
  128503. * @hidden
  128504. */
  128505. _onDeviceOrientationChangedObservable: Observable<void>;
  128506. /**
  128507. * Instantiates a new input
  128508. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128509. */
  128510. constructor();
  128511. /**
  128512. * Define the camera controlled by the input.
  128513. */
  128514. get camera(): FreeCamera;
  128515. set camera(camera: FreeCamera);
  128516. /**
  128517. * Attach the input controls to a specific dom element to get the input from.
  128518. * @param element Defines the element the controls should be listened from
  128519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128520. */
  128521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128522. private _orientationChanged;
  128523. private _deviceOrientation;
  128524. /**
  128525. * Detach the current controls from the specified dom element.
  128526. * @param element Defines the element to stop listening the inputs from
  128527. */
  128528. detachControl(element: Nullable<HTMLElement>): void;
  128529. /**
  128530. * Update the current camera state depending on the inputs that have been used this frame.
  128531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128532. */
  128533. checkInputs(): void;
  128534. /**
  128535. * Gets the class name of the current intput.
  128536. * @returns the class name
  128537. */
  128538. getClassName(): string;
  128539. /**
  128540. * Get the friendly name associated with the input class.
  128541. * @returns the input friendly name
  128542. */
  128543. getSimpleName(): string;
  128544. }
  128545. }
  128546. declare module BABYLON {
  128547. /**
  128548. * Manage the gamepad inputs to control a free camera.
  128549. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128550. */
  128551. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128552. /**
  128553. * Define the camera the input is attached to.
  128554. */
  128555. camera: FreeCamera;
  128556. /**
  128557. * Define the Gamepad controlling the input
  128558. */
  128559. gamepad: Nullable<Gamepad>;
  128560. /**
  128561. * Defines the gamepad rotation sensiblity.
  128562. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128563. */
  128564. gamepadAngularSensibility: number;
  128565. /**
  128566. * Defines the gamepad move sensiblity.
  128567. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128568. */
  128569. gamepadMoveSensibility: number;
  128570. private _yAxisScale;
  128571. /**
  128572. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128573. */
  128574. get invertYAxis(): boolean;
  128575. set invertYAxis(value: boolean);
  128576. private _onGamepadConnectedObserver;
  128577. private _onGamepadDisconnectedObserver;
  128578. private _cameraTransform;
  128579. private _deltaTransform;
  128580. private _vector3;
  128581. private _vector2;
  128582. /**
  128583. * Attach the input controls to a specific dom element to get the input from.
  128584. * @param element Defines the element the controls should be listened from
  128585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128586. */
  128587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128588. /**
  128589. * Detach the current controls from the specified dom element.
  128590. * @param element Defines the element to stop listening the inputs from
  128591. */
  128592. detachControl(element: Nullable<HTMLElement>): void;
  128593. /**
  128594. * Update the current camera state depending on the inputs that have been used this frame.
  128595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128596. */
  128597. checkInputs(): void;
  128598. /**
  128599. * Gets the class name of the current intput.
  128600. * @returns the class name
  128601. */
  128602. getClassName(): string;
  128603. /**
  128604. * Get the friendly name associated with the input class.
  128605. * @returns the input friendly name
  128606. */
  128607. getSimpleName(): string;
  128608. }
  128609. }
  128610. declare module BABYLON {
  128611. /**
  128612. * Defines the potential axis of a Joystick
  128613. */
  128614. export enum JoystickAxis {
  128615. /** X axis */
  128616. X = 0,
  128617. /** Y axis */
  128618. Y = 1,
  128619. /** Z axis */
  128620. Z = 2
  128621. }
  128622. /**
  128623. * Represents the different customization options available
  128624. * for VirtualJoystick
  128625. */
  128626. interface VirtualJoystickCustomizations {
  128627. /**
  128628. * Size of the joystick's puck
  128629. */
  128630. puckSize: number;
  128631. /**
  128632. * Size of the joystick's container
  128633. */
  128634. containerSize: number;
  128635. /**
  128636. * Color of the joystick && puck
  128637. */
  128638. color: string;
  128639. /**
  128640. * Image URL for the joystick's puck
  128641. */
  128642. puckImage?: string;
  128643. /**
  128644. * Image URL for the joystick's container
  128645. */
  128646. containerImage?: string;
  128647. /**
  128648. * Defines the unmoving position of the joystick container
  128649. */
  128650. position?: {
  128651. x: number;
  128652. y: number;
  128653. };
  128654. /**
  128655. * Defines whether or not the joystick container is always visible
  128656. */
  128657. alwaysVisible: boolean;
  128658. /**
  128659. * Defines whether or not to limit the movement of the puck to the joystick's container
  128660. */
  128661. limitToContainer: boolean;
  128662. }
  128663. /**
  128664. * Class used to define virtual joystick (used in touch mode)
  128665. */
  128666. export class VirtualJoystick {
  128667. /**
  128668. * Gets or sets a boolean indicating that left and right values must be inverted
  128669. */
  128670. reverseLeftRight: boolean;
  128671. /**
  128672. * Gets or sets a boolean indicating that up and down values must be inverted
  128673. */
  128674. reverseUpDown: boolean;
  128675. /**
  128676. * Gets the offset value for the position (ie. the change of the position value)
  128677. */
  128678. deltaPosition: Vector3;
  128679. /**
  128680. * Gets a boolean indicating if the virtual joystick was pressed
  128681. */
  128682. pressed: boolean;
  128683. /**
  128684. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128685. */
  128686. static Canvas: Nullable<HTMLCanvasElement>;
  128687. /**
  128688. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128689. */
  128690. limitToContainer: boolean;
  128691. private static _globalJoystickIndex;
  128692. private static _alwaysVisibleSticks;
  128693. private static vjCanvasContext;
  128694. private static vjCanvasWidth;
  128695. private static vjCanvasHeight;
  128696. private static halfWidth;
  128697. private static _GetDefaultOptions;
  128698. private _action;
  128699. private _axisTargetedByLeftAndRight;
  128700. private _axisTargetedByUpAndDown;
  128701. private _joystickSensibility;
  128702. private _inversedSensibility;
  128703. private _joystickPointerID;
  128704. private _joystickColor;
  128705. private _joystickPointerPos;
  128706. private _joystickPreviousPointerPos;
  128707. private _joystickPointerStartPos;
  128708. private _deltaJoystickVector;
  128709. private _leftJoystick;
  128710. private _touches;
  128711. private _joystickPosition;
  128712. private _alwaysVisible;
  128713. private _puckImage;
  128714. private _containerImage;
  128715. private _joystickPuckSize;
  128716. private _joystickContainerSize;
  128717. private _clearPuckSize;
  128718. private _clearContainerSize;
  128719. private _clearPuckSizeOffset;
  128720. private _clearContainerSizeOffset;
  128721. private _onPointerDownHandlerRef;
  128722. private _onPointerMoveHandlerRef;
  128723. private _onPointerUpHandlerRef;
  128724. private _onResize;
  128725. /**
  128726. * Creates a new virtual joystick
  128727. * @param leftJoystick defines that the joystick is for left hand (false by default)
  128728. * @param customizations Defines the options we want to customize the VirtualJoystick
  128729. */
  128730. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  128731. /**
  128732. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  128733. * @param newJoystickSensibility defines the new sensibility
  128734. */
  128735. setJoystickSensibility(newJoystickSensibility: number): void;
  128736. private _onPointerDown;
  128737. private _onPointerMove;
  128738. private _onPointerUp;
  128739. /**
  128740. * Change the color of the virtual joystick
  128741. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  128742. */
  128743. setJoystickColor(newColor: string): void;
  128744. /**
  128745. * Size of the joystick's container
  128746. */
  128747. set containerSize(newSize: number);
  128748. get containerSize(): number;
  128749. /**
  128750. * Size of the joystick's puck
  128751. */
  128752. set puckSize(newSize: number);
  128753. get puckSize(): number;
  128754. /**
  128755. * Clears the set position of the joystick
  128756. */
  128757. clearPosition(): void;
  128758. /**
  128759. * Defines whether or not the joystick container is always visible
  128760. */
  128761. set alwaysVisible(value: boolean);
  128762. get alwaysVisible(): boolean;
  128763. /**
  128764. * Sets the constant position of the Joystick container
  128765. * @param x X axis coordinate
  128766. * @param y Y axis coordinate
  128767. */
  128768. setPosition(x: number, y: number): void;
  128769. /**
  128770. * Defines a callback to call when the joystick is touched
  128771. * @param action defines the callback
  128772. */
  128773. setActionOnTouch(action: () => any): void;
  128774. /**
  128775. * Defines which axis you'd like to control for left & right
  128776. * @param axis defines the axis to use
  128777. */
  128778. setAxisForLeftRight(axis: JoystickAxis): void;
  128779. /**
  128780. * Defines which axis you'd like to control for up & down
  128781. * @param axis defines the axis to use
  128782. */
  128783. setAxisForUpDown(axis: JoystickAxis): void;
  128784. /**
  128785. * Clears the canvas from the previous puck / container draw
  128786. */
  128787. private _clearPreviousDraw;
  128788. /**
  128789. * Loads `urlPath` to be used for the container's image
  128790. * @param urlPath defines the urlPath of an image to use
  128791. */
  128792. setContainerImage(urlPath: string): void;
  128793. /**
  128794. * Loads `urlPath` to be used for the puck's image
  128795. * @param urlPath defines the urlPath of an image to use
  128796. */
  128797. setPuckImage(urlPath: string): void;
  128798. /**
  128799. * Draws the Virtual Joystick's container
  128800. */
  128801. private _drawContainer;
  128802. /**
  128803. * Draws the Virtual Joystick's puck
  128804. */
  128805. private _drawPuck;
  128806. private _drawVirtualJoystick;
  128807. /**
  128808. * Release internal HTML canvas
  128809. */
  128810. releaseCanvas(): void;
  128811. }
  128812. }
  128813. declare module BABYLON {
  128814. interface FreeCameraInputsManager {
  128815. /**
  128816. * Add virtual joystick input support to the input manager.
  128817. * @returns the current input manager
  128818. */
  128819. addVirtualJoystick(): FreeCameraInputsManager;
  128820. }
  128821. /**
  128822. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  128823. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128824. */
  128825. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  128826. /**
  128827. * Defines the camera the input is attached to.
  128828. */
  128829. camera: FreeCamera;
  128830. private _leftjoystick;
  128831. private _rightjoystick;
  128832. /**
  128833. * Gets the left stick of the virtual joystick.
  128834. * @returns The virtual Joystick
  128835. */
  128836. getLeftJoystick(): VirtualJoystick;
  128837. /**
  128838. * Gets the right stick of the virtual joystick.
  128839. * @returns The virtual Joystick
  128840. */
  128841. getRightJoystick(): VirtualJoystick;
  128842. /**
  128843. * Update the current camera state depending on the inputs that have been used this frame.
  128844. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128845. */
  128846. checkInputs(): void;
  128847. /**
  128848. * Attach the input controls to a specific dom element to get the input from.
  128849. * @param element Defines the element the controls should be listened from
  128850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128851. */
  128852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128853. /**
  128854. * Detach the current controls from the specified dom element.
  128855. * @param element Defines the element to stop listening the inputs from
  128856. */
  128857. detachControl(element: Nullable<HTMLElement>): void;
  128858. /**
  128859. * Gets the class name of the current intput.
  128860. * @returns the class name
  128861. */
  128862. getClassName(): string;
  128863. /**
  128864. * Get the friendly name associated with the input class.
  128865. * @returns the input friendly name
  128866. */
  128867. getSimpleName(): string;
  128868. }
  128869. }
  128870. declare module BABYLON {
  128871. /**
  128872. * This represents a FPS type of camera controlled by touch.
  128873. * This is like a universal camera minus the Gamepad controls.
  128874. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  128875. */
  128876. export class TouchCamera extends FreeCamera {
  128877. /**
  128878. * Defines the touch sensibility for rotation.
  128879. * The higher the faster.
  128880. */
  128881. get touchAngularSensibility(): number;
  128882. set touchAngularSensibility(value: number);
  128883. /**
  128884. * Defines the touch sensibility for move.
  128885. * The higher the faster.
  128886. */
  128887. get touchMoveSensibility(): number;
  128888. set touchMoveSensibility(value: number);
  128889. /**
  128890. * Instantiates a new touch camera.
  128891. * This represents a FPS type of camera controlled by touch.
  128892. * This is like a universal camera minus the Gamepad controls.
  128893. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  128894. * @param name Define the name of the camera in the scene
  128895. * @param position Define the start position of the camera in the scene
  128896. * @param scene Define the scene the camera belongs to
  128897. */
  128898. constructor(name: string, position: Vector3, scene: Scene);
  128899. /**
  128900. * Gets the current object class name.
  128901. * @return the class name
  128902. */
  128903. getClassName(): string;
  128904. /** @hidden */
  128905. _setupInputs(): void;
  128906. }
  128907. }
  128908. declare module BABYLON {
  128909. /**
  128910. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  128911. * being tilted forward or back and left or right.
  128912. */
  128913. export class DeviceOrientationCamera extends FreeCamera {
  128914. private _initialQuaternion;
  128915. private _quaternionCache;
  128916. private _tmpDragQuaternion;
  128917. private _disablePointerInputWhenUsingDeviceOrientation;
  128918. /**
  128919. * Creates a new device orientation camera
  128920. * @param name The name of the camera
  128921. * @param position The start position camera
  128922. * @param scene The scene the camera belongs to
  128923. */
  128924. constructor(name: string, position: Vector3, scene: Scene);
  128925. /**
  128926. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  128927. */
  128928. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  128929. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  128930. private _dragFactor;
  128931. /**
  128932. * Enabled turning on the y axis when the orientation sensor is active
  128933. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  128934. */
  128935. enableHorizontalDragging(dragFactor?: number): void;
  128936. /**
  128937. * Gets the current instance class name ("DeviceOrientationCamera").
  128938. * This helps avoiding instanceof at run time.
  128939. * @returns the class name
  128940. */
  128941. getClassName(): string;
  128942. /**
  128943. * @hidden
  128944. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  128945. */
  128946. _checkInputs(): void;
  128947. /**
  128948. * Reset the camera to its default orientation on the specified axis only.
  128949. * @param axis The axis to reset
  128950. */
  128951. resetToCurrentRotation(axis?: Axis): void;
  128952. }
  128953. }
  128954. declare module BABYLON {
  128955. /**
  128956. * Defines supported buttons for XBox360 compatible gamepads
  128957. */
  128958. export enum Xbox360Button {
  128959. /** A */
  128960. A = 0,
  128961. /** B */
  128962. B = 1,
  128963. /** X */
  128964. X = 2,
  128965. /** Y */
  128966. Y = 3,
  128967. /** Left button */
  128968. LB = 4,
  128969. /** Right button */
  128970. RB = 5,
  128971. /** Back */
  128972. Back = 8,
  128973. /** Start */
  128974. Start = 9,
  128975. /** Left stick */
  128976. LeftStick = 10,
  128977. /** Right stick */
  128978. RightStick = 11
  128979. }
  128980. /** Defines values for XBox360 DPad */
  128981. export enum Xbox360Dpad {
  128982. /** Up */
  128983. Up = 12,
  128984. /** Down */
  128985. Down = 13,
  128986. /** Left */
  128987. Left = 14,
  128988. /** Right */
  128989. Right = 15
  128990. }
  128991. /**
  128992. * Defines a XBox360 gamepad
  128993. */
  128994. export class Xbox360Pad extends Gamepad {
  128995. private _leftTrigger;
  128996. private _rightTrigger;
  128997. private _onlefttriggerchanged;
  128998. private _onrighttriggerchanged;
  128999. private _onbuttondown;
  129000. private _onbuttonup;
  129001. private _ondpaddown;
  129002. private _ondpadup;
  129003. /** Observable raised when a button is pressed */
  129004. onButtonDownObservable: Observable<Xbox360Button>;
  129005. /** Observable raised when a button is released */
  129006. onButtonUpObservable: Observable<Xbox360Button>;
  129007. /** Observable raised when a pad is pressed */
  129008. onPadDownObservable: Observable<Xbox360Dpad>;
  129009. /** Observable raised when a pad is released */
  129010. onPadUpObservable: Observable<Xbox360Dpad>;
  129011. private _buttonA;
  129012. private _buttonB;
  129013. private _buttonX;
  129014. private _buttonY;
  129015. private _buttonBack;
  129016. private _buttonStart;
  129017. private _buttonLB;
  129018. private _buttonRB;
  129019. private _buttonLeftStick;
  129020. private _buttonRightStick;
  129021. private _dPadUp;
  129022. private _dPadDown;
  129023. private _dPadLeft;
  129024. private _dPadRight;
  129025. private _isXboxOnePad;
  129026. /**
  129027. * Creates a new XBox360 gamepad object
  129028. * @param id defines the id of this gamepad
  129029. * @param index defines its index
  129030. * @param gamepad defines the internal HTML gamepad object
  129031. * @param xboxOne defines if it is a XBox One gamepad
  129032. */
  129033. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129034. /**
  129035. * Defines the callback to call when left trigger is pressed
  129036. * @param callback defines the callback to use
  129037. */
  129038. onlefttriggerchanged(callback: (value: number) => void): void;
  129039. /**
  129040. * Defines the callback to call when right trigger is pressed
  129041. * @param callback defines the callback to use
  129042. */
  129043. onrighttriggerchanged(callback: (value: number) => void): void;
  129044. /**
  129045. * Gets the left trigger value
  129046. */
  129047. get leftTrigger(): number;
  129048. /**
  129049. * Sets the left trigger value
  129050. */
  129051. set leftTrigger(newValue: number);
  129052. /**
  129053. * Gets the right trigger value
  129054. */
  129055. get rightTrigger(): number;
  129056. /**
  129057. * Sets the right trigger value
  129058. */
  129059. set rightTrigger(newValue: number);
  129060. /**
  129061. * Defines the callback to call when a button is pressed
  129062. * @param callback defines the callback to use
  129063. */
  129064. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129065. /**
  129066. * Defines the callback to call when a button is released
  129067. * @param callback defines the callback to use
  129068. */
  129069. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129070. /**
  129071. * Defines the callback to call when a pad is pressed
  129072. * @param callback defines the callback to use
  129073. */
  129074. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129075. /**
  129076. * Defines the callback to call when a pad is released
  129077. * @param callback defines the callback to use
  129078. */
  129079. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129080. private _setButtonValue;
  129081. private _setDPadValue;
  129082. /**
  129083. * Gets the value of the `A` button
  129084. */
  129085. get buttonA(): number;
  129086. /**
  129087. * Sets the value of the `A` button
  129088. */
  129089. set buttonA(value: number);
  129090. /**
  129091. * Gets the value of the `B` button
  129092. */
  129093. get buttonB(): number;
  129094. /**
  129095. * Sets the value of the `B` button
  129096. */
  129097. set buttonB(value: number);
  129098. /**
  129099. * Gets the value of the `X` button
  129100. */
  129101. get buttonX(): number;
  129102. /**
  129103. * Sets the value of the `X` button
  129104. */
  129105. set buttonX(value: number);
  129106. /**
  129107. * Gets the value of the `Y` button
  129108. */
  129109. get buttonY(): number;
  129110. /**
  129111. * Sets the value of the `Y` button
  129112. */
  129113. set buttonY(value: number);
  129114. /**
  129115. * Gets the value of the `Start` button
  129116. */
  129117. get buttonStart(): number;
  129118. /**
  129119. * Sets the value of the `Start` button
  129120. */
  129121. set buttonStart(value: number);
  129122. /**
  129123. * Gets the value of the `Back` button
  129124. */
  129125. get buttonBack(): number;
  129126. /**
  129127. * Sets the value of the `Back` button
  129128. */
  129129. set buttonBack(value: number);
  129130. /**
  129131. * Gets the value of the `Left` button
  129132. */
  129133. get buttonLB(): number;
  129134. /**
  129135. * Sets the value of the `Left` button
  129136. */
  129137. set buttonLB(value: number);
  129138. /**
  129139. * Gets the value of the `Right` button
  129140. */
  129141. get buttonRB(): number;
  129142. /**
  129143. * Sets the value of the `Right` button
  129144. */
  129145. set buttonRB(value: number);
  129146. /**
  129147. * Gets the value of the Left joystick
  129148. */
  129149. get buttonLeftStick(): number;
  129150. /**
  129151. * Sets the value of the Left joystick
  129152. */
  129153. set buttonLeftStick(value: number);
  129154. /**
  129155. * Gets the value of the Right joystick
  129156. */
  129157. get buttonRightStick(): number;
  129158. /**
  129159. * Sets the value of the Right joystick
  129160. */
  129161. set buttonRightStick(value: number);
  129162. /**
  129163. * Gets the value of D-pad up
  129164. */
  129165. get dPadUp(): number;
  129166. /**
  129167. * Sets the value of D-pad up
  129168. */
  129169. set dPadUp(value: number);
  129170. /**
  129171. * Gets the value of D-pad down
  129172. */
  129173. get dPadDown(): number;
  129174. /**
  129175. * Sets the value of D-pad down
  129176. */
  129177. set dPadDown(value: number);
  129178. /**
  129179. * Gets the value of D-pad left
  129180. */
  129181. get dPadLeft(): number;
  129182. /**
  129183. * Sets the value of D-pad left
  129184. */
  129185. set dPadLeft(value: number);
  129186. /**
  129187. * Gets the value of D-pad right
  129188. */
  129189. get dPadRight(): number;
  129190. /**
  129191. * Sets the value of D-pad right
  129192. */
  129193. set dPadRight(value: number);
  129194. /**
  129195. * Force the gamepad to synchronize with device values
  129196. */
  129197. update(): void;
  129198. /**
  129199. * Disposes the gamepad
  129200. */
  129201. dispose(): void;
  129202. }
  129203. }
  129204. declare module BABYLON {
  129205. /**
  129206. * Defines supported buttons for DualShock compatible gamepads
  129207. */
  129208. export enum DualShockButton {
  129209. /** Cross */
  129210. Cross = 0,
  129211. /** Circle */
  129212. Circle = 1,
  129213. /** Square */
  129214. Square = 2,
  129215. /** Triangle */
  129216. Triangle = 3,
  129217. /** L1 */
  129218. L1 = 4,
  129219. /** R1 */
  129220. R1 = 5,
  129221. /** Share */
  129222. Share = 8,
  129223. /** Options */
  129224. Options = 9,
  129225. /** Left stick */
  129226. LeftStick = 10,
  129227. /** Right stick */
  129228. RightStick = 11
  129229. }
  129230. /** Defines values for DualShock DPad */
  129231. export enum DualShockDpad {
  129232. /** Up */
  129233. Up = 12,
  129234. /** Down */
  129235. Down = 13,
  129236. /** Left */
  129237. Left = 14,
  129238. /** Right */
  129239. Right = 15
  129240. }
  129241. /**
  129242. * Defines a DualShock gamepad
  129243. */
  129244. export class DualShockPad extends Gamepad {
  129245. private _leftTrigger;
  129246. private _rightTrigger;
  129247. private _onlefttriggerchanged;
  129248. private _onrighttriggerchanged;
  129249. private _onbuttondown;
  129250. private _onbuttonup;
  129251. private _ondpaddown;
  129252. private _ondpadup;
  129253. /** Observable raised when a button is pressed */
  129254. onButtonDownObservable: Observable<DualShockButton>;
  129255. /** Observable raised when a button is released */
  129256. onButtonUpObservable: Observable<DualShockButton>;
  129257. /** Observable raised when a pad is pressed */
  129258. onPadDownObservable: Observable<DualShockDpad>;
  129259. /** Observable raised when a pad is released */
  129260. onPadUpObservable: Observable<DualShockDpad>;
  129261. private _buttonCross;
  129262. private _buttonCircle;
  129263. private _buttonSquare;
  129264. private _buttonTriangle;
  129265. private _buttonShare;
  129266. private _buttonOptions;
  129267. private _buttonL1;
  129268. private _buttonR1;
  129269. private _buttonLeftStick;
  129270. private _buttonRightStick;
  129271. private _dPadUp;
  129272. private _dPadDown;
  129273. private _dPadLeft;
  129274. private _dPadRight;
  129275. /**
  129276. * Creates a new DualShock gamepad object
  129277. * @param id defines the id of this gamepad
  129278. * @param index defines its index
  129279. * @param gamepad defines the internal HTML gamepad object
  129280. */
  129281. constructor(id: string, index: number, gamepad: any);
  129282. /**
  129283. * Defines the callback to call when left trigger is pressed
  129284. * @param callback defines the callback to use
  129285. */
  129286. onlefttriggerchanged(callback: (value: number) => void): void;
  129287. /**
  129288. * Defines the callback to call when right trigger is pressed
  129289. * @param callback defines the callback to use
  129290. */
  129291. onrighttriggerchanged(callback: (value: number) => void): void;
  129292. /**
  129293. * Gets the left trigger value
  129294. */
  129295. get leftTrigger(): number;
  129296. /**
  129297. * Sets the left trigger value
  129298. */
  129299. set leftTrigger(newValue: number);
  129300. /**
  129301. * Gets the right trigger value
  129302. */
  129303. get rightTrigger(): number;
  129304. /**
  129305. * Sets the right trigger value
  129306. */
  129307. set rightTrigger(newValue: number);
  129308. /**
  129309. * Defines the callback to call when a button is pressed
  129310. * @param callback defines the callback to use
  129311. */
  129312. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129313. /**
  129314. * Defines the callback to call when a button is released
  129315. * @param callback defines the callback to use
  129316. */
  129317. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129318. /**
  129319. * Defines the callback to call when a pad is pressed
  129320. * @param callback defines the callback to use
  129321. */
  129322. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129323. /**
  129324. * Defines the callback to call when a pad is released
  129325. * @param callback defines the callback to use
  129326. */
  129327. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129328. private _setButtonValue;
  129329. private _setDPadValue;
  129330. /**
  129331. * Gets the value of the `Cross` button
  129332. */
  129333. get buttonCross(): number;
  129334. /**
  129335. * Sets the value of the `Cross` button
  129336. */
  129337. set buttonCross(value: number);
  129338. /**
  129339. * Gets the value of the `Circle` button
  129340. */
  129341. get buttonCircle(): number;
  129342. /**
  129343. * Sets the value of the `Circle` button
  129344. */
  129345. set buttonCircle(value: number);
  129346. /**
  129347. * Gets the value of the `Square` button
  129348. */
  129349. get buttonSquare(): number;
  129350. /**
  129351. * Sets the value of the `Square` button
  129352. */
  129353. set buttonSquare(value: number);
  129354. /**
  129355. * Gets the value of the `Triangle` button
  129356. */
  129357. get buttonTriangle(): number;
  129358. /**
  129359. * Sets the value of the `Triangle` button
  129360. */
  129361. set buttonTriangle(value: number);
  129362. /**
  129363. * Gets the value of the `Options` button
  129364. */
  129365. get buttonOptions(): number;
  129366. /**
  129367. * Sets the value of the `Options` button
  129368. */
  129369. set buttonOptions(value: number);
  129370. /**
  129371. * Gets the value of the `Share` button
  129372. */
  129373. get buttonShare(): number;
  129374. /**
  129375. * Sets the value of the `Share` button
  129376. */
  129377. set buttonShare(value: number);
  129378. /**
  129379. * Gets the value of the `L1` button
  129380. */
  129381. get buttonL1(): number;
  129382. /**
  129383. * Sets the value of the `L1` button
  129384. */
  129385. set buttonL1(value: number);
  129386. /**
  129387. * Gets the value of the `R1` button
  129388. */
  129389. get buttonR1(): number;
  129390. /**
  129391. * Sets the value of the `R1` button
  129392. */
  129393. set buttonR1(value: number);
  129394. /**
  129395. * Gets the value of the Left joystick
  129396. */
  129397. get buttonLeftStick(): number;
  129398. /**
  129399. * Sets the value of the Left joystick
  129400. */
  129401. set buttonLeftStick(value: number);
  129402. /**
  129403. * Gets the value of the Right joystick
  129404. */
  129405. get buttonRightStick(): number;
  129406. /**
  129407. * Sets the value of the Right joystick
  129408. */
  129409. set buttonRightStick(value: number);
  129410. /**
  129411. * Gets the value of D-pad up
  129412. */
  129413. get dPadUp(): number;
  129414. /**
  129415. * Sets the value of D-pad up
  129416. */
  129417. set dPadUp(value: number);
  129418. /**
  129419. * Gets the value of D-pad down
  129420. */
  129421. get dPadDown(): number;
  129422. /**
  129423. * Sets the value of D-pad down
  129424. */
  129425. set dPadDown(value: number);
  129426. /**
  129427. * Gets the value of D-pad left
  129428. */
  129429. get dPadLeft(): number;
  129430. /**
  129431. * Sets the value of D-pad left
  129432. */
  129433. set dPadLeft(value: number);
  129434. /**
  129435. * Gets the value of D-pad right
  129436. */
  129437. get dPadRight(): number;
  129438. /**
  129439. * Sets the value of D-pad right
  129440. */
  129441. set dPadRight(value: number);
  129442. /**
  129443. * Force the gamepad to synchronize with device values
  129444. */
  129445. update(): void;
  129446. /**
  129447. * Disposes the gamepad
  129448. */
  129449. dispose(): void;
  129450. }
  129451. }
  129452. declare module BABYLON {
  129453. /**
  129454. * Manager for handling gamepads
  129455. */
  129456. export class GamepadManager {
  129457. private _scene?;
  129458. private _babylonGamepads;
  129459. private _oneGamepadConnected;
  129460. /** @hidden */
  129461. _isMonitoring: boolean;
  129462. private _gamepadEventSupported;
  129463. private _gamepadSupport?;
  129464. /**
  129465. * observable to be triggered when the gamepad controller has been connected
  129466. */
  129467. onGamepadConnectedObservable: Observable<Gamepad>;
  129468. /**
  129469. * observable to be triggered when the gamepad controller has been disconnected
  129470. */
  129471. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129472. private _onGamepadConnectedEvent;
  129473. private _onGamepadDisconnectedEvent;
  129474. /**
  129475. * Initializes the gamepad manager
  129476. * @param _scene BabylonJS scene
  129477. */
  129478. constructor(_scene?: Scene | undefined);
  129479. /**
  129480. * The gamepads in the game pad manager
  129481. */
  129482. get gamepads(): Gamepad[];
  129483. /**
  129484. * Get the gamepad controllers based on type
  129485. * @param type The type of gamepad controller
  129486. * @returns Nullable gamepad
  129487. */
  129488. getGamepadByType(type?: number): Nullable<Gamepad>;
  129489. /**
  129490. * Disposes the gamepad manager
  129491. */
  129492. dispose(): void;
  129493. private _addNewGamepad;
  129494. private _startMonitoringGamepads;
  129495. private _stopMonitoringGamepads;
  129496. /** @hidden */
  129497. _checkGamepadsStatus(): void;
  129498. private _updateGamepadObjects;
  129499. }
  129500. }
  129501. declare module BABYLON {
  129502. interface Scene {
  129503. /** @hidden */
  129504. _gamepadManager: Nullable<GamepadManager>;
  129505. /**
  129506. * Gets the gamepad manager associated with the scene
  129507. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129508. */
  129509. gamepadManager: GamepadManager;
  129510. }
  129511. /**
  129512. * Interface representing a free camera inputs manager
  129513. */
  129514. interface FreeCameraInputsManager {
  129515. /**
  129516. * Adds gamepad input support to the FreeCameraInputsManager.
  129517. * @returns the FreeCameraInputsManager
  129518. */
  129519. addGamepad(): FreeCameraInputsManager;
  129520. }
  129521. /**
  129522. * Interface representing an arc rotate camera inputs manager
  129523. */
  129524. interface ArcRotateCameraInputsManager {
  129525. /**
  129526. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129527. * @returns the camera inputs manager
  129528. */
  129529. addGamepad(): ArcRotateCameraInputsManager;
  129530. }
  129531. /**
  129532. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129533. */
  129534. export class GamepadSystemSceneComponent implements ISceneComponent {
  129535. /**
  129536. * The component name helpfull to identify the component in the list of scene components.
  129537. */
  129538. readonly name: string;
  129539. /**
  129540. * The scene the component belongs to.
  129541. */
  129542. scene: Scene;
  129543. /**
  129544. * Creates a new instance of the component for the given scene
  129545. * @param scene Defines the scene to register the component in
  129546. */
  129547. constructor(scene: Scene);
  129548. /**
  129549. * Registers the component in a given scene
  129550. */
  129551. register(): void;
  129552. /**
  129553. * Rebuilds the elements related to this component in case of
  129554. * context lost for instance.
  129555. */
  129556. rebuild(): void;
  129557. /**
  129558. * Disposes the component and the associated ressources
  129559. */
  129560. dispose(): void;
  129561. private _beforeCameraUpdate;
  129562. }
  129563. }
  129564. declare module BABYLON {
  129565. /**
  129566. * 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,
  129567. * which still works and will still be found in many Playgrounds.
  129568. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129569. */
  129570. export class UniversalCamera extends TouchCamera {
  129571. /**
  129572. * Defines the gamepad rotation sensiblity.
  129573. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129574. */
  129575. get gamepadAngularSensibility(): number;
  129576. set gamepadAngularSensibility(value: number);
  129577. /**
  129578. * Defines the gamepad move sensiblity.
  129579. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129580. */
  129581. get gamepadMoveSensibility(): number;
  129582. set gamepadMoveSensibility(value: number);
  129583. /**
  129584. * 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,
  129585. * which still works and will still be found in many Playgrounds.
  129586. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129587. * @param name Define the name of the camera in the scene
  129588. * @param position Define the start position of the camera in the scene
  129589. * @param scene Define the scene the camera belongs to
  129590. */
  129591. constructor(name: string, position: Vector3, scene: Scene);
  129592. /**
  129593. * Gets the current object class name.
  129594. * @return the class name
  129595. */
  129596. getClassName(): string;
  129597. }
  129598. }
  129599. declare module BABYLON {
  129600. /**
  129601. * This represents a FPS type of camera. This is only here for back compat purpose.
  129602. * Please use the UniversalCamera instead as both are identical.
  129603. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129604. */
  129605. export class GamepadCamera extends UniversalCamera {
  129606. /**
  129607. * Instantiates a new Gamepad Camera
  129608. * This represents a FPS type of camera. This is only here for back compat purpose.
  129609. * Please use the UniversalCamera instead as both are identical.
  129610. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129611. * @param name Define the name of the camera in the scene
  129612. * @param position Define the start position of the camera in the scene
  129613. * @param scene Define the scene the camera belongs to
  129614. */
  129615. constructor(name: string, position: Vector3, scene: Scene);
  129616. /**
  129617. * Gets the current object class name.
  129618. * @return the class name
  129619. */
  129620. getClassName(): string;
  129621. }
  129622. }
  129623. declare module BABYLON {
  129624. /** @hidden */
  129625. export var passPixelShader: {
  129626. name: string;
  129627. shader: string;
  129628. };
  129629. }
  129630. declare module BABYLON {
  129631. /** @hidden */
  129632. export var passCubePixelShader: {
  129633. name: string;
  129634. shader: string;
  129635. };
  129636. }
  129637. declare module BABYLON {
  129638. /**
  129639. * PassPostProcess which produces an output the same as it's input
  129640. */
  129641. export class PassPostProcess extends PostProcess {
  129642. /**
  129643. * Gets a string identifying the name of the class
  129644. * @returns "PassPostProcess" string
  129645. */
  129646. getClassName(): string;
  129647. /**
  129648. * Creates the PassPostProcess
  129649. * @param name The name of the effect.
  129650. * @param options The required width/height ratio to downsize to before computing the render pass.
  129651. * @param camera The camera to apply the render pass to.
  129652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129653. * @param engine The engine which the post process will be applied. (default: current engine)
  129654. * @param reusable If the post process can be reused on the same frame. (default: false)
  129655. * @param textureType The type of texture to be used when performing the post processing.
  129656. * @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)
  129657. */
  129658. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129659. /** @hidden */
  129660. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129661. }
  129662. /**
  129663. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129664. */
  129665. export class PassCubePostProcess extends PostProcess {
  129666. private _face;
  129667. /**
  129668. * Gets or sets the cube face to display.
  129669. * * 0 is +X
  129670. * * 1 is -X
  129671. * * 2 is +Y
  129672. * * 3 is -Y
  129673. * * 4 is +Z
  129674. * * 5 is -Z
  129675. */
  129676. get face(): number;
  129677. set face(value: number);
  129678. /**
  129679. * Gets a string identifying the name of the class
  129680. * @returns "PassCubePostProcess" string
  129681. */
  129682. getClassName(): string;
  129683. /**
  129684. * Creates the PassCubePostProcess
  129685. * @param name The name of the effect.
  129686. * @param options The required width/height ratio to downsize to before computing the render pass.
  129687. * @param camera The camera to apply the render pass to.
  129688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129689. * @param engine The engine which the post process will be applied. (default: current engine)
  129690. * @param reusable If the post process can be reused on the same frame. (default: false)
  129691. * @param textureType The type of texture to be used when performing the post processing.
  129692. * @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)
  129693. */
  129694. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129695. /** @hidden */
  129696. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129697. }
  129698. }
  129699. declare module BABYLON {
  129700. /** @hidden */
  129701. export var anaglyphPixelShader: {
  129702. name: string;
  129703. shader: string;
  129704. };
  129705. }
  129706. declare module BABYLON {
  129707. /**
  129708. * Postprocess used to generate anaglyphic rendering
  129709. */
  129710. export class AnaglyphPostProcess extends PostProcess {
  129711. private _passedProcess;
  129712. /**
  129713. * Gets a string identifying the name of the class
  129714. * @returns "AnaglyphPostProcess" string
  129715. */
  129716. getClassName(): string;
  129717. /**
  129718. * Creates a new AnaglyphPostProcess
  129719. * @param name defines postprocess name
  129720. * @param options defines creation options or target ratio scale
  129721. * @param rigCameras defines cameras using this postprocess
  129722. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  129723. * @param engine defines hosting engine
  129724. * @param reusable defines if the postprocess will be reused multiple times per frame
  129725. */
  129726. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  129727. }
  129728. }
  129729. declare module BABYLON {
  129730. /**
  129731. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  129732. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129733. */
  129734. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  129735. /**
  129736. * Creates a new AnaglyphArcRotateCamera
  129737. * @param name defines camera name
  129738. * @param alpha defines alpha angle (in radians)
  129739. * @param beta defines beta angle (in radians)
  129740. * @param radius defines radius
  129741. * @param target defines camera target
  129742. * @param interaxialDistance defines distance between each color axis
  129743. * @param scene defines the hosting scene
  129744. */
  129745. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  129746. /**
  129747. * Gets camera class name
  129748. * @returns AnaglyphArcRotateCamera
  129749. */
  129750. getClassName(): string;
  129751. }
  129752. }
  129753. declare module BABYLON {
  129754. /**
  129755. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  129756. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129757. */
  129758. export class AnaglyphFreeCamera extends FreeCamera {
  129759. /**
  129760. * Creates a new AnaglyphFreeCamera
  129761. * @param name defines camera name
  129762. * @param position defines initial position
  129763. * @param interaxialDistance defines distance between each color axis
  129764. * @param scene defines the hosting scene
  129765. */
  129766. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129767. /**
  129768. * Gets camera class name
  129769. * @returns AnaglyphFreeCamera
  129770. */
  129771. getClassName(): string;
  129772. }
  129773. }
  129774. declare module BABYLON {
  129775. /**
  129776. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  129777. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129778. */
  129779. export class AnaglyphGamepadCamera extends GamepadCamera {
  129780. /**
  129781. * Creates a new AnaglyphGamepadCamera
  129782. * @param name defines camera name
  129783. * @param position defines initial position
  129784. * @param interaxialDistance defines distance between each color axis
  129785. * @param scene defines the hosting scene
  129786. */
  129787. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129788. /**
  129789. * Gets camera class name
  129790. * @returns AnaglyphGamepadCamera
  129791. */
  129792. getClassName(): string;
  129793. }
  129794. }
  129795. declare module BABYLON {
  129796. /**
  129797. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  129798. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129799. */
  129800. export class AnaglyphUniversalCamera extends UniversalCamera {
  129801. /**
  129802. * Creates a new AnaglyphUniversalCamera
  129803. * @param name defines camera name
  129804. * @param position defines initial position
  129805. * @param interaxialDistance defines distance between each color axis
  129806. * @param scene defines the hosting scene
  129807. */
  129808. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129809. /**
  129810. * Gets camera class name
  129811. * @returns AnaglyphUniversalCamera
  129812. */
  129813. getClassName(): string;
  129814. }
  129815. }
  129816. declare module BABYLON {
  129817. /**
  129818. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  129819. * @see https://doc.babylonjs.com/features/cameras
  129820. */
  129821. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  129822. /**
  129823. * Creates a new StereoscopicArcRotateCamera
  129824. * @param name defines camera name
  129825. * @param alpha defines alpha angle (in radians)
  129826. * @param beta defines beta angle (in radians)
  129827. * @param radius defines radius
  129828. * @param target defines camera target
  129829. * @param interaxialDistance defines distance between each color axis
  129830. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129831. * @param scene defines the hosting scene
  129832. */
  129833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129834. /**
  129835. * Gets camera class name
  129836. * @returns StereoscopicArcRotateCamera
  129837. */
  129838. getClassName(): string;
  129839. }
  129840. }
  129841. declare module BABYLON {
  129842. /**
  129843. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  129844. * @see https://doc.babylonjs.com/features/cameras
  129845. */
  129846. export class StereoscopicFreeCamera extends FreeCamera {
  129847. /**
  129848. * Creates a new StereoscopicFreeCamera
  129849. * @param name defines camera name
  129850. * @param position defines initial position
  129851. * @param interaxialDistance defines distance between each color axis
  129852. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129853. * @param scene defines the hosting scene
  129854. */
  129855. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129856. /**
  129857. * Gets camera class name
  129858. * @returns StereoscopicFreeCamera
  129859. */
  129860. getClassName(): string;
  129861. }
  129862. }
  129863. declare module BABYLON {
  129864. /**
  129865. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  129866. * @see https://doc.babylonjs.com/features/cameras
  129867. */
  129868. export class StereoscopicGamepadCamera extends GamepadCamera {
  129869. /**
  129870. * Creates a new StereoscopicGamepadCamera
  129871. * @param name defines camera name
  129872. * @param position defines initial position
  129873. * @param interaxialDistance defines distance between each color axis
  129874. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129875. * @param scene defines the hosting scene
  129876. */
  129877. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129878. /**
  129879. * Gets camera class name
  129880. * @returns StereoscopicGamepadCamera
  129881. */
  129882. getClassName(): string;
  129883. }
  129884. }
  129885. declare module BABYLON {
  129886. /**
  129887. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  129888. * @see https://doc.babylonjs.com/features/cameras
  129889. */
  129890. export class StereoscopicUniversalCamera extends UniversalCamera {
  129891. /**
  129892. * Creates a new StereoscopicUniversalCamera
  129893. * @param name defines camera name
  129894. * @param position defines initial position
  129895. * @param interaxialDistance defines distance between each color axis
  129896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129897. * @param scene defines the hosting scene
  129898. */
  129899. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129900. /**
  129901. * Gets camera class name
  129902. * @returns StereoscopicUniversalCamera
  129903. */
  129904. getClassName(): string;
  129905. }
  129906. }
  129907. declare module BABYLON {
  129908. /**
  129909. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  129910. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  129911. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  129912. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  129913. */
  129914. export class VirtualJoysticksCamera extends FreeCamera {
  129915. /**
  129916. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  129917. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  129918. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  129919. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  129920. * @param name Define the name of the camera in the scene
  129921. * @param position Define the start position of the camera in the scene
  129922. * @param scene Define the scene the camera belongs to
  129923. */
  129924. constructor(name: string, position: Vector3, scene: Scene);
  129925. /**
  129926. * Gets the current object class name.
  129927. * @return the class name
  129928. */
  129929. getClassName(): string;
  129930. }
  129931. }
  129932. declare module BABYLON {
  129933. /**
  129934. * This represents all the required metrics to create a VR camera.
  129935. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  129936. */
  129937. export class VRCameraMetrics {
  129938. /**
  129939. * Define the horizontal resolution off the screen.
  129940. */
  129941. hResolution: number;
  129942. /**
  129943. * Define the vertical resolution off the screen.
  129944. */
  129945. vResolution: number;
  129946. /**
  129947. * Define the horizontal screen size.
  129948. */
  129949. hScreenSize: number;
  129950. /**
  129951. * Define the vertical screen size.
  129952. */
  129953. vScreenSize: number;
  129954. /**
  129955. * Define the vertical screen center position.
  129956. */
  129957. vScreenCenter: number;
  129958. /**
  129959. * Define the distance of the eyes to the screen.
  129960. */
  129961. eyeToScreenDistance: number;
  129962. /**
  129963. * Define the distance between both lenses
  129964. */
  129965. lensSeparationDistance: number;
  129966. /**
  129967. * Define the distance between both viewer's eyes.
  129968. */
  129969. interpupillaryDistance: number;
  129970. /**
  129971. * Define the distortion factor of the VR postprocess.
  129972. * Please, touch with care.
  129973. */
  129974. distortionK: number[];
  129975. /**
  129976. * Define the chromatic aberration correction factors for the VR post process.
  129977. */
  129978. chromaAbCorrection: number[];
  129979. /**
  129980. * Define the scale factor of the post process.
  129981. * The smaller the better but the slower.
  129982. */
  129983. postProcessScaleFactor: number;
  129984. /**
  129985. * Define an offset for the lens center.
  129986. */
  129987. lensCenterOffset: number;
  129988. /**
  129989. * Define if the current vr camera should compensate the distortion of the lense or not.
  129990. */
  129991. compensateDistortion: boolean;
  129992. /**
  129993. * Defines if multiview should be enabled when rendering (Default: false)
  129994. */
  129995. multiviewEnabled: boolean;
  129996. /**
  129997. * Gets the rendering aspect ratio based on the provided resolutions.
  129998. */
  129999. get aspectRatio(): number;
  130000. /**
  130001. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130002. */
  130003. get aspectRatioFov(): number;
  130004. /**
  130005. * @hidden
  130006. */
  130007. get leftHMatrix(): Matrix;
  130008. /**
  130009. * @hidden
  130010. */
  130011. get rightHMatrix(): Matrix;
  130012. /**
  130013. * @hidden
  130014. */
  130015. get leftPreViewMatrix(): Matrix;
  130016. /**
  130017. * @hidden
  130018. */
  130019. get rightPreViewMatrix(): Matrix;
  130020. /**
  130021. * Get the default VRMetrics based on the most generic setup.
  130022. * @returns the default vr metrics
  130023. */
  130024. static GetDefault(): VRCameraMetrics;
  130025. }
  130026. }
  130027. declare module BABYLON {
  130028. /** @hidden */
  130029. export var vrDistortionCorrectionPixelShader: {
  130030. name: string;
  130031. shader: string;
  130032. };
  130033. }
  130034. declare module BABYLON {
  130035. /**
  130036. * VRDistortionCorrectionPostProcess used for mobile VR
  130037. */
  130038. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130039. private _isRightEye;
  130040. private _distortionFactors;
  130041. private _postProcessScaleFactor;
  130042. private _lensCenterOffset;
  130043. private _scaleIn;
  130044. private _scaleFactor;
  130045. private _lensCenter;
  130046. /**
  130047. * Gets a string identifying the name of the class
  130048. * @returns "VRDistortionCorrectionPostProcess" string
  130049. */
  130050. getClassName(): string;
  130051. /**
  130052. * Initializes the VRDistortionCorrectionPostProcess
  130053. * @param name The name of the effect.
  130054. * @param camera The camera to apply the render pass to.
  130055. * @param isRightEye If this is for the right eye distortion
  130056. * @param vrMetrics All the required metrics for the VR camera
  130057. */
  130058. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130059. }
  130060. }
  130061. declare module BABYLON {
  130062. /**
  130063. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130064. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130065. */
  130066. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130067. /**
  130068. * Creates a new VRDeviceOrientationArcRotateCamera
  130069. * @param name defines camera name
  130070. * @param alpha defines the camera rotation along the logitudinal axis
  130071. * @param beta defines the camera rotation along the latitudinal axis
  130072. * @param radius defines the camera distance from its target
  130073. * @param target defines the camera target
  130074. * @param scene defines the scene the camera belongs to
  130075. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130076. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130077. */
  130078. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130079. /**
  130080. * Gets camera class name
  130081. * @returns VRDeviceOrientationArcRotateCamera
  130082. */
  130083. getClassName(): string;
  130084. }
  130085. }
  130086. declare module BABYLON {
  130087. /**
  130088. * Camera used to simulate VR rendering (based on FreeCamera)
  130089. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130090. */
  130091. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130092. /**
  130093. * Creates a new VRDeviceOrientationFreeCamera
  130094. * @param name defines camera name
  130095. * @param position defines the start position of the camera
  130096. * @param scene defines the scene the camera belongs to
  130097. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130098. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130099. */
  130100. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130101. /**
  130102. * Gets camera class name
  130103. * @returns VRDeviceOrientationFreeCamera
  130104. */
  130105. getClassName(): string;
  130106. }
  130107. }
  130108. declare module BABYLON {
  130109. /**
  130110. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130111. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130112. */
  130113. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130114. /**
  130115. * Creates a new VRDeviceOrientationGamepadCamera
  130116. * @param name defines camera name
  130117. * @param position defines the start position of the camera
  130118. * @param scene defines the scene the camera belongs to
  130119. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130120. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130121. */
  130122. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130123. /**
  130124. * Gets camera class name
  130125. * @returns VRDeviceOrientationGamepadCamera
  130126. */
  130127. getClassName(): string;
  130128. }
  130129. }
  130130. declare module BABYLON {
  130131. /**
  130132. * A class extending Texture allowing drawing on a texture
  130133. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130134. */
  130135. export class DynamicTexture extends Texture {
  130136. private _generateMipMaps;
  130137. private _canvas;
  130138. private _context;
  130139. /**
  130140. * Creates a DynamicTexture
  130141. * @param name defines the name of the texture
  130142. * @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
  130143. * @param scene defines the scene where you want the texture
  130144. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130145. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130146. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130147. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130148. */
  130149. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130150. /**
  130151. * Get the current class name of the texture useful for serialization or dynamic coding.
  130152. * @returns "DynamicTexture"
  130153. */
  130154. getClassName(): string;
  130155. /**
  130156. * Gets the current state of canRescale
  130157. */
  130158. get canRescale(): boolean;
  130159. private _recreate;
  130160. /**
  130161. * Scales the texture
  130162. * @param ratio the scale factor to apply to both width and height
  130163. */
  130164. scale(ratio: number): void;
  130165. /**
  130166. * Resizes the texture
  130167. * @param width the new width
  130168. * @param height the new height
  130169. */
  130170. scaleTo(width: number, height: number): void;
  130171. /**
  130172. * Gets the context of the canvas used by the texture
  130173. * @returns the canvas context of the dynamic texture
  130174. */
  130175. getContext(): CanvasRenderingContext2D;
  130176. /**
  130177. * Clears the texture
  130178. */
  130179. clear(): void;
  130180. /**
  130181. * Updates the texture
  130182. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130183. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130184. */
  130185. update(invertY?: boolean, premulAlpha?: boolean): void;
  130186. /**
  130187. * Draws text onto the texture
  130188. * @param text defines the text to be drawn
  130189. * @param x defines the placement of the text from the left
  130190. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130191. * @param font defines the font to be used with font-style, font-size, font-name
  130192. * @param color defines the color used for the text
  130193. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130194. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130195. * @param update defines whether texture is immediately update (default is true)
  130196. */
  130197. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130198. /**
  130199. * Clones the texture
  130200. * @returns the clone of the texture.
  130201. */
  130202. clone(): DynamicTexture;
  130203. /**
  130204. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130205. * @returns a serialized dynamic texture object
  130206. */
  130207. serialize(): any;
  130208. private _IsCanvasElement;
  130209. /** @hidden */
  130210. _rebuild(): void;
  130211. }
  130212. }
  130213. declare module BABYLON {
  130214. /**
  130215. * Class containing static functions to help procedurally build meshes
  130216. */
  130217. export class GroundBuilder {
  130218. /**
  130219. * Creates a ground mesh
  130220. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130221. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130223. * @param name defines the name of the mesh
  130224. * @param options defines the options used to create the mesh
  130225. * @param scene defines the hosting scene
  130226. * @returns the ground mesh
  130227. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130228. */
  130229. static CreateGround(name: string, options: {
  130230. width?: number;
  130231. height?: number;
  130232. subdivisions?: number;
  130233. subdivisionsX?: number;
  130234. subdivisionsY?: number;
  130235. updatable?: boolean;
  130236. }, scene: any): Mesh;
  130237. /**
  130238. * Creates a tiled ground mesh
  130239. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130240. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130241. * * 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
  130242. * * 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
  130243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130244. * @param name defines the name of the mesh
  130245. * @param options defines the options used to create the mesh
  130246. * @param scene defines the hosting scene
  130247. * @returns the tiled ground mesh
  130248. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130249. */
  130250. static CreateTiledGround(name: string, options: {
  130251. xmin: number;
  130252. zmin: number;
  130253. xmax: number;
  130254. zmax: number;
  130255. subdivisions?: {
  130256. w: number;
  130257. h: number;
  130258. };
  130259. precision?: {
  130260. w: number;
  130261. h: number;
  130262. };
  130263. updatable?: boolean;
  130264. }, scene?: Nullable<Scene>): Mesh;
  130265. /**
  130266. * Creates a ground mesh from a height map
  130267. * * The parameter `url` sets the URL of the height map image resource.
  130268. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130269. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130270. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130271. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130272. * * 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.
  130273. * * 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).
  130274. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130276. * @param name defines the name of the mesh
  130277. * @param url defines the url to the height map
  130278. * @param options defines the options used to create the mesh
  130279. * @param scene defines the hosting scene
  130280. * @returns the ground mesh
  130281. * @see https://doc.babylonjs.com/babylon101/height_map
  130282. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130283. */
  130284. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130285. width?: number;
  130286. height?: number;
  130287. subdivisions?: number;
  130288. minHeight?: number;
  130289. maxHeight?: number;
  130290. colorFilter?: Color3;
  130291. alphaFilter?: number;
  130292. updatable?: boolean;
  130293. onReady?: (mesh: GroundMesh) => void;
  130294. }, scene?: Nullable<Scene>): GroundMesh;
  130295. }
  130296. }
  130297. declare module BABYLON {
  130298. /**
  130299. * Class containing static functions to help procedurally build meshes
  130300. */
  130301. export class TorusBuilder {
  130302. /**
  130303. * Creates a torus mesh
  130304. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130305. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130306. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130310. * @param name defines the name of the mesh
  130311. * @param options defines the options used to create the mesh
  130312. * @param scene defines the hosting scene
  130313. * @returns the torus mesh
  130314. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130315. */
  130316. static CreateTorus(name: string, options: {
  130317. diameter?: number;
  130318. thickness?: number;
  130319. tessellation?: number;
  130320. updatable?: boolean;
  130321. sideOrientation?: number;
  130322. frontUVs?: Vector4;
  130323. backUVs?: Vector4;
  130324. }, scene: any): Mesh;
  130325. }
  130326. }
  130327. declare module BABYLON {
  130328. /**
  130329. * Class containing static functions to help procedurally build meshes
  130330. */
  130331. export class CylinderBuilder {
  130332. /**
  130333. * Creates a cylinder or a cone mesh
  130334. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130335. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130336. * * 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.
  130337. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130338. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130339. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130340. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130341. * * 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).
  130342. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130343. * * 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).
  130344. * * 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
  130345. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130346. * * 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
  130347. * * 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.
  130348. * * If `enclose` is false, a ring surface is one element.
  130349. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130350. * * 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
  130351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130354. * @param name defines the name of the mesh
  130355. * @param options defines the options used to create the mesh
  130356. * @param scene defines the hosting scene
  130357. * @returns the cylinder mesh
  130358. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130359. */
  130360. static CreateCylinder(name: string, options: {
  130361. height?: number;
  130362. diameterTop?: number;
  130363. diameterBottom?: number;
  130364. diameter?: number;
  130365. tessellation?: number;
  130366. subdivisions?: number;
  130367. arc?: number;
  130368. faceColors?: Color4[];
  130369. faceUV?: Vector4[];
  130370. updatable?: boolean;
  130371. hasRings?: boolean;
  130372. enclose?: boolean;
  130373. cap?: number;
  130374. sideOrientation?: number;
  130375. frontUVs?: Vector4;
  130376. backUVs?: Vector4;
  130377. }, scene: any): Mesh;
  130378. }
  130379. }
  130380. declare module BABYLON {
  130381. /**
  130382. * States of the webXR experience
  130383. */
  130384. export enum WebXRState {
  130385. /**
  130386. * Transitioning to being in XR mode
  130387. */
  130388. ENTERING_XR = 0,
  130389. /**
  130390. * Transitioning to non XR mode
  130391. */
  130392. EXITING_XR = 1,
  130393. /**
  130394. * In XR mode and presenting
  130395. */
  130396. IN_XR = 2,
  130397. /**
  130398. * Not entered XR mode
  130399. */
  130400. NOT_IN_XR = 3
  130401. }
  130402. /**
  130403. * Abstraction of the XR render target
  130404. */
  130405. export interface WebXRRenderTarget extends IDisposable {
  130406. /**
  130407. * xrpresent context of the canvas which can be used to display/mirror xr content
  130408. */
  130409. canvasContext: WebGLRenderingContext;
  130410. /**
  130411. * xr layer for the canvas
  130412. */
  130413. xrLayer: Nullable<XRWebGLLayer>;
  130414. /**
  130415. * Initializes the xr layer for the session
  130416. * @param xrSession xr session
  130417. * @returns a promise that will resolve once the XR Layer has been created
  130418. */
  130419. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130420. }
  130421. }
  130422. declare module BABYLON {
  130423. /**
  130424. * COnfiguration object for WebXR output canvas
  130425. */
  130426. export class WebXRManagedOutputCanvasOptions {
  130427. /**
  130428. * An optional canvas in case you wish to create it yourself and provide it here.
  130429. * If not provided, a new canvas will be created
  130430. */
  130431. canvasElement?: HTMLCanvasElement;
  130432. /**
  130433. * Options for this XR Layer output
  130434. */
  130435. canvasOptions?: XRWebGLLayerOptions;
  130436. /**
  130437. * CSS styling for a newly created canvas (if not provided)
  130438. */
  130439. newCanvasCssStyle?: string;
  130440. /**
  130441. * Get the default values of the configuration object
  130442. * @param engine defines the engine to use (can be null)
  130443. * @returns default values of this configuration object
  130444. */
  130445. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130446. }
  130447. /**
  130448. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130449. */
  130450. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130451. private _options;
  130452. private _canvas;
  130453. private _engine;
  130454. private _originalCanvasSize;
  130455. /**
  130456. * Rendering context of the canvas which can be used to display/mirror xr content
  130457. */
  130458. canvasContext: WebGLRenderingContext;
  130459. /**
  130460. * xr layer for the canvas
  130461. */
  130462. xrLayer: Nullable<XRWebGLLayer>;
  130463. /**
  130464. * Obseervers registered here will be triggered when the xr layer was initialized
  130465. */
  130466. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130467. /**
  130468. * Initializes the canvas to be added/removed upon entering/exiting xr
  130469. * @param _xrSessionManager The XR Session manager
  130470. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130471. */
  130472. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130473. /**
  130474. * Disposes of the object
  130475. */
  130476. dispose(): void;
  130477. /**
  130478. * Initializes the xr layer for the session
  130479. * @param xrSession xr session
  130480. * @returns a promise that will resolve once the XR Layer has been created
  130481. */
  130482. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130483. private _addCanvas;
  130484. private _removeCanvas;
  130485. private _setCanvasSize;
  130486. private _setManagedOutputCanvas;
  130487. }
  130488. }
  130489. declare module BABYLON {
  130490. /**
  130491. * Manages an XRSession to work with Babylon's engine
  130492. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130493. */
  130494. export class WebXRSessionManager implements IDisposable {
  130495. /** The scene which the session should be created for */
  130496. scene: Scene;
  130497. private _referenceSpace;
  130498. private _rttProvider;
  130499. private _sessionEnded;
  130500. private _xrNavigator;
  130501. private baseLayer;
  130502. /**
  130503. * The base reference space from which the session started. good if you want to reset your
  130504. * reference space
  130505. */
  130506. baseReferenceSpace: XRReferenceSpace;
  130507. /**
  130508. * Current XR frame
  130509. */
  130510. currentFrame: Nullable<XRFrame>;
  130511. /** WebXR timestamp updated every frame */
  130512. currentTimestamp: number;
  130513. /**
  130514. * Used just in case of a failure to initialize an immersive session.
  130515. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130516. */
  130517. defaultHeightCompensation: number;
  130518. /**
  130519. * Fires every time a new xrFrame arrives which can be used to update the camera
  130520. */
  130521. onXRFrameObservable: Observable<XRFrame>;
  130522. /**
  130523. * Fires when the reference space changed
  130524. */
  130525. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130526. /**
  130527. * Fires when the xr session is ended either by the device or manually done
  130528. */
  130529. onXRSessionEnded: Observable<any>;
  130530. /**
  130531. * Fires when the xr session is ended either by the device or manually done
  130532. */
  130533. onXRSessionInit: Observable<XRSession>;
  130534. /**
  130535. * Underlying xr session
  130536. */
  130537. session: XRSession;
  130538. /**
  130539. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130540. * or get the offset the player is currently at.
  130541. */
  130542. viewerReferenceSpace: XRReferenceSpace;
  130543. /**
  130544. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130545. * @param scene The scene which the session should be created for
  130546. */
  130547. constructor(
  130548. /** The scene which the session should be created for */
  130549. scene: Scene);
  130550. /**
  130551. * The current reference space used in this session. This reference space can constantly change!
  130552. * It is mainly used to offset the camera's position.
  130553. */
  130554. get referenceSpace(): XRReferenceSpace;
  130555. /**
  130556. * Set a new reference space and triggers the observable
  130557. */
  130558. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130559. /**
  130560. * Disposes of the session manager
  130561. */
  130562. dispose(): void;
  130563. /**
  130564. * Stops the xrSession and restores the render loop
  130565. * @returns Promise which resolves after it exits XR
  130566. */
  130567. exitXRAsync(): Promise<void>;
  130568. /**
  130569. * Gets the correct render target texture to be rendered this frame for this eye
  130570. * @param eye the eye for which to get the render target
  130571. * @returns the render target for the specified eye
  130572. */
  130573. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130574. /**
  130575. * Creates a WebXRRenderTarget object for the XR session
  130576. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130577. * @param options optional options to provide when creating a new render target
  130578. * @returns a WebXR render target to which the session can render
  130579. */
  130580. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130581. /**
  130582. * Initializes the manager
  130583. * After initialization enterXR can be called to start an XR session
  130584. * @returns Promise which resolves after it is initialized
  130585. */
  130586. initializeAsync(): Promise<void>;
  130587. /**
  130588. * Initializes an xr session
  130589. * @param xrSessionMode mode to initialize
  130590. * @param xrSessionInit defines optional and required values to pass to the session builder
  130591. * @returns a promise which will resolve once the session has been initialized
  130592. */
  130593. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130594. /**
  130595. * Checks if a session would be supported for the creation options specified
  130596. * @param sessionMode session mode to check if supported eg. immersive-vr
  130597. * @returns A Promise that resolves to true if supported and false if not
  130598. */
  130599. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130600. /**
  130601. * Resets the reference space to the one started the session
  130602. */
  130603. resetReferenceSpace(): void;
  130604. /**
  130605. * Starts rendering to the xr layer
  130606. */
  130607. runXRRenderLoop(): void;
  130608. /**
  130609. * Sets the reference space on the xr session
  130610. * @param referenceSpaceType space to set
  130611. * @returns a promise that will resolve once the reference space has been set
  130612. */
  130613. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130614. /**
  130615. * Updates the render state of the session
  130616. * @param state state to set
  130617. * @returns a promise that resolves once the render state has been updated
  130618. */
  130619. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130620. /**
  130621. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130622. * @param sessionMode defines the session to test
  130623. * @returns a promise with boolean as final value
  130624. */
  130625. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130626. private _createRenderTargetTexture;
  130627. }
  130628. }
  130629. declare module BABYLON {
  130630. /**
  130631. * WebXR Camera which holds the views for the xrSession
  130632. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130633. */
  130634. export class WebXRCamera extends FreeCamera {
  130635. private _xrSessionManager;
  130636. private _firstFrame;
  130637. private _referenceQuaternion;
  130638. private _referencedPosition;
  130639. private _xrInvPositionCache;
  130640. private _xrInvQuaternionCache;
  130641. /**
  130642. * Observable raised before camera teleportation
  130643. */
  130644. onBeforeCameraTeleport: Observable<Vector3>;
  130645. /**
  130646. * Observable raised after camera teleportation
  130647. */
  130648. onAfterCameraTeleport: Observable<Vector3>;
  130649. /**
  130650. * Should position compensation execute on first frame.
  130651. * This is used when copying the position from a native (non XR) camera
  130652. */
  130653. compensateOnFirstFrame: boolean;
  130654. /**
  130655. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130656. * @param name the name of the camera
  130657. * @param scene the scene to add the camera to
  130658. * @param _xrSessionManager a constructed xr session manager
  130659. */
  130660. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130661. /**
  130662. * Return the user's height, unrelated to the current ground.
  130663. * This will be the y position of this camera, when ground level is 0.
  130664. */
  130665. get realWorldHeight(): number;
  130666. /** @hidden */
  130667. _updateForDualEyeDebugging(): void;
  130668. /**
  130669. * Sets this camera's transformation based on a non-vr camera
  130670. * @param otherCamera the non-vr camera to copy the transformation from
  130671. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130672. */
  130673. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130674. /**
  130675. * Gets the current instance class name ("WebXRCamera").
  130676. * @returns the class name
  130677. */
  130678. getClassName(): string;
  130679. private _rotate180;
  130680. private _updateFromXRSession;
  130681. private _updateNumberOfRigCameras;
  130682. private _updateReferenceSpace;
  130683. private _updateReferenceSpaceOffset;
  130684. }
  130685. }
  130686. declare module BABYLON {
  130687. /**
  130688. * Defining the interface required for a (webxr) feature
  130689. */
  130690. export interface IWebXRFeature extends IDisposable {
  130691. /**
  130692. * Is this feature attached
  130693. */
  130694. attached: boolean;
  130695. /**
  130696. * Should auto-attach be disabled?
  130697. */
  130698. disableAutoAttach: boolean;
  130699. /**
  130700. * Attach the feature to the session
  130701. * Will usually be called by the features manager
  130702. *
  130703. * @param force should attachment be forced (even when already attached)
  130704. * @returns true if successful.
  130705. */
  130706. attach(force?: boolean): boolean;
  130707. /**
  130708. * Detach the feature from the session
  130709. * Will usually be called by the features manager
  130710. *
  130711. * @returns true if successful.
  130712. */
  130713. detach(): boolean;
  130714. /**
  130715. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  130716. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  130717. *
  130718. * @returns whether or not the feature is compatible in this environment
  130719. */
  130720. isCompatible(): boolean;
  130721. /**
  130722. * Was this feature disposed;
  130723. */
  130724. isDisposed: boolean;
  130725. /**
  130726. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  130727. */
  130728. xrNativeFeatureName?: string;
  130729. /**
  130730. * A list of (Babylon WebXR) features this feature depends on
  130731. */
  130732. dependsOn?: string[];
  130733. }
  130734. /**
  130735. * A list of the currently available features without referencing them
  130736. */
  130737. export class WebXRFeatureName {
  130738. /**
  130739. * The name of the anchor system feature
  130740. */
  130741. static readonly ANCHOR_SYSTEM: string;
  130742. /**
  130743. * The name of the background remover feature
  130744. */
  130745. static readonly BACKGROUND_REMOVER: string;
  130746. /**
  130747. * The name of the hit test feature
  130748. */
  130749. static readonly HIT_TEST: string;
  130750. /**
  130751. * physics impostors for xr controllers feature
  130752. */
  130753. static readonly PHYSICS_CONTROLLERS: string;
  130754. /**
  130755. * The name of the plane detection feature
  130756. */
  130757. static readonly PLANE_DETECTION: string;
  130758. /**
  130759. * The name of the pointer selection feature
  130760. */
  130761. static readonly POINTER_SELECTION: string;
  130762. /**
  130763. * The name of the teleportation feature
  130764. */
  130765. static readonly TELEPORTATION: string;
  130766. /**
  130767. * The name of the feature points feature.
  130768. */
  130769. static readonly FEATURE_POINTS: string;
  130770. /**
  130771. * The name of the hand tracking feature.
  130772. */
  130773. static readonly HAND_TRACKING: string;
  130774. }
  130775. /**
  130776. * Defining the constructor of a feature. Used to register the modules.
  130777. */
  130778. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  130779. /**
  130780. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  130781. * It is mainly used in AR sessions.
  130782. *
  130783. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  130784. */
  130785. export class WebXRFeaturesManager implements IDisposable {
  130786. private _xrSessionManager;
  130787. private static readonly _AvailableFeatures;
  130788. private _features;
  130789. /**
  130790. * constructs a new features manages.
  130791. *
  130792. * @param _xrSessionManager an instance of WebXRSessionManager
  130793. */
  130794. constructor(_xrSessionManager: WebXRSessionManager);
  130795. /**
  130796. * Used to register a module. After calling this function a developer can use this feature in the scene.
  130797. * Mainly used internally.
  130798. *
  130799. * @param featureName the name of the feature to register
  130800. * @param constructorFunction the function used to construct the module
  130801. * @param version the (babylon) version of the module
  130802. * @param stable is that a stable version of this module
  130803. */
  130804. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  130805. /**
  130806. * Returns a constructor of a specific feature.
  130807. *
  130808. * @param featureName the name of the feature to construct
  130809. * @param version the version of the feature to load
  130810. * @param xrSessionManager the xrSessionManager. Used to construct the module
  130811. * @param options optional options provided to the module.
  130812. * @returns a function that, when called, will return a new instance of this feature
  130813. */
  130814. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  130815. /**
  130816. * Can be used to return the list of features currently registered
  130817. *
  130818. * @returns an Array of available features
  130819. */
  130820. static GetAvailableFeatures(): string[];
  130821. /**
  130822. * Gets the versions available for a specific feature
  130823. * @param featureName the name of the feature
  130824. * @returns an array with the available versions
  130825. */
  130826. static GetAvailableVersions(featureName: string): string[];
  130827. /**
  130828. * Return the latest unstable version of this feature
  130829. * @param featureName the name of the feature to search
  130830. * @returns the version number. if not found will return -1
  130831. */
  130832. static GetLatestVersionOfFeature(featureName: string): number;
  130833. /**
  130834. * Return the latest stable version of this feature
  130835. * @param featureName the name of the feature to search
  130836. * @returns the version number. if not found will return -1
  130837. */
  130838. static GetStableVersionOfFeature(featureName: string): number;
  130839. /**
  130840. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  130841. * Can be used during a session to start a feature
  130842. * @param featureName the name of feature to attach
  130843. */
  130844. attachFeature(featureName: string): void;
  130845. /**
  130846. * Can be used inside a session or when the session ends to detach a specific feature
  130847. * @param featureName the name of the feature to detach
  130848. */
  130849. detachFeature(featureName: string): void;
  130850. /**
  130851. * Used to disable an already-enabled feature
  130852. * The feature will be disposed and will be recreated once enabled.
  130853. * @param featureName the feature to disable
  130854. * @returns true if disable was successful
  130855. */
  130856. disableFeature(featureName: string | {
  130857. Name: string;
  130858. }): boolean;
  130859. /**
  130860. * dispose this features manager
  130861. */
  130862. dispose(): void;
  130863. /**
  130864. * 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.
  130865. * 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.
  130866. *
  130867. * @param featureName the name of the feature to load or the class of the feature
  130868. * @param version optional version to load. if not provided the latest version will be enabled
  130869. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  130870. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  130871. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  130872. * @returns a new constructed feature or throws an error if feature not found.
  130873. */
  130874. enableFeature(featureName: string | {
  130875. Name: string;
  130876. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  130877. /**
  130878. * get the implementation of an enabled feature.
  130879. * @param featureName the name of the feature to load
  130880. * @returns the feature class, if found
  130881. */
  130882. getEnabledFeature(featureName: string): IWebXRFeature;
  130883. /**
  130884. * Get the list of enabled features
  130885. * @returns an array of enabled features
  130886. */
  130887. getEnabledFeatures(): string[];
  130888. /**
  130889. * This function will exten the session creation configuration object with enabled features.
  130890. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  130891. * according to the defined "required" variable, provided during enableFeature call
  130892. * @param xrSessionInit the xr Session init object to extend
  130893. *
  130894. * @returns an extended XRSessionInit object
  130895. */
  130896. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  130897. }
  130898. }
  130899. declare module BABYLON {
  130900. /**
  130901. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  130902. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  130903. */
  130904. export class WebXRExperienceHelper implements IDisposable {
  130905. private scene;
  130906. private _nonVRCamera;
  130907. private _originalSceneAutoClear;
  130908. private _supported;
  130909. /**
  130910. * Camera used to render xr content
  130911. */
  130912. camera: WebXRCamera;
  130913. /** A features manager for this xr session */
  130914. featuresManager: WebXRFeaturesManager;
  130915. /**
  130916. * Observers registered here will be triggered after the camera's initial transformation is set
  130917. * This can be used to set a different ground level or an extra rotation.
  130918. *
  130919. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  130920. * to the position set after this observable is done executing.
  130921. */
  130922. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  130923. /**
  130924. * Fires when the state of the experience helper has changed
  130925. */
  130926. onStateChangedObservable: Observable<WebXRState>;
  130927. /** Session manager used to keep track of xr session */
  130928. sessionManager: WebXRSessionManager;
  130929. /**
  130930. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  130931. */
  130932. state: WebXRState;
  130933. /**
  130934. * Creates a WebXRExperienceHelper
  130935. * @param scene The scene the helper should be created in
  130936. */
  130937. private constructor();
  130938. /**
  130939. * Creates the experience helper
  130940. * @param scene the scene to attach the experience helper to
  130941. * @returns a promise for the experience helper
  130942. */
  130943. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  130944. /**
  130945. * Disposes of the experience helper
  130946. */
  130947. dispose(): void;
  130948. /**
  130949. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  130950. * @param sessionMode options for the XR session
  130951. * @param referenceSpaceType frame of reference of the XR session
  130952. * @param renderTarget the output canvas that will be used to enter XR mode
  130953. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  130954. * @returns promise that resolves after xr mode has entered
  130955. */
  130956. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  130957. /**
  130958. * Exits XR mode and returns the scene to its original state
  130959. * @returns promise that resolves after xr mode has exited
  130960. */
  130961. exitXRAsync(): Promise<void>;
  130962. private _nonXRToXRCamera;
  130963. private _setState;
  130964. }
  130965. }
  130966. declare module BABYLON {
  130967. /**
  130968. * X-Y values for axes in WebXR
  130969. */
  130970. export interface IWebXRMotionControllerAxesValue {
  130971. /**
  130972. * The value of the x axis
  130973. */
  130974. x: number;
  130975. /**
  130976. * The value of the y-axis
  130977. */
  130978. y: number;
  130979. }
  130980. /**
  130981. * changed / previous values for the values of this component
  130982. */
  130983. export interface IWebXRMotionControllerComponentChangesValues<T> {
  130984. /**
  130985. * current (this frame) value
  130986. */
  130987. current: T;
  130988. /**
  130989. * previous (last change) value
  130990. */
  130991. previous: T;
  130992. }
  130993. /**
  130994. * Represents changes in the component between current frame and last values recorded
  130995. */
  130996. export interface IWebXRMotionControllerComponentChanges {
  130997. /**
  130998. * will be populated with previous and current values if axes changed
  130999. */
  131000. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131001. /**
  131002. * will be populated with previous and current values if pressed changed
  131003. */
  131004. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131005. /**
  131006. * will be populated with previous and current values if touched changed
  131007. */
  131008. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131009. /**
  131010. * will be populated with previous and current values if value changed
  131011. */
  131012. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131013. }
  131014. /**
  131015. * This class represents a single component (for example button or thumbstick) of a motion controller
  131016. */
  131017. export class WebXRControllerComponent implements IDisposable {
  131018. /**
  131019. * the id of this component
  131020. */
  131021. id: string;
  131022. /**
  131023. * the type of the component
  131024. */
  131025. type: MotionControllerComponentType;
  131026. private _buttonIndex;
  131027. private _axesIndices;
  131028. private _axes;
  131029. private _changes;
  131030. private _currentValue;
  131031. private _hasChanges;
  131032. private _pressed;
  131033. private _touched;
  131034. /**
  131035. * button component type
  131036. */
  131037. static BUTTON_TYPE: MotionControllerComponentType;
  131038. /**
  131039. * squeeze component type
  131040. */
  131041. static SQUEEZE_TYPE: MotionControllerComponentType;
  131042. /**
  131043. * Thumbstick component type
  131044. */
  131045. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131046. /**
  131047. * Touchpad component type
  131048. */
  131049. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131050. /**
  131051. * trigger component type
  131052. */
  131053. static TRIGGER_TYPE: MotionControllerComponentType;
  131054. /**
  131055. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131056. * the axes data changes
  131057. */
  131058. onAxisValueChangedObservable: Observable<{
  131059. x: number;
  131060. y: number;
  131061. }>;
  131062. /**
  131063. * Observers registered here will be triggered when the state of a button changes
  131064. * State change is either pressed / touched / value
  131065. */
  131066. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131067. /**
  131068. * Creates a new component for a motion controller.
  131069. * It is created by the motion controller itself
  131070. *
  131071. * @param id the id of this component
  131072. * @param type the type of the component
  131073. * @param _buttonIndex index in the buttons array of the gamepad
  131074. * @param _axesIndices indices of the values in the axes array of the gamepad
  131075. */
  131076. constructor(
  131077. /**
  131078. * the id of this component
  131079. */
  131080. id: string,
  131081. /**
  131082. * the type of the component
  131083. */
  131084. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131085. /**
  131086. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131087. */
  131088. get axes(): IWebXRMotionControllerAxesValue;
  131089. /**
  131090. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131091. */
  131092. get changes(): IWebXRMotionControllerComponentChanges;
  131093. /**
  131094. * Return whether or not the component changed the last frame
  131095. */
  131096. get hasChanges(): boolean;
  131097. /**
  131098. * is the button currently pressed
  131099. */
  131100. get pressed(): boolean;
  131101. /**
  131102. * is the button currently touched
  131103. */
  131104. get touched(): boolean;
  131105. /**
  131106. * Get the current value of this component
  131107. */
  131108. get value(): number;
  131109. /**
  131110. * Dispose this component
  131111. */
  131112. dispose(): void;
  131113. /**
  131114. * Are there axes correlating to this component
  131115. * @return true is axes data is available
  131116. */
  131117. isAxes(): boolean;
  131118. /**
  131119. * Is this component a button (hence - pressable)
  131120. * @returns true if can be pressed
  131121. */
  131122. isButton(): boolean;
  131123. /**
  131124. * update this component using the gamepad object it is in. Called on every frame
  131125. * @param nativeController the native gamepad controller object
  131126. */
  131127. update(nativeController: IMinimalMotionControllerObject): void;
  131128. }
  131129. }
  131130. declare module BABYLON {
  131131. /**
  131132. * Interface used to represent data loading progression
  131133. */
  131134. export interface ISceneLoaderProgressEvent {
  131135. /**
  131136. * Defines if data length to load can be evaluated
  131137. */
  131138. readonly lengthComputable: boolean;
  131139. /**
  131140. * Defines the loaded data length
  131141. */
  131142. readonly loaded: number;
  131143. /**
  131144. * Defines the data length to load
  131145. */
  131146. readonly total: number;
  131147. }
  131148. /**
  131149. * Interface used by SceneLoader plugins to define supported file extensions
  131150. */
  131151. export interface ISceneLoaderPluginExtensions {
  131152. /**
  131153. * Defines the list of supported extensions
  131154. */
  131155. [extension: string]: {
  131156. isBinary: boolean;
  131157. };
  131158. }
  131159. /**
  131160. * Interface used by SceneLoader plugin factory
  131161. */
  131162. export interface ISceneLoaderPluginFactory {
  131163. /**
  131164. * Defines the name of the factory
  131165. */
  131166. name: string;
  131167. /**
  131168. * Function called to create a new plugin
  131169. * @return the new plugin
  131170. */
  131171. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131172. /**
  131173. * The callback that returns true if the data can be directly loaded.
  131174. * @param data string containing the file data
  131175. * @returns if the data can be loaded directly
  131176. */
  131177. canDirectLoad?(data: string): boolean;
  131178. }
  131179. /**
  131180. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131181. */
  131182. export interface ISceneLoaderPluginBase {
  131183. /**
  131184. * The friendly name of this plugin.
  131185. */
  131186. name: string;
  131187. /**
  131188. * The file extensions supported by this plugin.
  131189. */
  131190. extensions: string | ISceneLoaderPluginExtensions;
  131191. /**
  131192. * The callback called when loading from a url.
  131193. * @param scene scene loading this url
  131194. * @param url url to load
  131195. * @param onSuccess callback called when the file successfully loads
  131196. * @param onProgress callback called while file is loading (if the server supports this mode)
  131197. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131198. * @param onError callback called when the file fails to load
  131199. * @returns a file request object
  131200. */
  131201. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131202. /**
  131203. * The callback called when loading from a file object.
  131204. * @param scene scene loading this file
  131205. * @param file defines the file to load
  131206. * @param onSuccess defines the callback to call when data is loaded
  131207. * @param onProgress defines the callback to call during loading process
  131208. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131209. * @param onError defines the callback to call when an error occurs
  131210. * @returns a file request object
  131211. */
  131212. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131213. /**
  131214. * The callback that returns true if the data can be directly loaded.
  131215. * @param data string containing the file data
  131216. * @returns if the data can be loaded directly
  131217. */
  131218. canDirectLoad?(data: string): boolean;
  131219. /**
  131220. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131221. * @param scene scene loading this data
  131222. * @param data string containing the data
  131223. * @returns data to pass to the plugin
  131224. */
  131225. directLoad?(scene: Scene, data: string): any;
  131226. /**
  131227. * The callback that allows custom handling of the root url based on the response url.
  131228. * @param rootUrl the original root url
  131229. * @param responseURL the response url if available
  131230. * @returns the new root url
  131231. */
  131232. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131233. }
  131234. /**
  131235. * Interface used to define a SceneLoader plugin
  131236. */
  131237. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131238. /**
  131239. * Import meshes into a scene.
  131240. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131241. * @param scene The scene to import into
  131242. * @param data The data to import
  131243. * @param rootUrl The root url for scene and resources
  131244. * @param meshes The meshes array to import into
  131245. * @param particleSystems The particle systems array to import into
  131246. * @param skeletons The skeletons array to import into
  131247. * @param onError The callback when import fails
  131248. * @returns True if successful or false otherwise
  131249. */
  131250. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131251. /**
  131252. * Load into a scene.
  131253. * @param scene The scene to load into
  131254. * @param data The data to import
  131255. * @param rootUrl The root url for scene and resources
  131256. * @param onError The callback when import fails
  131257. * @returns True if successful or false otherwise
  131258. */
  131259. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131260. /**
  131261. * Load into an asset container.
  131262. * @param scene The scene to load into
  131263. * @param data The data to import
  131264. * @param rootUrl The root url for scene and resources
  131265. * @param onError The callback when import fails
  131266. * @returns The loaded asset container
  131267. */
  131268. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131269. }
  131270. /**
  131271. * Interface used to define an async SceneLoader plugin
  131272. */
  131273. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131274. /**
  131275. * Import meshes into a scene.
  131276. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131277. * @param scene The scene to import into
  131278. * @param data The data to import
  131279. * @param rootUrl The root url for scene and resources
  131280. * @param onProgress The callback when the load progresses
  131281. * @param fileName Defines the name of the file to load
  131282. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131283. */
  131284. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131285. meshes: AbstractMesh[];
  131286. particleSystems: IParticleSystem[];
  131287. skeletons: Skeleton[];
  131288. animationGroups: AnimationGroup[];
  131289. }>;
  131290. /**
  131291. * Load into a scene.
  131292. * @param scene The scene to load into
  131293. * @param data The data to import
  131294. * @param rootUrl The root url for scene and resources
  131295. * @param onProgress The callback when the load progresses
  131296. * @param fileName Defines the name of the file to load
  131297. * @returns Nothing
  131298. */
  131299. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131300. /**
  131301. * Load into an asset container.
  131302. * @param scene The scene to load into
  131303. * @param data The data to import
  131304. * @param rootUrl The root url for scene and resources
  131305. * @param onProgress The callback when the load progresses
  131306. * @param fileName Defines the name of the file to load
  131307. * @returns The loaded asset container
  131308. */
  131309. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131310. }
  131311. /**
  131312. * Mode that determines how to handle old animation groups before loading new ones.
  131313. */
  131314. export enum SceneLoaderAnimationGroupLoadingMode {
  131315. /**
  131316. * Reset all old animations to initial state then dispose them.
  131317. */
  131318. Clean = 0,
  131319. /**
  131320. * Stop all old animations.
  131321. */
  131322. Stop = 1,
  131323. /**
  131324. * Restart old animations from first frame.
  131325. */
  131326. Sync = 2,
  131327. /**
  131328. * Old animations remains untouched.
  131329. */
  131330. NoSync = 3
  131331. }
  131332. /**
  131333. * Defines a plugin registered by the SceneLoader
  131334. */
  131335. interface IRegisteredPlugin {
  131336. /**
  131337. * Defines the plugin to use
  131338. */
  131339. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131340. /**
  131341. * Defines if the plugin supports binary data
  131342. */
  131343. isBinary: boolean;
  131344. }
  131345. /**
  131346. * Class used to load scene from various file formats using registered plugins
  131347. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131348. */
  131349. export class SceneLoader {
  131350. /**
  131351. * No logging while loading
  131352. */
  131353. static readonly NO_LOGGING: number;
  131354. /**
  131355. * Minimal logging while loading
  131356. */
  131357. static readonly MINIMAL_LOGGING: number;
  131358. /**
  131359. * Summary logging while loading
  131360. */
  131361. static readonly SUMMARY_LOGGING: number;
  131362. /**
  131363. * Detailled logging while loading
  131364. */
  131365. static readonly DETAILED_LOGGING: number;
  131366. /**
  131367. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131368. */
  131369. static get ForceFullSceneLoadingForIncremental(): boolean;
  131370. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131371. /**
  131372. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131373. */
  131374. static get ShowLoadingScreen(): boolean;
  131375. static set ShowLoadingScreen(value: boolean);
  131376. /**
  131377. * Defines the current logging level (while loading the scene)
  131378. * @ignorenaming
  131379. */
  131380. static get loggingLevel(): number;
  131381. static set loggingLevel(value: number);
  131382. /**
  131383. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131384. */
  131385. static get CleanBoneMatrixWeights(): boolean;
  131386. static set CleanBoneMatrixWeights(value: boolean);
  131387. /**
  131388. * Event raised when a plugin is used to load a scene
  131389. */
  131390. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131391. private static _registeredPlugins;
  131392. private static _showingLoadingScreen;
  131393. /**
  131394. * Gets the default plugin (used to load Babylon files)
  131395. * @returns the .babylon plugin
  131396. */
  131397. static GetDefaultPlugin(): IRegisteredPlugin;
  131398. private static _GetPluginForExtension;
  131399. private static _GetPluginForDirectLoad;
  131400. private static _GetPluginForFilename;
  131401. private static _GetDirectLoad;
  131402. private static _LoadData;
  131403. private static _GetFileInfo;
  131404. /**
  131405. * Gets a plugin that can load the given extension
  131406. * @param extension defines the extension to load
  131407. * @returns a plugin or null if none works
  131408. */
  131409. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131410. /**
  131411. * Gets a boolean indicating that the given extension can be loaded
  131412. * @param extension defines the extension to load
  131413. * @returns true if the extension is supported
  131414. */
  131415. static IsPluginForExtensionAvailable(extension: string): boolean;
  131416. /**
  131417. * Adds a new plugin to the list of registered plugins
  131418. * @param plugin defines the plugin to add
  131419. */
  131420. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131421. /**
  131422. * Import meshes into a scene
  131423. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131424. * @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)
  131425. * @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)
  131426. * @param scene the instance of BABYLON.Scene to append to
  131427. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131428. * @param onProgress a callback with a progress event for each file being loaded
  131429. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131430. * @param pluginExtension the extension used to determine the plugin
  131431. * @returns The loaded plugin
  131432. */
  131433. 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>;
  131434. /**
  131435. * Import meshes into a scene
  131436. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131437. * @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)
  131438. * @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)
  131439. * @param scene the instance of BABYLON.Scene to append to
  131440. * @param onProgress a callback with a progress event for each file being loaded
  131441. * @param pluginExtension the extension used to determine the plugin
  131442. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131443. */
  131444. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131445. meshes: AbstractMesh[];
  131446. particleSystems: IParticleSystem[];
  131447. skeletons: Skeleton[];
  131448. animationGroups: AnimationGroup[];
  131449. }>;
  131450. /**
  131451. * Load a scene
  131452. * @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)
  131453. * @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)
  131454. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131455. * @param onSuccess a callback with the scene when import succeeds
  131456. * @param onProgress a callback with a progress event for each file being loaded
  131457. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131458. * @param pluginExtension the extension used to determine the plugin
  131459. * @returns The loaded plugin
  131460. */
  131461. 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>;
  131462. /**
  131463. * Load a scene
  131464. * @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)
  131465. * @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)
  131466. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131467. * @param onProgress a callback with a progress event for each file being loaded
  131468. * @param pluginExtension the extension used to determine the plugin
  131469. * @returns The loaded scene
  131470. */
  131471. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131472. /**
  131473. * Append a scene
  131474. * @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)
  131475. * @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)
  131476. * @param scene is the instance of BABYLON.Scene to append to
  131477. * @param onSuccess a callback with the scene when import succeeds
  131478. * @param onProgress a callback with a progress event for each file being loaded
  131479. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131480. * @param pluginExtension the extension used to determine the plugin
  131481. * @returns The loaded plugin
  131482. */
  131483. 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>;
  131484. /**
  131485. * Append a scene
  131486. * @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)
  131487. * @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)
  131488. * @param scene is the instance of BABYLON.Scene to append to
  131489. * @param onProgress a callback with a progress event for each file being loaded
  131490. * @param pluginExtension the extension used to determine the plugin
  131491. * @returns The given scene
  131492. */
  131493. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131494. /**
  131495. * Load a scene into an asset container
  131496. * @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)
  131497. * @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)
  131498. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131499. * @param onSuccess a callback with the scene when import succeeds
  131500. * @param onProgress a callback with a progress event for each file being loaded
  131501. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131502. * @param pluginExtension the extension used to determine the plugin
  131503. * @returns The loaded plugin
  131504. */
  131505. 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>;
  131506. /**
  131507. * Load a scene into an asset container
  131508. * @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)
  131509. * @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)
  131510. * @param scene is the instance of Scene to append to
  131511. * @param onProgress a callback with a progress event for each file being loaded
  131512. * @param pluginExtension the extension used to determine the plugin
  131513. * @returns The loaded asset container
  131514. */
  131515. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131516. /**
  131517. * Import animations from a file into a scene
  131518. * @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)
  131519. * @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)
  131520. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131521. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131522. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131523. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131524. * @param onSuccess a callback with the scene when import succeeds
  131525. * @param onProgress a callback with a progress event for each file being loaded
  131526. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131527. * @param pluginExtension the extension used to determine the plugin
  131528. */
  131529. 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;
  131530. /**
  131531. * Import animations from a file into a scene
  131532. * @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)
  131533. * @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)
  131534. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131535. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131536. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131537. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131538. * @param onSuccess a callback with the scene when import succeeds
  131539. * @param onProgress a callback with a progress event for each file being loaded
  131540. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131541. * @param pluginExtension the extension used to determine the plugin
  131542. * @returns the updated scene with imported animations
  131543. */
  131544. 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>;
  131545. }
  131546. }
  131547. declare module BABYLON {
  131548. /**
  131549. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131550. */
  131551. export type MotionControllerHandedness = "none" | "left" | "right";
  131552. /**
  131553. * The type of components available in motion controllers.
  131554. * This is not the name of the component.
  131555. */
  131556. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131557. /**
  131558. * The state of a controller component
  131559. */
  131560. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131561. /**
  131562. * The schema of motion controller layout.
  131563. * No object will be initialized using this interface
  131564. * This is used just to define the profile.
  131565. */
  131566. export interface IMotionControllerLayout {
  131567. /**
  131568. * Path to load the assets. Usually relative to the base path
  131569. */
  131570. assetPath: string;
  131571. /**
  131572. * Available components (unsorted)
  131573. */
  131574. components: {
  131575. /**
  131576. * A map of component Ids
  131577. */
  131578. [componentId: string]: {
  131579. /**
  131580. * The type of input the component outputs
  131581. */
  131582. type: MotionControllerComponentType;
  131583. /**
  131584. * The indices of this component in the gamepad object
  131585. */
  131586. gamepadIndices: {
  131587. /**
  131588. * Index of button
  131589. */
  131590. button?: number;
  131591. /**
  131592. * If available, index of x-axis
  131593. */
  131594. xAxis?: number;
  131595. /**
  131596. * If available, index of y-axis
  131597. */
  131598. yAxis?: number;
  131599. };
  131600. /**
  131601. * The mesh's root node name
  131602. */
  131603. rootNodeName: string;
  131604. /**
  131605. * Animation definitions for this model
  131606. */
  131607. visualResponses: {
  131608. [stateKey: string]: {
  131609. /**
  131610. * What property will be animated
  131611. */
  131612. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131613. /**
  131614. * What states influence this visual response
  131615. */
  131616. states: MotionControllerComponentStateType[];
  131617. /**
  131618. * Type of animation - movement or visibility
  131619. */
  131620. valueNodeProperty: "transform" | "visibility";
  131621. /**
  131622. * Base node name to move. Its position will be calculated according to the min and max nodes
  131623. */
  131624. valueNodeName?: string;
  131625. /**
  131626. * Minimum movement node
  131627. */
  131628. minNodeName?: string;
  131629. /**
  131630. * Max movement node
  131631. */
  131632. maxNodeName?: string;
  131633. };
  131634. };
  131635. /**
  131636. * If touch enabled, what is the name of node to display user feedback
  131637. */
  131638. touchPointNodeName?: string;
  131639. };
  131640. };
  131641. /**
  131642. * Is it xr standard mapping or not
  131643. */
  131644. gamepadMapping: "" | "xr-standard";
  131645. /**
  131646. * Base root node of this entire model
  131647. */
  131648. rootNodeName: string;
  131649. /**
  131650. * Defines the main button component id
  131651. */
  131652. selectComponentId: string;
  131653. }
  131654. /**
  131655. * A definition for the layout map in the input profile
  131656. */
  131657. export interface IMotionControllerLayoutMap {
  131658. /**
  131659. * Layouts with handedness type as a key
  131660. */
  131661. [handedness: string]: IMotionControllerLayout;
  131662. }
  131663. /**
  131664. * The XR Input profile schema
  131665. * Profiles can be found here:
  131666. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131667. */
  131668. export interface IMotionControllerProfile {
  131669. /**
  131670. * fallback profiles for this profileId
  131671. */
  131672. fallbackProfileIds: string[];
  131673. /**
  131674. * The layout map, with handedness as key
  131675. */
  131676. layouts: IMotionControllerLayoutMap;
  131677. /**
  131678. * The id of this profile
  131679. * correlates to the profile(s) in the xrInput.profiles array
  131680. */
  131681. profileId: string;
  131682. }
  131683. /**
  131684. * A helper-interface for the 3 meshes needed for controller button animation
  131685. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  131686. */
  131687. export interface IMotionControllerButtonMeshMap {
  131688. /**
  131689. * the mesh that defines the pressed value mesh position.
  131690. * This is used to find the max-position of this button
  131691. */
  131692. pressedMesh: AbstractMesh;
  131693. /**
  131694. * the mesh that defines the unpressed value mesh position.
  131695. * This is used to find the min (or initial) position of this button
  131696. */
  131697. unpressedMesh: AbstractMesh;
  131698. /**
  131699. * The mesh that will be changed when value changes
  131700. */
  131701. valueMesh: AbstractMesh;
  131702. }
  131703. /**
  131704. * A helper-interface for the 3 meshes needed for controller axis animation.
  131705. * This will be expanded when touchpad animations are fully supported
  131706. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  131707. */
  131708. export interface IMotionControllerMeshMap {
  131709. /**
  131710. * the mesh that defines the maximum value mesh position.
  131711. */
  131712. maxMesh?: AbstractMesh;
  131713. /**
  131714. * the mesh that defines the minimum value mesh position.
  131715. */
  131716. minMesh?: AbstractMesh;
  131717. /**
  131718. * The mesh that will be changed when axis value changes
  131719. */
  131720. valueMesh?: AbstractMesh;
  131721. }
  131722. /**
  131723. * The elements needed for change-detection of the gamepad objects in motion controllers
  131724. */
  131725. export interface IMinimalMotionControllerObject {
  131726. /**
  131727. * Available axes of this controller
  131728. */
  131729. axes: number[];
  131730. /**
  131731. * An array of available buttons
  131732. */
  131733. buttons: Array<{
  131734. /**
  131735. * Value of the button/trigger
  131736. */
  131737. value: number;
  131738. /**
  131739. * If the button/trigger is currently touched
  131740. */
  131741. touched: boolean;
  131742. /**
  131743. * If the button/trigger is currently pressed
  131744. */
  131745. pressed: boolean;
  131746. }>;
  131747. /**
  131748. * EXPERIMENTAL haptic support.
  131749. */
  131750. hapticActuators?: Array<{
  131751. pulse: (value: number, duration: number) => Promise<boolean>;
  131752. }>;
  131753. }
  131754. /**
  131755. * An Abstract Motion controller
  131756. * This class receives an xrInput and a profile layout and uses those to initialize the components
  131757. * Each component has an observable to check for changes in value and state
  131758. */
  131759. export abstract class WebXRAbstractMotionController implements IDisposable {
  131760. protected scene: Scene;
  131761. protected layout: IMotionControllerLayout;
  131762. /**
  131763. * The gamepad object correlating to this controller
  131764. */
  131765. gamepadObject: IMinimalMotionControllerObject;
  131766. /**
  131767. * handedness (left/right/none) of this controller
  131768. */
  131769. handedness: MotionControllerHandedness;
  131770. private _initComponent;
  131771. private _modelReady;
  131772. /**
  131773. * A map of components (WebXRControllerComponent) in this motion controller
  131774. * Components have a ComponentType and can also have both button and axis definitions
  131775. */
  131776. readonly components: {
  131777. [id: string]: WebXRControllerComponent;
  131778. };
  131779. /**
  131780. * Disable the model's animation. Can be set at any time.
  131781. */
  131782. disableAnimation: boolean;
  131783. /**
  131784. * Observers registered here will be triggered when the model of this controller is done loading
  131785. */
  131786. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  131787. /**
  131788. * The profile id of this motion controller
  131789. */
  131790. abstract profileId: string;
  131791. /**
  131792. * The root mesh of the model. It is null if the model was not yet initialized
  131793. */
  131794. rootMesh: Nullable<AbstractMesh>;
  131795. /**
  131796. * constructs a new abstract motion controller
  131797. * @param scene the scene to which the model of the controller will be added
  131798. * @param layout The profile layout to load
  131799. * @param gamepadObject The gamepad object correlating to this controller
  131800. * @param handedness handedness (left/right/none) of this controller
  131801. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  131802. */
  131803. constructor(scene: Scene, layout: IMotionControllerLayout,
  131804. /**
  131805. * The gamepad object correlating to this controller
  131806. */
  131807. gamepadObject: IMinimalMotionControllerObject,
  131808. /**
  131809. * handedness (left/right/none) of this controller
  131810. */
  131811. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  131812. /**
  131813. * Dispose this controller, the model mesh and all its components
  131814. */
  131815. dispose(): void;
  131816. /**
  131817. * Returns all components of specific type
  131818. * @param type the type to search for
  131819. * @return an array of components with this type
  131820. */
  131821. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  131822. /**
  131823. * get a component based an its component id as defined in layout.components
  131824. * @param id the id of the component
  131825. * @returns the component correlates to the id or undefined if not found
  131826. */
  131827. getComponent(id: string): WebXRControllerComponent;
  131828. /**
  131829. * Get the list of components available in this motion controller
  131830. * @returns an array of strings correlating to available components
  131831. */
  131832. getComponentIds(): string[];
  131833. /**
  131834. * Get the first component of specific type
  131835. * @param type type of component to find
  131836. * @return a controller component or null if not found
  131837. */
  131838. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  131839. /**
  131840. * Get the main (Select) component of this controller as defined in the layout
  131841. * @returns the main component of this controller
  131842. */
  131843. getMainComponent(): WebXRControllerComponent;
  131844. /**
  131845. * Loads the model correlating to this controller
  131846. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  131847. * @returns A promise fulfilled with the result of the model loading
  131848. */
  131849. loadModel(): Promise<boolean>;
  131850. /**
  131851. * Update this model using the current XRFrame
  131852. * @param xrFrame the current xr frame to use and update the model
  131853. */
  131854. updateFromXRFrame(xrFrame: XRFrame): void;
  131855. /**
  131856. * Backwards compatibility due to a deeply-integrated typo
  131857. */
  131858. get handness(): XREye;
  131859. /**
  131860. * Pulse (vibrate) this controller
  131861. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  131862. * Consecutive calls to this function will cancel the last pulse call
  131863. *
  131864. * @param value the strength of the pulse in 0.0...1.0 range
  131865. * @param duration Duration of the pulse in milliseconds
  131866. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  131867. * @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
  131868. */
  131869. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  131870. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  131871. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  131872. /**
  131873. * Moves the axis on the controller mesh based on its current state
  131874. * @param axis the index of the axis
  131875. * @param axisValue the value of the axis which determines the meshes new position
  131876. * @hidden
  131877. */
  131878. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  131879. /**
  131880. * Update the model itself with the current frame data
  131881. * @param xrFrame the frame to use for updating the model mesh
  131882. */
  131883. protected updateModel(xrFrame: XRFrame): void;
  131884. /**
  131885. * Get the filename and path for this controller's model
  131886. * @returns a map of filename and path
  131887. */
  131888. protected abstract _getFilenameAndPath(): {
  131889. filename: string;
  131890. path: string;
  131891. };
  131892. /**
  131893. * This function is called before the mesh is loaded. It checks for loading constraints.
  131894. * For example, this function can check if the GLB loader is available
  131895. * If this function returns false, the generic controller will be loaded instead
  131896. * @returns Is the client ready to load the mesh
  131897. */
  131898. protected abstract _getModelLoadingConstraints(): boolean;
  131899. /**
  131900. * This function will be called after the model was successfully loaded and can be used
  131901. * for mesh transformations before it is available for the user
  131902. * @param meshes the loaded meshes
  131903. */
  131904. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  131905. /**
  131906. * Set the root mesh for this controller. Important for the WebXR controller class
  131907. * @param meshes the loaded meshes
  131908. */
  131909. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  131910. /**
  131911. * A function executed each frame that updates the mesh (if needed)
  131912. * @param xrFrame the current xrFrame
  131913. */
  131914. protected abstract _updateModel(xrFrame: XRFrame): void;
  131915. private _getGenericFilenameAndPath;
  131916. private _getGenericParentMesh;
  131917. }
  131918. }
  131919. declare module BABYLON {
  131920. /**
  131921. * A generic trigger-only motion controller for WebXR
  131922. */
  131923. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  131924. /**
  131925. * Static version of the profile id of this controller
  131926. */
  131927. static ProfileId: string;
  131928. profileId: string;
  131929. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  131930. protected _getFilenameAndPath(): {
  131931. filename: string;
  131932. path: string;
  131933. };
  131934. protected _getModelLoadingConstraints(): boolean;
  131935. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  131936. protected _setRootMesh(meshes: AbstractMesh[]): void;
  131937. protected _updateModel(): void;
  131938. }
  131939. }
  131940. declare module BABYLON {
  131941. /**
  131942. * Class containing static functions to help procedurally build meshes
  131943. */
  131944. export class SphereBuilder {
  131945. /**
  131946. * Creates a sphere mesh
  131947. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  131948. * * 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`)
  131949. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  131950. * * 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
  131951. * * 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)
  131952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131955. * @param name defines the name of the mesh
  131956. * @param options defines the options used to create the mesh
  131957. * @param scene defines the hosting scene
  131958. * @returns the sphere mesh
  131959. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  131960. */
  131961. static CreateSphere(name: string, options: {
  131962. segments?: number;
  131963. diameter?: number;
  131964. diameterX?: number;
  131965. diameterY?: number;
  131966. diameterZ?: number;
  131967. arc?: number;
  131968. slice?: number;
  131969. sideOrientation?: number;
  131970. frontUVs?: Vector4;
  131971. backUVs?: Vector4;
  131972. updatable?: boolean;
  131973. }, scene?: Nullable<Scene>): Mesh;
  131974. }
  131975. }
  131976. declare module BABYLON {
  131977. /**
  131978. * A profiled motion controller has its profile loaded from an online repository.
  131979. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  131980. */
  131981. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  131982. private _repositoryUrl;
  131983. private _buttonMeshMapping;
  131984. private _touchDots;
  131985. /**
  131986. * The profile ID of this controller. Will be populated when the controller initializes.
  131987. */
  131988. profileId: string;
  131989. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  131990. dispose(): void;
  131991. protected _getFilenameAndPath(): {
  131992. filename: string;
  131993. path: string;
  131994. };
  131995. protected _getModelLoadingConstraints(): boolean;
  131996. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  131997. protected _setRootMesh(meshes: AbstractMesh[]): void;
  131998. protected _updateModel(_xrFrame: XRFrame): void;
  131999. }
  132000. }
  132001. declare module BABYLON {
  132002. /**
  132003. * A construction function type to create a new controller based on an xrInput object
  132004. */
  132005. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132006. /**
  132007. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132008. *
  132009. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132010. * it should be replaced with auto-loaded controllers.
  132011. *
  132012. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132013. */
  132014. export class WebXRMotionControllerManager {
  132015. private static _AvailableControllers;
  132016. private static _Fallbacks;
  132017. private static _ProfileLoadingPromises;
  132018. private static _ProfilesList;
  132019. /**
  132020. * The base URL of the online controller repository. Can be changed at any time.
  132021. */
  132022. static BaseRepositoryUrl: string;
  132023. /**
  132024. * Which repository gets priority - local or online
  132025. */
  132026. static PrioritizeOnlineRepository: boolean;
  132027. /**
  132028. * Use the online repository, or use only locally-defined controllers
  132029. */
  132030. static UseOnlineRepository: boolean;
  132031. /**
  132032. * Clear the cache used for profile loading and reload when requested again
  132033. */
  132034. static ClearProfilesCache(): void;
  132035. /**
  132036. * Register the default fallbacks.
  132037. * This function is called automatically when this file is imported.
  132038. */
  132039. static DefaultFallbacks(): void;
  132040. /**
  132041. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132042. * @param profileId the profile to which a fallback needs to be found
  132043. * @return an array with corresponding fallback profiles
  132044. */
  132045. static FindFallbackWithProfileId(profileId: string): string[];
  132046. /**
  132047. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132048. * The order of search:
  132049. *
  132050. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132051. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132052. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132053. * 4) return the generic trigger controller if none were found
  132054. *
  132055. * @param xrInput the xrInput to which a new controller is initialized
  132056. * @param scene the scene to which the model will be added
  132057. * @param forceProfile force a certain profile for this controller
  132058. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132059. */
  132060. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132061. /**
  132062. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132063. *
  132064. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132065. *
  132066. * @param type the profile type to register
  132067. * @param constructFunction the function to be called when loading this profile
  132068. */
  132069. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132070. /**
  132071. * Register a fallback to a specific profile.
  132072. * @param profileId the profileId that will receive the fallbacks
  132073. * @param fallbacks A list of fallback profiles
  132074. */
  132075. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132076. /**
  132077. * Will update the list of profiles available in the repository
  132078. * @return a promise that resolves to a map of profiles available online
  132079. */
  132080. static UpdateProfilesList(): Promise<{
  132081. [profile: string]: string;
  132082. }>;
  132083. private static _LoadProfileFromRepository;
  132084. private static _LoadProfilesFromAvailableControllers;
  132085. }
  132086. }
  132087. declare module BABYLON {
  132088. /**
  132089. * Configuration options for the WebXR controller creation
  132090. */
  132091. export interface IWebXRControllerOptions {
  132092. /**
  132093. * Should the controller mesh be animated when a user interacts with it
  132094. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132095. */
  132096. disableMotionControllerAnimation?: boolean;
  132097. /**
  132098. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132099. */
  132100. doNotLoadControllerMesh?: boolean;
  132101. /**
  132102. * Force a specific controller type for this controller.
  132103. * This can be used when creating your own profile or when testing different controllers
  132104. */
  132105. forceControllerProfile?: string;
  132106. /**
  132107. * Defines a rendering group ID for meshes that will be loaded.
  132108. * This is for the default controllers only.
  132109. */
  132110. renderingGroupId?: number;
  132111. }
  132112. /**
  132113. * Represents an XR controller
  132114. */
  132115. export class WebXRInputSource {
  132116. private _scene;
  132117. /** The underlying input source for the controller */
  132118. inputSource: XRInputSource;
  132119. private _options;
  132120. private _tmpVector;
  132121. private _uniqueId;
  132122. private _disposed;
  132123. /**
  132124. * 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
  132125. */
  132126. grip?: AbstractMesh;
  132127. /**
  132128. * If available, this is the gamepad object related to this controller.
  132129. * Using this object it is possible to get click events and trackpad changes of the
  132130. * webxr controller that is currently being used.
  132131. */
  132132. motionController?: WebXRAbstractMotionController;
  132133. /**
  132134. * Event that fires when the controller is removed/disposed.
  132135. * The object provided as event data is this controller, after associated assets were disposed.
  132136. * uniqueId is still available.
  132137. */
  132138. onDisposeObservable: Observable<WebXRInputSource>;
  132139. /**
  132140. * Will be triggered when the mesh associated with the motion controller is done loading.
  132141. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132142. * A shortened version of controller -> motion controller -> on mesh loaded.
  132143. */
  132144. onMeshLoadedObservable: Observable<AbstractMesh>;
  132145. /**
  132146. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132147. */
  132148. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132149. /**
  132150. * Pointer which can be used to select objects or attach a visible laser to
  132151. */
  132152. pointer: AbstractMesh;
  132153. /**
  132154. * Creates the input source object
  132155. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132156. * @param _scene the scene which the controller should be associated to
  132157. * @param inputSource the underlying input source for the controller
  132158. * @param _options options for this controller creation
  132159. */
  132160. constructor(_scene: Scene,
  132161. /** The underlying input source for the controller */
  132162. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132163. /**
  132164. * Get this controllers unique id
  132165. */
  132166. get uniqueId(): string;
  132167. /**
  132168. * Disposes of the object
  132169. */
  132170. dispose(): void;
  132171. /**
  132172. * Gets a world space ray coming from the pointer or grip
  132173. * @param result the resulting ray
  132174. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132175. */
  132176. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132177. /**
  132178. * Updates the controller pose based on the given XRFrame
  132179. * @param xrFrame xr frame to update the pose with
  132180. * @param referenceSpace reference space to use
  132181. */
  132182. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132183. }
  132184. }
  132185. declare module BABYLON {
  132186. /**
  132187. * The schema for initialization options of the XR Input class
  132188. */
  132189. export interface IWebXRInputOptions {
  132190. /**
  132191. * If set to true no model will be automatically loaded
  132192. */
  132193. doNotLoadControllerMeshes?: boolean;
  132194. /**
  132195. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132196. * If not found, the xr input profile data will be used.
  132197. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132198. */
  132199. forceInputProfile?: string;
  132200. /**
  132201. * Do not send a request to the controller repository to load the profile.
  132202. *
  132203. * Instead, use the controllers available in babylon itself.
  132204. */
  132205. disableOnlineControllerRepository?: boolean;
  132206. /**
  132207. * A custom URL for the controllers repository
  132208. */
  132209. customControllersRepositoryURL?: string;
  132210. /**
  132211. * Should the controller model's components not move according to the user input
  132212. */
  132213. disableControllerAnimation?: boolean;
  132214. /**
  132215. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132216. */
  132217. controllerOptions?: IWebXRControllerOptions;
  132218. }
  132219. /**
  132220. * XR input used to track XR inputs such as controllers/rays
  132221. */
  132222. export class WebXRInput implements IDisposable {
  132223. /**
  132224. * the xr session manager for this session
  132225. */
  132226. xrSessionManager: WebXRSessionManager;
  132227. /**
  132228. * the WebXR camera for this session. Mainly used for teleportation
  132229. */
  132230. xrCamera: WebXRCamera;
  132231. private readonly options;
  132232. /**
  132233. * XR controllers being tracked
  132234. */
  132235. controllers: Array<WebXRInputSource>;
  132236. private _frameObserver;
  132237. private _sessionEndedObserver;
  132238. private _sessionInitObserver;
  132239. /**
  132240. * Event when a controller has been connected/added
  132241. */
  132242. onControllerAddedObservable: Observable<WebXRInputSource>;
  132243. /**
  132244. * Event when a controller has been removed/disconnected
  132245. */
  132246. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132247. /**
  132248. * Initializes the WebXRInput
  132249. * @param xrSessionManager the xr session manager for this session
  132250. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132251. * @param options = initialization options for this xr input
  132252. */
  132253. constructor(
  132254. /**
  132255. * the xr session manager for this session
  132256. */
  132257. xrSessionManager: WebXRSessionManager,
  132258. /**
  132259. * the WebXR camera for this session. Mainly used for teleportation
  132260. */
  132261. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132262. private _onInputSourcesChange;
  132263. private _addAndRemoveControllers;
  132264. /**
  132265. * Disposes of the object
  132266. */
  132267. dispose(): void;
  132268. }
  132269. }
  132270. declare module BABYLON {
  132271. /**
  132272. * This is the base class for all WebXR features.
  132273. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132274. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132275. */
  132276. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132277. protected _xrSessionManager: WebXRSessionManager;
  132278. private _attached;
  132279. private _removeOnDetach;
  132280. /**
  132281. * Is this feature disposed?
  132282. */
  132283. isDisposed: boolean;
  132284. /**
  132285. * Should auto-attach be disabled?
  132286. */
  132287. disableAutoAttach: boolean;
  132288. /**
  132289. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132290. */
  132291. xrNativeFeatureName: string;
  132292. /**
  132293. * Construct a new (abstract) WebXR feature
  132294. * @param _xrSessionManager the xr session manager for this feature
  132295. */
  132296. constructor(_xrSessionManager: WebXRSessionManager);
  132297. /**
  132298. * Is this feature attached
  132299. */
  132300. get attached(): boolean;
  132301. /**
  132302. * attach this feature
  132303. *
  132304. * @param force should attachment be forced (even when already attached)
  132305. * @returns true if successful, false is failed or already attached
  132306. */
  132307. attach(force?: boolean): boolean;
  132308. /**
  132309. * detach this feature.
  132310. *
  132311. * @returns true if successful, false if failed or already detached
  132312. */
  132313. detach(): boolean;
  132314. /**
  132315. * Dispose this feature and all of the resources attached
  132316. */
  132317. dispose(): void;
  132318. /**
  132319. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132320. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132321. *
  132322. * @returns whether or not the feature is compatible in this environment
  132323. */
  132324. isCompatible(): boolean;
  132325. /**
  132326. * This is used to register callbacks that will automatically be removed when detach is called.
  132327. * @param observable the observable to which the observer will be attached
  132328. * @param callback the callback to register
  132329. */
  132330. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132331. /**
  132332. * Code in this function will be executed on each xrFrame received from the browser.
  132333. * This function will not execute after the feature is detached.
  132334. * @param _xrFrame the current frame
  132335. */
  132336. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132337. }
  132338. }
  132339. declare module BABYLON {
  132340. /**
  132341. * Renders a layer on top of an existing scene
  132342. */
  132343. export class UtilityLayerRenderer implements IDisposable {
  132344. /** the original scene that will be rendered on top of */
  132345. originalScene: Scene;
  132346. private _pointerCaptures;
  132347. private _lastPointerEvents;
  132348. private static _DefaultUtilityLayer;
  132349. private static _DefaultKeepDepthUtilityLayer;
  132350. private _sharedGizmoLight;
  132351. private _renderCamera;
  132352. /**
  132353. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132354. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132355. * @returns the camera that is used when rendering the utility layer
  132356. */
  132357. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132358. /**
  132359. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132360. * @param cam the camera that should be used when rendering the utility layer
  132361. */
  132362. setRenderCamera(cam: Nullable<Camera>): void;
  132363. /**
  132364. * @hidden
  132365. * Light which used by gizmos to get light shading
  132366. */
  132367. _getSharedGizmoLight(): HemisphericLight;
  132368. /**
  132369. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132370. */
  132371. pickUtilitySceneFirst: boolean;
  132372. /**
  132373. * 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)
  132374. */
  132375. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132376. /**
  132377. * 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)
  132378. */
  132379. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132380. /**
  132381. * The scene that is rendered on top of the original scene
  132382. */
  132383. utilityLayerScene: Scene;
  132384. /**
  132385. * If the utility layer should automatically be rendered on top of existing scene
  132386. */
  132387. shouldRender: boolean;
  132388. /**
  132389. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132390. */
  132391. onlyCheckPointerDownEvents: boolean;
  132392. /**
  132393. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132394. */
  132395. processAllEvents: boolean;
  132396. /**
  132397. * Observable raised when the pointer move from the utility layer scene to the main scene
  132398. */
  132399. onPointerOutObservable: Observable<number>;
  132400. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132401. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132402. private _afterRenderObserver;
  132403. private _sceneDisposeObserver;
  132404. private _originalPointerObserver;
  132405. /**
  132406. * Instantiates a UtilityLayerRenderer
  132407. * @param originalScene the original scene that will be rendered on top of
  132408. * @param handleEvents boolean indicating if the utility layer should handle events
  132409. */
  132410. constructor(
  132411. /** the original scene that will be rendered on top of */
  132412. originalScene: Scene, handleEvents?: boolean);
  132413. private _notifyObservers;
  132414. /**
  132415. * Renders the utility layers scene on top of the original scene
  132416. */
  132417. render(): void;
  132418. /**
  132419. * Disposes of the renderer
  132420. */
  132421. dispose(): void;
  132422. private _updateCamera;
  132423. }
  132424. }
  132425. declare module BABYLON {
  132426. /**
  132427. * Options interface for the pointer selection module
  132428. */
  132429. export interface IWebXRControllerPointerSelectionOptions {
  132430. /**
  132431. * if provided, this scene will be used to render meshes.
  132432. */
  132433. customUtilityLayerScene?: Scene;
  132434. /**
  132435. * 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)
  132436. * If not disabled, the last picked point will be used to execute a pointer up event
  132437. * If disabled, pointer up event will be triggered right after the pointer down event.
  132438. * Used in screen and gaze target ray mode only
  132439. */
  132440. disablePointerUpOnTouchOut: boolean;
  132441. /**
  132442. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132443. */
  132444. forceGazeMode: boolean;
  132445. /**
  132446. * 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
  132447. * to start a new countdown to the pointer down event.
  132448. * Defaults to 1.
  132449. */
  132450. gazeModePointerMovedFactor?: number;
  132451. /**
  132452. * Different button type to use instead of the main component
  132453. */
  132454. overrideButtonId?: string;
  132455. /**
  132456. * use this rendering group id for the meshes (optional)
  132457. */
  132458. renderingGroupId?: number;
  132459. /**
  132460. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132461. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132462. * 3000 means 3 seconds between pointing at something and selecting it
  132463. */
  132464. timeToSelect?: number;
  132465. /**
  132466. * Should meshes created here be added to a utility layer or the main scene
  132467. */
  132468. useUtilityLayer?: boolean;
  132469. /**
  132470. * Optional WebXR camera to be used for gaze selection
  132471. */
  132472. gazeCamera?: WebXRCamera;
  132473. /**
  132474. * the xr input to use with this pointer selection
  132475. */
  132476. xrInput: WebXRInput;
  132477. }
  132478. /**
  132479. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132480. */
  132481. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132482. private readonly _options;
  132483. private static _idCounter;
  132484. private _attachController;
  132485. private _controllers;
  132486. private _scene;
  132487. private _tmpVectorForPickCompare;
  132488. /**
  132489. * The module's name
  132490. */
  132491. static readonly Name: string;
  132492. /**
  132493. * The (Babylon) version of this module.
  132494. * This is an integer representing the implementation version.
  132495. * This number does not correspond to the WebXR specs version
  132496. */
  132497. static readonly Version: number;
  132498. /**
  132499. * Disable lighting on the laser pointer (so it will always be visible)
  132500. */
  132501. disablePointerLighting: boolean;
  132502. /**
  132503. * Disable lighting on the selection mesh (so it will always be visible)
  132504. */
  132505. disableSelectionMeshLighting: boolean;
  132506. /**
  132507. * Should the laser pointer be displayed
  132508. */
  132509. displayLaserPointer: boolean;
  132510. /**
  132511. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132512. */
  132513. displaySelectionMesh: boolean;
  132514. /**
  132515. * This color will be set to the laser pointer when selection is triggered
  132516. */
  132517. laserPointerPickedColor: Color3;
  132518. /**
  132519. * Default color of the laser pointer
  132520. */
  132521. laserPointerDefaultColor: Color3;
  132522. /**
  132523. * default color of the selection ring
  132524. */
  132525. selectionMeshDefaultColor: Color3;
  132526. /**
  132527. * This color will be applied to the selection ring when selection is triggered
  132528. */
  132529. selectionMeshPickedColor: Color3;
  132530. /**
  132531. * Optional filter to be used for ray selection. This predicate shares behavior with
  132532. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132533. */
  132534. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132535. /**
  132536. * constructs a new background remover module
  132537. * @param _xrSessionManager the session manager for this module
  132538. * @param _options read-only options to be used in this module
  132539. */
  132540. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132541. /**
  132542. * attach this feature
  132543. * Will usually be called by the features manager
  132544. *
  132545. * @returns true if successful.
  132546. */
  132547. attach(): boolean;
  132548. /**
  132549. * detach this feature.
  132550. * Will usually be called by the features manager
  132551. *
  132552. * @returns true if successful.
  132553. */
  132554. detach(): boolean;
  132555. /**
  132556. * Will get the mesh under a specific pointer.
  132557. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132558. * @param controllerId the controllerId to check
  132559. * @returns The mesh under pointer or null if no mesh is under the pointer
  132560. */
  132561. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132562. /**
  132563. * Get the xr controller that correlates to the pointer id in the pointer event
  132564. *
  132565. * @param id the pointer id to search for
  132566. * @returns the controller that correlates to this id or null if not found
  132567. */
  132568. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132569. protected _onXRFrame(_xrFrame: XRFrame): void;
  132570. private _attachGazeMode;
  132571. private _attachScreenRayMode;
  132572. private _attachTrackedPointerRayMode;
  132573. private _convertNormalToDirectionOfRay;
  132574. private _detachController;
  132575. private _generateNewMeshPair;
  132576. private _pickingMoved;
  132577. private _updatePointerDistance;
  132578. /** @hidden */
  132579. get lasterPointerDefaultColor(): Color3;
  132580. }
  132581. }
  132582. declare module BABYLON {
  132583. /**
  132584. * Button which can be used to enter a different mode of XR
  132585. */
  132586. export class WebXREnterExitUIButton {
  132587. /** button element */
  132588. element: HTMLElement;
  132589. /** XR initialization options for the button */
  132590. sessionMode: XRSessionMode;
  132591. /** Reference space type */
  132592. referenceSpaceType: XRReferenceSpaceType;
  132593. /**
  132594. * Creates a WebXREnterExitUIButton
  132595. * @param element button element
  132596. * @param sessionMode XR initialization session mode
  132597. * @param referenceSpaceType the type of reference space to be used
  132598. */
  132599. constructor(
  132600. /** button element */
  132601. element: HTMLElement,
  132602. /** XR initialization options for the button */
  132603. sessionMode: XRSessionMode,
  132604. /** Reference space type */
  132605. referenceSpaceType: XRReferenceSpaceType);
  132606. /**
  132607. * Extendable function which can be used to update the button's visuals when the state changes
  132608. * @param activeButton the current active button in the UI
  132609. */
  132610. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132611. }
  132612. /**
  132613. * Options to create the webXR UI
  132614. */
  132615. export class WebXREnterExitUIOptions {
  132616. /**
  132617. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132618. */
  132619. customButtons?: Array<WebXREnterExitUIButton>;
  132620. /**
  132621. * A reference space type to use when creating the default button.
  132622. * Default is local-floor
  132623. */
  132624. referenceSpaceType?: XRReferenceSpaceType;
  132625. /**
  132626. * Context to enter xr with
  132627. */
  132628. renderTarget?: Nullable<WebXRRenderTarget>;
  132629. /**
  132630. * A session mode to use when creating the default button.
  132631. * Default is immersive-vr
  132632. */
  132633. sessionMode?: XRSessionMode;
  132634. /**
  132635. * A list of optional features to init the session with
  132636. */
  132637. optionalFeatures?: string[];
  132638. /**
  132639. * A list of optional features to init the session with
  132640. */
  132641. requiredFeatures?: string[];
  132642. }
  132643. /**
  132644. * UI to allow the user to enter/exit XR mode
  132645. */
  132646. export class WebXREnterExitUI implements IDisposable {
  132647. private scene;
  132648. /** version of the options passed to this UI */
  132649. options: WebXREnterExitUIOptions;
  132650. private _activeButton;
  132651. private _buttons;
  132652. /**
  132653. * The HTML Div Element to which buttons are added.
  132654. */
  132655. readonly overlay: HTMLDivElement;
  132656. /**
  132657. * Fired every time the active button is changed.
  132658. *
  132659. * When xr is entered via a button that launches xr that button will be the callback parameter
  132660. *
  132661. * When exiting xr the callback parameter will be null)
  132662. */
  132663. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  132664. /**
  132665. *
  132666. * @param scene babylon scene object to use
  132667. * @param options (read-only) version of the options passed to this UI
  132668. */
  132669. private constructor();
  132670. /**
  132671. * Creates UI to allow the user to enter/exit XR mode
  132672. * @param scene the scene to add the ui to
  132673. * @param helper the xr experience helper to enter/exit xr with
  132674. * @param options options to configure the UI
  132675. * @returns the created ui
  132676. */
  132677. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  132678. /**
  132679. * Disposes of the XR UI component
  132680. */
  132681. dispose(): void;
  132682. private _updateButtons;
  132683. }
  132684. }
  132685. declare module BABYLON {
  132686. /**
  132687. * Class containing static functions to help procedurally build meshes
  132688. */
  132689. export class LinesBuilder {
  132690. /**
  132691. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  132692. * * 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
  132693. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  132694. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  132695. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  132696. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  132697. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132698. * * 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
  132699. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  132700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  132702. * @param name defines the name of the new line system
  132703. * @param options defines the options used to create the line system
  132704. * @param scene defines the hosting scene
  132705. * @returns a new line system mesh
  132706. */
  132707. static CreateLineSystem(name: string, options: {
  132708. lines: Vector3[][];
  132709. updatable?: boolean;
  132710. instance?: Nullable<LinesMesh>;
  132711. colors?: Nullable<Color4[][]>;
  132712. useVertexAlpha?: boolean;
  132713. }, scene: Nullable<Scene>): LinesMesh;
  132714. /**
  132715. * Creates a line mesh
  132716. * 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
  132717. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132718. * * The parameter `points` is an array successive Vector3
  132719. * * 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
  132720. * * The optional parameter `colors` is an array of successive Color4, one per line point
  132721. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  132722. * * When updating an instance, remember that only point positions can change, not the number of points
  132723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  132725. * @param name defines the name of the new line system
  132726. * @param options defines the options used to create the line system
  132727. * @param scene defines the hosting scene
  132728. * @returns a new line mesh
  132729. */
  132730. static CreateLines(name: string, options: {
  132731. points: Vector3[];
  132732. updatable?: boolean;
  132733. instance?: Nullable<LinesMesh>;
  132734. colors?: Color4[];
  132735. useVertexAlpha?: boolean;
  132736. }, scene?: Nullable<Scene>): LinesMesh;
  132737. /**
  132738. * Creates a dashed line mesh
  132739. * * 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
  132740. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132741. * * The parameter `points` is an array successive Vector3
  132742. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  132743. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  132744. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  132745. * * 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
  132746. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132747. * * When updating an instance, remember that only point positions can change, not the number of points
  132748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132749. * @param name defines the name of the mesh
  132750. * @param options defines the options used to create the mesh
  132751. * @param scene defines the hosting scene
  132752. * @returns the dashed line mesh
  132753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  132754. */
  132755. static CreateDashedLines(name: string, options: {
  132756. points: Vector3[];
  132757. dashSize?: number;
  132758. gapSize?: number;
  132759. dashNb?: number;
  132760. updatable?: boolean;
  132761. instance?: LinesMesh;
  132762. useVertexAlpha?: boolean;
  132763. }, scene?: Nullable<Scene>): LinesMesh;
  132764. }
  132765. }
  132766. declare module BABYLON {
  132767. /**
  132768. * Construction options for a timer
  132769. */
  132770. export interface ITimerOptions<T> {
  132771. /**
  132772. * Time-to-end
  132773. */
  132774. timeout: number;
  132775. /**
  132776. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  132777. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  132778. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  132779. */
  132780. contextObservable: Observable<T>;
  132781. /**
  132782. * Optional parameters when adding an observer to the observable
  132783. */
  132784. observableParameters?: {
  132785. mask?: number;
  132786. insertFirst?: boolean;
  132787. scope?: any;
  132788. };
  132789. /**
  132790. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  132791. */
  132792. breakCondition?: (data?: ITimerData<T>) => boolean;
  132793. /**
  132794. * Will be triggered when the time condition has met
  132795. */
  132796. onEnded?: (data: ITimerData<any>) => void;
  132797. /**
  132798. * Will be triggered when the break condition has met (prematurely ended)
  132799. */
  132800. onAborted?: (data: ITimerData<any>) => void;
  132801. /**
  132802. * Optional function to execute on each tick (or count)
  132803. */
  132804. onTick?: (data: ITimerData<any>) => void;
  132805. }
  132806. /**
  132807. * An interface defining the data sent by the timer
  132808. */
  132809. export interface ITimerData<T> {
  132810. /**
  132811. * When did it start
  132812. */
  132813. startTime: number;
  132814. /**
  132815. * Time now
  132816. */
  132817. currentTime: number;
  132818. /**
  132819. * Time passed since started
  132820. */
  132821. deltaTime: number;
  132822. /**
  132823. * How much is completed, in [0.0...1.0].
  132824. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  132825. */
  132826. completeRate: number;
  132827. /**
  132828. * What the registered observable sent in the last count
  132829. */
  132830. payload: T;
  132831. }
  132832. /**
  132833. * The current state of the timer
  132834. */
  132835. export enum TimerState {
  132836. /**
  132837. * Timer initialized, not yet started
  132838. */
  132839. INIT = 0,
  132840. /**
  132841. * Timer started and counting
  132842. */
  132843. STARTED = 1,
  132844. /**
  132845. * Timer ended (whether aborted or time reached)
  132846. */
  132847. ENDED = 2
  132848. }
  132849. /**
  132850. * A simple version of the timer. Will take options and start the timer immediately after calling it
  132851. *
  132852. * @param options options with which to initialize this timer
  132853. */
  132854. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  132855. /**
  132856. * An advanced implementation of a timer class
  132857. */
  132858. export class AdvancedTimer<T = any> implements IDisposable {
  132859. /**
  132860. * Will notify each time the timer calculates the remaining time
  132861. */
  132862. onEachCountObservable: Observable<ITimerData<T>>;
  132863. /**
  132864. * Will trigger when the timer was aborted due to the break condition
  132865. */
  132866. onTimerAbortedObservable: Observable<ITimerData<T>>;
  132867. /**
  132868. * Will trigger when the timer ended successfully
  132869. */
  132870. onTimerEndedObservable: Observable<ITimerData<T>>;
  132871. /**
  132872. * Will trigger when the timer state has changed
  132873. */
  132874. onStateChangedObservable: Observable<TimerState>;
  132875. private _observer;
  132876. private _contextObservable;
  132877. private _observableParameters;
  132878. private _startTime;
  132879. private _timer;
  132880. private _state;
  132881. private _breakCondition;
  132882. private _timeToEnd;
  132883. private _breakOnNextTick;
  132884. /**
  132885. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  132886. * @param options construction options for this advanced timer
  132887. */
  132888. constructor(options: ITimerOptions<T>);
  132889. /**
  132890. * set a breaking condition for this timer. Default is to never break during count
  132891. * @param predicate the new break condition. Returns true to break, false otherwise
  132892. */
  132893. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  132894. /**
  132895. * Reset ALL associated observables in this advanced timer
  132896. */
  132897. clearObservables(): void;
  132898. /**
  132899. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  132900. *
  132901. * @param timeToEnd how much time to measure until timer ended
  132902. */
  132903. start(timeToEnd?: number): void;
  132904. /**
  132905. * Will force a stop on the next tick.
  132906. */
  132907. stop(): void;
  132908. /**
  132909. * Dispose this timer, clearing all resources
  132910. */
  132911. dispose(): void;
  132912. private _setState;
  132913. private _tick;
  132914. private _stop;
  132915. }
  132916. }
  132917. declare module BABYLON {
  132918. /**
  132919. * The options container for the teleportation module
  132920. */
  132921. export interface IWebXRTeleportationOptions {
  132922. /**
  132923. * if provided, this scene will be used to render meshes.
  132924. */
  132925. customUtilityLayerScene?: Scene;
  132926. /**
  132927. * Values to configure the default target mesh
  132928. */
  132929. defaultTargetMeshOptions?: {
  132930. /**
  132931. * Fill color of the teleportation area
  132932. */
  132933. teleportationFillColor?: string;
  132934. /**
  132935. * Border color for the teleportation area
  132936. */
  132937. teleportationBorderColor?: string;
  132938. /**
  132939. * Disable the mesh's animation sequence
  132940. */
  132941. disableAnimation?: boolean;
  132942. /**
  132943. * Disable lighting on the material or the ring and arrow
  132944. */
  132945. disableLighting?: boolean;
  132946. /**
  132947. * Override the default material of the torus and arrow
  132948. */
  132949. torusArrowMaterial?: Material;
  132950. };
  132951. /**
  132952. * A list of meshes to use as floor meshes.
  132953. * Meshes can be added and removed after initializing the feature using the
  132954. * addFloorMesh and removeFloorMesh functions
  132955. * If empty, rotation will still work
  132956. */
  132957. floorMeshes?: AbstractMesh[];
  132958. /**
  132959. * use this rendering group id for the meshes (optional)
  132960. */
  132961. renderingGroupId?: number;
  132962. /**
  132963. * Should teleportation move only to snap points
  132964. */
  132965. snapPointsOnly?: boolean;
  132966. /**
  132967. * An array of points to which the teleportation will snap to.
  132968. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  132969. */
  132970. snapPositions?: Vector3[];
  132971. /**
  132972. * How close should the teleportation ray be in order to snap to position.
  132973. * Default to 0.8 units (meters)
  132974. */
  132975. snapToPositionRadius?: number;
  132976. /**
  132977. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  132978. * If you want to support rotation, make sure your mesh has a direction indicator.
  132979. *
  132980. * When left untouched, the default mesh will be initialized.
  132981. */
  132982. teleportationTargetMesh?: AbstractMesh;
  132983. /**
  132984. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  132985. */
  132986. timeToTeleport?: number;
  132987. /**
  132988. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  132989. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  132990. */
  132991. useMainComponentOnly?: boolean;
  132992. /**
  132993. * Should meshes created here be added to a utility layer or the main scene
  132994. */
  132995. useUtilityLayer?: boolean;
  132996. /**
  132997. * Babylon XR Input class for controller
  132998. */
  132999. xrInput: WebXRInput;
  133000. /**
  133001. * Meshes that the teleportation ray cannot go through
  133002. */
  133003. pickBlockerMeshes?: AbstractMesh[];
  133004. }
  133005. /**
  133006. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133007. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133008. * the input of the attached controllers.
  133009. */
  133010. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133011. private _options;
  133012. private _controllers;
  133013. private _currentTeleportationControllerId;
  133014. private _floorMeshes;
  133015. private _quadraticBezierCurve;
  133016. private _selectionFeature;
  133017. private _snapToPositions;
  133018. private _snappedToPoint;
  133019. private _teleportationRingMaterial?;
  133020. private _tmpRay;
  133021. private _tmpVector;
  133022. private _tmpQuaternion;
  133023. /**
  133024. * The module's name
  133025. */
  133026. static readonly Name: string;
  133027. /**
  133028. * The (Babylon) version of this module.
  133029. * This is an integer representing the implementation version.
  133030. * This number does not correspond to the webxr specs version
  133031. */
  133032. static readonly Version: number;
  133033. /**
  133034. * Is movement backwards enabled
  133035. */
  133036. backwardsMovementEnabled: boolean;
  133037. /**
  133038. * Distance to travel when moving backwards
  133039. */
  133040. backwardsTeleportationDistance: number;
  133041. /**
  133042. * The distance from the user to the inspection point in the direction of the controller
  133043. * A higher number will allow the user to move further
  133044. * defaults to 5 (meters, in xr units)
  133045. */
  133046. parabolicCheckRadius: number;
  133047. /**
  133048. * Should the module support parabolic ray on top of direct ray
  133049. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133050. * Very helpful when moving between floors / different heights
  133051. */
  133052. parabolicRayEnabled: boolean;
  133053. /**
  133054. * How much rotation should be applied when rotating right and left
  133055. */
  133056. rotationAngle: number;
  133057. /**
  133058. * Is rotation enabled when moving forward?
  133059. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133060. */
  133061. rotationEnabled: boolean;
  133062. /**
  133063. * constructs a new anchor system
  133064. * @param _xrSessionManager an instance of WebXRSessionManager
  133065. * @param _options configuration object for this feature
  133066. */
  133067. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133068. /**
  133069. * Get the snapPointsOnly flag
  133070. */
  133071. get snapPointsOnly(): boolean;
  133072. /**
  133073. * Sets the snapPointsOnly flag
  133074. * @param snapToPoints should teleportation be exclusively to snap points
  133075. */
  133076. set snapPointsOnly(snapToPoints: boolean);
  133077. /**
  133078. * Add a new mesh to the floor meshes array
  133079. * @param mesh the mesh to use as floor mesh
  133080. */
  133081. addFloorMesh(mesh: AbstractMesh): void;
  133082. /**
  133083. * Add a new snap-to point to fix teleportation to this position
  133084. * @param newSnapPoint The new Snap-To point
  133085. */
  133086. addSnapPoint(newSnapPoint: Vector3): void;
  133087. attach(): boolean;
  133088. detach(): boolean;
  133089. dispose(): void;
  133090. /**
  133091. * Remove a mesh from the floor meshes array
  133092. * @param mesh the mesh to remove
  133093. */
  133094. removeFloorMesh(mesh: AbstractMesh): void;
  133095. /**
  133096. * Remove a mesh from the floor meshes array using its name
  133097. * @param name the mesh name to remove
  133098. */
  133099. removeFloorMeshByName(name: string): void;
  133100. /**
  133101. * 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
  133102. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133103. * @returns was the point found and removed or not
  133104. */
  133105. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133106. /**
  133107. * This function sets a selection feature that will be disabled when
  133108. * the forward ray is shown and will be reattached when hidden.
  133109. * This is used to remove the selection rays when moving.
  133110. * @param selectionFeature the feature to disable when forward movement is enabled
  133111. */
  133112. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133113. protected _onXRFrame(_xrFrame: XRFrame): void;
  133114. private _attachController;
  133115. private _createDefaultTargetMesh;
  133116. private _detachController;
  133117. private _findClosestSnapPointWithRadius;
  133118. private _setTargetMeshPosition;
  133119. private _setTargetMeshVisibility;
  133120. private _showParabolicPath;
  133121. private _teleportForward;
  133122. }
  133123. }
  133124. declare module BABYLON {
  133125. /**
  133126. * Options for the default xr helper
  133127. */
  133128. export class WebXRDefaultExperienceOptions {
  133129. /**
  133130. * Enable or disable default UI to enter XR
  133131. */
  133132. disableDefaultUI?: boolean;
  133133. /**
  133134. * Should teleportation not initialize. defaults to false.
  133135. */
  133136. disableTeleportation?: boolean;
  133137. /**
  133138. * Floor meshes that will be used for teleport
  133139. */
  133140. floorMeshes?: Array<AbstractMesh>;
  133141. /**
  133142. * If set to true, the first frame will not be used to reset position
  133143. * The first frame is mainly used when copying transformation from the old camera
  133144. * Mainly used in AR
  133145. */
  133146. ignoreNativeCameraTransformation?: boolean;
  133147. /**
  133148. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133149. */
  133150. inputOptions?: IWebXRInputOptions;
  133151. /**
  133152. * optional configuration for the output canvas
  133153. */
  133154. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133155. /**
  133156. * optional UI options. This can be used among other to change session mode and reference space type
  133157. */
  133158. uiOptions?: WebXREnterExitUIOptions;
  133159. /**
  133160. * When loading teleportation and pointer select, use stable versions instead of latest.
  133161. */
  133162. useStablePlugins?: boolean;
  133163. /**
  133164. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133165. */
  133166. renderingGroupId?: number;
  133167. /**
  133168. * A list of optional features to init the session with
  133169. * If set to true, all features we support will be added
  133170. */
  133171. optionalFeatures?: boolean | string[];
  133172. }
  133173. /**
  133174. * Default experience which provides a similar setup to the previous webVRExperience
  133175. */
  133176. export class WebXRDefaultExperience {
  133177. /**
  133178. * Base experience
  133179. */
  133180. baseExperience: WebXRExperienceHelper;
  133181. /**
  133182. * Enables ui for entering/exiting xr
  133183. */
  133184. enterExitUI: WebXREnterExitUI;
  133185. /**
  133186. * Input experience extension
  133187. */
  133188. input: WebXRInput;
  133189. /**
  133190. * Enables laser pointer and selection
  133191. */
  133192. pointerSelection: WebXRControllerPointerSelection;
  133193. /**
  133194. * Default target xr should render to
  133195. */
  133196. renderTarget: WebXRRenderTarget;
  133197. /**
  133198. * Enables teleportation
  133199. */
  133200. teleportation: WebXRMotionControllerTeleportation;
  133201. private constructor();
  133202. /**
  133203. * Creates the default xr experience
  133204. * @param scene scene
  133205. * @param options options for basic configuration
  133206. * @returns resulting WebXRDefaultExperience
  133207. */
  133208. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133209. /**
  133210. * DIsposes of the experience helper
  133211. */
  133212. dispose(): void;
  133213. }
  133214. }
  133215. declare module BABYLON {
  133216. /**
  133217. * Options to modify the vr teleportation behavior.
  133218. */
  133219. export interface VRTeleportationOptions {
  133220. /**
  133221. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133222. */
  133223. floorMeshName?: string;
  133224. /**
  133225. * A list of meshes to be used as the teleportation floor. (default: empty)
  133226. */
  133227. floorMeshes?: Mesh[];
  133228. /**
  133229. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133230. */
  133231. teleportationMode?: number;
  133232. /**
  133233. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133234. */
  133235. teleportationTime?: number;
  133236. /**
  133237. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133238. */
  133239. teleportationSpeed?: number;
  133240. /**
  133241. * The easing function used in the animation or null for Linear. (default CircleEase)
  133242. */
  133243. easingFunction?: EasingFunction;
  133244. }
  133245. /**
  133246. * Options to modify the vr experience helper's behavior.
  133247. */
  133248. export interface VRExperienceHelperOptions extends WebVROptions {
  133249. /**
  133250. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133251. */
  133252. createDeviceOrientationCamera?: boolean;
  133253. /**
  133254. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133255. */
  133256. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133257. /**
  133258. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133259. */
  133260. laserToggle?: boolean;
  133261. /**
  133262. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133263. */
  133264. floorMeshes?: Mesh[];
  133265. /**
  133266. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133267. */
  133268. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133269. /**
  133270. * Defines if WebXR should be used instead of WebVR (if available)
  133271. */
  133272. useXR?: boolean;
  133273. }
  133274. /**
  133275. * Event containing information after VR has been entered
  133276. */
  133277. export class OnAfterEnteringVRObservableEvent {
  133278. /**
  133279. * If entering vr was successful
  133280. */
  133281. success: boolean;
  133282. }
  133283. /**
  133284. * Helps to quickly add VR support to an existing scene.
  133285. * See https://doc.babylonjs.com/how_to/webvr_helper
  133286. */
  133287. export class VRExperienceHelper {
  133288. /** Options to modify the vr experience helper's behavior. */
  133289. webVROptions: VRExperienceHelperOptions;
  133290. private _scene;
  133291. private _position;
  133292. private _btnVR;
  133293. private _btnVRDisplayed;
  133294. private _webVRsupported;
  133295. private _webVRready;
  133296. private _webVRrequesting;
  133297. private _webVRpresenting;
  133298. private _hasEnteredVR;
  133299. private _fullscreenVRpresenting;
  133300. private _inputElement;
  133301. private _webVRCamera;
  133302. private _vrDeviceOrientationCamera;
  133303. private _deviceOrientationCamera;
  133304. private _existingCamera;
  133305. private _onKeyDown;
  133306. private _onVrDisplayPresentChange;
  133307. private _onVRDisplayChanged;
  133308. private _onVRRequestPresentStart;
  133309. private _onVRRequestPresentComplete;
  133310. /**
  133311. * 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)
  133312. */
  133313. enableGazeEvenWhenNoPointerLock: boolean;
  133314. /**
  133315. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133316. */
  133317. exitVROnDoubleTap: boolean;
  133318. /**
  133319. * Observable raised right before entering VR.
  133320. */
  133321. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133322. /**
  133323. * Observable raised when entering VR has completed.
  133324. */
  133325. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133326. /**
  133327. * Observable raised when exiting VR.
  133328. */
  133329. onExitingVRObservable: Observable<VRExperienceHelper>;
  133330. /**
  133331. * Observable raised when controller mesh is loaded.
  133332. */
  133333. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133334. /** Return this.onEnteringVRObservable
  133335. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133336. */
  133337. get onEnteringVR(): Observable<VRExperienceHelper>;
  133338. /** Return this.onExitingVRObservable
  133339. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133340. */
  133341. get onExitingVR(): Observable<VRExperienceHelper>;
  133342. /** Return this.onControllerMeshLoadedObservable
  133343. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133344. */
  133345. get onControllerMeshLoaded(): Observable<WebVRController>;
  133346. private _rayLength;
  133347. private _useCustomVRButton;
  133348. private _teleportationRequested;
  133349. private _teleportActive;
  133350. private _floorMeshName;
  133351. private _floorMeshesCollection;
  133352. private _teleportationMode;
  133353. private _teleportationTime;
  133354. private _teleportationSpeed;
  133355. private _teleportationEasing;
  133356. private _rotationAllowed;
  133357. private _teleportBackwardsVector;
  133358. private _teleportationTarget;
  133359. private _isDefaultTeleportationTarget;
  133360. private _postProcessMove;
  133361. private _teleportationFillColor;
  133362. private _teleportationBorderColor;
  133363. private _rotationAngle;
  133364. private _haloCenter;
  133365. private _cameraGazer;
  133366. private _padSensibilityUp;
  133367. private _padSensibilityDown;
  133368. private _leftController;
  133369. private _rightController;
  133370. private _gazeColor;
  133371. private _laserColor;
  133372. private _pickedLaserColor;
  133373. private _pickedGazeColor;
  133374. /**
  133375. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133376. */
  133377. onNewMeshSelected: Observable<AbstractMesh>;
  133378. /**
  133379. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133380. * This observable will provide the mesh and the controller used to select the mesh
  133381. */
  133382. onMeshSelectedWithController: Observable<{
  133383. mesh: AbstractMesh;
  133384. controller: WebVRController;
  133385. }>;
  133386. /**
  133387. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133388. */
  133389. onNewMeshPicked: Observable<PickingInfo>;
  133390. private _circleEase;
  133391. /**
  133392. * Observable raised before camera teleportation
  133393. */
  133394. onBeforeCameraTeleport: Observable<Vector3>;
  133395. /**
  133396. * Observable raised after camera teleportation
  133397. */
  133398. onAfterCameraTeleport: Observable<Vector3>;
  133399. /**
  133400. * Observable raised when current selected mesh gets unselected
  133401. */
  133402. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133403. private _raySelectionPredicate;
  133404. /**
  133405. * To be optionaly changed by user to define custom ray selection
  133406. */
  133407. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133408. /**
  133409. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133410. */
  133411. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133412. /**
  133413. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133414. */
  133415. teleportationEnabled: boolean;
  133416. private _defaultHeight;
  133417. private _teleportationInitialized;
  133418. private _interactionsEnabled;
  133419. private _interactionsRequested;
  133420. private _displayGaze;
  133421. private _displayLaserPointer;
  133422. /**
  133423. * The mesh used to display where the user is going to teleport.
  133424. */
  133425. get teleportationTarget(): Mesh;
  133426. /**
  133427. * Sets the mesh to be used to display where the user is going to teleport.
  133428. */
  133429. set teleportationTarget(value: Mesh);
  133430. /**
  133431. * 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
  133432. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133433. * See https://doc.babylonjs.com/resources/baking_transformations
  133434. */
  133435. get gazeTrackerMesh(): Mesh;
  133436. set gazeTrackerMesh(value: Mesh);
  133437. /**
  133438. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133439. */
  133440. updateGazeTrackerScale: boolean;
  133441. /**
  133442. * If the gaze trackers color should be updated when selecting meshes
  133443. */
  133444. updateGazeTrackerColor: boolean;
  133445. /**
  133446. * If the controller laser color should be updated when selecting meshes
  133447. */
  133448. updateControllerLaserColor: boolean;
  133449. /**
  133450. * The gaze tracking mesh corresponding to the left controller
  133451. */
  133452. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133453. /**
  133454. * The gaze tracking mesh corresponding to the right controller
  133455. */
  133456. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133457. /**
  133458. * If the ray of the gaze should be displayed.
  133459. */
  133460. get displayGaze(): boolean;
  133461. /**
  133462. * Sets if the ray of the gaze should be displayed.
  133463. */
  133464. set displayGaze(value: boolean);
  133465. /**
  133466. * If the ray of the LaserPointer should be displayed.
  133467. */
  133468. get displayLaserPointer(): boolean;
  133469. /**
  133470. * Sets if the ray of the LaserPointer should be displayed.
  133471. */
  133472. set displayLaserPointer(value: boolean);
  133473. /**
  133474. * The deviceOrientationCamera used as the camera when not in VR.
  133475. */
  133476. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133477. /**
  133478. * Based on the current WebVR support, returns the current VR camera used.
  133479. */
  133480. get currentVRCamera(): Nullable<Camera>;
  133481. /**
  133482. * The webVRCamera which is used when in VR.
  133483. */
  133484. get webVRCamera(): WebVRFreeCamera;
  133485. /**
  133486. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133487. */
  133488. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133489. /**
  133490. * The html button that is used to trigger entering into VR.
  133491. */
  133492. get vrButton(): Nullable<HTMLButtonElement>;
  133493. private get _teleportationRequestInitiated();
  133494. /**
  133495. * Defines whether or not Pointer lock should be requested when switching to
  133496. * full screen.
  133497. */
  133498. requestPointerLockOnFullScreen: boolean;
  133499. /**
  133500. * If asking to force XR, this will be populated with the default xr experience
  133501. */
  133502. xr: WebXRDefaultExperience;
  133503. /**
  133504. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133505. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133506. */
  133507. xrTestDone: boolean;
  133508. /**
  133509. * Instantiates a VRExperienceHelper.
  133510. * Helps to quickly add VR support to an existing scene.
  133511. * @param scene The scene the VRExperienceHelper belongs to.
  133512. * @param webVROptions Options to modify the vr experience helper's behavior.
  133513. */
  133514. constructor(scene: Scene,
  133515. /** Options to modify the vr experience helper's behavior. */
  133516. webVROptions?: VRExperienceHelperOptions);
  133517. private completeVRInit;
  133518. private _onDefaultMeshLoaded;
  133519. private _onResize;
  133520. private _onFullscreenChange;
  133521. /**
  133522. * Gets a value indicating if we are currently in VR mode.
  133523. */
  133524. get isInVRMode(): boolean;
  133525. private onVrDisplayPresentChange;
  133526. private onVRDisplayChanged;
  133527. private moveButtonToBottomRight;
  133528. private displayVRButton;
  133529. private updateButtonVisibility;
  133530. private _cachedAngularSensibility;
  133531. /**
  133532. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133533. * Otherwise, will use the fullscreen API.
  133534. */
  133535. enterVR(): void;
  133536. /**
  133537. * Attempt to exit VR, or fullscreen.
  133538. */
  133539. exitVR(): void;
  133540. /**
  133541. * The position of the vr experience helper.
  133542. */
  133543. get position(): Vector3;
  133544. /**
  133545. * Sets the position of the vr experience helper.
  133546. */
  133547. set position(value: Vector3);
  133548. /**
  133549. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133550. */
  133551. enableInteractions(): void;
  133552. private get _noControllerIsActive();
  133553. private beforeRender;
  133554. private _isTeleportationFloor;
  133555. /**
  133556. * Adds a floor mesh to be used for teleportation.
  133557. * @param floorMesh the mesh to be used for teleportation.
  133558. */
  133559. addFloorMesh(floorMesh: Mesh): void;
  133560. /**
  133561. * Removes a floor mesh from being used for teleportation.
  133562. * @param floorMesh the mesh to be removed.
  133563. */
  133564. removeFloorMesh(floorMesh: Mesh): void;
  133565. /**
  133566. * Enables interactions and teleportation using the VR controllers and gaze.
  133567. * @param vrTeleportationOptions options to modify teleportation behavior.
  133568. */
  133569. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133570. private _onNewGamepadConnected;
  133571. private _tryEnableInteractionOnController;
  133572. private _onNewGamepadDisconnected;
  133573. private _enableInteractionOnController;
  133574. private _checkTeleportWithRay;
  133575. private _checkRotate;
  133576. private _checkTeleportBackwards;
  133577. private _enableTeleportationOnController;
  133578. private _createTeleportationCircles;
  133579. private _displayTeleportationTarget;
  133580. private _hideTeleportationTarget;
  133581. private _rotateCamera;
  133582. private _moveTeleportationSelectorTo;
  133583. private _workingVector;
  133584. private _workingQuaternion;
  133585. private _workingMatrix;
  133586. /**
  133587. * Time Constant Teleportation Mode
  133588. */
  133589. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133590. /**
  133591. * Speed Constant Teleportation Mode
  133592. */
  133593. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133594. /**
  133595. * Teleports the users feet to the desired location
  133596. * @param location The location where the user's feet should be placed
  133597. */
  133598. teleportCamera(location: Vector3): void;
  133599. private _convertNormalToDirectionOfRay;
  133600. private _castRayAndSelectObject;
  133601. private _notifySelectedMeshUnselected;
  133602. /**
  133603. * Permanently set new colors for the laser pointer
  133604. * @param color the new laser color
  133605. * @param pickedColor the new laser color when picked mesh detected
  133606. */
  133607. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133608. /**
  133609. * Set lighting enabled / disabled on the laser pointer of both controllers
  133610. * @param enabled should the lighting be enabled on the laser pointer
  133611. */
  133612. setLaserLightingState(enabled?: boolean): void;
  133613. /**
  133614. * Permanently set new colors for the gaze pointer
  133615. * @param color the new gaze color
  133616. * @param pickedColor the new gaze color when picked mesh detected
  133617. */
  133618. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133619. /**
  133620. * Sets the color of the laser ray from the vr controllers.
  133621. * @param color new color for the ray.
  133622. */
  133623. changeLaserColor(color: Color3): void;
  133624. /**
  133625. * Sets the color of the ray from the vr headsets gaze.
  133626. * @param color new color for the ray.
  133627. */
  133628. changeGazeColor(color: Color3): void;
  133629. /**
  133630. * Exits VR and disposes of the vr experience helper
  133631. */
  133632. dispose(): void;
  133633. /**
  133634. * Gets the name of the VRExperienceHelper class
  133635. * @returns "VRExperienceHelper"
  133636. */
  133637. getClassName(): string;
  133638. }
  133639. }
  133640. declare module BABYLON {
  133641. /**
  133642. * Contains an array of blocks representing the octree
  133643. */
  133644. export interface IOctreeContainer<T> {
  133645. /**
  133646. * Blocks within the octree
  133647. */
  133648. blocks: Array<OctreeBlock<T>>;
  133649. }
  133650. /**
  133651. * Class used to store a cell in an octree
  133652. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133653. */
  133654. export class OctreeBlock<T> {
  133655. /**
  133656. * Gets the content of the current block
  133657. */
  133658. entries: T[];
  133659. /**
  133660. * Gets the list of block children
  133661. */
  133662. blocks: Array<OctreeBlock<T>>;
  133663. private _depth;
  133664. private _maxDepth;
  133665. private _capacity;
  133666. private _minPoint;
  133667. private _maxPoint;
  133668. private _boundingVectors;
  133669. private _creationFunc;
  133670. /**
  133671. * Creates a new block
  133672. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  133673. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  133674. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133675. * @param depth defines the current depth of this block in the octree
  133676. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  133677. * @param creationFunc defines a callback to call when an element is added to the block
  133678. */
  133679. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  133680. /**
  133681. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133682. */
  133683. get capacity(): number;
  133684. /**
  133685. * Gets the minimum vector (in world space) of the block's bounding box
  133686. */
  133687. get minPoint(): Vector3;
  133688. /**
  133689. * Gets the maximum vector (in world space) of the block's bounding box
  133690. */
  133691. get maxPoint(): Vector3;
  133692. /**
  133693. * Add a new element to this block
  133694. * @param entry defines the element to add
  133695. */
  133696. addEntry(entry: T): void;
  133697. /**
  133698. * Remove an element from this block
  133699. * @param entry defines the element to remove
  133700. */
  133701. removeEntry(entry: T): void;
  133702. /**
  133703. * Add an array of elements to this block
  133704. * @param entries defines the array of elements to add
  133705. */
  133706. addEntries(entries: T[]): void;
  133707. /**
  133708. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  133709. * @param frustumPlanes defines the frustum planes to test
  133710. * @param selection defines the array to store current content if selection is positive
  133711. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133712. */
  133713. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133714. /**
  133715. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  133716. * @param sphereCenter defines the bounding sphere center
  133717. * @param sphereRadius defines the bounding sphere radius
  133718. * @param selection defines the array to store current content if selection is positive
  133719. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133720. */
  133721. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133722. /**
  133723. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  133724. * @param ray defines the ray to test with
  133725. * @param selection defines the array to store current content if selection is positive
  133726. */
  133727. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  133728. /**
  133729. * Subdivide the content into child blocks (this block will then be empty)
  133730. */
  133731. createInnerBlocks(): void;
  133732. /**
  133733. * @hidden
  133734. */
  133735. 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;
  133736. }
  133737. }
  133738. declare module BABYLON {
  133739. /**
  133740. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  133741. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133742. */
  133743. export class Octree<T> {
  133744. /** 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.) */
  133745. maxDepth: number;
  133746. /**
  133747. * Blocks within the octree containing objects
  133748. */
  133749. blocks: Array<OctreeBlock<T>>;
  133750. /**
  133751. * Content stored in the octree
  133752. */
  133753. dynamicContent: T[];
  133754. private _maxBlockCapacity;
  133755. private _selectionContent;
  133756. private _creationFunc;
  133757. /**
  133758. * Creates a octree
  133759. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133760. * @param creationFunc function to be used to instatiate the octree
  133761. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  133762. * @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.)
  133763. */
  133764. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  133765. /** 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.) */
  133766. maxDepth?: number);
  133767. /**
  133768. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  133769. * @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);
  133770. * @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);
  133771. * @param entries meshes to be added to the octree blocks
  133772. */
  133773. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  133774. /**
  133775. * Adds a mesh to the octree
  133776. * @param entry Mesh to add to the octree
  133777. */
  133778. addMesh(entry: T): void;
  133779. /**
  133780. * Remove an element from the octree
  133781. * @param entry defines the element to remove
  133782. */
  133783. removeMesh(entry: T): void;
  133784. /**
  133785. * Selects an array of meshes within the frustum
  133786. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  133787. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  133788. * @returns array of meshes within the frustum
  133789. */
  133790. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  133791. /**
  133792. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  133793. * @param sphereCenter defines the bounding sphere center
  133794. * @param sphereRadius defines the bounding sphere radius
  133795. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133796. * @returns an array of objects that intersect the sphere
  133797. */
  133798. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  133799. /**
  133800. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  133801. * @param ray defines the ray to test with
  133802. * @returns array of intersected objects
  133803. */
  133804. intersectsRay(ray: Ray): SmartArray<T>;
  133805. /**
  133806. * Adds a mesh into the octree block if it intersects the block
  133807. */
  133808. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  133809. /**
  133810. * Adds a submesh into the octree block if it intersects the block
  133811. */
  133812. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  133813. }
  133814. }
  133815. declare module BABYLON {
  133816. interface Scene {
  133817. /**
  133818. * @hidden
  133819. * Backing Filed
  133820. */
  133821. _selectionOctree: Octree<AbstractMesh>;
  133822. /**
  133823. * Gets the octree used to boost mesh selection (picking)
  133824. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133825. */
  133826. selectionOctree: Octree<AbstractMesh>;
  133827. /**
  133828. * Creates or updates the octree used to boost selection (picking)
  133829. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133830. * @param maxCapacity defines the maximum capacity per leaf
  133831. * @param maxDepth defines the maximum depth of the octree
  133832. * @returns an octree of AbstractMesh
  133833. */
  133834. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  133835. }
  133836. interface AbstractMesh {
  133837. /**
  133838. * @hidden
  133839. * Backing Field
  133840. */
  133841. _submeshesOctree: Octree<SubMesh>;
  133842. /**
  133843. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  133844. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  133845. * @param maxCapacity defines the maximum size of each block (64 by default)
  133846. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  133847. * @returns the new octree
  133848. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  133849. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133850. */
  133851. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  133852. }
  133853. /**
  133854. * Defines the octree scene component responsible to manage any octrees
  133855. * in a given scene.
  133856. */
  133857. export class OctreeSceneComponent {
  133858. /**
  133859. * The component name help to identify the component in the list of scene components.
  133860. */
  133861. readonly name: string;
  133862. /**
  133863. * The scene the component belongs to.
  133864. */
  133865. scene: Scene;
  133866. /**
  133867. * Indicates if the meshes have been checked to make sure they are isEnabled()
  133868. */
  133869. readonly checksIsEnabled: boolean;
  133870. /**
  133871. * Creates a new instance of the component for the given scene
  133872. * @param scene Defines the scene to register the component in
  133873. */
  133874. constructor(scene: Scene);
  133875. /**
  133876. * Registers the component in a given scene
  133877. */
  133878. register(): void;
  133879. /**
  133880. * Return the list of active meshes
  133881. * @returns the list of active meshes
  133882. */
  133883. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  133884. /**
  133885. * Return the list of active sub meshes
  133886. * @param mesh The mesh to get the candidates sub meshes from
  133887. * @returns the list of active sub meshes
  133888. */
  133889. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  133890. private _tempRay;
  133891. /**
  133892. * Return the list of sub meshes intersecting with a given local ray
  133893. * @param mesh defines the mesh to find the submesh for
  133894. * @param localRay defines the ray in local space
  133895. * @returns the list of intersecting sub meshes
  133896. */
  133897. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  133898. /**
  133899. * Return the list of sub meshes colliding with a collider
  133900. * @param mesh defines the mesh to find the submesh for
  133901. * @param collider defines the collider to evaluate the collision against
  133902. * @returns the list of colliding sub meshes
  133903. */
  133904. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  133905. /**
  133906. * Rebuilds the elements related to this component in case of
  133907. * context lost for instance.
  133908. */
  133909. rebuild(): void;
  133910. /**
  133911. * Disposes the component and the associated ressources.
  133912. */
  133913. dispose(): void;
  133914. }
  133915. }
  133916. declare module BABYLON {
  133917. /**
  133918. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  133919. */
  133920. export class Gizmo implements IDisposable {
  133921. /** The utility layer the gizmo will be added to */
  133922. gizmoLayer: UtilityLayerRenderer;
  133923. /**
  133924. * The root mesh of the gizmo
  133925. */
  133926. _rootMesh: Mesh;
  133927. private _attachedMesh;
  133928. private _attachedNode;
  133929. /**
  133930. * Ratio for the scale of the gizmo (Default: 1)
  133931. */
  133932. protected _scaleRatio: number;
  133933. /**
  133934. * boolean updated by pointermove when a gizmo mesh is hovered
  133935. */
  133936. protected _isHovered: boolean;
  133937. /**
  133938. * Ratio for the scale of the gizmo (Default: 1)
  133939. */
  133940. set scaleRatio(value: number);
  133941. get scaleRatio(): number;
  133942. /**
  133943. * True when the mouse pointer is hovered a gizmo mesh
  133944. */
  133945. get isHovered(): boolean;
  133946. /**
  133947. * If a custom mesh has been set (Default: false)
  133948. */
  133949. protected _customMeshSet: boolean;
  133950. /**
  133951. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  133952. * * When set, interactions will be enabled
  133953. */
  133954. get attachedMesh(): Nullable<AbstractMesh>;
  133955. set attachedMesh(value: Nullable<AbstractMesh>);
  133956. /**
  133957. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  133958. * * When set, interactions will be enabled
  133959. */
  133960. get attachedNode(): Nullable<Node>;
  133961. set attachedNode(value: Nullable<Node>);
  133962. /**
  133963. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133964. * @param mesh The mesh to replace the default mesh of the gizmo
  133965. */
  133966. setCustomMesh(mesh: Mesh): void;
  133967. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  133968. /**
  133969. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  133970. */
  133971. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133972. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133973. /**
  133974. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  133975. */
  133976. updateGizmoPositionToMatchAttachedMesh: boolean;
  133977. /**
  133978. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  133979. */
  133980. updateScale: boolean;
  133981. protected _interactionsEnabled: boolean;
  133982. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133983. private _beforeRenderObserver;
  133984. private _tempQuaternion;
  133985. private _tempVector;
  133986. private _tempVector2;
  133987. private _tempMatrix1;
  133988. private _tempMatrix2;
  133989. private _rightHandtoLeftHandMatrix;
  133990. /**
  133991. * Creates a gizmo
  133992. * @param gizmoLayer The utility layer the gizmo will be added to
  133993. */
  133994. constructor(
  133995. /** The utility layer the gizmo will be added to */
  133996. gizmoLayer?: UtilityLayerRenderer);
  133997. /**
  133998. * Updates the gizmo to match the attached mesh's position/rotation
  133999. */
  134000. protected _update(): void;
  134001. /**
  134002. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134003. * @param value Node, TransformNode or mesh
  134004. */
  134005. protected _matrixChanged(): void;
  134006. /**
  134007. * Disposes of the gizmo
  134008. */
  134009. dispose(): void;
  134010. }
  134011. }
  134012. declare module BABYLON {
  134013. /**
  134014. * Single plane drag gizmo
  134015. */
  134016. export class PlaneDragGizmo extends Gizmo {
  134017. /**
  134018. * Drag behavior responsible for the gizmos dragging interactions
  134019. */
  134020. dragBehavior: PointerDragBehavior;
  134021. private _pointerObserver;
  134022. /**
  134023. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134024. */
  134025. snapDistance: number;
  134026. /**
  134027. * Event that fires each time the gizmo snaps to a new location.
  134028. * * snapDistance is the the change in distance
  134029. */
  134030. onSnapObservable: Observable<{
  134031. snapDistance: number;
  134032. }>;
  134033. private _plane;
  134034. private _coloredMaterial;
  134035. private _hoverMaterial;
  134036. private _isEnabled;
  134037. private _parent;
  134038. /** @hidden */
  134039. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134040. /** @hidden */
  134041. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134042. /**
  134043. * Creates a PlaneDragGizmo
  134044. * @param gizmoLayer The utility layer the gizmo will be added to
  134045. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134046. * @param color The color of the gizmo
  134047. */
  134048. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134049. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134050. /**
  134051. * If the gizmo is enabled
  134052. */
  134053. set isEnabled(value: boolean);
  134054. get isEnabled(): boolean;
  134055. /**
  134056. * Disposes of the gizmo
  134057. */
  134058. dispose(): void;
  134059. }
  134060. }
  134061. declare module BABYLON {
  134062. /**
  134063. * Gizmo that enables dragging a mesh along 3 axis
  134064. */
  134065. export class PositionGizmo extends Gizmo {
  134066. /**
  134067. * Internal gizmo used for interactions on the x axis
  134068. */
  134069. xGizmo: AxisDragGizmo;
  134070. /**
  134071. * Internal gizmo used for interactions on the y axis
  134072. */
  134073. yGizmo: AxisDragGizmo;
  134074. /**
  134075. * Internal gizmo used for interactions on the z axis
  134076. */
  134077. zGizmo: AxisDragGizmo;
  134078. /**
  134079. * Internal gizmo used for interactions on the yz plane
  134080. */
  134081. xPlaneGizmo: PlaneDragGizmo;
  134082. /**
  134083. * Internal gizmo used for interactions on the xz plane
  134084. */
  134085. yPlaneGizmo: PlaneDragGizmo;
  134086. /**
  134087. * Internal gizmo used for interactions on the xy plane
  134088. */
  134089. zPlaneGizmo: PlaneDragGizmo;
  134090. /**
  134091. * private variables
  134092. */
  134093. private _meshAttached;
  134094. private _nodeAttached;
  134095. private _snapDistance;
  134096. /** Fires an event when any of it's sub gizmos are dragged */
  134097. onDragStartObservable: Observable<unknown>;
  134098. /** Fires an event when any of it's sub gizmos are released from dragging */
  134099. onDragEndObservable: Observable<unknown>;
  134100. /**
  134101. * If set to true, planar drag is enabled
  134102. */
  134103. private _planarGizmoEnabled;
  134104. get attachedMesh(): Nullable<AbstractMesh>;
  134105. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134106. get attachedNode(): Nullable<Node>;
  134107. set attachedNode(node: Nullable<Node>);
  134108. /**
  134109. * True when the mouse pointer is hovering a gizmo mesh
  134110. */
  134111. get isHovered(): boolean;
  134112. /**
  134113. * Creates a PositionGizmo
  134114. * @param gizmoLayer The utility layer the gizmo will be added to
  134115. @param thickness display gizmo axis thickness
  134116. */
  134117. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134118. /**
  134119. * If the planar drag gizmo is enabled
  134120. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134121. */
  134122. set planarGizmoEnabled(value: boolean);
  134123. get planarGizmoEnabled(): boolean;
  134124. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134125. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134126. /**
  134127. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134128. */
  134129. set snapDistance(value: number);
  134130. get snapDistance(): number;
  134131. /**
  134132. * Ratio for the scale of the gizmo (Default: 1)
  134133. */
  134134. set scaleRatio(value: number);
  134135. get scaleRatio(): number;
  134136. /**
  134137. * Disposes of the gizmo
  134138. */
  134139. dispose(): void;
  134140. /**
  134141. * CustomMeshes are not supported by this gizmo
  134142. * @param mesh The mesh to replace the default mesh of the gizmo
  134143. */
  134144. setCustomMesh(mesh: Mesh): void;
  134145. }
  134146. }
  134147. declare module BABYLON {
  134148. /**
  134149. * Single axis drag gizmo
  134150. */
  134151. export class AxisDragGizmo extends Gizmo {
  134152. /**
  134153. * Drag behavior responsible for the gizmos dragging interactions
  134154. */
  134155. dragBehavior: PointerDragBehavior;
  134156. private _pointerObserver;
  134157. /**
  134158. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134159. */
  134160. snapDistance: number;
  134161. /**
  134162. * Event that fires each time the gizmo snaps to a new location.
  134163. * * snapDistance is the the change in distance
  134164. */
  134165. onSnapObservable: Observable<{
  134166. snapDistance: number;
  134167. }>;
  134168. private _isEnabled;
  134169. private _parent;
  134170. private _arrow;
  134171. private _coloredMaterial;
  134172. private _hoverMaterial;
  134173. /** @hidden */
  134174. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134175. /** @hidden */
  134176. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134177. /**
  134178. * Creates an AxisDragGizmo
  134179. * @param gizmoLayer The utility layer the gizmo will be added to
  134180. * @param dragAxis The axis which the gizmo will be able to drag on
  134181. * @param color The color of the gizmo
  134182. * @param thickness display gizmo axis thickness
  134183. */
  134184. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134185. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134186. /**
  134187. * If the gizmo is enabled
  134188. */
  134189. set isEnabled(value: boolean);
  134190. get isEnabled(): boolean;
  134191. /**
  134192. * Disposes of the gizmo
  134193. */
  134194. dispose(): void;
  134195. }
  134196. }
  134197. declare module BABYLON.Debug {
  134198. /**
  134199. * The Axes viewer will show 3 axes in a specific point in space
  134200. */
  134201. export class AxesViewer {
  134202. private _xAxis;
  134203. private _yAxis;
  134204. private _zAxis;
  134205. private _scaleLinesFactor;
  134206. private _instanced;
  134207. /**
  134208. * Gets the hosting scene
  134209. */
  134210. scene: Nullable<Scene>;
  134211. /**
  134212. * Gets or sets a number used to scale line length
  134213. */
  134214. scaleLines: number;
  134215. /** Gets the node hierarchy used to render x-axis */
  134216. get xAxis(): TransformNode;
  134217. /** Gets the node hierarchy used to render y-axis */
  134218. get yAxis(): TransformNode;
  134219. /** Gets the node hierarchy used to render z-axis */
  134220. get zAxis(): TransformNode;
  134221. /**
  134222. * Creates a new AxesViewer
  134223. * @param scene defines the hosting scene
  134224. * @param scaleLines defines a number used to scale line length (1 by default)
  134225. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134226. * @param xAxis defines the node hierarchy used to render the x-axis
  134227. * @param yAxis defines the node hierarchy used to render the y-axis
  134228. * @param zAxis defines the node hierarchy used to render the z-axis
  134229. */
  134230. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134231. /**
  134232. * Force the viewer to update
  134233. * @param position defines the position of the viewer
  134234. * @param xaxis defines the x axis of the viewer
  134235. * @param yaxis defines the y axis of the viewer
  134236. * @param zaxis defines the z axis of the viewer
  134237. */
  134238. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134239. /**
  134240. * Creates an instance of this axes viewer.
  134241. * @returns a new axes viewer with instanced meshes
  134242. */
  134243. createInstance(): AxesViewer;
  134244. /** Releases resources */
  134245. dispose(): void;
  134246. private static _SetRenderingGroupId;
  134247. }
  134248. }
  134249. declare module BABYLON.Debug {
  134250. /**
  134251. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134252. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134253. */
  134254. export class BoneAxesViewer extends AxesViewer {
  134255. /**
  134256. * Gets or sets the target mesh where to display the axes viewer
  134257. */
  134258. mesh: Nullable<Mesh>;
  134259. /**
  134260. * Gets or sets the target bone where to display the axes viewer
  134261. */
  134262. bone: Nullable<Bone>;
  134263. /** Gets current position */
  134264. pos: Vector3;
  134265. /** Gets direction of X axis */
  134266. xaxis: Vector3;
  134267. /** Gets direction of Y axis */
  134268. yaxis: Vector3;
  134269. /** Gets direction of Z axis */
  134270. zaxis: Vector3;
  134271. /**
  134272. * Creates a new BoneAxesViewer
  134273. * @param scene defines the hosting scene
  134274. * @param bone defines the target bone
  134275. * @param mesh defines the target mesh
  134276. * @param scaleLines defines a scaling factor for line length (1 by default)
  134277. */
  134278. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134279. /**
  134280. * Force the viewer to update
  134281. */
  134282. update(): void;
  134283. /** Releases resources */
  134284. dispose(): void;
  134285. }
  134286. }
  134287. declare module BABYLON {
  134288. /**
  134289. * Interface used to define scene explorer extensibility option
  134290. */
  134291. export interface IExplorerExtensibilityOption {
  134292. /**
  134293. * Define the option label
  134294. */
  134295. label: string;
  134296. /**
  134297. * Defines the action to execute on click
  134298. */
  134299. action: (entity: any) => void;
  134300. }
  134301. /**
  134302. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134303. */
  134304. export interface IExplorerExtensibilityGroup {
  134305. /**
  134306. * Defines a predicate to test if a given type mut be extended
  134307. */
  134308. predicate: (entity: any) => boolean;
  134309. /**
  134310. * Gets the list of options added to a type
  134311. */
  134312. entries: IExplorerExtensibilityOption[];
  134313. }
  134314. /**
  134315. * Interface used to define the options to use to create the Inspector
  134316. */
  134317. export interface IInspectorOptions {
  134318. /**
  134319. * Display in overlay mode (default: false)
  134320. */
  134321. overlay?: boolean;
  134322. /**
  134323. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134324. */
  134325. globalRoot?: HTMLElement;
  134326. /**
  134327. * Display the Scene explorer
  134328. */
  134329. showExplorer?: boolean;
  134330. /**
  134331. * Display the property inspector
  134332. */
  134333. showInspector?: boolean;
  134334. /**
  134335. * Display in embed mode (both panes on the right)
  134336. */
  134337. embedMode?: boolean;
  134338. /**
  134339. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134340. */
  134341. handleResize?: boolean;
  134342. /**
  134343. * Allow the panes to popup (default: true)
  134344. */
  134345. enablePopup?: boolean;
  134346. /**
  134347. * Allow the panes to be closed by users (default: true)
  134348. */
  134349. enableClose?: boolean;
  134350. /**
  134351. * Optional list of extensibility entries
  134352. */
  134353. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134354. /**
  134355. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134356. */
  134357. inspectorURL?: string;
  134358. /**
  134359. * Optional initial tab (default to DebugLayerTab.Properties)
  134360. */
  134361. initialTab?: DebugLayerTab;
  134362. }
  134363. interface Scene {
  134364. /**
  134365. * @hidden
  134366. * Backing field
  134367. */
  134368. _debugLayer: DebugLayer;
  134369. /**
  134370. * Gets the debug layer (aka Inspector) associated with the scene
  134371. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134372. */
  134373. debugLayer: DebugLayer;
  134374. }
  134375. /**
  134376. * Enum of inspector action tab
  134377. */
  134378. export enum DebugLayerTab {
  134379. /**
  134380. * Properties tag (default)
  134381. */
  134382. Properties = 0,
  134383. /**
  134384. * Debug tab
  134385. */
  134386. Debug = 1,
  134387. /**
  134388. * Statistics tab
  134389. */
  134390. Statistics = 2,
  134391. /**
  134392. * Tools tab
  134393. */
  134394. Tools = 3,
  134395. /**
  134396. * Settings tab
  134397. */
  134398. Settings = 4
  134399. }
  134400. /**
  134401. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134402. * what is happening in your scene
  134403. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134404. */
  134405. export class DebugLayer {
  134406. /**
  134407. * Define the url to get the inspector script from.
  134408. * By default it uses the babylonjs CDN.
  134409. * @ignoreNaming
  134410. */
  134411. static InspectorURL: string;
  134412. private _scene;
  134413. private BJSINSPECTOR;
  134414. private _onPropertyChangedObservable?;
  134415. /**
  134416. * Observable triggered when a property is changed through the inspector.
  134417. */
  134418. get onPropertyChangedObservable(): any;
  134419. /**
  134420. * Instantiates a new debug layer.
  134421. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134422. * what is happening in your scene
  134423. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134424. * @param scene Defines the scene to inspect
  134425. */
  134426. constructor(scene: Scene);
  134427. /** Creates the inspector window. */
  134428. private _createInspector;
  134429. /**
  134430. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134431. * @param entity defines the entity to select
  134432. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134433. */
  134434. select(entity: any, lineContainerTitles?: string | string[]): void;
  134435. /** Get the inspector from bundle or global */
  134436. private _getGlobalInspector;
  134437. /**
  134438. * Get if the inspector is visible or not.
  134439. * @returns true if visible otherwise, false
  134440. */
  134441. isVisible(): boolean;
  134442. /**
  134443. * Hide the inspector and close its window.
  134444. */
  134445. hide(): void;
  134446. /**
  134447. * Update the scene in the inspector
  134448. */
  134449. setAsActiveScene(): void;
  134450. /**
  134451. * Launch the debugLayer.
  134452. * @param config Define the configuration of the inspector
  134453. * @return a promise fulfilled when the debug layer is visible
  134454. */
  134455. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134456. }
  134457. }
  134458. declare module BABYLON {
  134459. /**
  134460. * Class containing static functions to help procedurally build meshes
  134461. */
  134462. export class BoxBuilder {
  134463. /**
  134464. * Creates a box mesh
  134465. * * The parameter `size` sets the size (float) of each box side (default 1)
  134466. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134467. * * 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)
  134468. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134472. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134473. * @param name defines the name of the mesh
  134474. * @param options defines the options used to create the mesh
  134475. * @param scene defines the hosting scene
  134476. * @returns the box mesh
  134477. */
  134478. static CreateBox(name: string, options: {
  134479. size?: number;
  134480. width?: number;
  134481. height?: number;
  134482. depth?: number;
  134483. faceUV?: Vector4[];
  134484. faceColors?: Color4[];
  134485. sideOrientation?: number;
  134486. frontUVs?: Vector4;
  134487. backUVs?: Vector4;
  134488. wrap?: boolean;
  134489. topBaseAt?: number;
  134490. bottomBaseAt?: number;
  134491. updatable?: boolean;
  134492. }, scene?: Nullable<Scene>): Mesh;
  134493. }
  134494. }
  134495. declare module BABYLON.Debug {
  134496. /**
  134497. * Used to show the physics impostor around the specific mesh
  134498. */
  134499. export class PhysicsViewer {
  134500. /** @hidden */
  134501. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134502. /** @hidden */
  134503. protected _meshes: Array<Nullable<AbstractMesh>>;
  134504. /** @hidden */
  134505. protected _scene: Nullable<Scene>;
  134506. /** @hidden */
  134507. protected _numMeshes: number;
  134508. /** @hidden */
  134509. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134510. private _renderFunction;
  134511. private _utilityLayer;
  134512. private _debugBoxMesh;
  134513. private _debugSphereMesh;
  134514. private _debugCylinderMesh;
  134515. private _debugMaterial;
  134516. private _debugMeshMeshes;
  134517. /**
  134518. * Creates a new PhysicsViewer
  134519. * @param scene defines the hosting scene
  134520. */
  134521. constructor(scene: Scene);
  134522. /** @hidden */
  134523. protected _updateDebugMeshes(): void;
  134524. /**
  134525. * Renders a specified physic impostor
  134526. * @param impostor defines the impostor to render
  134527. * @param targetMesh defines the mesh represented by the impostor
  134528. * @returns the new debug mesh used to render the impostor
  134529. */
  134530. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134531. /**
  134532. * Hides a specified physic impostor
  134533. * @param impostor defines the impostor to hide
  134534. */
  134535. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134536. private _getDebugMaterial;
  134537. private _getDebugBoxMesh;
  134538. private _getDebugSphereMesh;
  134539. private _getDebugCylinderMesh;
  134540. private _getDebugMeshMesh;
  134541. private _getDebugMesh;
  134542. /** Releases all resources */
  134543. dispose(): void;
  134544. }
  134545. }
  134546. declare module BABYLON {
  134547. /**
  134548. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134549. * in order to better appreciate the issue one might have.
  134550. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134551. */
  134552. export class RayHelper {
  134553. /**
  134554. * Defines the ray we are currently tryin to visualize.
  134555. */
  134556. ray: Nullable<Ray>;
  134557. private _renderPoints;
  134558. private _renderLine;
  134559. private _renderFunction;
  134560. private _scene;
  134561. private _onAfterRenderObserver;
  134562. private _onAfterStepObserver;
  134563. private _attachedToMesh;
  134564. private _meshSpaceDirection;
  134565. private _meshSpaceOrigin;
  134566. /**
  134567. * Helper function to create a colored helper in a scene in one line.
  134568. * @param ray Defines the ray we are currently tryin to visualize
  134569. * @param scene Defines the scene the ray is used in
  134570. * @param color Defines the color we want to see the ray in
  134571. * @returns The newly created ray helper.
  134572. */
  134573. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134574. /**
  134575. * Instantiate a new ray helper.
  134576. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134577. * in order to better appreciate the issue one might have.
  134578. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134579. * @param ray Defines the ray we are currently tryin to visualize
  134580. */
  134581. constructor(ray: Ray);
  134582. /**
  134583. * Shows the ray we are willing to debug.
  134584. * @param scene Defines the scene the ray needs to be rendered in
  134585. * @param color Defines the color the ray needs to be rendered in
  134586. */
  134587. show(scene: Scene, color?: Color3): void;
  134588. /**
  134589. * Hides the ray we are debugging.
  134590. */
  134591. hide(): void;
  134592. private _render;
  134593. /**
  134594. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134595. * @param mesh Defines the mesh we want the helper attached to
  134596. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134597. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134598. * @param length Defines the length of the ray
  134599. */
  134600. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134601. /**
  134602. * Detach the ray helper from the mesh it has previously been attached to.
  134603. */
  134604. detachFromMesh(): void;
  134605. private _updateToMesh;
  134606. /**
  134607. * Dispose the helper and release its associated resources.
  134608. */
  134609. dispose(): void;
  134610. }
  134611. }
  134612. declare module BABYLON {
  134613. /**
  134614. * Defines the options associated with the creation of a SkeletonViewer.
  134615. */
  134616. export interface ISkeletonViewerOptions {
  134617. /** Should the system pause animations before building the Viewer? */
  134618. pauseAnimations: boolean;
  134619. /** Should the system return the skeleton to rest before building? */
  134620. returnToRest: boolean;
  134621. /** public Display Mode of the Viewer */
  134622. displayMode: number;
  134623. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134624. displayOptions: ISkeletonViewerDisplayOptions;
  134625. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134626. computeBonesUsingShaders: boolean;
  134627. /** Flag ignore non weighted bones */
  134628. useAllBones: boolean;
  134629. }
  134630. /**
  134631. * Defines how to display the various bone meshes for the viewer.
  134632. */
  134633. export interface ISkeletonViewerDisplayOptions {
  134634. /** How far down to start tapering the bone spurs */
  134635. midStep?: number;
  134636. /** How big is the midStep? */
  134637. midStepFactor?: number;
  134638. /** Base for the Sphere Size */
  134639. sphereBaseSize?: number;
  134640. /** The ratio of the sphere to the longest bone in units */
  134641. sphereScaleUnit?: number;
  134642. /** Ratio for the Sphere Size */
  134643. sphereFactor?: number;
  134644. /** Whether a spur should attach its far end to the child bone position */
  134645. spurFollowsChild?: boolean;
  134646. /** Whether to show local axes or not */
  134647. showLocalAxes?: boolean;
  134648. /** Length of each local axis */
  134649. localAxesSize?: number;
  134650. }
  134651. /**
  134652. * Defines the constructor options for the BoneWeight Shader.
  134653. */
  134654. export interface IBoneWeightShaderOptions {
  134655. /** Skeleton to Map */
  134656. skeleton: Skeleton;
  134657. /** Colors for Uninfluenced bones */
  134658. colorBase?: Color3;
  134659. /** Colors for 0.0-0.25 Weight bones */
  134660. colorZero?: Color3;
  134661. /** Color for 0.25-0.5 Weight Influence */
  134662. colorQuarter?: Color3;
  134663. /** Color for 0.5-0.75 Weight Influence */
  134664. colorHalf?: Color3;
  134665. /** Color for 0.75-1 Weight Influence */
  134666. colorFull?: Color3;
  134667. /** Color for Zero Weight Influence */
  134668. targetBoneIndex?: number;
  134669. }
  134670. /**
  134671. * Simple structure of the gradient steps for the Color Map.
  134672. */
  134673. export interface ISkeletonMapShaderColorMapKnot {
  134674. /** Color of the Knot */
  134675. color: Color3;
  134676. /** Location of the Knot */
  134677. location: number;
  134678. }
  134679. /**
  134680. * Defines the constructor options for the SkeletonMap Shader.
  134681. */
  134682. export interface ISkeletonMapShaderOptions {
  134683. /** Skeleton to Map */
  134684. skeleton: Skeleton;
  134685. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  134686. colorMap?: ISkeletonMapShaderColorMapKnot[];
  134687. }
  134688. }
  134689. declare module BABYLON {
  134690. /**
  134691. * Class containing static functions to help procedurally build meshes
  134692. */
  134693. export class RibbonBuilder {
  134694. /**
  134695. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134696. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134697. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134698. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134699. * * 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
  134700. * * 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
  134701. * * 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
  134702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134704. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134705. * * 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
  134706. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134707. * * 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
  134708. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134710. * @param name defines the name of the mesh
  134711. * @param options defines the options used to create the mesh
  134712. * @param scene defines the hosting scene
  134713. * @returns the ribbon mesh
  134714. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134716. */
  134717. static CreateRibbon(name: string, options: {
  134718. pathArray: Vector3[][];
  134719. closeArray?: boolean;
  134720. closePath?: boolean;
  134721. offset?: number;
  134722. updatable?: boolean;
  134723. sideOrientation?: number;
  134724. frontUVs?: Vector4;
  134725. backUVs?: Vector4;
  134726. instance?: Mesh;
  134727. invertUV?: boolean;
  134728. uvs?: Vector2[];
  134729. colors?: Color4[];
  134730. }, scene?: Nullable<Scene>): Mesh;
  134731. }
  134732. }
  134733. declare module BABYLON {
  134734. /**
  134735. * Class containing static functions to help procedurally build meshes
  134736. */
  134737. export class ShapeBuilder {
  134738. /**
  134739. * 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.
  134740. * * 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.
  134741. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134742. * * 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.
  134743. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134744. * * 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
  134745. * * 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
  134746. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134751. * @param name defines the name of the mesh
  134752. * @param options defines the options used to create the mesh
  134753. * @param scene defines the hosting scene
  134754. * @returns the extruded shape mesh
  134755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134757. */
  134758. static ExtrudeShape(name: string, options: {
  134759. shape: Vector3[];
  134760. path: Vector3[];
  134761. scale?: number;
  134762. rotation?: number;
  134763. cap?: number;
  134764. updatable?: boolean;
  134765. sideOrientation?: number;
  134766. frontUVs?: Vector4;
  134767. backUVs?: Vector4;
  134768. instance?: Mesh;
  134769. invertUV?: boolean;
  134770. }, scene?: Nullable<Scene>): Mesh;
  134771. /**
  134772. * Creates an custom extruded shape mesh.
  134773. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134774. * * 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.
  134775. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134776. * * 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
  134777. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134778. * * 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
  134779. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134780. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134781. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134782. * * 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
  134783. * * 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
  134784. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134789. * @param name defines the name of the mesh
  134790. * @param options defines the options used to create the mesh
  134791. * @param scene defines the hosting scene
  134792. * @returns the custom extruded shape mesh
  134793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134796. */
  134797. static ExtrudeShapeCustom(name: string, options: {
  134798. shape: Vector3[];
  134799. path: Vector3[];
  134800. scaleFunction?: any;
  134801. rotationFunction?: any;
  134802. ribbonCloseArray?: boolean;
  134803. ribbonClosePath?: boolean;
  134804. cap?: number;
  134805. updatable?: boolean;
  134806. sideOrientation?: number;
  134807. frontUVs?: Vector4;
  134808. backUVs?: Vector4;
  134809. instance?: Mesh;
  134810. invertUV?: boolean;
  134811. }, scene?: Nullable<Scene>): Mesh;
  134812. private static _ExtrudeShapeGeneric;
  134813. }
  134814. }
  134815. declare module BABYLON.Debug {
  134816. /**
  134817. * Class used to render a debug view of a given skeleton
  134818. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  134819. */
  134820. export class SkeletonViewer {
  134821. /** defines the skeleton to render */
  134822. skeleton: Skeleton;
  134823. /** defines the mesh attached to the skeleton */
  134824. mesh: AbstractMesh;
  134825. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134826. autoUpdateBonesMatrices: boolean;
  134827. /** defines the rendering group id to use with the viewer */
  134828. renderingGroupId: number;
  134829. /** is the options for the viewer */
  134830. options: Partial<ISkeletonViewerOptions>;
  134831. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  134832. static readonly DISPLAY_LINES: number;
  134833. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  134834. static readonly DISPLAY_SPHERES: number;
  134835. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  134836. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  134837. /** public static method to create a BoneWeight Shader
  134838. * @param options The constructor options
  134839. * @param scene The scene that the shader is scoped to
  134840. * @returns The created ShaderMaterial
  134841. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  134842. */
  134843. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  134844. /** public static method to create a BoneWeight Shader
  134845. * @param options The constructor options
  134846. * @param scene The scene that the shader is scoped to
  134847. * @returns The created ShaderMaterial
  134848. */
  134849. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  134850. /** private static method to create a BoneWeight Shader
  134851. * @param size The size of the buffer to create (usually the bone count)
  134852. * @param colorMap The gradient data to generate
  134853. * @param scene The scene that the shader is scoped to
  134854. * @returns an Array of floats from the color gradient values
  134855. */
  134856. private static _CreateBoneMapColorBuffer;
  134857. /** If SkeletonViewer scene scope. */
  134858. private _scene;
  134859. /** Gets or sets the color used to render the skeleton */
  134860. color: Color3;
  134861. /** Array of the points of the skeleton fo the line view. */
  134862. private _debugLines;
  134863. /** The SkeletonViewers Mesh. */
  134864. private _debugMesh;
  134865. /** The local axes Meshes. */
  134866. private _localAxes;
  134867. /** If SkeletonViewer is enabled. */
  134868. private _isEnabled;
  134869. /** If SkeletonViewer is ready. */
  134870. private _ready;
  134871. /** SkeletonViewer render observable. */
  134872. private _obs;
  134873. /** The Utility Layer to render the gizmos in. */
  134874. private _utilityLayer;
  134875. private _boneIndices;
  134876. /** Gets the Scene. */
  134877. get scene(): Scene;
  134878. /** Gets the utilityLayer. */
  134879. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  134880. /** Checks Ready Status. */
  134881. get isReady(): Boolean;
  134882. /** Sets Ready Status. */
  134883. set ready(value: boolean);
  134884. /** Gets the debugMesh */
  134885. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  134886. /** Sets the debugMesh */
  134887. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  134888. /** Gets the displayMode */
  134889. get displayMode(): number;
  134890. /** Sets the displayMode */
  134891. set displayMode(value: number);
  134892. /**
  134893. * Creates a new SkeletonViewer
  134894. * @param skeleton defines the skeleton to render
  134895. * @param mesh defines the mesh attached to the skeleton
  134896. * @param scene defines the hosting scene
  134897. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  134898. * @param renderingGroupId defines the rendering group id to use with the viewer
  134899. * @param options All of the extra constructor options for the SkeletonViewer
  134900. */
  134901. constructor(
  134902. /** defines the skeleton to render */
  134903. skeleton: Skeleton,
  134904. /** defines the mesh attached to the skeleton */
  134905. mesh: AbstractMesh,
  134906. /** The Scene scope*/
  134907. scene: Scene,
  134908. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134909. autoUpdateBonesMatrices?: boolean,
  134910. /** defines the rendering group id to use with the viewer */
  134911. renderingGroupId?: number,
  134912. /** is the options for the viewer */
  134913. options?: Partial<ISkeletonViewerOptions>);
  134914. /** The Dynamic bindings for the update functions */
  134915. private _bindObs;
  134916. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  134917. update(): void;
  134918. /** Gets or sets a boolean indicating if the viewer is enabled */
  134919. set isEnabled(value: boolean);
  134920. get isEnabled(): boolean;
  134921. private _getBonePosition;
  134922. private _getLinesForBonesWithLength;
  134923. private _getLinesForBonesNoLength;
  134924. /** function to revert the mesh and scene back to the initial state. */
  134925. private _revert;
  134926. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  134927. private _getAbsoluteBindPoseToRef;
  134928. /** function to build and bind sphere joint points and spur bone representations. */
  134929. private _buildSpheresAndSpurs;
  134930. private _buildLocalAxes;
  134931. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  134932. private _displayLinesUpdate;
  134933. /** Changes the displayMode of the skeleton viewer
  134934. * @param mode The displayMode numerical value
  134935. */
  134936. changeDisplayMode(mode: number): void;
  134937. /** Sets a display option of the skeleton viewer
  134938. *
  134939. * | Option | Type | Default | Description |
  134940. * | ---------------- | ------- | ------- | ----------- |
  134941. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  134942. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  134943. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  134944. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  134945. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  134946. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  134947. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  134948. *
  134949. * @param option String of the option name
  134950. * @param value The numerical option value
  134951. */
  134952. changeDisplayOptions(option: string, value: number): void;
  134953. /** Release associated resources */
  134954. dispose(): void;
  134955. }
  134956. }
  134957. declare module BABYLON {
  134958. /**
  134959. * Enum for Device Types
  134960. */
  134961. export enum DeviceType {
  134962. /** Generic */
  134963. Generic = 0,
  134964. /** Keyboard */
  134965. Keyboard = 1,
  134966. /** Mouse */
  134967. Mouse = 2,
  134968. /** Touch Pointers */
  134969. Touch = 3,
  134970. /** PS4 Dual Shock */
  134971. DualShock = 4,
  134972. /** Xbox */
  134973. Xbox = 5,
  134974. /** Switch Controller */
  134975. Switch = 6
  134976. }
  134977. /**
  134978. * Enum for All Pointers (Touch/Mouse)
  134979. */
  134980. export enum PointerInput {
  134981. /** Horizontal Axis */
  134982. Horizontal = 0,
  134983. /** Vertical Axis */
  134984. Vertical = 1,
  134985. /** Left Click or Touch */
  134986. LeftClick = 2,
  134987. /** Middle Click */
  134988. MiddleClick = 3,
  134989. /** Right Click */
  134990. RightClick = 4,
  134991. /** Browser Back */
  134992. BrowserBack = 5,
  134993. /** Browser Forward */
  134994. BrowserForward = 6
  134995. }
  134996. /**
  134997. * Enum for Dual Shock Gamepad
  134998. */
  134999. export enum DualShockInput {
  135000. /** Cross */
  135001. Cross = 0,
  135002. /** Circle */
  135003. Circle = 1,
  135004. /** Square */
  135005. Square = 2,
  135006. /** Triangle */
  135007. Triangle = 3,
  135008. /** L1 */
  135009. L1 = 4,
  135010. /** R1 */
  135011. R1 = 5,
  135012. /** L2 */
  135013. L2 = 6,
  135014. /** R2 */
  135015. R2 = 7,
  135016. /** Share */
  135017. Share = 8,
  135018. /** Options */
  135019. Options = 9,
  135020. /** L3 */
  135021. L3 = 10,
  135022. /** R3 */
  135023. R3 = 11,
  135024. /** DPadUp */
  135025. DPadUp = 12,
  135026. /** DPadDown */
  135027. DPadDown = 13,
  135028. /** DPadLeft */
  135029. DPadLeft = 14,
  135030. /** DRight */
  135031. DPadRight = 15,
  135032. /** Home */
  135033. Home = 16,
  135034. /** TouchPad */
  135035. TouchPad = 17,
  135036. /** LStickXAxis */
  135037. LStickXAxis = 18,
  135038. /** LStickYAxis */
  135039. LStickYAxis = 19,
  135040. /** RStickXAxis */
  135041. RStickXAxis = 20,
  135042. /** RStickYAxis */
  135043. RStickYAxis = 21
  135044. }
  135045. /**
  135046. * Enum for Xbox Gamepad
  135047. */
  135048. export enum XboxInput {
  135049. /** A */
  135050. A = 0,
  135051. /** B */
  135052. B = 1,
  135053. /** X */
  135054. X = 2,
  135055. /** Y */
  135056. Y = 3,
  135057. /** LB */
  135058. LB = 4,
  135059. /** RB */
  135060. RB = 5,
  135061. /** LT */
  135062. LT = 6,
  135063. /** RT */
  135064. RT = 7,
  135065. /** Back */
  135066. Back = 8,
  135067. /** Start */
  135068. Start = 9,
  135069. /** LS */
  135070. LS = 10,
  135071. /** RS */
  135072. RS = 11,
  135073. /** DPadUp */
  135074. DPadUp = 12,
  135075. /** DPadDown */
  135076. DPadDown = 13,
  135077. /** DPadLeft */
  135078. DPadLeft = 14,
  135079. /** DRight */
  135080. DPadRight = 15,
  135081. /** Home */
  135082. Home = 16,
  135083. /** LStickXAxis */
  135084. LStickXAxis = 17,
  135085. /** LStickYAxis */
  135086. LStickYAxis = 18,
  135087. /** RStickXAxis */
  135088. RStickXAxis = 19,
  135089. /** RStickYAxis */
  135090. RStickYAxis = 20
  135091. }
  135092. /**
  135093. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135094. */
  135095. export enum SwitchInput {
  135096. /** B */
  135097. B = 0,
  135098. /** A */
  135099. A = 1,
  135100. /** Y */
  135101. Y = 2,
  135102. /** X */
  135103. X = 3,
  135104. /** L */
  135105. L = 4,
  135106. /** R */
  135107. R = 5,
  135108. /** ZL */
  135109. ZL = 6,
  135110. /** ZR */
  135111. ZR = 7,
  135112. /** Minus */
  135113. Minus = 8,
  135114. /** Plus */
  135115. Plus = 9,
  135116. /** LS */
  135117. LS = 10,
  135118. /** RS */
  135119. RS = 11,
  135120. /** DPadUp */
  135121. DPadUp = 12,
  135122. /** DPadDown */
  135123. DPadDown = 13,
  135124. /** DPadLeft */
  135125. DPadLeft = 14,
  135126. /** DRight */
  135127. DPadRight = 15,
  135128. /** Home */
  135129. Home = 16,
  135130. /** Capture */
  135131. Capture = 17,
  135132. /** LStickXAxis */
  135133. LStickXAxis = 18,
  135134. /** LStickYAxis */
  135135. LStickYAxis = 19,
  135136. /** RStickXAxis */
  135137. RStickXAxis = 20,
  135138. /** RStickYAxis */
  135139. RStickYAxis = 21
  135140. }
  135141. }
  135142. declare module BABYLON {
  135143. /**
  135144. * This class will take all inputs from Keyboard, Pointer, and
  135145. * any Gamepads and provide a polling system that all devices
  135146. * will use. This class assumes that there will only be one
  135147. * pointer device and one keyboard.
  135148. */
  135149. export class DeviceInputSystem implements IDisposable {
  135150. /**
  135151. * Callback to be triggered when a device is connected
  135152. */
  135153. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135154. /**
  135155. * Callback to be triggered when a device is disconnected
  135156. */
  135157. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135158. /**
  135159. * Callback to be triggered when event driven input is updated
  135160. */
  135161. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135162. private _inputs;
  135163. private _gamepads;
  135164. private _keyboardActive;
  135165. private _pointerActive;
  135166. private _elementToAttachTo;
  135167. private _keyboardDownEvent;
  135168. private _keyboardUpEvent;
  135169. private _pointerMoveEvent;
  135170. private _pointerDownEvent;
  135171. private _pointerUpEvent;
  135172. private _gamepadConnectedEvent;
  135173. private _gamepadDisconnectedEvent;
  135174. private static _MAX_KEYCODES;
  135175. private static _MAX_POINTER_INPUTS;
  135176. private constructor();
  135177. /**
  135178. * Creates a new DeviceInputSystem instance
  135179. * @param engine Engine to pull input element from
  135180. * @returns The new instance
  135181. */
  135182. static Create(engine: Engine): DeviceInputSystem;
  135183. /**
  135184. * Checks for current device input value, given an id and input index
  135185. * @param deviceName Id of connected device
  135186. * @param inputIndex Index of device input
  135187. * @returns Current value of input
  135188. */
  135189. /**
  135190. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135191. * @param deviceType Enum specifiying device type
  135192. * @param deviceSlot "Slot" or index that device is referenced in
  135193. * @param inputIndex Id of input to be checked
  135194. * @returns Current value of input
  135195. */
  135196. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135197. /**
  135198. * Dispose of all the eventlisteners
  135199. */
  135200. dispose(): void;
  135201. /**
  135202. * Add device and inputs to device array
  135203. * @param deviceType Enum specifiying device type
  135204. * @param deviceSlot "Slot" or index that device is referenced in
  135205. * @param numberOfInputs Number of input entries to create for given device
  135206. */
  135207. private _registerDevice;
  135208. /**
  135209. * Given a specific device name, remove that device from the device map
  135210. * @param deviceType Enum specifiying device type
  135211. * @param deviceSlot "Slot" or index that device is referenced in
  135212. */
  135213. private _unregisterDevice;
  135214. /**
  135215. * Handle all actions that come from keyboard interaction
  135216. */
  135217. private _handleKeyActions;
  135218. /**
  135219. * Handle all actions that come from pointer interaction
  135220. */
  135221. private _handlePointerActions;
  135222. /**
  135223. * Handle all actions that come from gamepad interaction
  135224. */
  135225. private _handleGamepadActions;
  135226. /**
  135227. * Update all non-event based devices with each frame
  135228. * @param deviceType Enum specifiying device type
  135229. * @param deviceSlot "Slot" or index that device is referenced in
  135230. * @param inputIndex Id of input to be checked
  135231. */
  135232. private _updateDevice;
  135233. /**
  135234. * Gets DeviceType from the device name
  135235. * @param deviceName Name of Device from DeviceInputSystem
  135236. * @returns DeviceType enum value
  135237. */
  135238. private _getGamepadDeviceType;
  135239. }
  135240. }
  135241. declare module BABYLON {
  135242. /**
  135243. * Type to handle enforcement of inputs
  135244. */
  135245. 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;
  135246. }
  135247. declare module BABYLON {
  135248. /**
  135249. * Class that handles all input for a specific device
  135250. */
  135251. export class DeviceSource<T extends DeviceType> {
  135252. /** Type of device */
  135253. readonly deviceType: DeviceType;
  135254. /** "Slot" or index that device is referenced in */
  135255. readonly deviceSlot: number;
  135256. /**
  135257. * Observable to handle device input changes per device
  135258. */
  135259. readonly onInputChangedObservable: Observable<{
  135260. inputIndex: DeviceInput<T>;
  135261. previousState: Nullable<number>;
  135262. currentState: Nullable<number>;
  135263. }>;
  135264. private readonly _deviceInputSystem;
  135265. /**
  135266. * Default Constructor
  135267. * @param deviceInputSystem Reference to DeviceInputSystem
  135268. * @param deviceType Type of device
  135269. * @param deviceSlot "Slot" or index that device is referenced in
  135270. */
  135271. constructor(deviceInputSystem: DeviceInputSystem,
  135272. /** Type of device */
  135273. deviceType: DeviceType,
  135274. /** "Slot" or index that device is referenced in */
  135275. deviceSlot?: number);
  135276. /**
  135277. * Get input for specific input
  135278. * @param inputIndex index of specific input on device
  135279. * @returns Input value from DeviceInputSystem
  135280. */
  135281. getInput(inputIndex: DeviceInput<T>): number;
  135282. }
  135283. /**
  135284. * Class to keep track of devices
  135285. */
  135286. export class DeviceSourceManager implements IDisposable {
  135287. /**
  135288. * Observable to be triggered when before a device is connected
  135289. */
  135290. readonly onBeforeDeviceConnectedObservable: Observable<{
  135291. deviceType: DeviceType;
  135292. deviceSlot: number;
  135293. }>;
  135294. /**
  135295. * Observable to be triggered when before a device is disconnected
  135296. */
  135297. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135298. deviceType: DeviceType;
  135299. deviceSlot: number;
  135300. }>;
  135301. /**
  135302. * Observable to be triggered when after a device is connected
  135303. */
  135304. readonly onAfterDeviceConnectedObservable: Observable<{
  135305. deviceType: DeviceType;
  135306. deviceSlot: number;
  135307. }>;
  135308. /**
  135309. * Observable to be triggered when after a device is disconnected
  135310. */
  135311. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135312. deviceType: DeviceType;
  135313. deviceSlot: number;
  135314. }>;
  135315. private readonly _devices;
  135316. private readonly _firstDevice;
  135317. private readonly _deviceInputSystem;
  135318. /**
  135319. * Default Constructor
  135320. * @param engine engine to pull input element from
  135321. */
  135322. constructor(engine: Engine);
  135323. /**
  135324. * Gets a DeviceSource, given a type and slot
  135325. * @param deviceType Enum specifying device type
  135326. * @param deviceSlot "Slot" or index that device is referenced in
  135327. * @returns DeviceSource object
  135328. */
  135329. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135330. /**
  135331. * Gets an array of DeviceSource objects for a given device type
  135332. * @param deviceType Enum specifying device type
  135333. * @returns Array of DeviceSource objects
  135334. */
  135335. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135336. /**
  135337. * Dispose of DeviceInputSystem and other parts
  135338. */
  135339. dispose(): void;
  135340. /**
  135341. * Function to add device name to device list
  135342. * @param deviceType Enum specifying device type
  135343. * @param deviceSlot "Slot" or index that device is referenced in
  135344. */
  135345. private _addDevice;
  135346. /**
  135347. * Function to remove device name to device list
  135348. * @param deviceType Enum specifying device type
  135349. * @param deviceSlot "Slot" or index that device is referenced in
  135350. */
  135351. private _removeDevice;
  135352. /**
  135353. * Updates array storing first connected device of each type
  135354. * @param type Type of Device
  135355. */
  135356. private _updateFirstDevices;
  135357. }
  135358. }
  135359. declare module BABYLON {
  135360. /**
  135361. * Options to create the null engine
  135362. */
  135363. export class NullEngineOptions {
  135364. /**
  135365. * Render width (Default: 512)
  135366. */
  135367. renderWidth: number;
  135368. /**
  135369. * Render height (Default: 256)
  135370. */
  135371. renderHeight: number;
  135372. /**
  135373. * Texture size (Default: 512)
  135374. */
  135375. textureSize: number;
  135376. /**
  135377. * If delta time between frames should be constant
  135378. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135379. */
  135380. deterministicLockstep: boolean;
  135381. /**
  135382. * Maximum about of steps between frames (Default: 4)
  135383. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135384. */
  135385. lockstepMaxSteps: number;
  135386. /**
  135387. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135388. */
  135389. useHighPrecisionMatrix?: boolean;
  135390. }
  135391. /**
  135392. * The null engine class provides support for headless version of babylon.js.
  135393. * This can be used in server side scenario or for testing purposes
  135394. */
  135395. export class NullEngine extends Engine {
  135396. private _options;
  135397. /**
  135398. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135399. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135400. * @returns true if engine is in deterministic lock step mode
  135401. */
  135402. isDeterministicLockStep(): boolean;
  135403. /**
  135404. * Gets the max steps when engine is running in deterministic lock step
  135405. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135406. * @returns the max steps
  135407. */
  135408. getLockstepMaxSteps(): number;
  135409. /**
  135410. * Gets the current hardware scaling level.
  135411. * By default the hardware scaling level is computed from the window device ratio.
  135412. * 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.
  135413. * @returns a number indicating the current hardware scaling level
  135414. */
  135415. getHardwareScalingLevel(): number;
  135416. constructor(options?: NullEngineOptions);
  135417. /**
  135418. * Creates a vertex buffer
  135419. * @param vertices the data for the vertex buffer
  135420. * @returns the new WebGL static buffer
  135421. */
  135422. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135423. /**
  135424. * Creates a new index buffer
  135425. * @param indices defines the content of the index buffer
  135426. * @param updatable defines if the index buffer must be updatable
  135427. * @returns a new webGL buffer
  135428. */
  135429. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135430. /**
  135431. * Clear the current render buffer or the current render target (if any is set up)
  135432. * @param color defines the color to use
  135433. * @param backBuffer defines if the back buffer must be cleared
  135434. * @param depth defines if the depth buffer must be cleared
  135435. * @param stencil defines if the stencil buffer must be cleared
  135436. */
  135437. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135438. /**
  135439. * Gets the current render width
  135440. * @param useScreen defines if screen size must be used (or the current render target if any)
  135441. * @returns a number defining the current render width
  135442. */
  135443. getRenderWidth(useScreen?: boolean): number;
  135444. /**
  135445. * Gets the current render height
  135446. * @param useScreen defines if screen size must be used (or the current render target if any)
  135447. * @returns a number defining the current render height
  135448. */
  135449. getRenderHeight(useScreen?: boolean): number;
  135450. /**
  135451. * Set the WebGL's viewport
  135452. * @param viewport defines the viewport element to be used
  135453. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135454. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135455. */
  135456. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135457. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135458. /**
  135459. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135460. * @param pipelineContext defines the pipeline context to use
  135461. * @param uniformsNames defines the list of uniform names
  135462. * @returns an array of webGL uniform locations
  135463. */
  135464. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135465. /**
  135466. * Gets the lsit of active attributes for a given webGL program
  135467. * @param pipelineContext defines the pipeline context to use
  135468. * @param attributesNames defines the list of attribute names to get
  135469. * @returns an array of indices indicating the offset of each attribute
  135470. */
  135471. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135472. /**
  135473. * Binds an effect to the webGL context
  135474. * @param effect defines the effect to bind
  135475. */
  135476. bindSamplers(effect: Effect): void;
  135477. /**
  135478. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135479. * @param effect defines the effect to activate
  135480. */
  135481. enableEffect(effect: Effect): void;
  135482. /**
  135483. * Set various states to the webGL context
  135484. * @param culling defines backface culling state
  135485. * @param zOffset defines the value to apply to zOffset (0 by default)
  135486. * @param force defines if states must be applied even if cache is up to date
  135487. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135488. */
  135489. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135490. /**
  135491. * Set the value of an uniform to an array of int32
  135492. * @param uniform defines the webGL uniform location where to store the value
  135493. * @param array defines the array of int32 to store
  135494. * @returns true if value was set
  135495. */
  135496. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135497. /**
  135498. * Set the value of an uniform to an array of int32 (stored as vec2)
  135499. * @param uniform defines the webGL uniform location where to store the value
  135500. * @param array defines the array of int32 to store
  135501. * @returns true if value was set
  135502. */
  135503. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135504. /**
  135505. * Set the value of an uniform to an array of int32 (stored as vec3)
  135506. * @param uniform defines the webGL uniform location where to store the value
  135507. * @param array defines the array of int32 to store
  135508. * @returns true if value was set
  135509. */
  135510. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135511. /**
  135512. * Set the value of an uniform to an array of int32 (stored as vec4)
  135513. * @param uniform defines the webGL uniform location where to store the value
  135514. * @param array defines the array of int32 to store
  135515. * @returns true if value was set
  135516. */
  135517. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135518. /**
  135519. * Set the value of an uniform to an array of float32
  135520. * @param uniform defines the webGL uniform location where to store the value
  135521. * @param array defines the array of float32 to store
  135522. * @returns true if value was set
  135523. */
  135524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135525. /**
  135526. * Set the value of an uniform to an array of float32 (stored as vec2)
  135527. * @param uniform defines the webGL uniform location where to store the value
  135528. * @param array defines the array of float32 to store
  135529. * @returns true if value was set
  135530. */
  135531. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135532. /**
  135533. * Set the value of an uniform to an array of float32 (stored as vec3)
  135534. * @param uniform defines the webGL uniform location where to store the value
  135535. * @param array defines the array of float32 to store
  135536. * @returns true if value was set
  135537. */
  135538. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135539. /**
  135540. * Set the value of an uniform to an array of float32 (stored as vec4)
  135541. * @param uniform defines the webGL uniform location where to store the value
  135542. * @param array defines the array of float32 to store
  135543. * @returns true if value was set
  135544. */
  135545. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135546. /**
  135547. * Set the value of an uniform to an array of number
  135548. * @param uniform defines the webGL uniform location where to store the value
  135549. * @param array defines the array of number to store
  135550. * @returns true if value was set
  135551. */
  135552. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135553. /**
  135554. * Set the value of an uniform to an array of number (stored as vec2)
  135555. * @param uniform defines the webGL uniform location where to store the value
  135556. * @param array defines the array of number to store
  135557. * @returns true if value was set
  135558. */
  135559. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135560. /**
  135561. * Set the value of an uniform to an array of number (stored as vec3)
  135562. * @param uniform defines the webGL uniform location where to store the value
  135563. * @param array defines the array of number to store
  135564. * @returns true if value was set
  135565. */
  135566. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135567. /**
  135568. * Set the value of an uniform to an array of number (stored as vec4)
  135569. * @param uniform defines the webGL uniform location where to store the value
  135570. * @param array defines the array of number to store
  135571. * @returns true if value was set
  135572. */
  135573. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135574. /**
  135575. * Set the value of an uniform to an array of float32 (stored as matrices)
  135576. * @param uniform defines the webGL uniform location where to store the value
  135577. * @param matrices defines the array of float32 to store
  135578. * @returns true if value was set
  135579. */
  135580. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135581. /**
  135582. * Set the value of an uniform to a matrix (3x3)
  135583. * @param uniform defines the webGL uniform location where to store the value
  135584. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135585. * @returns true if value was set
  135586. */
  135587. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135588. /**
  135589. * Set the value of an uniform to a matrix (2x2)
  135590. * @param uniform defines the webGL uniform location where to store the value
  135591. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135592. * @returns true if value was set
  135593. */
  135594. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135595. /**
  135596. * Set the value of an uniform to a number (float)
  135597. * @param uniform defines the webGL uniform location where to store the value
  135598. * @param value defines the float number to store
  135599. * @returns true if value was set
  135600. */
  135601. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135602. /**
  135603. * Set the value of an uniform to a vec2
  135604. * @param uniform defines the webGL uniform location where to store the value
  135605. * @param x defines the 1st component of the value
  135606. * @param y defines the 2nd component of the value
  135607. * @returns true if value was set
  135608. */
  135609. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135610. /**
  135611. * Set the value of an uniform to a vec3
  135612. * @param uniform defines the webGL uniform location where to store the value
  135613. * @param x defines the 1st component of the value
  135614. * @param y defines the 2nd component of the value
  135615. * @param z defines the 3rd component of the value
  135616. * @returns true if value was set
  135617. */
  135618. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135619. /**
  135620. * Set the value of an uniform to a boolean
  135621. * @param uniform defines the webGL uniform location where to store the value
  135622. * @param bool defines the boolean to store
  135623. * @returns true if value was set
  135624. */
  135625. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135626. /**
  135627. * Set the value of an uniform to a vec4
  135628. * @param uniform defines the webGL uniform location where to store the value
  135629. * @param x defines the 1st component of the value
  135630. * @param y defines the 2nd component of the value
  135631. * @param z defines the 3rd component of the value
  135632. * @param w defines the 4th component of the value
  135633. * @returns true if value was set
  135634. */
  135635. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135636. /**
  135637. * Sets the current alpha mode
  135638. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135639. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135640. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135641. */
  135642. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135643. /**
  135644. * Bind webGl buffers directly to the webGL context
  135645. * @param vertexBuffers defines the vertex buffer to bind
  135646. * @param indexBuffer defines the index buffer to bind
  135647. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135648. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135649. * @param effect defines the effect associated with the vertex buffer
  135650. */
  135651. bindBuffers(vertexBuffers: {
  135652. [key: string]: VertexBuffer;
  135653. }, indexBuffer: DataBuffer, effect: Effect): void;
  135654. /**
  135655. * Force the entire cache to be cleared
  135656. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  135657. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  135658. */
  135659. wipeCaches(bruteForce?: boolean): void;
  135660. /**
  135661. * Send a draw order
  135662. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  135663. * @param indexStart defines the starting index
  135664. * @param indexCount defines the number of index to draw
  135665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135666. */
  135667. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  135668. /**
  135669. * Draw a list of indexed primitives
  135670. * @param fillMode defines the primitive to use
  135671. * @param indexStart defines the starting index
  135672. * @param indexCount defines the number of index to draw
  135673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135674. */
  135675. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  135676. /**
  135677. * Draw a list of unindexed primitives
  135678. * @param fillMode defines the primitive to use
  135679. * @param verticesStart defines the index of first vertex to draw
  135680. * @param verticesCount defines the count of vertices to draw
  135681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135682. */
  135683. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  135684. /** @hidden */
  135685. _createTexture(): WebGLTexture;
  135686. /** @hidden */
  135687. _releaseTexture(texture: InternalTexture): void;
  135688. /**
  135689. * Usually called from Texture.ts.
  135690. * Passed information to create a WebGLTexture
  135691. * @param urlArg defines a value which contains one of the following:
  135692. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  135693. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  135694. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  135695. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  135696. * @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)
  135697. * @param scene needed for loading to the correct scene
  135698. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  135699. * @param onLoad optional callback to be called upon successful completion
  135700. * @param onError optional callback to be called upon failure
  135701. * @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
  135702. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  135703. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  135704. * @param forcedExtension defines the extension to use to pick the right loader
  135705. * @param mimeType defines an optional mime type
  135706. * @returns a InternalTexture for assignment back into BABYLON.Texture
  135707. */
  135708. 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;
  135709. /**
  135710. * Creates a new render target texture
  135711. * @param size defines the size of the texture
  135712. * @param options defines the options used to create the texture
  135713. * @returns a new render target texture stored in an InternalTexture
  135714. */
  135715. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  135716. /**
  135717. * Update the sampling mode of a given texture
  135718. * @param samplingMode defines the required sampling mode
  135719. * @param texture defines the texture to update
  135720. */
  135721. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  135722. /**
  135723. * Binds the frame buffer to the specified texture.
  135724. * @param texture The texture to render to or null for the default canvas
  135725. * @param faceIndex The face of the texture to render to in case of cube texture
  135726. * @param requiredWidth The width of the target to render to
  135727. * @param requiredHeight The height of the target to render to
  135728. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  135729. * @param lodLevel defines le lod level to bind to the frame buffer
  135730. */
  135731. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  135732. /**
  135733. * Unbind the current render target texture from the webGL context
  135734. * @param texture defines the render target texture to unbind
  135735. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  135736. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  135737. */
  135738. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  135739. /**
  135740. * Creates a dynamic vertex buffer
  135741. * @param vertices the data for the dynamic vertex buffer
  135742. * @returns the new WebGL dynamic buffer
  135743. */
  135744. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  135745. /**
  135746. * Update the content of a dynamic texture
  135747. * @param texture defines the texture to update
  135748. * @param canvas defines the canvas containing the source
  135749. * @param invertY defines if data must be stored with Y axis inverted
  135750. * @param premulAlpha defines if alpha is stored as premultiplied
  135751. * @param format defines the format of the data
  135752. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  135753. */
  135754. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  135755. /**
  135756. * Gets a boolean indicating if all created effects are ready
  135757. * @returns true if all effects are ready
  135758. */
  135759. areAllEffectsReady(): boolean;
  135760. /**
  135761. * @hidden
  135762. * Get the current error code of the webGL context
  135763. * @returns the error code
  135764. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  135765. */
  135766. getError(): number;
  135767. /** @hidden */
  135768. _getUnpackAlignement(): number;
  135769. /** @hidden */
  135770. _unpackFlipY(value: boolean): void;
  135771. /**
  135772. * Update a dynamic index buffer
  135773. * @param indexBuffer defines the target index buffer
  135774. * @param indices defines the data to update
  135775. * @param offset defines the offset in the target index buffer where update should start
  135776. */
  135777. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  135778. /**
  135779. * Updates a dynamic vertex buffer.
  135780. * @param vertexBuffer the vertex buffer to update
  135781. * @param vertices the data used to update the vertex buffer
  135782. * @param byteOffset the byte offset of the data (optional)
  135783. * @param byteLength the byte length of the data (optional)
  135784. */
  135785. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  135786. /** @hidden */
  135787. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  135788. /** @hidden */
  135789. _bindTexture(channel: number, texture: InternalTexture): void;
  135790. protected _deleteBuffer(buffer: WebGLBuffer): void;
  135791. /**
  135792. * 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
  135793. */
  135794. releaseEffects(): void;
  135795. displayLoadingUI(): void;
  135796. hideLoadingUI(): void;
  135797. /** @hidden */
  135798. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135799. /** @hidden */
  135800. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135801. /** @hidden */
  135802. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135803. /** @hidden */
  135804. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  135805. }
  135806. }
  135807. declare module BABYLON {
  135808. /**
  135809. * @hidden
  135810. **/
  135811. export class _TimeToken {
  135812. _startTimeQuery: Nullable<WebGLQuery>;
  135813. _endTimeQuery: Nullable<WebGLQuery>;
  135814. _timeElapsedQuery: Nullable<WebGLQuery>;
  135815. _timeElapsedQueryEnded: boolean;
  135816. }
  135817. }
  135818. declare module BABYLON {
  135819. /** @hidden */
  135820. export class _OcclusionDataStorage {
  135821. /** @hidden */
  135822. occlusionInternalRetryCounter: number;
  135823. /** @hidden */
  135824. isOcclusionQueryInProgress: boolean;
  135825. /** @hidden */
  135826. isOccluded: boolean;
  135827. /** @hidden */
  135828. occlusionRetryCount: number;
  135829. /** @hidden */
  135830. occlusionType: number;
  135831. /** @hidden */
  135832. occlusionQueryAlgorithmType: number;
  135833. }
  135834. interface Engine {
  135835. /**
  135836. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  135837. * @return the new query
  135838. */
  135839. createQuery(): WebGLQuery;
  135840. /**
  135841. * Delete and release a webGL query
  135842. * @param query defines the query to delete
  135843. * @return the current engine
  135844. */
  135845. deleteQuery(query: WebGLQuery): Engine;
  135846. /**
  135847. * Check if a given query has resolved and got its value
  135848. * @param query defines the query to check
  135849. * @returns true if the query got its value
  135850. */
  135851. isQueryResultAvailable(query: WebGLQuery): boolean;
  135852. /**
  135853. * Gets the value of a given query
  135854. * @param query defines the query to check
  135855. * @returns the value of the query
  135856. */
  135857. getQueryResult(query: WebGLQuery): number;
  135858. /**
  135859. * Initiates an occlusion query
  135860. * @param algorithmType defines the algorithm to use
  135861. * @param query defines the query to use
  135862. * @returns the current engine
  135863. * @see https://doc.babylonjs.com/features/occlusionquery
  135864. */
  135865. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  135866. /**
  135867. * Ends an occlusion query
  135868. * @see https://doc.babylonjs.com/features/occlusionquery
  135869. * @param algorithmType defines the algorithm to use
  135870. * @returns the current engine
  135871. */
  135872. endOcclusionQuery(algorithmType: number): Engine;
  135873. /**
  135874. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  135875. * Please note that only one query can be issued at a time
  135876. * @returns a time token used to track the time span
  135877. */
  135878. startTimeQuery(): Nullable<_TimeToken>;
  135879. /**
  135880. * Ends a time query
  135881. * @param token defines the token used to measure the time span
  135882. * @returns the time spent (in ns)
  135883. */
  135884. endTimeQuery(token: _TimeToken): int;
  135885. /** @hidden */
  135886. _currentNonTimestampToken: Nullable<_TimeToken>;
  135887. /** @hidden */
  135888. _createTimeQuery(): WebGLQuery;
  135889. /** @hidden */
  135890. _deleteTimeQuery(query: WebGLQuery): void;
  135891. /** @hidden */
  135892. _getGlAlgorithmType(algorithmType: number): number;
  135893. /** @hidden */
  135894. _getTimeQueryResult(query: WebGLQuery): any;
  135895. /** @hidden */
  135896. _getTimeQueryAvailability(query: WebGLQuery): any;
  135897. }
  135898. interface AbstractMesh {
  135899. /**
  135900. * Backing filed
  135901. * @hidden
  135902. */
  135903. __occlusionDataStorage: _OcclusionDataStorage;
  135904. /**
  135905. * Access property
  135906. * @hidden
  135907. */
  135908. _occlusionDataStorage: _OcclusionDataStorage;
  135909. /**
  135910. * 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.
  135911. * The default value is -1 which means don't break the query and wait till the result
  135912. * @see https://doc.babylonjs.com/features/occlusionquery
  135913. */
  135914. occlusionRetryCount: number;
  135915. /**
  135916. * 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:
  135917. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  135918. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  135919. * * 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.
  135920. * @see https://doc.babylonjs.com/features/occlusionquery
  135921. */
  135922. occlusionType: number;
  135923. /**
  135924. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  135925. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  135926. * * 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.
  135927. * @see https://doc.babylonjs.com/features/occlusionquery
  135928. */
  135929. occlusionQueryAlgorithmType: number;
  135930. /**
  135931. * 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
  135932. * @see https://doc.babylonjs.com/features/occlusionquery
  135933. */
  135934. isOccluded: boolean;
  135935. /**
  135936. * Flag to check the progress status of the query
  135937. * @see https://doc.babylonjs.com/features/occlusionquery
  135938. */
  135939. isOcclusionQueryInProgress: boolean;
  135940. }
  135941. }
  135942. declare module BABYLON {
  135943. /** @hidden */
  135944. export var _forceTransformFeedbackToBundle: boolean;
  135945. interface Engine {
  135946. /**
  135947. * Creates a webGL transform feedback object
  135948. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  135949. * @returns the webGL transform feedback object
  135950. */
  135951. createTransformFeedback(): WebGLTransformFeedback;
  135952. /**
  135953. * Delete a webGL transform feedback object
  135954. * @param value defines the webGL transform feedback object to delete
  135955. */
  135956. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  135957. /**
  135958. * Bind a webGL transform feedback object to the webgl context
  135959. * @param value defines the webGL transform feedback object to bind
  135960. */
  135961. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  135962. /**
  135963. * Begins a transform feedback operation
  135964. * @param usePoints defines if points or triangles must be used
  135965. */
  135966. beginTransformFeedback(usePoints: boolean): void;
  135967. /**
  135968. * Ends a transform feedback operation
  135969. */
  135970. endTransformFeedback(): void;
  135971. /**
  135972. * Specify the varyings to use with transform feedback
  135973. * @param program defines the associated webGL program
  135974. * @param value defines the list of strings representing the varying names
  135975. */
  135976. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  135977. /**
  135978. * Bind a webGL buffer for a transform feedback operation
  135979. * @param value defines the webGL buffer to bind
  135980. */
  135981. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  135982. }
  135983. }
  135984. declare module BABYLON {
  135985. /**
  135986. * Class used to define an additional view for the engine
  135987. * @see https://doc.babylonjs.com/how_to/multi_canvases
  135988. */
  135989. export class EngineView {
  135990. /** Defines the canvas where to render the view */
  135991. target: HTMLCanvasElement;
  135992. /** Defines an optional camera used to render the view (will use active camera else) */
  135993. camera?: Camera;
  135994. }
  135995. interface Engine {
  135996. /**
  135997. * Gets or sets the HTML element to use for attaching events
  135998. */
  135999. inputElement: Nullable<HTMLElement>;
  136000. /**
  136001. * Gets the current engine view
  136002. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136003. */
  136004. activeView: Nullable<EngineView>;
  136005. /** Gets or sets the list of views */
  136006. views: EngineView[];
  136007. /**
  136008. * Register a new child canvas
  136009. * @param canvas defines the canvas to register
  136010. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136011. * @returns the associated view
  136012. */
  136013. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136014. /**
  136015. * Remove a registered child canvas
  136016. * @param canvas defines the canvas to remove
  136017. * @returns the current engine
  136018. */
  136019. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136020. }
  136021. }
  136022. declare module BABYLON {
  136023. interface Engine {
  136024. /** @hidden */
  136025. _excludedCompressedTextures: string[];
  136026. /** @hidden */
  136027. _textureFormatInUse: string;
  136028. /**
  136029. * Gets the list of texture formats supported
  136030. */
  136031. readonly texturesSupported: Array<string>;
  136032. /**
  136033. * Gets the texture format in use
  136034. */
  136035. readonly textureFormatInUse: Nullable<string>;
  136036. /**
  136037. * Set the compressed texture extensions or file names to skip.
  136038. *
  136039. * @param skippedFiles defines the list of those texture files you want to skip
  136040. * Example: [".dds", ".env", "myfile.png"]
  136041. */
  136042. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136043. /**
  136044. * Set the compressed texture format to use, based on the formats you have, and the formats
  136045. * supported by the hardware / browser.
  136046. *
  136047. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136048. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136049. * to API arguments needed to compressed textures. This puts the burden on the container
  136050. * generator to house the arcane code for determining these for current & future formats.
  136051. *
  136052. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136053. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136054. *
  136055. * Note: The result of this call is not taken into account when a texture is base64.
  136056. *
  136057. * @param formatsAvailable defines the list of those format families you have created
  136058. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136059. *
  136060. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136061. * @returns The extension selected.
  136062. */
  136063. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136064. }
  136065. }
  136066. declare module BABYLON {
  136067. /** @hidden */
  136068. export var rgbdEncodePixelShader: {
  136069. name: string;
  136070. shader: string;
  136071. };
  136072. }
  136073. declare module BABYLON {
  136074. /**
  136075. * Raw texture data and descriptor sufficient for WebGL texture upload
  136076. */
  136077. export interface EnvironmentTextureInfo {
  136078. /**
  136079. * Version of the environment map
  136080. */
  136081. version: number;
  136082. /**
  136083. * Width of image
  136084. */
  136085. width: number;
  136086. /**
  136087. * Irradiance information stored in the file.
  136088. */
  136089. irradiance: any;
  136090. /**
  136091. * Specular information stored in the file.
  136092. */
  136093. specular: any;
  136094. }
  136095. /**
  136096. * Defines One Image in the file. It requires only the position in the file
  136097. * as well as the length.
  136098. */
  136099. interface BufferImageData {
  136100. /**
  136101. * Length of the image data.
  136102. */
  136103. length: number;
  136104. /**
  136105. * Position of the data from the null terminator delimiting the end of the JSON.
  136106. */
  136107. position: number;
  136108. }
  136109. /**
  136110. * Defines the specular data enclosed in the file.
  136111. * This corresponds to the version 1 of the data.
  136112. */
  136113. export interface EnvironmentTextureSpecularInfoV1 {
  136114. /**
  136115. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136116. */
  136117. specularDataPosition?: number;
  136118. /**
  136119. * This contains all the images data needed to reconstruct the cubemap.
  136120. */
  136121. mipmaps: Array<BufferImageData>;
  136122. /**
  136123. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136124. */
  136125. lodGenerationScale: number;
  136126. }
  136127. /**
  136128. * Sets of helpers addressing the serialization and deserialization of environment texture
  136129. * stored in a BabylonJS env file.
  136130. * Those files are usually stored as .env files.
  136131. */
  136132. export class EnvironmentTextureTools {
  136133. /**
  136134. * Magic number identifying the env file.
  136135. */
  136136. private static _MagicBytes;
  136137. /**
  136138. * Gets the environment info from an env file.
  136139. * @param data The array buffer containing the .env bytes.
  136140. * @returns the environment file info (the json header) if successfully parsed.
  136141. */
  136142. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136143. /**
  136144. * Creates an environment texture from a loaded cube texture.
  136145. * @param texture defines the cube texture to convert in env file
  136146. * @return a promise containing the environment data if succesfull.
  136147. */
  136148. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136149. /**
  136150. * Creates a JSON representation of the spherical data.
  136151. * @param texture defines the texture containing the polynomials
  136152. * @return the JSON representation of the spherical info
  136153. */
  136154. private static _CreateEnvTextureIrradiance;
  136155. /**
  136156. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136157. * @param data the image data
  136158. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136159. * @return the views described by info providing access to the underlying buffer
  136160. */
  136161. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136162. /**
  136163. * Uploads the texture info contained in the env file to the GPU.
  136164. * @param texture defines the internal texture to upload to
  136165. * @param data defines the data to load
  136166. * @param info defines the texture info retrieved through the GetEnvInfo method
  136167. * @returns a promise
  136168. */
  136169. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136170. private static _OnImageReadyAsync;
  136171. /**
  136172. * Uploads the levels of image data to the GPU.
  136173. * @param texture defines the internal texture to upload to
  136174. * @param imageData defines the array buffer views of image data [mipmap][face]
  136175. * @returns a promise
  136176. */
  136177. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136178. /**
  136179. * Uploads spherical polynomials information to the texture.
  136180. * @param texture defines the texture we are trying to upload the information to
  136181. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136182. */
  136183. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136184. /** @hidden */
  136185. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136186. }
  136187. }
  136188. declare module BABYLON {
  136189. /**
  136190. * Class used to inline functions in shader code
  136191. */
  136192. export class ShaderCodeInliner {
  136193. private static readonly _RegexpFindFunctionNameAndType;
  136194. private _sourceCode;
  136195. private _functionDescr;
  136196. private _numMaxIterations;
  136197. /** Gets or sets the token used to mark the functions to inline */
  136198. inlineToken: string;
  136199. /** Gets or sets the debug mode */
  136200. debug: boolean;
  136201. /** Gets the code after the inlining process */
  136202. get code(): string;
  136203. /**
  136204. * Initializes the inliner
  136205. * @param sourceCode shader code source to inline
  136206. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136207. */
  136208. constructor(sourceCode: string, numMaxIterations?: number);
  136209. /**
  136210. * Start the processing of the shader code
  136211. */
  136212. processCode(): void;
  136213. private _collectFunctions;
  136214. private _processInlining;
  136215. private _extractBetweenMarkers;
  136216. private _skipWhitespaces;
  136217. private _removeComments;
  136218. private _replaceFunctionCallsByCode;
  136219. private _findBackward;
  136220. private _escapeRegExp;
  136221. private _replaceNames;
  136222. }
  136223. }
  136224. declare module BABYLON {
  136225. /**
  136226. * Container for accessors for natively-stored mesh data buffers.
  136227. */
  136228. class NativeDataBuffer extends DataBuffer {
  136229. /**
  136230. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136231. */
  136232. nativeIndexBuffer?: any;
  136233. /**
  136234. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136235. */
  136236. nativeVertexBuffer?: any;
  136237. }
  136238. /** @hidden */
  136239. class NativeTexture extends InternalTexture {
  136240. getInternalTexture(): InternalTexture;
  136241. getViewCount(): number;
  136242. }
  136243. /** @hidden */
  136244. export class NativeEngine extends Engine {
  136245. private readonly _native;
  136246. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136247. private readonly INVALID_HANDLE;
  136248. private _boundBuffersVertexArray;
  136249. private _currentDepthTest;
  136250. getHardwareScalingLevel(): number;
  136251. constructor();
  136252. dispose(): void;
  136253. /**
  136254. * Can be used to override the current requestAnimationFrame requester.
  136255. * @hidden
  136256. */
  136257. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136258. /**
  136259. * Override default engine behavior.
  136260. * @param color
  136261. * @param backBuffer
  136262. * @param depth
  136263. * @param stencil
  136264. */
  136265. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136266. /**
  136267. * Gets host document
  136268. * @returns the host document object
  136269. */
  136270. getHostDocument(): Nullable<Document>;
  136271. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136272. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136273. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136274. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136275. [key: string]: VertexBuffer;
  136276. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136277. bindBuffers(vertexBuffers: {
  136278. [key: string]: VertexBuffer;
  136279. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136280. recordVertexArrayObject(vertexBuffers: {
  136281. [key: string]: VertexBuffer;
  136282. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136283. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136284. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136285. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136286. /**
  136287. * Draw a list of indexed primitives
  136288. * @param fillMode defines the primitive to use
  136289. * @param indexStart defines the starting index
  136290. * @param indexCount defines the number of index to draw
  136291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136292. */
  136293. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136294. /**
  136295. * Draw a list of unindexed primitives
  136296. * @param fillMode defines the primitive to use
  136297. * @param verticesStart defines the index of first vertex to draw
  136298. * @param verticesCount defines the count of vertices to draw
  136299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136300. */
  136301. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136302. createPipelineContext(): IPipelineContext;
  136303. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136304. /** @hidden */
  136305. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136306. /** @hidden */
  136307. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136308. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136309. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136310. protected _setProgram(program: WebGLProgram): void;
  136311. _releaseEffect(effect: Effect): void;
  136312. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136313. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136314. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136315. bindSamplers(effect: Effect): void;
  136316. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136317. getRenderWidth(useScreen?: boolean): number;
  136318. getRenderHeight(useScreen?: boolean): number;
  136319. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136320. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136321. /**
  136322. * Set the z offset to apply to current rendering
  136323. * @param value defines the offset to apply
  136324. */
  136325. setZOffset(value: number): void;
  136326. /**
  136327. * Gets the current value of the zOffset
  136328. * @returns the current zOffset state
  136329. */
  136330. getZOffset(): number;
  136331. /**
  136332. * Enable or disable depth buffering
  136333. * @param enable defines the state to set
  136334. */
  136335. setDepthBuffer(enable: boolean): void;
  136336. /**
  136337. * Gets a boolean indicating if depth writing is enabled
  136338. * @returns the current depth writing state
  136339. */
  136340. getDepthWrite(): boolean;
  136341. setDepthFunctionToGreater(): void;
  136342. setDepthFunctionToGreaterOrEqual(): void;
  136343. setDepthFunctionToLess(): void;
  136344. setDepthFunctionToLessOrEqual(): void;
  136345. /**
  136346. * Enable or disable depth writing
  136347. * @param enable defines the state to set
  136348. */
  136349. setDepthWrite(enable: boolean): void;
  136350. /**
  136351. * Enable or disable color writing
  136352. * @param enable defines the state to set
  136353. */
  136354. setColorWrite(enable: boolean): void;
  136355. /**
  136356. * Gets a boolean indicating if color writing is enabled
  136357. * @returns the current color writing state
  136358. */
  136359. getColorWrite(): boolean;
  136360. /**
  136361. * Sets alpha constants used by some alpha blending modes
  136362. * @param r defines the red component
  136363. * @param g defines the green component
  136364. * @param b defines the blue component
  136365. * @param a defines the alpha component
  136366. */
  136367. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136368. /**
  136369. * Sets the current alpha mode
  136370. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136371. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136372. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136373. */
  136374. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136375. /**
  136376. * Gets the current alpha mode
  136377. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136378. * @returns the current alpha mode
  136379. */
  136380. getAlphaMode(): number;
  136381. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136382. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136383. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136384. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136385. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136386. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136387. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136388. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136389. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136390. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136391. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136392. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136393. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136394. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136395. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136396. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136397. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136398. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136399. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136400. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136401. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136402. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136403. wipeCaches(bruteForce?: boolean): void;
  136404. _createTexture(): WebGLTexture;
  136405. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136406. /**
  136407. * Update the content of a dynamic texture
  136408. * @param texture defines the texture to update
  136409. * @param canvas defines the canvas containing the source
  136410. * @param invertY defines if data must be stored with Y axis inverted
  136411. * @param premulAlpha defines if alpha is stored as premultiplied
  136412. * @param format defines the format of the data
  136413. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136414. */
  136415. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136416. /**
  136417. * Usually called from Texture.ts.
  136418. * Passed information to create a WebGLTexture
  136419. * @param url defines a value which contains one of the following:
  136420. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136421. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136422. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136424. * @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)
  136425. * @param scene needed for loading to the correct scene
  136426. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136427. * @param onLoad optional callback to be called upon successful completion
  136428. * @param onError optional callback to be called upon failure
  136429. * @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
  136430. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136431. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136432. * @param forcedExtension defines the extension to use to pick the right loader
  136433. * @param mimeType defines an optional mime type
  136434. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136435. */
  136436. 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;
  136437. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136438. _releaseFramebufferObjects(texture: InternalTexture): void;
  136439. /**
  136440. * Creates a cube texture
  136441. * @param rootUrl defines the url where the files to load is located
  136442. * @param scene defines the current scene
  136443. * @param files defines the list of files to load (1 per face)
  136444. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136445. * @param onLoad defines an optional callback raised when the texture is loaded
  136446. * @param onError defines an optional callback raised if there is an issue to load the texture
  136447. * @param format defines the format of the data
  136448. * @param forcedExtension defines the extension to use to pick the right loader
  136449. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136450. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136451. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136452. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136453. * @returns the cube texture as an InternalTexture
  136454. */
  136455. 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;
  136456. createRenderTargetTexture(size: number | {
  136457. width: number;
  136458. height: number;
  136459. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136461. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136462. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136463. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136464. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136465. /**
  136466. * Updates a dynamic vertex buffer.
  136467. * @param vertexBuffer the vertex buffer to update
  136468. * @param data the data used to update the vertex buffer
  136469. * @param byteOffset the byte offset of the data (optional)
  136470. * @param byteLength the byte length of the data (optional)
  136471. */
  136472. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136473. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136474. private _updateAnisotropicLevel;
  136475. private _getAddressMode;
  136476. /** @hidden */
  136477. _bindTexture(channel: number, texture: InternalTexture): void;
  136478. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136479. releaseEffects(): void;
  136480. /** @hidden */
  136481. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136482. /** @hidden */
  136483. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136484. /** @hidden */
  136485. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136486. /** @hidden */
  136487. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136488. private _getNativeSamplingMode;
  136489. private _getNativeTextureFormat;
  136490. private _getNativeAlphaMode;
  136491. private _getNativeAttribType;
  136492. }
  136493. }
  136494. declare module BABYLON {
  136495. /**
  136496. * Gather the list of clipboard event types as constants.
  136497. */
  136498. export class ClipboardEventTypes {
  136499. /**
  136500. * The clipboard event is fired when a copy command is active (pressed).
  136501. */
  136502. static readonly COPY: number;
  136503. /**
  136504. * The clipboard event is fired when a cut command is active (pressed).
  136505. */
  136506. static readonly CUT: number;
  136507. /**
  136508. * The clipboard event is fired when a paste command is active (pressed).
  136509. */
  136510. static readonly PASTE: number;
  136511. }
  136512. /**
  136513. * This class is used to store clipboard related info for the onClipboardObservable event.
  136514. */
  136515. export class ClipboardInfo {
  136516. /**
  136517. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136518. */
  136519. type: number;
  136520. /**
  136521. * Defines the related dom event
  136522. */
  136523. event: ClipboardEvent;
  136524. /**
  136525. *Creates an instance of ClipboardInfo.
  136526. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136527. * @param event Defines the related dom event
  136528. */
  136529. constructor(
  136530. /**
  136531. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136532. */
  136533. type: number,
  136534. /**
  136535. * Defines the related dom event
  136536. */
  136537. event: ClipboardEvent);
  136538. /**
  136539. * Get the clipboard event's type from the keycode.
  136540. * @param keyCode Defines the keyCode for the current keyboard event.
  136541. * @return {number}
  136542. */
  136543. static GetTypeFromCharacter(keyCode: number): number;
  136544. }
  136545. }
  136546. declare module BABYLON {
  136547. /**
  136548. * Google Daydream controller
  136549. */
  136550. export class DaydreamController extends WebVRController {
  136551. /**
  136552. * Base Url for the controller model.
  136553. */
  136554. static MODEL_BASE_URL: string;
  136555. /**
  136556. * File name for the controller model.
  136557. */
  136558. static MODEL_FILENAME: string;
  136559. /**
  136560. * Gamepad Id prefix used to identify Daydream Controller.
  136561. */
  136562. static readonly GAMEPAD_ID_PREFIX: string;
  136563. /**
  136564. * Creates a new DaydreamController from a gamepad
  136565. * @param vrGamepad the gamepad that the controller should be created from
  136566. */
  136567. constructor(vrGamepad: any);
  136568. /**
  136569. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136570. * @param scene scene in which to add meshes
  136571. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136572. */
  136573. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136574. /**
  136575. * Called once for each button that changed state since the last frame
  136576. * @param buttonIdx Which button index changed
  136577. * @param state New state of the button
  136578. * @param changes Which properties on the state changed since last frame
  136579. */
  136580. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136581. }
  136582. }
  136583. declare module BABYLON {
  136584. /**
  136585. * Gear VR Controller
  136586. */
  136587. export class GearVRController extends WebVRController {
  136588. /**
  136589. * Base Url for the controller model.
  136590. */
  136591. static MODEL_BASE_URL: string;
  136592. /**
  136593. * File name for the controller model.
  136594. */
  136595. static MODEL_FILENAME: string;
  136596. /**
  136597. * Gamepad Id prefix used to identify this controller.
  136598. */
  136599. static readonly GAMEPAD_ID_PREFIX: string;
  136600. private readonly _buttonIndexToObservableNameMap;
  136601. /**
  136602. * Creates a new GearVRController from a gamepad
  136603. * @param vrGamepad the gamepad that the controller should be created from
  136604. */
  136605. constructor(vrGamepad: any);
  136606. /**
  136607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136608. * @param scene scene in which to add meshes
  136609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136610. */
  136611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136612. /**
  136613. * Called once for each button that changed state since the last frame
  136614. * @param buttonIdx Which button index changed
  136615. * @param state New state of the button
  136616. * @param changes Which properties on the state changed since last frame
  136617. */
  136618. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136619. }
  136620. }
  136621. declare module BABYLON {
  136622. /**
  136623. * Generic Controller
  136624. */
  136625. export class GenericController extends WebVRController {
  136626. /**
  136627. * Base Url for the controller model.
  136628. */
  136629. static readonly MODEL_BASE_URL: string;
  136630. /**
  136631. * File name for the controller model.
  136632. */
  136633. static readonly MODEL_FILENAME: string;
  136634. /**
  136635. * Creates a new GenericController from a gamepad
  136636. * @param vrGamepad the gamepad that the controller should be created from
  136637. */
  136638. constructor(vrGamepad: any);
  136639. /**
  136640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136641. * @param scene scene in which to add meshes
  136642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136643. */
  136644. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136645. /**
  136646. * Called once for each button that changed state since the last frame
  136647. * @param buttonIdx Which button index changed
  136648. * @param state New state of the button
  136649. * @param changes Which properties on the state changed since last frame
  136650. */
  136651. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136652. }
  136653. }
  136654. declare module BABYLON {
  136655. /**
  136656. * Oculus Touch Controller
  136657. */
  136658. export class OculusTouchController extends WebVRController {
  136659. /**
  136660. * Base Url for the controller model.
  136661. */
  136662. static MODEL_BASE_URL: string;
  136663. /**
  136664. * File name for the left controller model.
  136665. */
  136666. static MODEL_LEFT_FILENAME: string;
  136667. /**
  136668. * File name for the right controller model.
  136669. */
  136670. static MODEL_RIGHT_FILENAME: string;
  136671. /**
  136672. * Base Url for the Quest controller model.
  136673. */
  136674. static QUEST_MODEL_BASE_URL: string;
  136675. /**
  136676. * @hidden
  136677. * If the controllers are running on a device that needs the updated Quest controller models
  136678. */
  136679. static _IsQuest: boolean;
  136680. /**
  136681. * Fired when the secondary trigger on this controller is modified
  136682. */
  136683. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  136684. /**
  136685. * Fired when the thumb rest on this controller is modified
  136686. */
  136687. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  136688. /**
  136689. * Creates a new OculusTouchController from a gamepad
  136690. * @param vrGamepad the gamepad that the controller should be created from
  136691. */
  136692. constructor(vrGamepad: any);
  136693. /**
  136694. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136695. * @param scene scene in which to add meshes
  136696. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136697. */
  136698. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136699. /**
  136700. * Fired when the A button on this controller is modified
  136701. */
  136702. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136703. /**
  136704. * Fired when the B button on this controller is modified
  136705. */
  136706. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136707. /**
  136708. * Fired when the X button on this controller is modified
  136709. */
  136710. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136711. /**
  136712. * Fired when the Y button on this controller is modified
  136713. */
  136714. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136715. /**
  136716. * Called once for each button that changed state since the last frame
  136717. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  136718. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  136719. * 2) secondary trigger (same)
  136720. * 3) A (right) X (left), touch, pressed = value
  136721. * 4) B / Y
  136722. * 5) thumb rest
  136723. * @param buttonIdx Which button index changed
  136724. * @param state New state of the button
  136725. * @param changes Which properties on the state changed since last frame
  136726. */
  136727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136728. }
  136729. }
  136730. declare module BABYLON {
  136731. /**
  136732. * Vive Controller
  136733. */
  136734. export class ViveController extends WebVRController {
  136735. /**
  136736. * Base Url for the controller model.
  136737. */
  136738. static MODEL_BASE_URL: string;
  136739. /**
  136740. * File name for the controller model.
  136741. */
  136742. static MODEL_FILENAME: string;
  136743. /**
  136744. * Creates a new ViveController from a gamepad
  136745. * @param vrGamepad the gamepad that the controller should be created from
  136746. */
  136747. constructor(vrGamepad: any);
  136748. /**
  136749. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136750. * @param scene scene in which to add meshes
  136751. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136752. */
  136753. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136754. /**
  136755. * Fired when the left button on this controller is modified
  136756. */
  136757. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136758. /**
  136759. * Fired when the right button on this controller is modified
  136760. */
  136761. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136762. /**
  136763. * Fired when the menu button on this controller is modified
  136764. */
  136765. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136766. /**
  136767. * Called once for each button that changed state since the last frame
  136768. * Vive mapping:
  136769. * 0: touchpad
  136770. * 1: trigger
  136771. * 2: left AND right buttons
  136772. * 3: menu button
  136773. * @param buttonIdx Which button index changed
  136774. * @param state New state of the button
  136775. * @param changes Which properties on the state changed since last frame
  136776. */
  136777. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136778. }
  136779. }
  136780. declare module BABYLON {
  136781. /**
  136782. * Defines the WindowsMotionController object that the state of the windows motion controller
  136783. */
  136784. export class WindowsMotionController extends WebVRController {
  136785. /**
  136786. * The base url used to load the left and right controller models
  136787. */
  136788. static MODEL_BASE_URL: string;
  136789. /**
  136790. * The name of the left controller model file
  136791. */
  136792. static MODEL_LEFT_FILENAME: string;
  136793. /**
  136794. * The name of the right controller model file
  136795. */
  136796. static MODEL_RIGHT_FILENAME: string;
  136797. /**
  136798. * The controller name prefix for this controller type
  136799. */
  136800. static readonly GAMEPAD_ID_PREFIX: string;
  136801. /**
  136802. * The controller id pattern for this controller type
  136803. */
  136804. private static readonly GAMEPAD_ID_PATTERN;
  136805. private _loadedMeshInfo;
  136806. protected readonly _mapping: {
  136807. buttons: string[];
  136808. buttonMeshNames: {
  136809. trigger: string;
  136810. menu: string;
  136811. grip: string;
  136812. thumbstick: string;
  136813. trackpad: string;
  136814. };
  136815. buttonObservableNames: {
  136816. trigger: string;
  136817. menu: string;
  136818. grip: string;
  136819. thumbstick: string;
  136820. trackpad: string;
  136821. };
  136822. axisMeshNames: string[];
  136823. pointingPoseMeshName: string;
  136824. };
  136825. /**
  136826. * Fired when the trackpad on this controller is clicked
  136827. */
  136828. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136829. /**
  136830. * Fired when the trackpad on this controller is modified
  136831. */
  136832. onTrackpadValuesChangedObservable: Observable<StickValues>;
  136833. /**
  136834. * The current x and y values of this controller's trackpad
  136835. */
  136836. trackpad: StickValues;
  136837. /**
  136838. * Creates a new WindowsMotionController from a gamepad
  136839. * @param vrGamepad the gamepad that the controller should be created from
  136840. */
  136841. constructor(vrGamepad: any);
  136842. /**
  136843. * Fired when the trigger on this controller is modified
  136844. */
  136845. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136846. /**
  136847. * Fired when the menu button on this controller is modified
  136848. */
  136849. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136850. /**
  136851. * Fired when the grip button on this controller is modified
  136852. */
  136853. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136854. /**
  136855. * Fired when the thumbstick button on this controller is modified
  136856. */
  136857. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136858. /**
  136859. * Fired when the touchpad button on this controller is modified
  136860. */
  136861. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136862. /**
  136863. * Fired when the touchpad values on this controller are modified
  136864. */
  136865. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  136866. protected _updateTrackpad(): void;
  136867. /**
  136868. * Called once per frame by the engine.
  136869. */
  136870. update(): void;
  136871. /**
  136872. * Called once for each button that changed state since the last frame
  136873. * @param buttonIdx Which button index changed
  136874. * @param state New state of the button
  136875. * @param changes Which properties on the state changed since last frame
  136876. */
  136877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136878. /**
  136879. * Moves the buttons on the controller mesh based on their current state
  136880. * @param buttonName the name of the button to move
  136881. * @param buttonValue the value of the button which determines the buttons new position
  136882. */
  136883. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  136884. /**
  136885. * Moves the axis on the controller mesh based on its current state
  136886. * @param axis the index of the axis
  136887. * @param axisValue the value of the axis which determines the meshes new position
  136888. * @hidden
  136889. */
  136890. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  136891. /**
  136892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136893. * @param scene scene in which to add meshes
  136894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136895. */
  136896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  136897. /**
  136898. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  136899. * can be transformed by button presses and axes values, based on this._mapping.
  136900. *
  136901. * @param scene scene in which the meshes exist
  136902. * @param meshes list of meshes that make up the controller model to process
  136903. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  136904. */
  136905. private processModel;
  136906. private createMeshInfo;
  136907. /**
  136908. * Gets the ray of the controller in the direction the controller is pointing
  136909. * @param length the length the resulting ray should be
  136910. * @returns a ray in the direction the controller is pointing
  136911. */
  136912. getForwardRay(length?: number): Ray;
  136913. /**
  136914. * Disposes of the controller
  136915. */
  136916. dispose(): void;
  136917. }
  136918. /**
  136919. * This class represents a new windows motion controller in XR.
  136920. */
  136921. export class XRWindowsMotionController extends WindowsMotionController {
  136922. /**
  136923. * Changing the original WIndowsMotionController mapping to fir the new mapping
  136924. */
  136925. protected readonly _mapping: {
  136926. buttons: string[];
  136927. buttonMeshNames: {
  136928. trigger: string;
  136929. menu: string;
  136930. grip: string;
  136931. thumbstick: string;
  136932. trackpad: string;
  136933. };
  136934. buttonObservableNames: {
  136935. trigger: string;
  136936. menu: string;
  136937. grip: string;
  136938. thumbstick: string;
  136939. trackpad: string;
  136940. };
  136941. axisMeshNames: string[];
  136942. pointingPoseMeshName: string;
  136943. };
  136944. /**
  136945. * Construct a new XR-Based windows motion controller
  136946. *
  136947. * @param gamepadInfo the gamepad object from the browser
  136948. */
  136949. constructor(gamepadInfo: any);
  136950. /**
  136951. * holds the thumbstick values (X,Y)
  136952. */
  136953. thumbstickValues: StickValues;
  136954. /**
  136955. * Fired when the thumbstick on this controller is clicked
  136956. */
  136957. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  136958. /**
  136959. * Fired when the thumbstick on this controller is modified
  136960. */
  136961. onThumbstickValuesChangedObservable: Observable<StickValues>;
  136962. /**
  136963. * Fired when the touchpad button on this controller is modified
  136964. */
  136965. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136966. /**
  136967. * Fired when the touchpad values on this controller are modified
  136968. */
  136969. onTrackpadValuesChangedObservable: Observable<StickValues>;
  136970. /**
  136971. * Fired when the thumbstick button on this controller is modified
  136972. * here to prevent breaking changes
  136973. */
  136974. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136975. /**
  136976. * updating the thumbstick(!) and not the trackpad.
  136977. * This is named this way due to the difference between WebVR and XR and to avoid
  136978. * changing the parent class.
  136979. */
  136980. protected _updateTrackpad(): void;
  136981. /**
  136982. * Disposes the class with joy
  136983. */
  136984. dispose(): void;
  136985. }
  136986. }
  136987. declare module BABYLON {
  136988. /**
  136989. * Class containing static functions to help procedurally build meshes
  136990. */
  136991. export class PolyhedronBuilder {
  136992. /**
  136993. * Creates a polyhedron mesh
  136994. * * 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
  136995. * * The parameter `size` (positive float, default 1) sets the polygon size
  136996. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136997. * * 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`
  136998. * * 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
  136999. * * 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)`)
  137000. * * 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
  137001. * * 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
  137002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137005. * @param name defines the name of the mesh
  137006. * @param options defines the options used to create the mesh
  137007. * @param scene defines the hosting scene
  137008. * @returns the polyhedron mesh
  137009. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137010. */
  137011. static CreatePolyhedron(name: string, options: {
  137012. type?: number;
  137013. size?: number;
  137014. sizeX?: number;
  137015. sizeY?: number;
  137016. sizeZ?: number;
  137017. custom?: any;
  137018. faceUV?: Vector4[];
  137019. faceColors?: Color4[];
  137020. flat?: boolean;
  137021. updatable?: boolean;
  137022. sideOrientation?: number;
  137023. frontUVs?: Vector4;
  137024. backUVs?: Vector4;
  137025. }, scene?: Nullable<Scene>): Mesh;
  137026. }
  137027. }
  137028. declare module BABYLON {
  137029. /**
  137030. * Gizmo that enables scaling a mesh along 3 axis
  137031. */
  137032. export class ScaleGizmo extends Gizmo {
  137033. /**
  137034. * Internal gizmo used for interactions on the x axis
  137035. */
  137036. xGizmo: AxisScaleGizmo;
  137037. /**
  137038. * Internal gizmo used for interactions on the y axis
  137039. */
  137040. yGizmo: AxisScaleGizmo;
  137041. /**
  137042. * Internal gizmo used for interactions on the z axis
  137043. */
  137044. zGizmo: AxisScaleGizmo;
  137045. /**
  137046. * Internal gizmo used to scale all axis equally
  137047. */
  137048. uniformScaleGizmo: AxisScaleGizmo;
  137049. private _meshAttached;
  137050. private _nodeAttached;
  137051. private _snapDistance;
  137052. private _uniformScalingMesh;
  137053. private _octahedron;
  137054. private _sensitivity;
  137055. /** Fires an event when any of it's sub gizmos are dragged */
  137056. onDragStartObservable: Observable<unknown>;
  137057. /** Fires an event when any of it's sub gizmos are released from dragging */
  137058. onDragEndObservable: Observable<unknown>;
  137059. get attachedMesh(): Nullable<AbstractMesh>;
  137060. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137061. get attachedNode(): Nullable<Node>;
  137062. set attachedNode(node: Nullable<Node>);
  137063. /**
  137064. * True when the mouse pointer is hovering a gizmo mesh
  137065. */
  137066. get isHovered(): boolean;
  137067. /**
  137068. * Creates a ScaleGizmo
  137069. * @param gizmoLayer The utility layer the gizmo will be added to
  137070. * @param thickness display gizmo axis thickness
  137071. */
  137072. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137073. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137074. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137075. /**
  137076. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137077. */
  137078. set snapDistance(value: number);
  137079. get snapDistance(): number;
  137080. /**
  137081. * Ratio for the scale of the gizmo (Default: 1)
  137082. */
  137083. set scaleRatio(value: number);
  137084. get scaleRatio(): number;
  137085. /**
  137086. * Sensitivity factor for dragging (Default: 1)
  137087. */
  137088. set sensitivity(value: number);
  137089. get sensitivity(): number;
  137090. /**
  137091. * Disposes of the gizmo
  137092. */
  137093. dispose(): void;
  137094. }
  137095. }
  137096. declare module BABYLON {
  137097. /**
  137098. * Single axis scale gizmo
  137099. */
  137100. export class AxisScaleGizmo extends Gizmo {
  137101. /**
  137102. * Drag behavior responsible for the gizmos dragging interactions
  137103. */
  137104. dragBehavior: PointerDragBehavior;
  137105. private _pointerObserver;
  137106. /**
  137107. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137108. */
  137109. snapDistance: number;
  137110. /**
  137111. * Event that fires each time the gizmo snaps to a new location.
  137112. * * snapDistance is the the change in distance
  137113. */
  137114. onSnapObservable: Observable<{
  137115. snapDistance: number;
  137116. }>;
  137117. /**
  137118. * If the scaling operation should be done on all axis (default: false)
  137119. */
  137120. uniformScaling: boolean;
  137121. /**
  137122. * Custom sensitivity value for the drag strength
  137123. */
  137124. sensitivity: number;
  137125. private _isEnabled;
  137126. private _parent;
  137127. private _arrow;
  137128. private _coloredMaterial;
  137129. private _hoverMaterial;
  137130. /**
  137131. * Creates an AxisScaleGizmo
  137132. * @param gizmoLayer The utility layer the gizmo will be added to
  137133. * @param dragAxis The axis which the gizmo will be able to scale on
  137134. * @param color The color of the gizmo
  137135. * @param thickness display gizmo axis thickness
  137136. */
  137137. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137138. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137139. /**
  137140. * If the gizmo is enabled
  137141. */
  137142. set isEnabled(value: boolean);
  137143. get isEnabled(): boolean;
  137144. /**
  137145. * Disposes of the gizmo
  137146. */
  137147. dispose(): void;
  137148. /**
  137149. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137150. * @param mesh The mesh to replace the default mesh of the gizmo
  137151. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137152. */
  137153. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137154. }
  137155. }
  137156. declare module BABYLON {
  137157. /**
  137158. * Bounding box gizmo
  137159. */
  137160. export class BoundingBoxGizmo extends Gizmo {
  137161. private _lineBoundingBox;
  137162. private _rotateSpheresParent;
  137163. private _scaleBoxesParent;
  137164. private _boundingDimensions;
  137165. private _renderObserver;
  137166. private _pointerObserver;
  137167. private _scaleDragSpeed;
  137168. private _tmpQuaternion;
  137169. private _tmpVector;
  137170. private _tmpRotationMatrix;
  137171. /**
  137172. * 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)
  137173. */
  137174. ignoreChildren: boolean;
  137175. /**
  137176. * 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)
  137177. */
  137178. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137179. /**
  137180. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137181. */
  137182. rotationSphereSize: number;
  137183. /**
  137184. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137185. */
  137186. scaleBoxSize: number;
  137187. /**
  137188. * 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)
  137189. */
  137190. fixedDragMeshScreenSize: boolean;
  137191. /**
  137192. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137193. */
  137194. fixedDragMeshScreenSizeDistanceFactor: number;
  137195. /**
  137196. * Fired when a rotation sphere or scale box is dragged
  137197. */
  137198. onDragStartObservable: Observable<{}>;
  137199. /**
  137200. * Fired when a scale box is dragged
  137201. */
  137202. onScaleBoxDragObservable: Observable<{}>;
  137203. /**
  137204. * Fired when a scale box drag is ended
  137205. */
  137206. onScaleBoxDragEndObservable: Observable<{}>;
  137207. /**
  137208. * Fired when a rotation sphere is dragged
  137209. */
  137210. onRotationSphereDragObservable: Observable<{}>;
  137211. /**
  137212. * Fired when a rotation sphere drag is ended
  137213. */
  137214. onRotationSphereDragEndObservable: Observable<{}>;
  137215. /**
  137216. * 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)
  137217. */
  137218. scalePivot: Nullable<Vector3>;
  137219. /**
  137220. * Mesh used as a pivot to rotate the attached node
  137221. */
  137222. private _anchorMesh;
  137223. private _existingMeshScale;
  137224. private _dragMesh;
  137225. private pointerDragBehavior;
  137226. private coloredMaterial;
  137227. private hoverColoredMaterial;
  137228. /**
  137229. * Sets the color of the bounding box gizmo
  137230. * @param color the color to set
  137231. */
  137232. setColor(color: Color3): void;
  137233. /**
  137234. * Creates an BoundingBoxGizmo
  137235. * @param gizmoLayer The utility layer the gizmo will be added to
  137236. * @param color The color of the gizmo
  137237. */
  137238. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137239. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137240. private _selectNode;
  137241. /**
  137242. * Updates the bounding box information for the Gizmo
  137243. */
  137244. updateBoundingBox(): void;
  137245. private _updateRotationSpheres;
  137246. private _updateScaleBoxes;
  137247. /**
  137248. * Enables rotation on the specified axis and disables rotation on the others
  137249. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137250. */
  137251. setEnabledRotationAxis(axis: string): void;
  137252. /**
  137253. * Enables/disables scaling
  137254. * @param enable if scaling should be enabled
  137255. * @param homogeneousScaling defines if scaling should only be homogeneous
  137256. */
  137257. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137258. private _updateDummy;
  137259. /**
  137260. * Enables a pointer drag behavior on the bounding box of the gizmo
  137261. */
  137262. enableDragBehavior(): void;
  137263. /**
  137264. * Disposes of the gizmo
  137265. */
  137266. dispose(): void;
  137267. /**
  137268. * 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)
  137269. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137270. * @returns the bounding box mesh with the passed in mesh as a child
  137271. */
  137272. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137273. /**
  137274. * CustomMeshes are not supported by this gizmo
  137275. * @param mesh The mesh to replace the default mesh of the gizmo
  137276. */
  137277. setCustomMesh(mesh: Mesh): void;
  137278. }
  137279. }
  137280. declare module BABYLON {
  137281. /**
  137282. * Single plane rotation gizmo
  137283. */
  137284. export class PlaneRotationGizmo extends Gizmo {
  137285. /**
  137286. * Drag behavior responsible for the gizmos dragging interactions
  137287. */
  137288. dragBehavior: PointerDragBehavior;
  137289. private _pointerObserver;
  137290. /**
  137291. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137292. */
  137293. snapDistance: number;
  137294. /**
  137295. * Event that fires each time the gizmo snaps to a new location.
  137296. * * snapDistance is the the change in distance
  137297. */
  137298. onSnapObservable: Observable<{
  137299. snapDistance: number;
  137300. }>;
  137301. private _isEnabled;
  137302. private _parent;
  137303. /**
  137304. * Creates a PlaneRotationGizmo
  137305. * @param gizmoLayer The utility layer the gizmo will be added to
  137306. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137307. * @param color The color of the gizmo
  137308. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137309. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137310. * @param thickness display gizmo axis thickness
  137311. */
  137312. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137313. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137314. /**
  137315. * If the gizmo is enabled
  137316. */
  137317. set isEnabled(value: boolean);
  137318. get isEnabled(): boolean;
  137319. /**
  137320. * Disposes of the gizmo
  137321. */
  137322. dispose(): void;
  137323. }
  137324. }
  137325. declare module BABYLON {
  137326. /**
  137327. * Gizmo that enables rotating a mesh along 3 axis
  137328. */
  137329. export class RotationGizmo extends Gizmo {
  137330. /**
  137331. * Internal gizmo used for interactions on the x axis
  137332. */
  137333. xGizmo: PlaneRotationGizmo;
  137334. /**
  137335. * Internal gizmo used for interactions on the y axis
  137336. */
  137337. yGizmo: PlaneRotationGizmo;
  137338. /**
  137339. * Internal gizmo used for interactions on the z axis
  137340. */
  137341. zGizmo: PlaneRotationGizmo;
  137342. /** Fires an event when any of it's sub gizmos are dragged */
  137343. onDragStartObservable: Observable<unknown>;
  137344. /** Fires an event when any of it's sub gizmos are released from dragging */
  137345. onDragEndObservable: Observable<unknown>;
  137346. private _meshAttached;
  137347. private _nodeAttached;
  137348. get attachedMesh(): Nullable<AbstractMesh>;
  137349. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137350. get attachedNode(): Nullable<Node>;
  137351. set attachedNode(node: Nullable<Node>);
  137352. /**
  137353. * True when the mouse pointer is hovering a gizmo mesh
  137354. */
  137355. get isHovered(): boolean;
  137356. /**
  137357. * Creates a RotationGizmo
  137358. * @param gizmoLayer The utility layer the gizmo will be added to
  137359. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137360. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137361. * @param thickness display gizmo axis thickness
  137362. */
  137363. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137364. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137365. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137366. /**
  137367. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137368. */
  137369. set snapDistance(value: number);
  137370. get snapDistance(): number;
  137371. /**
  137372. * Ratio for the scale of the gizmo (Default: 1)
  137373. */
  137374. set scaleRatio(value: number);
  137375. get scaleRatio(): number;
  137376. /**
  137377. * Disposes of the gizmo
  137378. */
  137379. dispose(): void;
  137380. /**
  137381. * CustomMeshes are not supported by this gizmo
  137382. * @param mesh The mesh to replace the default mesh of the gizmo
  137383. */
  137384. setCustomMesh(mesh: Mesh): void;
  137385. }
  137386. }
  137387. declare module BABYLON {
  137388. /**
  137389. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137390. */
  137391. export class GizmoManager implements IDisposable {
  137392. private scene;
  137393. /**
  137394. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137395. */
  137396. gizmos: {
  137397. positionGizmo: Nullable<PositionGizmo>;
  137398. rotationGizmo: Nullable<RotationGizmo>;
  137399. scaleGizmo: Nullable<ScaleGizmo>;
  137400. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137401. };
  137402. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137403. clearGizmoOnEmptyPointerEvent: boolean;
  137404. /** Fires an event when the manager is attached to a mesh */
  137405. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137406. /** Fires an event when the manager is attached to a node */
  137407. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137408. private _gizmosEnabled;
  137409. private _pointerObserver;
  137410. private _attachedMesh;
  137411. private _attachedNode;
  137412. private _boundingBoxColor;
  137413. private _defaultUtilityLayer;
  137414. private _defaultKeepDepthUtilityLayer;
  137415. private _thickness;
  137416. /**
  137417. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137418. */
  137419. boundingBoxDragBehavior: SixDofDragBehavior;
  137420. /**
  137421. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137422. */
  137423. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137424. /**
  137425. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137426. */
  137427. attachableNodes: Nullable<Array<Node>>;
  137428. /**
  137429. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137430. */
  137431. usePointerToAttachGizmos: boolean;
  137432. /**
  137433. * Utility layer that the bounding box gizmo belongs to
  137434. */
  137435. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137436. /**
  137437. * Utility layer that all gizmos besides bounding box belong to
  137438. */
  137439. get utilityLayer(): UtilityLayerRenderer;
  137440. /**
  137441. * True when the mouse pointer is hovering a gizmo mesh
  137442. */
  137443. get isHovered(): boolean;
  137444. /**
  137445. * Instatiates a gizmo manager
  137446. * @param scene the scene to overlay the gizmos on top of
  137447. * @param thickness display gizmo axis thickness
  137448. */
  137449. constructor(scene: Scene, thickness?: number);
  137450. /**
  137451. * Attaches a set of gizmos to the specified mesh
  137452. * @param mesh The mesh the gizmo's should be attached to
  137453. */
  137454. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137455. /**
  137456. * Attaches a set of gizmos to the specified node
  137457. * @param node The node the gizmo's should be attached to
  137458. */
  137459. attachToNode(node: Nullable<Node>): void;
  137460. /**
  137461. * If the position gizmo is enabled
  137462. */
  137463. set positionGizmoEnabled(value: boolean);
  137464. get positionGizmoEnabled(): boolean;
  137465. /**
  137466. * If the rotation gizmo is enabled
  137467. */
  137468. set rotationGizmoEnabled(value: boolean);
  137469. get rotationGizmoEnabled(): boolean;
  137470. /**
  137471. * If the scale gizmo is enabled
  137472. */
  137473. set scaleGizmoEnabled(value: boolean);
  137474. get scaleGizmoEnabled(): boolean;
  137475. /**
  137476. * If the boundingBox gizmo is enabled
  137477. */
  137478. set boundingBoxGizmoEnabled(value: boolean);
  137479. get boundingBoxGizmoEnabled(): boolean;
  137480. /**
  137481. * Disposes of the gizmo manager
  137482. */
  137483. dispose(): void;
  137484. }
  137485. }
  137486. declare module BABYLON {
  137487. /**
  137488. * A directional light is defined by a direction (what a surprise!).
  137489. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137490. * 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.
  137491. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137492. */
  137493. export class DirectionalLight extends ShadowLight {
  137494. private _shadowFrustumSize;
  137495. /**
  137496. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137497. */
  137498. get shadowFrustumSize(): number;
  137499. /**
  137500. * Specifies a fix frustum size for the shadow generation.
  137501. */
  137502. set shadowFrustumSize(value: number);
  137503. private _shadowOrthoScale;
  137504. /**
  137505. * Gets the shadow projection scale against the optimal computed one.
  137506. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137507. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137508. */
  137509. get shadowOrthoScale(): number;
  137510. /**
  137511. * Sets the shadow projection scale against the optimal computed one.
  137512. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137513. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137514. */
  137515. set shadowOrthoScale(value: number);
  137516. /**
  137517. * Automatically compute the projection matrix to best fit (including all the casters)
  137518. * on each frame.
  137519. */
  137520. autoUpdateExtends: boolean;
  137521. /**
  137522. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137523. * on each frame. autoUpdateExtends must be set to true for this to work
  137524. */
  137525. autoCalcShadowZBounds: boolean;
  137526. private _orthoLeft;
  137527. private _orthoRight;
  137528. private _orthoTop;
  137529. private _orthoBottom;
  137530. /**
  137531. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137532. * The directional light is emitted from everywhere in the given direction.
  137533. * It can cast shadows.
  137534. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137535. * @param name The friendly name of the light
  137536. * @param direction The direction of the light
  137537. * @param scene The scene the light belongs to
  137538. */
  137539. constructor(name: string, direction: Vector3, scene: Scene);
  137540. /**
  137541. * Returns the string "DirectionalLight".
  137542. * @return The class name
  137543. */
  137544. getClassName(): string;
  137545. /**
  137546. * Returns the integer 1.
  137547. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137548. */
  137549. getTypeID(): number;
  137550. /**
  137551. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137552. * Returns the DirectionalLight Shadow projection matrix.
  137553. */
  137554. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137555. /**
  137556. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137557. * Returns the DirectionalLight Shadow projection matrix.
  137558. */
  137559. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137560. /**
  137561. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137562. * Returns the DirectionalLight Shadow projection matrix.
  137563. */
  137564. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137565. protected _buildUniformLayout(): void;
  137566. /**
  137567. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137568. * @param effect The effect to update
  137569. * @param lightIndex The index of the light in the effect to update
  137570. * @returns The directional light
  137571. */
  137572. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137573. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137574. /**
  137575. * Gets the minZ used for shadow according to both the scene and the light.
  137576. *
  137577. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137578. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137579. * @param activeCamera The camera we are returning the min for
  137580. * @returns the depth min z
  137581. */
  137582. getDepthMinZ(activeCamera: Camera): number;
  137583. /**
  137584. * Gets the maxZ used for shadow according to both the scene and the light.
  137585. *
  137586. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137587. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137588. * @param activeCamera The camera we are returning the max for
  137589. * @returns the depth max z
  137590. */
  137591. getDepthMaxZ(activeCamera: Camera): number;
  137592. /**
  137593. * Prepares the list of defines specific to the light type.
  137594. * @param defines the list of defines
  137595. * @param lightIndex defines the index of the light for the effect
  137596. */
  137597. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137598. }
  137599. }
  137600. declare module BABYLON {
  137601. /**
  137602. * Class containing static functions to help procedurally build meshes
  137603. */
  137604. export class HemisphereBuilder {
  137605. /**
  137606. * Creates a hemisphere mesh
  137607. * @param name defines the name of the mesh
  137608. * @param options defines the options used to create the mesh
  137609. * @param scene defines the hosting scene
  137610. * @returns the hemisphere mesh
  137611. */
  137612. static CreateHemisphere(name: string, options: {
  137613. segments?: number;
  137614. diameter?: number;
  137615. sideOrientation?: number;
  137616. }, scene: any): Mesh;
  137617. }
  137618. }
  137619. declare module BABYLON {
  137620. /**
  137621. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137622. * These values define a cone of light starting from the position, emitting toward the direction.
  137623. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137624. * and the exponent defines the speed of the decay of the light with distance (reach).
  137625. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137626. */
  137627. export class SpotLight extends ShadowLight {
  137628. private _angle;
  137629. private _innerAngle;
  137630. private _cosHalfAngle;
  137631. private _lightAngleScale;
  137632. private _lightAngleOffset;
  137633. /**
  137634. * Gets the cone angle of the spot light in Radians.
  137635. */
  137636. get angle(): number;
  137637. /**
  137638. * Sets the cone angle of the spot light in Radians.
  137639. */
  137640. set angle(value: number);
  137641. /**
  137642. * Only used in gltf falloff mode, this defines the angle where
  137643. * the directional falloff will start before cutting at angle which could be seen
  137644. * as outer angle.
  137645. */
  137646. get innerAngle(): number;
  137647. /**
  137648. * Only used in gltf falloff mode, this defines the angle where
  137649. * the directional falloff will start before cutting at angle which could be seen
  137650. * as outer angle.
  137651. */
  137652. set innerAngle(value: number);
  137653. private _shadowAngleScale;
  137654. /**
  137655. * Allows scaling the angle of the light for shadow generation only.
  137656. */
  137657. get shadowAngleScale(): number;
  137658. /**
  137659. * Allows scaling the angle of the light for shadow generation only.
  137660. */
  137661. set shadowAngleScale(value: number);
  137662. /**
  137663. * The light decay speed with the distance from the emission spot.
  137664. */
  137665. exponent: number;
  137666. private _projectionTextureMatrix;
  137667. /**
  137668. * Allows reading the projecton texture
  137669. */
  137670. get projectionTextureMatrix(): Matrix;
  137671. protected _projectionTextureLightNear: number;
  137672. /**
  137673. * Gets the near clip of the Spotlight for texture projection.
  137674. */
  137675. get projectionTextureLightNear(): number;
  137676. /**
  137677. * Sets the near clip of the Spotlight for texture projection.
  137678. */
  137679. set projectionTextureLightNear(value: number);
  137680. protected _projectionTextureLightFar: number;
  137681. /**
  137682. * Gets the far clip of the Spotlight for texture projection.
  137683. */
  137684. get projectionTextureLightFar(): number;
  137685. /**
  137686. * Sets the far clip of the Spotlight for texture projection.
  137687. */
  137688. set projectionTextureLightFar(value: number);
  137689. protected _projectionTextureUpDirection: Vector3;
  137690. /**
  137691. * Gets the Up vector of the Spotlight for texture projection.
  137692. */
  137693. get projectionTextureUpDirection(): Vector3;
  137694. /**
  137695. * Sets the Up vector of the Spotlight for texture projection.
  137696. */
  137697. set projectionTextureUpDirection(value: Vector3);
  137698. private _projectionTexture;
  137699. /**
  137700. * Gets the projection texture of the light.
  137701. */
  137702. get projectionTexture(): Nullable<BaseTexture>;
  137703. /**
  137704. * Sets the projection texture of the light.
  137705. */
  137706. set projectionTexture(value: Nullable<BaseTexture>);
  137707. private _projectionTextureViewLightDirty;
  137708. private _projectionTextureProjectionLightDirty;
  137709. private _projectionTextureDirty;
  137710. private _projectionTextureViewTargetVector;
  137711. private _projectionTextureViewLightMatrix;
  137712. private _projectionTextureProjectionLightMatrix;
  137713. private _projectionTextureScalingMatrix;
  137714. /**
  137715. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  137716. * It can cast shadows.
  137717. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137718. * @param name The light friendly name
  137719. * @param position The position of the spot light in the scene
  137720. * @param direction The direction of the light in the scene
  137721. * @param angle The cone angle of the light in Radians
  137722. * @param exponent The light decay speed with the distance from the emission spot
  137723. * @param scene The scene the lights belongs to
  137724. */
  137725. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  137726. /**
  137727. * Returns the string "SpotLight".
  137728. * @returns the class name
  137729. */
  137730. getClassName(): string;
  137731. /**
  137732. * Returns the integer 2.
  137733. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137734. */
  137735. getTypeID(): number;
  137736. /**
  137737. * Overrides the direction setter to recompute the projection texture view light Matrix.
  137738. */
  137739. protected _setDirection(value: Vector3): void;
  137740. /**
  137741. * Overrides the position setter to recompute the projection texture view light Matrix.
  137742. */
  137743. protected _setPosition(value: Vector3): void;
  137744. /**
  137745. * 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.
  137746. * Returns the SpotLight.
  137747. */
  137748. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137749. protected _computeProjectionTextureViewLightMatrix(): void;
  137750. protected _computeProjectionTextureProjectionLightMatrix(): void;
  137751. /**
  137752. * Main function for light texture projection matrix computing.
  137753. */
  137754. protected _computeProjectionTextureMatrix(): void;
  137755. protected _buildUniformLayout(): void;
  137756. private _computeAngleValues;
  137757. /**
  137758. * Sets the passed Effect "effect" with the Light textures.
  137759. * @param effect The effect to update
  137760. * @param lightIndex The index of the light in the effect to update
  137761. * @returns The light
  137762. */
  137763. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  137764. /**
  137765. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  137766. * @param effect The effect to update
  137767. * @param lightIndex The index of the light in the effect to update
  137768. * @returns The spot light
  137769. */
  137770. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  137771. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137772. /**
  137773. * Disposes the light and the associated resources.
  137774. */
  137775. dispose(): void;
  137776. /**
  137777. * Prepares the list of defines specific to the light type.
  137778. * @param defines the list of defines
  137779. * @param lightIndex defines the index of the light for the effect
  137780. */
  137781. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137782. }
  137783. }
  137784. declare module BABYLON {
  137785. /**
  137786. * Gizmo that enables viewing a light
  137787. */
  137788. export class LightGizmo extends Gizmo {
  137789. private _lightMesh;
  137790. private _material;
  137791. private _cachedPosition;
  137792. private _cachedForward;
  137793. private _attachedMeshParent;
  137794. private _pointerObserver;
  137795. /**
  137796. * Event that fires each time the gizmo is clicked
  137797. */
  137798. onClickedObservable: Observable<Light>;
  137799. /**
  137800. * Creates a LightGizmo
  137801. * @param gizmoLayer The utility layer the gizmo will be added to
  137802. */
  137803. constructor(gizmoLayer?: UtilityLayerRenderer);
  137804. private _light;
  137805. /**
  137806. * The light that the gizmo is attached to
  137807. */
  137808. set light(light: Nullable<Light>);
  137809. get light(): Nullable<Light>;
  137810. /**
  137811. * Gets the material used to render the light gizmo
  137812. */
  137813. get material(): StandardMaterial;
  137814. /**
  137815. * @hidden
  137816. * Updates the gizmo to match the attached mesh's position/rotation
  137817. */
  137818. protected _update(): void;
  137819. private static _Scale;
  137820. /**
  137821. * Creates the lines for a light mesh
  137822. */
  137823. private static _CreateLightLines;
  137824. /**
  137825. * Disposes of the light gizmo
  137826. */
  137827. dispose(): void;
  137828. private static _CreateHemisphericLightMesh;
  137829. private static _CreatePointLightMesh;
  137830. private static _CreateSpotLightMesh;
  137831. private static _CreateDirectionalLightMesh;
  137832. }
  137833. }
  137834. declare module BABYLON {
  137835. /**
  137836. * Gizmo that enables viewing a camera
  137837. */
  137838. export class CameraGizmo extends Gizmo {
  137839. private _cameraMesh;
  137840. private _cameraLinesMesh;
  137841. private _material;
  137842. private _pointerObserver;
  137843. /**
  137844. * Event that fires each time the gizmo is clicked
  137845. */
  137846. onClickedObservable: Observable<Camera>;
  137847. /**
  137848. * Creates a CameraGizmo
  137849. * @param gizmoLayer The utility layer the gizmo will be added to
  137850. */
  137851. constructor(gizmoLayer?: UtilityLayerRenderer);
  137852. private _camera;
  137853. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  137854. get displayFrustum(): boolean;
  137855. set displayFrustum(value: boolean);
  137856. /**
  137857. * The camera that the gizmo is attached to
  137858. */
  137859. set camera(camera: Nullable<Camera>);
  137860. get camera(): Nullable<Camera>;
  137861. /**
  137862. * Gets the material used to render the camera gizmo
  137863. */
  137864. get material(): StandardMaterial;
  137865. /**
  137866. * @hidden
  137867. * Updates the gizmo to match the attached mesh's position/rotation
  137868. */
  137869. protected _update(): void;
  137870. private static _Scale;
  137871. private _invProjection;
  137872. /**
  137873. * Disposes of the camera gizmo
  137874. */
  137875. dispose(): void;
  137876. private static _CreateCameraMesh;
  137877. private static _CreateCameraFrustum;
  137878. }
  137879. }
  137880. declare module BABYLON {
  137881. /** @hidden */
  137882. export var backgroundFragmentDeclaration: {
  137883. name: string;
  137884. shader: string;
  137885. };
  137886. }
  137887. declare module BABYLON {
  137888. /** @hidden */
  137889. export var backgroundUboDeclaration: {
  137890. name: string;
  137891. shader: string;
  137892. };
  137893. }
  137894. declare module BABYLON {
  137895. /** @hidden */
  137896. export var backgroundPixelShader: {
  137897. name: string;
  137898. shader: string;
  137899. };
  137900. }
  137901. declare module BABYLON {
  137902. /** @hidden */
  137903. export var backgroundVertexDeclaration: {
  137904. name: string;
  137905. shader: string;
  137906. };
  137907. }
  137908. declare module BABYLON {
  137909. /** @hidden */
  137910. export var backgroundVertexShader: {
  137911. name: string;
  137912. shader: string;
  137913. };
  137914. }
  137915. declare module BABYLON {
  137916. /**
  137917. * Background material used to create an efficient environement around your scene.
  137918. */
  137919. export class BackgroundMaterial extends PushMaterial {
  137920. /**
  137921. * Standard reflectance value at parallel view angle.
  137922. */
  137923. static StandardReflectance0: number;
  137924. /**
  137925. * Standard reflectance value at grazing angle.
  137926. */
  137927. static StandardReflectance90: number;
  137928. protected _primaryColor: Color3;
  137929. /**
  137930. * Key light Color (multiply against the environement texture)
  137931. */
  137932. primaryColor: Color3;
  137933. protected __perceptualColor: Nullable<Color3>;
  137934. /**
  137935. * Experimental Internal Use Only.
  137936. *
  137937. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  137938. * This acts as a helper to set the primary color to a more "human friendly" value.
  137939. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  137940. * output color as close as possible from the chosen value.
  137941. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  137942. * part of lighting setup.)
  137943. */
  137944. get _perceptualColor(): Nullable<Color3>;
  137945. set _perceptualColor(value: Nullable<Color3>);
  137946. protected _primaryColorShadowLevel: float;
  137947. /**
  137948. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  137949. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  137950. */
  137951. get primaryColorShadowLevel(): float;
  137952. set primaryColorShadowLevel(value: float);
  137953. protected _primaryColorHighlightLevel: float;
  137954. /**
  137955. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  137956. * The primary color is used at the level chosen to define what the white area would look.
  137957. */
  137958. get primaryColorHighlightLevel(): float;
  137959. set primaryColorHighlightLevel(value: float);
  137960. protected _reflectionTexture: Nullable<BaseTexture>;
  137961. /**
  137962. * Reflection Texture used in the material.
  137963. * Should be author in a specific way for the best result (refer to the documentation).
  137964. */
  137965. reflectionTexture: Nullable<BaseTexture>;
  137966. protected _reflectionBlur: float;
  137967. /**
  137968. * Reflection Texture level of blur.
  137969. *
  137970. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  137971. * texture twice.
  137972. */
  137973. reflectionBlur: float;
  137974. protected _diffuseTexture: Nullable<BaseTexture>;
  137975. /**
  137976. * Diffuse Texture used in the material.
  137977. * Should be author in a specific way for the best result (refer to the documentation).
  137978. */
  137979. diffuseTexture: Nullable<BaseTexture>;
  137980. protected _shadowLights: Nullable<IShadowLight[]>;
  137981. /**
  137982. * Specify the list of lights casting shadow on the material.
  137983. * All scene shadow lights will be included if null.
  137984. */
  137985. shadowLights: Nullable<IShadowLight[]>;
  137986. protected _shadowLevel: float;
  137987. /**
  137988. * Helps adjusting the shadow to a softer level if required.
  137989. * 0 means black shadows and 1 means no shadows.
  137990. */
  137991. shadowLevel: float;
  137992. protected _sceneCenter: Vector3;
  137993. /**
  137994. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  137995. * It is usually zero but might be interesting to modify according to your setup.
  137996. */
  137997. sceneCenter: Vector3;
  137998. protected _opacityFresnel: boolean;
  137999. /**
  138000. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138001. * This helps ensuring a nice transition when the camera goes under the ground.
  138002. */
  138003. opacityFresnel: boolean;
  138004. protected _reflectionFresnel: boolean;
  138005. /**
  138006. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138007. * This helps adding a mirror texture on the ground.
  138008. */
  138009. reflectionFresnel: boolean;
  138010. protected _reflectionFalloffDistance: number;
  138011. /**
  138012. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138013. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138014. */
  138015. reflectionFalloffDistance: number;
  138016. protected _reflectionAmount: number;
  138017. /**
  138018. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138019. */
  138020. reflectionAmount: number;
  138021. protected _reflectionReflectance0: number;
  138022. /**
  138023. * This specifies the weight of the reflection at grazing angle.
  138024. */
  138025. reflectionReflectance0: number;
  138026. protected _reflectionReflectance90: number;
  138027. /**
  138028. * This specifies the weight of the reflection at a perpendicular point of view.
  138029. */
  138030. reflectionReflectance90: number;
  138031. /**
  138032. * Sets the reflection reflectance fresnel values according to the default standard
  138033. * empirically know to work well :-)
  138034. */
  138035. set reflectionStandardFresnelWeight(value: number);
  138036. protected _useRGBColor: boolean;
  138037. /**
  138038. * Helps to directly use the maps channels instead of their level.
  138039. */
  138040. useRGBColor: boolean;
  138041. protected _enableNoise: boolean;
  138042. /**
  138043. * This helps reducing the banding effect that could occur on the background.
  138044. */
  138045. enableNoise: boolean;
  138046. /**
  138047. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138048. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138049. * Recommended to be keep at 1.0 except for special cases.
  138050. */
  138051. get fovMultiplier(): number;
  138052. set fovMultiplier(value: number);
  138053. private _fovMultiplier;
  138054. /**
  138055. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138056. */
  138057. useEquirectangularFOV: boolean;
  138058. private _maxSimultaneousLights;
  138059. /**
  138060. * Number of Simultaneous lights allowed on the material.
  138061. */
  138062. maxSimultaneousLights: int;
  138063. private _shadowOnly;
  138064. /**
  138065. * Make the material only render shadows
  138066. */
  138067. shadowOnly: boolean;
  138068. /**
  138069. * Default configuration related to image processing available in the Background Material.
  138070. */
  138071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138072. /**
  138073. * Keep track of the image processing observer to allow dispose and replace.
  138074. */
  138075. private _imageProcessingObserver;
  138076. /**
  138077. * Attaches a new image processing configuration to the PBR Material.
  138078. * @param configuration (if null the scene configuration will be use)
  138079. */
  138080. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138081. /**
  138082. * Gets the image processing configuration used either in this material.
  138083. */
  138084. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138085. /**
  138086. * Sets the Default image processing configuration used either in the this material.
  138087. *
  138088. * If sets to null, the scene one is in use.
  138089. */
  138090. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138091. /**
  138092. * Gets wether the color curves effect is enabled.
  138093. */
  138094. get cameraColorCurvesEnabled(): boolean;
  138095. /**
  138096. * Sets wether the color curves effect is enabled.
  138097. */
  138098. set cameraColorCurvesEnabled(value: boolean);
  138099. /**
  138100. * Gets wether the color grading effect is enabled.
  138101. */
  138102. get cameraColorGradingEnabled(): boolean;
  138103. /**
  138104. * Gets wether the color grading effect is enabled.
  138105. */
  138106. set cameraColorGradingEnabled(value: boolean);
  138107. /**
  138108. * Gets wether tonemapping is enabled or not.
  138109. */
  138110. get cameraToneMappingEnabled(): boolean;
  138111. /**
  138112. * Sets wether tonemapping is enabled or not
  138113. */
  138114. set cameraToneMappingEnabled(value: boolean);
  138115. /**
  138116. * The camera exposure used on this material.
  138117. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138118. * This corresponds to a photographic exposure.
  138119. */
  138120. get cameraExposure(): float;
  138121. /**
  138122. * The camera exposure used on this material.
  138123. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138124. * This corresponds to a photographic exposure.
  138125. */
  138126. set cameraExposure(value: float);
  138127. /**
  138128. * Gets The camera contrast used on this material.
  138129. */
  138130. get cameraContrast(): float;
  138131. /**
  138132. * Sets The camera contrast used on this material.
  138133. */
  138134. set cameraContrast(value: float);
  138135. /**
  138136. * Gets the Color Grading 2D Lookup Texture.
  138137. */
  138138. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138139. /**
  138140. * Sets the Color Grading 2D Lookup Texture.
  138141. */
  138142. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138143. /**
  138144. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138145. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138146. * 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;
  138147. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138148. */
  138149. get cameraColorCurves(): Nullable<ColorCurves>;
  138150. /**
  138151. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138152. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138153. * 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;
  138154. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138155. */
  138156. set cameraColorCurves(value: Nullable<ColorCurves>);
  138157. /**
  138158. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138159. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138160. */
  138161. switchToBGR: boolean;
  138162. private _renderTargets;
  138163. private _reflectionControls;
  138164. private _white;
  138165. private _primaryShadowColor;
  138166. private _primaryHighlightColor;
  138167. /**
  138168. * Instantiates a Background Material in the given scene
  138169. * @param name The friendly name of the material
  138170. * @param scene The scene to add the material to
  138171. */
  138172. constructor(name: string, scene: Scene);
  138173. /**
  138174. * Gets a boolean indicating that current material needs to register RTT
  138175. */
  138176. get hasRenderTargetTextures(): boolean;
  138177. /**
  138178. * The entire material has been created in order to prevent overdraw.
  138179. * @returns false
  138180. */
  138181. needAlphaTesting(): boolean;
  138182. /**
  138183. * The entire material has been created in order to prevent overdraw.
  138184. * @returns true if blending is enable
  138185. */
  138186. needAlphaBlending(): boolean;
  138187. /**
  138188. * Checks wether the material is ready to be rendered for a given mesh.
  138189. * @param mesh The mesh to render
  138190. * @param subMesh The submesh to check against
  138191. * @param useInstances Specify wether or not the material is used with instances
  138192. * @returns true if all the dependencies are ready (Textures, Effects...)
  138193. */
  138194. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138195. /**
  138196. * Compute the primary color according to the chosen perceptual color.
  138197. */
  138198. private _computePrimaryColorFromPerceptualColor;
  138199. /**
  138200. * Compute the highlights and shadow colors according to their chosen levels.
  138201. */
  138202. private _computePrimaryColors;
  138203. /**
  138204. * Build the uniform buffer used in the material.
  138205. */
  138206. buildUniformLayout(): void;
  138207. /**
  138208. * Unbind the material.
  138209. */
  138210. unbind(): void;
  138211. /**
  138212. * Bind only the world matrix to the material.
  138213. * @param world The world matrix to bind.
  138214. */
  138215. bindOnlyWorldMatrix(world: Matrix): void;
  138216. /**
  138217. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138218. * @param world The world matrix to bind.
  138219. * @param subMesh The submesh to bind for.
  138220. */
  138221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138222. /**
  138223. * Checks to see if a texture is used in the material.
  138224. * @param texture - Base texture to use.
  138225. * @returns - Boolean specifying if a texture is used in the material.
  138226. */
  138227. hasTexture(texture: BaseTexture): boolean;
  138228. /**
  138229. * Dispose the material.
  138230. * @param forceDisposeEffect Force disposal of the associated effect.
  138231. * @param forceDisposeTextures Force disposal of the associated textures.
  138232. */
  138233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138234. /**
  138235. * Clones the material.
  138236. * @param name The cloned name.
  138237. * @returns The cloned material.
  138238. */
  138239. clone(name: string): BackgroundMaterial;
  138240. /**
  138241. * Serializes the current material to its JSON representation.
  138242. * @returns The JSON representation.
  138243. */
  138244. serialize(): any;
  138245. /**
  138246. * Gets the class name of the material
  138247. * @returns "BackgroundMaterial"
  138248. */
  138249. getClassName(): string;
  138250. /**
  138251. * Parse a JSON input to create back a background material.
  138252. * @param source The JSON data to parse
  138253. * @param scene The scene to create the parsed material in
  138254. * @param rootUrl The root url of the assets the material depends upon
  138255. * @returns the instantiated BackgroundMaterial.
  138256. */
  138257. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138258. }
  138259. }
  138260. declare module BABYLON {
  138261. /**
  138262. * Represents the different options available during the creation of
  138263. * a Environment helper.
  138264. *
  138265. * This can control the default ground, skybox and image processing setup of your scene.
  138266. */
  138267. export interface IEnvironmentHelperOptions {
  138268. /**
  138269. * Specifies whether or not to create a ground.
  138270. * True by default.
  138271. */
  138272. createGround: boolean;
  138273. /**
  138274. * Specifies the ground size.
  138275. * 15 by default.
  138276. */
  138277. groundSize: number;
  138278. /**
  138279. * The texture used on the ground for the main color.
  138280. * Comes from the BabylonJS CDN by default.
  138281. *
  138282. * Remarks: Can be either a texture or a url.
  138283. */
  138284. groundTexture: string | BaseTexture;
  138285. /**
  138286. * The color mixed in the ground texture by default.
  138287. * BabylonJS clearColor by default.
  138288. */
  138289. groundColor: Color3;
  138290. /**
  138291. * Specifies the ground opacity.
  138292. * 1 by default.
  138293. */
  138294. groundOpacity: number;
  138295. /**
  138296. * Enables the ground to receive shadows.
  138297. * True by default.
  138298. */
  138299. enableGroundShadow: boolean;
  138300. /**
  138301. * Helps preventing the shadow to be fully black on the ground.
  138302. * 0.5 by default.
  138303. */
  138304. groundShadowLevel: number;
  138305. /**
  138306. * Creates a mirror texture attach to the ground.
  138307. * false by default.
  138308. */
  138309. enableGroundMirror: boolean;
  138310. /**
  138311. * Specifies the ground mirror size ratio.
  138312. * 0.3 by default as the default kernel is 64.
  138313. */
  138314. groundMirrorSizeRatio: number;
  138315. /**
  138316. * Specifies the ground mirror blur kernel size.
  138317. * 64 by default.
  138318. */
  138319. groundMirrorBlurKernel: number;
  138320. /**
  138321. * Specifies the ground mirror visibility amount.
  138322. * 1 by default
  138323. */
  138324. groundMirrorAmount: number;
  138325. /**
  138326. * Specifies the ground mirror reflectance weight.
  138327. * This uses the standard weight of the background material to setup the fresnel effect
  138328. * of the mirror.
  138329. * 1 by default.
  138330. */
  138331. groundMirrorFresnelWeight: number;
  138332. /**
  138333. * Specifies the ground mirror Falloff distance.
  138334. * This can helps reducing the size of the reflection.
  138335. * 0 by Default.
  138336. */
  138337. groundMirrorFallOffDistance: number;
  138338. /**
  138339. * Specifies the ground mirror texture type.
  138340. * Unsigned Int by Default.
  138341. */
  138342. groundMirrorTextureType: number;
  138343. /**
  138344. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138345. * the shown objects.
  138346. */
  138347. groundYBias: number;
  138348. /**
  138349. * Specifies whether or not to create a skybox.
  138350. * True by default.
  138351. */
  138352. createSkybox: boolean;
  138353. /**
  138354. * Specifies the skybox size.
  138355. * 20 by default.
  138356. */
  138357. skyboxSize: number;
  138358. /**
  138359. * The texture used on the skybox for the main color.
  138360. * Comes from the BabylonJS CDN by default.
  138361. *
  138362. * Remarks: Can be either a texture or a url.
  138363. */
  138364. skyboxTexture: string | BaseTexture;
  138365. /**
  138366. * The color mixed in the skybox texture by default.
  138367. * BabylonJS clearColor by default.
  138368. */
  138369. skyboxColor: Color3;
  138370. /**
  138371. * The background rotation around the Y axis of the scene.
  138372. * This helps aligning the key lights of your scene with the background.
  138373. * 0 by default.
  138374. */
  138375. backgroundYRotation: number;
  138376. /**
  138377. * Compute automatically the size of the elements to best fit with the scene.
  138378. */
  138379. sizeAuto: boolean;
  138380. /**
  138381. * Default position of the rootMesh if autoSize is not true.
  138382. */
  138383. rootPosition: Vector3;
  138384. /**
  138385. * Sets up the image processing in the scene.
  138386. * true by default.
  138387. */
  138388. setupImageProcessing: boolean;
  138389. /**
  138390. * The texture used as your environment texture in the scene.
  138391. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138392. *
  138393. * Remarks: Can be either a texture or a url.
  138394. */
  138395. environmentTexture: string | BaseTexture;
  138396. /**
  138397. * The value of the exposure to apply to the scene.
  138398. * 0.6 by default if setupImageProcessing is true.
  138399. */
  138400. cameraExposure: number;
  138401. /**
  138402. * The value of the contrast to apply to the scene.
  138403. * 1.6 by default if setupImageProcessing is true.
  138404. */
  138405. cameraContrast: number;
  138406. /**
  138407. * Specifies whether or not tonemapping should be enabled in the scene.
  138408. * true by default if setupImageProcessing is true.
  138409. */
  138410. toneMappingEnabled: boolean;
  138411. }
  138412. /**
  138413. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138414. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138415. * It also helps with the default setup of your imageProcessing configuration.
  138416. */
  138417. export class EnvironmentHelper {
  138418. /**
  138419. * Default ground texture URL.
  138420. */
  138421. private static _groundTextureCDNUrl;
  138422. /**
  138423. * Default skybox texture URL.
  138424. */
  138425. private static _skyboxTextureCDNUrl;
  138426. /**
  138427. * Default environment texture URL.
  138428. */
  138429. private static _environmentTextureCDNUrl;
  138430. /**
  138431. * Creates the default options for the helper.
  138432. */
  138433. private static _getDefaultOptions;
  138434. private _rootMesh;
  138435. /**
  138436. * Gets the root mesh created by the helper.
  138437. */
  138438. get rootMesh(): Mesh;
  138439. private _skybox;
  138440. /**
  138441. * Gets the skybox created by the helper.
  138442. */
  138443. get skybox(): Nullable<Mesh>;
  138444. private _skyboxTexture;
  138445. /**
  138446. * Gets the skybox texture created by the helper.
  138447. */
  138448. get skyboxTexture(): Nullable<BaseTexture>;
  138449. private _skyboxMaterial;
  138450. /**
  138451. * Gets the skybox material created by the helper.
  138452. */
  138453. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138454. private _ground;
  138455. /**
  138456. * Gets the ground mesh created by the helper.
  138457. */
  138458. get ground(): Nullable<Mesh>;
  138459. private _groundTexture;
  138460. /**
  138461. * Gets the ground texture created by the helper.
  138462. */
  138463. get groundTexture(): Nullable<BaseTexture>;
  138464. private _groundMirror;
  138465. /**
  138466. * Gets the ground mirror created by the helper.
  138467. */
  138468. get groundMirror(): Nullable<MirrorTexture>;
  138469. /**
  138470. * Gets the ground mirror render list to helps pushing the meshes
  138471. * you wish in the ground reflection.
  138472. */
  138473. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138474. private _groundMaterial;
  138475. /**
  138476. * Gets the ground material created by the helper.
  138477. */
  138478. get groundMaterial(): Nullable<BackgroundMaterial>;
  138479. /**
  138480. * Stores the creation options.
  138481. */
  138482. private readonly _scene;
  138483. private _options;
  138484. /**
  138485. * This observable will be notified with any error during the creation of the environment,
  138486. * mainly texture creation errors.
  138487. */
  138488. onErrorObservable: Observable<{
  138489. message?: string;
  138490. exception?: any;
  138491. }>;
  138492. /**
  138493. * constructor
  138494. * @param options Defines the options we want to customize the helper
  138495. * @param scene The scene to add the material to
  138496. */
  138497. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138498. /**
  138499. * Updates the background according to the new options
  138500. * @param options
  138501. */
  138502. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138503. /**
  138504. * Sets the primary color of all the available elements.
  138505. * @param color the main color to affect to the ground and the background
  138506. */
  138507. setMainColor(color: Color3): void;
  138508. /**
  138509. * Setup the image processing according to the specified options.
  138510. */
  138511. private _setupImageProcessing;
  138512. /**
  138513. * Setup the environment texture according to the specified options.
  138514. */
  138515. private _setupEnvironmentTexture;
  138516. /**
  138517. * Setup the background according to the specified options.
  138518. */
  138519. private _setupBackground;
  138520. /**
  138521. * Get the scene sizes according to the setup.
  138522. */
  138523. private _getSceneSize;
  138524. /**
  138525. * Setup the ground according to the specified options.
  138526. */
  138527. private _setupGround;
  138528. /**
  138529. * Setup the ground material according to the specified options.
  138530. */
  138531. private _setupGroundMaterial;
  138532. /**
  138533. * Setup the ground diffuse texture according to the specified options.
  138534. */
  138535. private _setupGroundDiffuseTexture;
  138536. /**
  138537. * Setup the ground mirror texture according to the specified options.
  138538. */
  138539. private _setupGroundMirrorTexture;
  138540. /**
  138541. * Setup the ground to receive the mirror texture.
  138542. */
  138543. private _setupMirrorInGroundMaterial;
  138544. /**
  138545. * Setup the skybox according to the specified options.
  138546. */
  138547. private _setupSkybox;
  138548. /**
  138549. * Setup the skybox material according to the specified options.
  138550. */
  138551. private _setupSkyboxMaterial;
  138552. /**
  138553. * Setup the skybox reflection texture according to the specified options.
  138554. */
  138555. private _setupSkyboxReflectionTexture;
  138556. private _errorHandler;
  138557. /**
  138558. * Dispose all the elements created by the Helper.
  138559. */
  138560. dispose(): void;
  138561. }
  138562. }
  138563. declare module BABYLON {
  138564. /**
  138565. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138566. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138567. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138568. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138569. */
  138570. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138571. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138572. /**
  138573. * Define the source as a Monoscopic panoramic 360/180.
  138574. */
  138575. static readonly MODE_MONOSCOPIC: number;
  138576. /**
  138577. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138578. */
  138579. static readonly MODE_TOPBOTTOM: number;
  138580. /**
  138581. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138582. */
  138583. static readonly MODE_SIDEBYSIDE: number;
  138584. private _halfDome;
  138585. protected _useDirectMapping: boolean;
  138586. /**
  138587. * The texture being displayed on the sphere
  138588. */
  138589. protected _texture: T;
  138590. /**
  138591. * Gets the texture being displayed on the sphere
  138592. */
  138593. get texture(): T;
  138594. /**
  138595. * Sets the texture being displayed on the sphere
  138596. */
  138597. set texture(newTexture: T);
  138598. /**
  138599. * The skybox material
  138600. */
  138601. protected _material: BackgroundMaterial;
  138602. /**
  138603. * The surface used for the dome
  138604. */
  138605. protected _mesh: Mesh;
  138606. /**
  138607. * Gets the mesh used for the dome.
  138608. */
  138609. get mesh(): Mesh;
  138610. /**
  138611. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138612. */
  138613. private _halfDomeMask;
  138614. /**
  138615. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138616. * Also see the options.resolution property.
  138617. */
  138618. get fovMultiplier(): number;
  138619. set fovMultiplier(value: number);
  138620. protected _textureMode: number;
  138621. /**
  138622. * Gets or set the current texture mode for the texture. It can be:
  138623. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138624. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138625. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138626. */
  138627. get textureMode(): number;
  138628. /**
  138629. * Sets the current texture mode for the texture. It can be:
  138630. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138631. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138632. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138633. */
  138634. set textureMode(value: number);
  138635. /**
  138636. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138637. */
  138638. get halfDome(): boolean;
  138639. /**
  138640. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138641. */
  138642. set halfDome(enabled: boolean);
  138643. /**
  138644. * Oberserver used in Stereoscopic VR Mode.
  138645. */
  138646. private _onBeforeCameraRenderObserver;
  138647. /**
  138648. * Observable raised when an error occured while loading the 360 image
  138649. */
  138650. onLoadErrorObservable: Observable<string>;
  138651. /**
  138652. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  138653. * @param name Element's name, child elements will append suffixes for their own names.
  138654. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  138655. * @param options An object containing optional or exposed sub element properties
  138656. */
  138657. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  138658. resolution?: number;
  138659. clickToPlay?: boolean;
  138660. autoPlay?: boolean;
  138661. loop?: boolean;
  138662. size?: number;
  138663. poster?: string;
  138664. faceForward?: boolean;
  138665. useDirectMapping?: boolean;
  138666. halfDomeMode?: boolean;
  138667. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  138668. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  138669. protected _changeTextureMode(value: number): void;
  138670. /**
  138671. * Releases resources associated with this node.
  138672. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  138673. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  138674. */
  138675. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  138676. }
  138677. }
  138678. declare module BABYLON {
  138679. /**
  138680. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  138681. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  138682. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138683. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138684. */
  138685. export class PhotoDome extends TextureDome<Texture> {
  138686. /**
  138687. * Define the image as a Monoscopic panoramic 360 image.
  138688. */
  138689. static readonly MODE_MONOSCOPIC: number;
  138690. /**
  138691. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  138692. */
  138693. static readonly MODE_TOPBOTTOM: number;
  138694. /**
  138695. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  138696. */
  138697. static readonly MODE_SIDEBYSIDE: number;
  138698. /**
  138699. * Gets or sets the texture being displayed on the sphere
  138700. */
  138701. get photoTexture(): Texture;
  138702. /**
  138703. * sets the texture being displayed on the sphere
  138704. */
  138705. set photoTexture(value: Texture);
  138706. /**
  138707. * Gets the current video mode for the video. It can be:
  138708. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138709. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138710. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138711. */
  138712. get imageMode(): number;
  138713. /**
  138714. * Sets the current video mode for the video. It can be:
  138715. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138716. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138717. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138718. */
  138719. set imageMode(value: number);
  138720. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  138721. }
  138722. }
  138723. declare module BABYLON {
  138724. /**
  138725. * Direct draw surface info
  138726. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138727. */
  138728. export interface DDSInfo {
  138729. /**
  138730. * Width of the texture
  138731. */
  138732. width: number;
  138733. /**
  138734. * Width of the texture
  138735. */
  138736. height: number;
  138737. /**
  138738. * Number of Mipmaps for the texture
  138739. * @see https://en.wikipedia.org/wiki/Mipmap
  138740. */
  138741. mipmapCount: number;
  138742. /**
  138743. * If the textures format is a known fourCC format
  138744. * @see https://www.fourcc.org/
  138745. */
  138746. isFourCC: boolean;
  138747. /**
  138748. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138749. */
  138750. isRGB: boolean;
  138751. /**
  138752. * If the texture is a lumincance format
  138753. */
  138754. isLuminance: boolean;
  138755. /**
  138756. * If this is a cube texture
  138757. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138758. */
  138759. isCube: boolean;
  138760. /**
  138761. * If the texture is a compressed format eg. FOURCC_DXT1
  138762. */
  138763. isCompressed: boolean;
  138764. /**
  138765. * The dxgiFormat of the texture
  138766. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138767. */
  138768. dxgiFormat: number;
  138769. /**
  138770. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138771. */
  138772. textureType: number;
  138773. /**
  138774. * Sphericle polynomial created for the dds texture
  138775. */
  138776. sphericalPolynomial?: SphericalPolynomial;
  138777. }
  138778. /**
  138779. * Class used to provide DDS decompression tools
  138780. */
  138781. export class DDSTools {
  138782. /**
  138783. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138784. */
  138785. static StoreLODInAlphaChannel: boolean;
  138786. /**
  138787. * Gets DDS information from an array buffer
  138788. * @param data defines the array buffer view to read data from
  138789. * @returns the DDS information
  138790. */
  138791. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138792. private static _FloatView;
  138793. private static _Int32View;
  138794. private static _ToHalfFloat;
  138795. private static _FromHalfFloat;
  138796. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138797. private static _GetHalfFloatRGBAArrayBuffer;
  138798. private static _GetFloatRGBAArrayBuffer;
  138799. private static _GetFloatAsUIntRGBAArrayBuffer;
  138800. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138801. private static _GetRGBAArrayBuffer;
  138802. private static _ExtractLongWordOrder;
  138803. private static _GetRGBArrayBuffer;
  138804. private static _GetLuminanceArrayBuffer;
  138805. /**
  138806. * Uploads DDS Levels to a Babylon Texture
  138807. * @hidden
  138808. */
  138809. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138810. }
  138811. interface ThinEngine {
  138812. /**
  138813. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138814. * @param rootUrl defines the url where the file to load is located
  138815. * @param scene defines the current scene
  138816. * @param lodScale defines scale to apply to the mip map selection
  138817. * @param lodOffset defines offset to apply to the mip map selection
  138818. * @param onLoad defines an optional callback raised when the texture is loaded
  138819. * @param onError defines an optional callback raised if there is an issue to load the texture
  138820. * @param format defines the format of the data
  138821. * @param forcedExtension defines the extension to use to pick the right loader
  138822. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138823. * @returns the cube texture as an InternalTexture
  138824. */
  138825. 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;
  138826. }
  138827. }
  138828. declare module BABYLON {
  138829. /**
  138830. * Implementation of the DDS Texture Loader.
  138831. * @hidden
  138832. */
  138833. export class _DDSTextureLoader implements IInternalTextureLoader {
  138834. /**
  138835. * Defines wether the loader supports cascade loading the different faces.
  138836. */
  138837. readonly supportCascades: boolean;
  138838. /**
  138839. * This returns if the loader support the current file information.
  138840. * @param extension defines the file extension of the file being loaded
  138841. * @returns true if the loader can load the specified file
  138842. */
  138843. canLoad(extension: string): boolean;
  138844. /**
  138845. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138846. * @param data contains the texture data
  138847. * @param texture defines the BabylonJS internal texture
  138848. * @param createPolynomials will be true if polynomials have been requested
  138849. * @param onLoad defines the callback to trigger once the texture is ready
  138850. * @param onError defines the callback to trigger in case of error
  138851. */
  138852. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138853. /**
  138854. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138855. * @param data contains the texture data
  138856. * @param texture defines the BabylonJS internal texture
  138857. * @param callback defines the method to call once ready to upload
  138858. */
  138859. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138860. }
  138861. }
  138862. declare module BABYLON {
  138863. /**
  138864. * Implementation of the ENV Texture Loader.
  138865. * @hidden
  138866. */
  138867. export class _ENVTextureLoader implements IInternalTextureLoader {
  138868. /**
  138869. * Defines wether the loader supports cascade loading the different faces.
  138870. */
  138871. readonly supportCascades: boolean;
  138872. /**
  138873. * This returns if the loader support the current file information.
  138874. * @param extension defines the file extension of the file being loaded
  138875. * @returns true if the loader can load the specified file
  138876. */
  138877. canLoad(extension: string): boolean;
  138878. /**
  138879. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138880. * @param data contains the texture data
  138881. * @param texture defines the BabylonJS internal texture
  138882. * @param createPolynomials will be true if polynomials have been requested
  138883. * @param onLoad defines the callback to trigger once the texture is ready
  138884. * @param onError defines the callback to trigger in case of error
  138885. */
  138886. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138887. /**
  138888. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138889. * @param data contains the texture data
  138890. * @param texture defines the BabylonJS internal texture
  138891. * @param callback defines the method to call once ready to upload
  138892. */
  138893. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138894. }
  138895. }
  138896. declare module BABYLON {
  138897. /**
  138898. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138899. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138900. */
  138901. export class KhronosTextureContainer {
  138902. /** contents of the KTX container file */
  138903. data: ArrayBufferView;
  138904. private static HEADER_LEN;
  138905. private static COMPRESSED_2D;
  138906. private static COMPRESSED_3D;
  138907. private static TEX_2D;
  138908. private static TEX_3D;
  138909. /**
  138910. * Gets the openGL type
  138911. */
  138912. glType: number;
  138913. /**
  138914. * Gets the openGL type size
  138915. */
  138916. glTypeSize: number;
  138917. /**
  138918. * Gets the openGL format
  138919. */
  138920. glFormat: number;
  138921. /**
  138922. * Gets the openGL internal format
  138923. */
  138924. glInternalFormat: number;
  138925. /**
  138926. * Gets the base internal format
  138927. */
  138928. glBaseInternalFormat: number;
  138929. /**
  138930. * Gets image width in pixel
  138931. */
  138932. pixelWidth: number;
  138933. /**
  138934. * Gets image height in pixel
  138935. */
  138936. pixelHeight: number;
  138937. /**
  138938. * Gets image depth in pixels
  138939. */
  138940. pixelDepth: number;
  138941. /**
  138942. * Gets the number of array elements
  138943. */
  138944. numberOfArrayElements: number;
  138945. /**
  138946. * Gets the number of faces
  138947. */
  138948. numberOfFaces: number;
  138949. /**
  138950. * Gets the number of mipmap levels
  138951. */
  138952. numberOfMipmapLevels: number;
  138953. /**
  138954. * Gets the bytes of key value data
  138955. */
  138956. bytesOfKeyValueData: number;
  138957. /**
  138958. * Gets the load type
  138959. */
  138960. loadType: number;
  138961. /**
  138962. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138963. */
  138964. isInvalid: boolean;
  138965. /**
  138966. * Creates a new KhronosTextureContainer
  138967. * @param data contents of the KTX container file
  138968. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138969. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138970. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138971. */
  138972. constructor(
  138973. /** contents of the KTX container file */
  138974. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138975. /**
  138976. * Uploads KTX content to a Babylon Texture.
  138977. * It is assumed that the texture has already been created & is currently bound
  138978. * @hidden
  138979. */
  138980. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138981. private _upload2DCompressedLevels;
  138982. /**
  138983. * Checks if the given data starts with a KTX file identifier.
  138984. * @param data the data to check
  138985. * @returns true if the data is a KTX file or false otherwise
  138986. */
  138987. static IsValid(data: ArrayBufferView): boolean;
  138988. }
  138989. }
  138990. declare module BABYLON {
  138991. /**
  138992. * Helper class to push actions to a pool of workers.
  138993. */
  138994. export class WorkerPool implements IDisposable {
  138995. private _workerInfos;
  138996. private _pendingActions;
  138997. /**
  138998. * Constructor
  138999. * @param workers Array of workers to use for actions
  139000. */
  139001. constructor(workers: Array<Worker>);
  139002. /**
  139003. * Terminates all workers and clears any pending actions.
  139004. */
  139005. dispose(): void;
  139006. /**
  139007. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139008. * pended until a worker has completed its action.
  139009. * @param action The action to perform. Call onComplete when the action is complete.
  139010. */
  139011. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139012. private _execute;
  139013. }
  139014. }
  139015. declare module BABYLON {
  139016. /**
  139017. * Class for loading KTX2 files
  139018. */
  139019. export class KhronosTextureContainer2 {
  139020. private static _WorkerPoolPromise?;
  139021. private static _Initialized;
  139022. private static _Ktx2Decoder;
  139023. /**
  139024. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139025. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139026. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139027. * Urls you can change:
  139028. * URLConfig.jsDecoderModule
  139029. * URLConfig.wasmUASTCToASTC
  139030. * URLConfig.wasmUASTCToBC7
  139031. * URLConfig.jsMSCTranscoder
  139032. * URLConfig.wasmMSCTranscoder
  139033. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139034. */
  139035. static URLConfig: {
  139036. jsDecoderModule: string;
  139037. wasmUASTCToASTC: null;
  139038. wasmUASTCToBC7: null;
  139039. jsMSCTranscoder: null;
  139040. wasmMSCTranscoder: null;
  139041. };
  139042. /**
  139043. * Default number of workers used to handle data decoding
  139044. */
  139045. static DefaultNumWorkers: number;
  139046. private static GetDefaultNumWorkers;
  139047. private _engine;
  139048. private static _CreateWorkerPool;
  139049. /**
  139050. * Constructor
  139051. * @param engine The engine to use
  139052. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139053. */
  139054. constructor(engine: ThinEngine, numWorkers?: number);
  139055. /** @hidden */
  139056. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  139057. /**
  139058. * Stop all async operations and release resources.
  139059. */
  139060. dispose(): void;
  139061. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139062. /**
  139063. * Checks if the given data starts with a KTX2 file identifier.
  139064. * @param data the data to check
  139065. * @returns true if the data is a KTX2 file or false otherwise
  139066. */
  139067. static IsValid(data: ArrayBufferView): boolean;
  139068. }
  139069. }
  139070. declare module BABYLON {
  139071. /**
  139072. * Implementation of the KTX Texture Loader.
  139073. * @hidden
  139074. */
  139075. export class _KTXTextureLoader implements IInternalTextureLoader {
  139076. /**
  139077. * Defines wether the loader supports cascade loading the different faces.
  139078. */
  139079. readonly supportCascades: boolean;
  139080. /**
  139081. * This returns if the loader support the current file information.
  139082. * @param extension defines the file extension of the file being loaded
  139083. * @param mimeType defines the optional mime type of the file being loaded
  139084. * @returns true if the loader can load the specified file
  139085. */
  139086. canLoad(extension: string, mimeType?: string): boolean;
  139087. /**
  139088. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139089. * @param data contains the texture data
  139090. * @param texture defines the BabylonJS internal texture
  139091. * @param createPolynomials will be true if polynomials have been requested
  139092. * @param onLoad defines the callback to trigger once the texture is ready
  139093. * @param onError defines the callback to trigger in case of error
  139094. */
  139095. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139096. /**
  139097. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139098. * @param data contains the texture data
  139099. * @param texture defines the BabylonJS internal texture
  139100. * @param callback defines the method to call once ready to upload
  139101. */
  139102. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  139103. }
  139104. }
  139105. declare module BABYLON {
  139106. /** @hidden */
  139107. export var _forceSceneHelpersToBundle: boolean;
  139108. interface Scene {
  139109. /**
  139110. * Creates a default light for the scene.
  139111. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139112. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139113. */
  139114. createDefaultLight(replace?: boolean): void;
  139115. /**
  139116. * Creates a default camera for the scene.
  139117. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139118. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139119. * @param replace has default false, when true replaces the active camera in the scene
  139120. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139121. */
  139122. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139123. /**
  139124. * Creates a default camera and a default light.
  139125. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139126. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139127. * @param replace has the default false, when true replaces the active camera/light in the scene
  139128. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139129. */
  139130. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139131. /**
  139132. * Creates a new sky box
  139133. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139134. * @param environmentTexture defines the texture to use as environment texture
  139135. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139136. * @param scale defines the overall scale of the skybox
  139137. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139138. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139139. * @returns a new mesh holding the sky box
  139140. */
  139141. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139142. /**
  139143. * Creates a new environment
  139144. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139145. * @param options defines the options you can use to configure the environment
  139146. * @returns the new EnvironmentHelper
  139147. */
  139148. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139149. /**
  139150. * Creates a new VREXperienceHelper
  139151. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139152. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139153. * @returns a new VREXperienceHelper
  139154. */
  139155. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139156. /**
  139157. * Creates a new WebXRDefaultExperience
  139158. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139159. * @param options experience options
  139160. * @returns a promise for a new WebXRDefaultExperience
  139161. */
  139162. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139163. }
  139164. }
  139165. declare module BABYLON {
  139166. /**
  139167. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139168. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139169. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139170. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139171. */
  139172. export class VideoDome extends TextureDome<VideoTexture> {
  139173. /**
  139174. * Define the video source as a Monoscopic panoramic 360 video.
  139175. */
  139176. static readonly MODE_MONOSCOPIC: number;
  139177. /**
  139178. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139179. */
  139180. static readonly MODE_TOPBOTTOM: number;
  139181. /**
  139182. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139183. */
  139184. static readonly MODE_SIDEBYSIDE: number;
  139185. /**
  139186. * Get the video texture associated with this video dome
  139187. */
  139188. get videoTexture(): VideoTexture;
  139189. /**
  139190. * Get the video mode of this dome
  139191. */
  139192. get videoMode(): number;
  139193. /**
  139194. * Set the video mode of this dome.
  139195. * @see textureMode
  139196. */
  139197. set videoMode(value: number);
  139198. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139199. }
  139200. }
  139201. declare module BABYLON {
  139202. /**
  139203. * This class can be used to get instrumentation data from a Babylon engine
  139204. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139205. */
  139206. export class EngineInstrumentation implements IDisposable {
  139207. /**
  139208. * Define the instrumented engine.
  139209. */
  139210. engine: Engine;
  139211. private _captureGPUFrameTime;
  139212. private _gpuFrameTimeToken;
  139213. private _gpuFrameTime;
  139214. private _captureShaderCompilationTime;
  139215. private _shaderCompilationTime;
  139216. private _onBeginFrameObserver;
  139217. private _onEndFrameObserver;
  139218. private _onBeforeShaderCompilationObserver;
  139219. private _onAfterShaderCompilationObserver;
  139220. /**
  139221. * Gets the perf counter used for GPU frame time
  139222. */
  139223. get gpuFrameTimeCounter(): PerfCounter;
  139224. /**
  139225. * Gets the GPU frame time capture status
  139226. */
  139227. get captureGPUFrameTime(): boolean;
  139228. /**
  139229. * Enable or disable the GPU frame time capture
  139230. */
  139231. set captureGPUFrameTime(value: boolean);
  139232. /**
  139233. * Gets the perf counter used for shader compilation time
  139234. */
  139235. get shaderCompilationTimeCounter(): PerfCounter;
  139236. /**
  139237. * Gets the shader compilation time capture status
  139238. */
  139239. get captureShaderCompilationTime(): boolean;
  139240. /**
  139241. * Enable or disable the shader compilation time capture
  139242. */
  139243. set captureShaderCompilationTime(value: boolean);
  139244. /**
  139245. * Instantiates a new engine instrumentation.
  139246. * This class can be used to get instrumentation data from a Babylon engine
  139247. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139248. * @param engine Defines the engine to instrument
  139249. */
  139250. constructor(
  139251. /**
  139252. * Define the instrumented engine.
  139253. */
  139254. engine: Engine);
  139255. /**
  139256. * Dispose and release associated resources.
  139257. */
  139258. dispose(): void;
  139259. }
  139260. }
  139261. declare module BABYLON {
  139262. /**
  139263. * This class can be used to get instrumentation data from a Babylon engine
  139264. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139265. */
  139266. export class SceneInstrumentation implements IDisposable {
  139267. /**
  139268. * Defines the scene to instrument
  139269. */
  139270. scene: Scene;
  139271. private _captureActiveMeshesEvaluationTime;
  139272. private _activeMeshesEvaluationTime;
  139273. private _captureRenderTargetsRenderTime;
  139274. private _renderTargetsRenderTime;
  139275. private _captureFrameTime;
  139276. private _frameTime;
  139277. private _captureRenderTime;
  139278. private _renderTime;
  139279. private _captureInterFrameTime;
  139280. private _interFrameTime;
  139281. private _captureParticlesRenderTime;
  139282. private _particlesRenderTime;
  139283. private _captureSpritesRenderTime;
  139284. private _spritesRenderTime;
  139285. private _capturePhysicsTime;
  139286. private _physicsTime;
  139287. private _captureAnimationsTime;
  139288. private _animationsTime;
  139289. private _captureCameraRenderTime;
  139290. private _cameraRenderTime;
  139291. private _onBeforeActiveMeshesEvaluationObserver;
  139292. private _onAfterActiveMeshesEvaluationObserver;
  139293. private _onBeforeRenderTargetsRenderObserver;
  139294. private _onAfterRenderTargetsRenderObserver;
  139295. private _onAfterRenderObserver;
  139296. private _onBeforeDrawPhaseObserver;
  139297. private _onAfterDrawPhaseObserver;
  139298. private _onBeforeAnimationsObserver;
  139299. private _onBeforeParticlesRenderingObserver;
  139300. private _onAfterParticlesRenderingObserver;
  139301. private _onBeforeSpritesRenderingObserver;
  139302. private _onAfterSpritesRenderingObserver;
  139303. private _onBeforePhysicsObserver;
  139304. private _onAfterPhysicsObserver;
  139305. private _onAfterAnimationsObserver;
  139306. private _onBeforeCameraRenderObserver;
  139307. private _onAfterCameraRenderObserver;
  139308. /**
  139309. * Gets the perf counter used for active meshes evaluation time
  139310. */
  139311. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139312. /**
  139313. * Gets the active meshes evaluation time capture status
  139314. */
  139315. get captureActiveMeshesEvaluationTime(): boolean;
  139316. /**
  139317. * Enable or disable the active meshes evaluation time capture
  139318. */
  139319. set captureActiveMeshesEvaluationTime(value: boolean);
  139320. /**
  139321. * Gets the perf counter used for render targets render time
  139322. */
  139323. get renderTargetsRenderTimeCounter(): PerfCounter;
  139324. /**
  139325. * Gets the render targets render time capture status
  139326. */
  139327. get captureRenderTargetsRenderTime(): boolean;
  139328. /**
  139329. * Enable or disable the render targets render time capture
  139330. */
  139331. set captureRenderTargetsRenderTime(value: boolean);
  139332. /**
  139333. * Gets the perf counter used for particles render time
  139334. */
  139335. get particlesRenderTimeCounter(): PerfCounter;
  139336. /**
  139337. * Gets the particles render time capture status
  139338. */
  139339. get captureParticlesRenderTime(): boolean;
  139340. /**
  139341. * Enable or disable the particles render time capture
  139342. */
  139343. set captureParticlesRenderTime(value: boolean);
  139344. /**
  139345. * Gets the perf counter used for sprites render time
  139346. */
  139347. get spritesRenderTimeCounter(): PerfCounter;
  139348. /**
  139349. * Gets the sprites render time capture status
  139350. */
  139351. get captureSpritesRenderTime(): boolean;
  139352. /**
  139353. * Enable or disable the sprites render time capture
  139354. */
  139355. set captureSpritesRenderTime(value: boolean);
  139356. /**
  139357. * Gets the perf counter used for physics time
  139358. */
  139359. get physicsTimeCounter(): PerfCounter;
  139360. /**
  139361. * Gets the physics time capture status
  139362. */
  139363. get capturePhysicsTime(): boolean;
  139364. /**
  139365. * Enable or disable the physics time capture
  139366. */
  139367. set capturePhysicsTime(value: boolean);
  139368. /**
  139369. * Gets the perf counter used for animations time
  139370. */
  139371. get animationsTimeCounter(): PerfCounter;
  139372. /**
  139373. * Gets the animations time capture status
  139374. */
  139375. get captureAnimationsTime(): boolean;
  139376. /**
  139377. * Enable or disable the animations time capture
  139378. */
  139379. set captureAnimationsTime(value: boolean);
  139380. /**
  139381. * Gets the perf counter used for frame time capture
  139382. */
  139383. get frameTimeCounter(): PerfCounter;
  139384. /**
  139385. * Gets the frame time capture status
  139386. */
  139387. get captureFrameTime(): boolean;
  139388. /**
  139389. * Enable or disable the frame time capture
  139390. */
  139391. set captureFrameTime(value: boolean);
  139392. /**
  139393. * Gets the perf counter used for inter-frames time capture
  139394. */
  139395. get interFrameTimeCounter(): PerfCounter;
  139396. /**
  139397. * Gets the inter-frames time capture status
  139398. */
  139399. get captureInterFrameTime(): boolean;
  139400. /**
  139401. * Enable or disable the inter-frames time capture
  139402. */
  139403. set captureInterFrameTime(value: boolean);
  139404. /**
  139405. * Gets the perf counter used for render time capture
  139406. */
  139407. get renderTimeCounter(): PerfCounter;
  139408. /**
  139409. * Gets the render time capture status
  139410. */
  139411. get captureRenderTime(): boolean;
  139412. /**
  139413. * Enable or disable the render time capture
  139414. */
  139415. set captureRenderTime(value: boolean);
  139416. /**
  139417. * Gets the perf counter used for camera render time capture
  139418. */
  139419. get cameraRenderTimeCounter(): PerfCounter;
  139420. /**
  139421. * Gets the camera render time capture status
  139422. */
  139423. get captureCameraRenderTime(): boolean;
  139424. /**
  139425. * Enable or disable the camera render time capture
  139426. */
  139427. set captureCameraRenderTime(value: boolean);
  139428. /**
  139429. * Gets the perf counter used for draw calls
  139430. */
  139431. get drawCallsCounter(): PerfCounter;
  139432. /**
  139433. * Instantiates a new scene instrumentation.
  139434. * This class can be used to get instrumentation data from a Babylon engine
  139435. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139436. * @param scene Defines the scene to instrument
  139437. */
  139438. constructor(
  139439. /**
  139440. * Defines the scene to instrument
  139441. */
  139442. scene: Scene);
  139443. /**
  139444. * Dispose and release associated resources.
  139445. */
  139446. dispose(): void;
  139447. }
  139448. }
  139449. declare module BABYLON {
  139450. /** @hidden */
  139451. export var glowMapGenerationPixelShader: {
  139452. name: string;
  139453. shader: string;
  139454. };
  139455. }
  139456. declare module BABYLON {
  139457. /** @hidden */
  139458. export var glowMapGenerationVertexShader: {
  139459. name: string;
  139460. shader: string;
  139461. };
  139462. }
  139463. declare module BABYLON {
  139464. /**
  139465. * Effect layer options. This helps customizing the behaviour
  139466. * of the effect layer.
  139467. */
  139468. export interface IEffectLayerOptions {
  139469. /**
  139470. * Multiplication factor apply to the canvas size to compute the render target size
  139471. * used to generated the objects (the smaller the faster).
  139472. */
  139473. mainTextureRatio: number;
  139474. /**
  139475. * Enforces a fixed size texture to ensure effect stability across devices.
  139476. */
  139477. mainTextureFixedSize?: number;
  139478. /**
  139479. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139480. */
  139481. alphaBlendingMode: number;
  139482. /**
  139483. * The camera attached to the layer.
  139484. */
  139485. camera: Nullable<Camera>;
  139486. /**
  139487. * The rendering group to draw the layer in.
  139488. */
  139489. renderingGroupId: number;
  139490. }
  139491. /**
  139492. * The effect layer Helps adding post process effect blended with the main pass.
  139493. *
  139494. * This can be for instance use to generate glow or higlight effects on the scene.
  139495. *
  139496. * The effect layer class can not be used directly and is intented to inherited from to be
  139497. * customized per effects.
  139498. */
  139499. export abstract class EffectLayer {
  139500. private _vertexBuffers;
  139501. private _indexBuffer;
  139502. private _cachedDefines;
  139503. private _effectLayerMapGenerationEffect;
  139504. private _effectLayerOptions;
  139505. private _mergeEffect;
  139506. protected _scene: Scene;
  139507. protected _engine: Engine;
  139508. protected _maxSize: number;
  139509. protected _mainTextureDesiredSize: ISize;
  139510. protected _mainTexture: RenderTargetTexture;
  139511. protected _shouldRender: boolean;
  139512. protected _postProcesses: PostProcess[];
  139513. protected _textures: BaseTexture[];
  139514. protected _emissiveTextureAndColor: {
  139515. texture: Nullable<BaseTexture>;
  139516. color: Color4;
  139517. };
  139518. /**
  139519. * The name of the layer
  139520. */
  139521. name: string;
  139522. /**
  139523. * The clear color of the texture used to generate the glow map.
  139524. */
  139525. neutralColor: Color4;
  139526. /**
  139527. * Specifies whether the highlight layer is enabled or not.
  139528. */
  139529. isEnabled: boolean;
  139530. /**
  139531. * Gets the camera attached to the layer.
  139532. */
  139533. get camera(): Nullable<Camera>;
  139534. /**
  139535. * Gets the rendering group id the layer should render in.
  139536. */
  139537. get renderingGroupId(): number;
  139538. set renderingGroupId(renderingGroupId: number);
  139539. /**
  139540. * An event triggered when the effect layer has been disposed.
  139541. */
  139542. onDisposeObservable: Observable<EffectLayer>;
  139543. /**
  139544. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139545. */
  139546. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139547. /**
  139548. * An event triggered when the generated texture is being merged in the scene.
  139549. */
  139550. onBeforeComposeObservable: Observable<EffectLayer>;
  139551. /**
  139552. * An event triggered when the mesh is rendered into the effect render target.
  139553. */
  139554. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139555. /**
  139556. * An event triggered after the mesh has been rendered into the effect render target.
  139557. */
  139558. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139559. /**
  139560. * An event triggered when the generated texture has been merged in the scene.
  139561. */
  139562. onAfterComposeObservable: Observable<EffectLayer>;
  139563. /**
  139564. * An event triggered when the efffect layer changes its size.
  139565. */
  139566. onSizeChangedObservable: Observable<EffectLayer>;
  139567. /** @hidden */
  139568. static _SceneComponentInitialization: (scene: Scene) => void;
  139569. /**
  139570. * Instantiates a new effect Layer and references it in the scene.
  139571. * @param name The name of the layer
  139572. * @param scene The scene to use the layer in
  139573. */
  139574. constructor(
  139575. /** The Friendly of the effect in the scene */
  139576. name: string, scene: Scene);
  139577. /**
  139578. * Get the effect name of the layer.
  139579. * @return The effect name
  139580. */
  139581. abstract getEffectName(): string;
  139582. /**
  139583. * Checks for the readiness of the element composing the layer.
  139584. * @param subMesh the mesh to check for
  139585. * @param useInstances specify whether or not to use instances to render the mesh
  139586. * @return true if ready otherwise, false
  139587. */
  139588. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139589. /**
  139590. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139591. * @returns true if the effect requires stencil during the main canvas render pass.
  139592. */
  139593. abstract needStencil(): boolean;
  139594. /**
  139595. * Create the merge effect. This is the shader use to blit the information back
  139596. * to the main canvas at the end of the scene rendering.
  139597. * @returns The effect containing the shader used to merge the effect on the main canvas
  139598. */
  139599. protected abstract _createMergeEffect(): Effect;
  139600. /**
  139601. * Creates the render target textures and post processes used in the effect layer.
  139602. */
  139603. protected abstract _createTextureAndPostProcesses(): void;
  139604. /**
  139605. * Implementation specific of rendering the generating effect on the main canvas.
  139606. * @param effect The effect used to render through
  139607. */
  139608. protected abstract _internalRender(effect: Effect): void;
  139609. /**
  139610. * Sets the required values for both the emissive texture and and the main color.
  139611. */
  139612. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139613. /**
  139614. * Free any resources and references associated to a mesh.
  139615. * Internal use
  139616. * @param mesh The mesh to free.
  139617. */
  139618. abstract _disposeMesh(mesh: Mesh): void;
  139619. /**
  139620. * Serializes this layer (Glow or Highlight for example)
  139621. * @returns a serialized layer object
  139622. */
  139623. abstract serialize?(): any;
  139624. /**
  139625. * Initializes the effect layer with the required options.
  139626. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139627. */
  139628. protected _init(options: Partial<IEffectLayerOptions>): void;
  139629. /**
  139630. * Generates the index buffer of the full screen quad blending to the main canvas.
  139631. */
  139632. private _generateIndexBuffer;
  139633. /**
  139634. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139635. */
  139636. private _generateVertexBuffer;
  139637. /**
  139638. * Sets the main texture desired size which is the closest power of two
  139639. * of the engine canvas size.
  139640. */
  139641. private _setMainTextureSize;
  139642. /**
  139643. * Creates the main texture for the effect layer.
  139644. */
  139645. protected _createMainTexture(): void;
  139646. /**
  139647. * Adds specific effects defines.
  139648. * @param defines The defines to add specifics to.
  139649. */
  139650. protected _addCustomEffectDefines(defines: string[]): void;
  139651. /**
  139652. * Checks for the readiness of the element composing the layer.
  139653. * @param subMesh the mesh to check for
  139654. * @param useInstances specify whether or not to use instances to render the mesh
  139655. * @param emissiveTexture the associated emissive texture used to generate the glow
  139656. * @return true if ready otherwise, false
  139657. */
  139658. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139659. /**
  139660. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139661. */
  139662. render(): void;
  139663. /**
  139664. * Determine if a given mesh will be used in the current effect.
  139665. * @param mesh mesh to test
  139666. * @returns true if the mesh will be used
  139667. */
  139668. hasMesh(mesh: AbstractMesh): boolean;
  139669. /**
  139670. * Returns true if the layer contains information to display, otherwise false.
  139671. * @returns true if the glow layer should be rendered
  139672. */
  139673. shouldRender(): boolean;
  139674. /**
  139675. * Returns true if the mesh should render, otherwise false.
  139676. * @param mesh The mesh to render
  139677. * @returns true if it should render otherwise false
  139678. */
  139679. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139680. /**
  139681. * Returns true if the mesh can be rendered, otherwise false.
  139682. * @param mesh The mesh to render
  139683. * @param material The material used on the mesh
  139684. * @returns true if it can be rendered otherwise false
  139685. */
  139686. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139687. /**
  139688. * Returns true if the mesh should render, otherwise false.
  139689. * @param mesh The mesh to render
  139690. * @returns true if it should render otherwise false
  139691. */
  139692. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139693. /**
  139694. * Renders the submesh passed in parameter to the generation map.
  139695. */
  139696. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139697. /**
  139698. * Defines whether the current material of the mesh should be use to render the effect.
  139699. * @param mesh defines the current mesh to render
  139700. */
  139701. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139702. /**
  139703. * Rebuild the required buffers.
  139704. * @hidden Internal use only.
  139705. */
  139706. _rebuild(): void;
  139707. /**
  139708. * Dispose only the render target textures and post process.
  139709. */
  139710. private _disposeTextureAndPostProcesses;
  139711. /**
  139712. * Dispose the highlight layer and free resources.
  139713. */
  139714. dispose(): void;
  139715. /**
  139716. * Gets the class name of the effect layer
  139717. * @returns the string with the class name of the effect layer
  139718. */
  139719. getClassName(): string;
  139720. /**
  139721. * Creates an effect layer from parsed effect layer data
  139722. * @param parsedEffectLayer defines effect layer data
  139723. * @param scene defines the current scene
  139724. * @param rootUrl defines the root URL containing the effect layer information
  139725. * @returns a parsed effect Layer
  139726. */
  139727. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139728. }
  139729. }
  139730. declare module BABYLON {
  139731. interface AbstractScene {
  139732. /**
  139733. * The list of effect layers (highlights/glow) added to the scene
  139734. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139735. * @see https://doc.babylonjs.com/how_to/glow_layer
  139736. */
  139737. effectLayers: Array<EffectLayer>;
  139738. /**
  139739. * Removes the given effect layer from this scene.
  139740. * @param toRemove defines the effect layer to remove
  139741. * @returns the index of the removed effect layer
  139742. */
  139743. removeEffectLayer(toRemove: EffectLayer): number;
  139744. /**
  139745. * Adds the given effect layer to this scene
  139746. * @param newEffectLayer defines the effect layer to add
  139747. */
  139748. addEffectLayer(newEffectLayer: EffectLayer): void;
  139749. }
  139750. /**
  139751. * Defines the layer scene component responsible to manage any effect layers
  139752. * in a given scene.
  139753. */
  139754. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139755. /**
  139756. * The component name helpfull to identify the component in the list of scene components.
  139757. */
  139758. readonly name: string;
  139759. /**
  139760. * The scene the component belongs to.
  139761. */
  139762. scene: Scene;
  139763. private _engine;
  139764. private _renderEffects;
  139765. private _needStencil;
  139766. private _previousStencilState;
  139767. /**
  139768. * Creates a new instance of the component for the given scene
  139769. * @param scene Defines the scene to register the component in
  139770. */
  139771. constructor(scene: Scene);
  139772. /**
  139773. * Registers the component in a given scene
  139774. */
  139775. register(): void;
  139776. /**
  139777. * Rebuilds the elements related to this component in case of
  139778. * context lost for instance.
  139779. */
  139780. rebuild(): void;
  139781. /**
  139782. * Serializes the component data to the specified json object
  139783. * @param serializationObject The object to serialize to
  139784. */
  139785. serialize(serializationObject: any): void;
  139786. /**
  139787. * Adds all the elements from the container to the scene
  139788. * @param container the container holding the elements
  139789. */
  139790. addFromContainer(container: AbstractScene): void;
  139791. /**
  139792. * Removes all the elements in the container from the scene
  139793. * @param container contains the elements to remove
  139794. * @param dispose if the removed element should be disposed (default: false)
  139795. */
  139796. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139797. /**
  139798. * Disposes the component and the associated ressources.
  139799. */
  139800. dispose(): void;
  139801. private _isReadyForMesh;
  139802. private _renderMainTexture;
  139803. private _setStencil;
  139804. private _setStencilBack;
  139805. private _draw;
  139806. private _drawCamera;
  139807. private _drawRenderingGroup;
  139808. }
  139809. }
  139810. declare module BABYLON {
  139811. /** @hidden */
  139812. export var glowMapMergePixelShader: {
  139813. name: string;
  139814. shader: string;
  139815. };
  139816. }
  139817. declare module BABYLON {
  139818. /** @hidden */
  139819. export var glowMapMergeVertexShader: {
  139820. name: string;
  139821. shader: string;
  139822. };
  139823. }
  139824. declare module BABYLON {
  139825. interface AbstractScene {
  139826. /**
  139827. * Return a the first highlight layer of the scene with a given name.
  139828. * @param name The name of the highlight layer to look for.
  139829. * @return The highlight layer if found otherwise null.
  139830. */
  139831. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139832. }
  139833. /**
  139834. * Glow layer options. This helps customizing the behaviour
  139835. * of the glow layer.
  139836. */
  139837. export interface IGlowLayerOptions {
  139838. /**
  139839. * Multiplication factor apply to the canvas size to compute the render target size
  139840. * used to generated the glowing objects (the smaller the faster).
  139841. */
  139842. mainTextureRatio: number;
  139843. /**
  139844. * Enforces a fixed size texture to ensure resize independant blur.
  139845. */
  139846. mainTextureFixedSize?: number;
  139847. /**
  139848. * How big is the kernel of the blur texture.
  139849. */
  139850. blurKernelSize: number;
  139851. /**
  139852. * The camera attached to the layer.
  139853. */
  139854. camera: Nullable<Camera>;
  139855. /**
  139856. * Enable MSAA by chosing the number of samples.
  139857. */
  139858. mainTextureSamples?: number;
  139859. /**
  139860. * The rendering group to draw the layer in.
  139861. */
  139862. renderingGroupId: number;
  139863. }
  139864. /**
  139865. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139866. *
  139867. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139868. *
  139869. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139870. */
  139871. export class GlowLayer extends EffectLayer {
  139872. /**
  139873. * Effect Name of the layer.
  139874. */
  139875. static readonly EffectName: string;
  139876. /**
  139877. * The default blur kernel size used for the glow.
  139878. */
  139879. static DefaultBlurKernelSize: number;
  139880. /**
  139881. * The default texture size ratio used for the glow.
  139882. */
  139883. static DefaultTextureRatio: number;
  139884. /**
  139885. * Sets the kernel size of the blur.
  139886. */
  139887. set blurKernelSize(value: number);
  139888. /**
  139889. * Gets the kernel size of the blur.
  139890. */
  139891. get blurKernelSize(): number;
  139892. /**
  139893. * Sets the glow intensity.
  139894. */
  139895. set intensity(value: number);
  139896. /**
  139897. * Gets the glow intensity.
  139898. */
  139899. get intensity(): number;
  139900. private _options;
  139901. private _intensity;
  139902. private _horizontalBlurPostprocess1;
  139903. private _verticalBlurPostprocess1;
  139904. private _horizontalBlurPostprocess2;
  139905. private _verticalBlurPostprocess2;
  139906. private _blurTexture1;
  139907. private _blurTexture2;
  139908. private _postProcesses1;
  139909. private _postProcesses2;
  139910. private _includedOnlyMeshes;
  139911. private _excludedMeshes;
  139912. private _meshesUsingTheirOwnMaterials;
  139913. /**
  139914. * Callback used to let the user override the color selection on a per mesh basis
  139915. */
  139916. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139917. /**
  139918. * Callback used to let the user override the texture selection on a per mesh basis
  139919. */
  139920. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139921. /**
  139922. * Instantiates a new glow Layer and references it to the scene.
  139923. * @param name The name of the layer
  139924. * @param scene The scene to use the layer in
  139925. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139926. */
  139927. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139928. /**
  139929. * Get the effect name of the layer.
  139930. * @return The effect name
  139931. */
  139932. getEffectName(): string;
  139933. /**
  139934. * Create the merge effect. This is the shader use to blit the information back
  139935. * to the main canvas at the end of the scene rendering.
  139936. */
  139937. protected _createMergeEffect(): Effect;
  139938. /**
  139939. * Creates the render target textures and post processes used in the glow layer.
  139940. */
  139941. protected _createTextureAndPostProcesses(): void;
  139942. /**
  139943. * Checks for the readiness of the element composing the layer.
  139944. * @param subMesh the mesh to check for
  139945. * @param useInstances specify wether or not to use instances to render the mesh
  139946. * @param emissiveTexture the associated emissive texture used to generate the glow
  139947. * @return true if ready otherwise, false
  139948. */
  139949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139950. /**
  139951. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139952. */
  139953. needStencil(): boolean;
  139954. /**
  139955. * Returns true if the mesh can be rendered, otherwise false.
  139956. * @param mesh The mesh to render
  139957. * @param material The material used on the mesh
  139958. * @returns true if it can be rendered otherwise false
  139959. */
  139960. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139961. /**
  139962. * Implementation specific of rendering the generating effect on the main canvas.
  139963. * @param effect The effect used to render through
  139964. */
  139965. protected _internalRender(effect: Effect): void;
  139966. /**
  139967. * Sets the required values for both the emissive texture and and the main color.
  139968. */
  139969. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139970. /**
  139971. * Returns true if the mesh should render, otherwise false.
  139972. * @param mesh The mesh to render
  139973. * @returns true if it should render otherwise false
  139974. */
  139975. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139976. /**
  139977. * Adds specific effects defines.
  139978. * @param defines The defines to add specifics to.
  139979. */
  139980. protected _addCustomEffectDefines(defines: string[]): void;
  139981. /**
  139982. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139983. * @param mesh The mesh to exclude from the glow layer
  139984. */
  139985. addExcludedMesh(mesh: Mesh): void;
  139986. /**
  139987. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139988. * @param mesh The mesh to remove
  139989. */
  139990. removeExcludedMesh(mesh: Mesh): void;
  139991. /**
  139992. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139993. * @param mesh The mesh to include in the glow layer
  139994. */
  139995. addIncludedOnlyMesh(mesh: Mesh): void;
  139996. /**
  139997. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139998. * @param mesh The mesh to remove
  139999. */
  140000. removeIncludedOnlyMesh(mesh: Mesh): void;
  140001. /**
  140002. * Determine if a given mesh will be used in the glow layer
  140003. * @param mesh The mesh to test
  140004. * @returns true if the mesh will be highlighted by the current glow layer
  140005. */
  140006. hasMesh(mesh: AbstractMesh): boolean;
  140007. /**
  140008. * Defines whether the current material of the mesh should be use to render the effect.
  140009. * @param mesh defines the current mesh to render
  140010. */
  140011. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140012. /**
  140013. * Add a mesh to be rendered through its own material and not with emissive only.
  140014. * @param mesh The mesh for which we need to use its material
  140015. */
  140016. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140017. /**
  140018. * Remove a mesh from being rendered through its own material and not with emissive only.
  140019. * @param mesh The mesh for which we need to not use its material
  140020. */
  140021. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140022. /**
  140023. * Free any resources and references associated to a mesh.
  140024. * Internal use
  140025. * @param mesh The mesh to free.
  140026. * @hidden
  140027. */
  140028. _disposeMesh(mesh: Mesh): void;
  140029. /**
  140030. * Gets the class name of the effect layer
  140031. * @returns the string with the class name of the effect layer
  140032. */
  140033. getClassName(): string;
  140034. /**
  140035. * Serializes this glow layer
  140036. * @returns a serialized glow layer object
  140037. */
  140038. serialize(): any;
  140039. /**
  140040. * Creates a Glow Layer from parsed glow layer data
  140041. * @param parsedGlowLayer defines glow layer data
  140042. * @param scene defines the current scene
  140043. * @param rootUrl defines the root URL containing the glow layer information
  140044. * @returns a parsed Glow Layer
  140045. */
  140046. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140047. }
  140048. }
  140049. declare module BABYLON {
  140050. /** @hidden */
  140051. export var glowBlurPostProcessPixelShader: {
  140052. name: string;
  140053. shader: string;
  140054. };
  140055. }
  140056. declare module BABYLON {
  140057. interface AbstractScene {
  140058. /**
  140059. * Return a the first highlight layer of the scene with a given name.
  140060. * @param name The name of the highlight layer to look for.
  140061. * @return The highlight layer if found otherwise null.
  140062. */
  140063. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140064. }
  140065. /**
  140066. * Highlight layer options. This helps customizing the behaviour
  140067. * of the highlight layer.
  140068. */
  140069. export interface IHighlightLayerOptions {
  140070. /**
  140071. * Multiplication factor apply to the canvas size to compute the render target size
  140072. * used to generated the glowing objects (the smaller the faster).
  140073. */
  140074. mainTextureRatio: number;
  140075. /**
  140076. * Enforces a fixed size texture to ensure resize independant blur.
  140077. */
  140078. mainTextureFixedSize?: number;
  140079. /**
  140080. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140081. * of the picture to blur (the smaller the faster).
  140082. */
  140083. blurTextureSizeRatio: number;
  140084. /**
  140085. * How big in texel of the blur texture is the vertical blur.
  140086. */
  140087. blurVerticalSize: number;
  140088. /**
  140089. * How big in texel of the blur texture is the horizontal blur.
  140090. */
  140091. blurHorizontalSize: number;
  140092. /**
  140093. * Alpha blending mode used to apply the blur. Default is combine.
  140094. */
  140095. alphaBlendingMode: number;
  140096. /**
  140097. * The camera attached to the layer.
  140098. */
  140099. camera: Nullable<Camera>;
  140100. /**
  140101. * Should we display highlight as a solid stroke?
  140102. */
  140103. isStroke?: boolean;
  140104. /**
  140105. * The rendering group to draw the layer in.
  140106. */
  140107. renderingGroupId: number;
  140108. }
  140109. /**
  140110. * The highlight layer Helps adding a glow effect around a mesh.
  140111. *
  140112. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140113. * glowy meshes to your scene.
  140114. *
  140115. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140116. */
  140117. export class HighlightLayer extends EffectLayer {
  140118. name: string;
  140119. /**
  140120. * Effect Name of the highlight layer.
  140121. */
  140122. static readonly EffectName: string;
  140123. /**
  140124. * The neutral color used during the preparation of the glow effect.
  140125. * This is black by default as the blend operation is a blend operation.
  140126. */
  140127. static NeutralColor: Color4;
  140128. /**
  140129. * Stencil value used for glowing meshes.
  140130. */
  140131. static GlowingMeshStencilReference: number;
  140132. /**
  140133. * Stencil value used for the other meshes in the scene.
  140134. */
  140135. static NormalMeshStencilReference: number;
  140136. /**
  140137. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140138. */
  140139. innerGlow: boolean;
  140140. /**
  140141. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140142. */
  140143. outerGlow: boolean;
  140144. /**
  140145. * Specifies the horizontal size of the blur.
  140146. */
  140147. set blurHorizontalSize(value: number);
  140148. /**
  140149. * Specifies the vertical size of the blur.
  140150. */
  140151. set blurVerticalSize(value: number);
  140152. /**
  140153. * Gets the horizontal size of the blur.
  140154. */
  140155. get blurHorizontalSize(): number;
  140156. /**
  140157. * Gets the vertical size of the blur.
  140158. */
  140159. get blurVerticalSize(): number;
  140160. /**
  140161. * An event triggered when the highlight layer is being blurred.
  140162. */
  140163. onBeforeBlurObservable: Observable<HighlightLayer>;
  140164. /**
  140165. * An event triggered when the highlight layer has been blurred.
  140166. */
  140167. onAfterBlurObservable: Observable<HighlightLayer>;
  140168. private _instanceGlowingMeshStencilReference;
  140169. private _options;
  140170. private _downSamplePostprocess;
  140171. private _horizontalBlurPostprocess;
  140172. private _verticalBlurPostprocess;
  140173. private _blurTexture;
  140174. private _meshes;
  140175. private _excludedMeshes;
  140176. /**
  140177. * Instantiates a new highlight Layer and references it to the scene..
  140178. * @param name The name of the layer
  140179. * @param scene The scene to use the layer in
  140180. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140181. */
  140182. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140183. /**
  140184. * Get the effect name of the layer.
  140185. * @return The effect name
  140186. */
  140187. getEffectName(): string;
  140188. /**
  140189. * Create the merge effect. This is the shader use to blit the information back
  140190. * to the main canvas at the end of the scene rendering.
  140191. */
  140192. protected _createMergeEffect(): Effect;
  140193. /**
  140194. * Creates the render target textures and post processes used in the highlight layer.
  140195. */
  140196. protected _createTextureAndPostProcesses(): void;
  140197. /**
  140198. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140199. */
  140200. needStencil(): boolean;
  140201. /**
  140202. * Checks for the readiness of the element composing the layer.
  140203. * @param subMesh the mesh to check for
  140204. * @param useInstances specify wether or not to use instances to render the mesh
  140205. * @param emissiveTexture the associated emissive texture used to generate the glow
  140206. * @return true if ready otherwise, false
  140207. */
  140208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140209. /**
  140210. * Implementation specific of rendering the generating effect on the main canvas.
  140211. * @param effect The effect used to render through
  140212. */
  140213. protected _internalRender(effect: Effect): void;
  140214. /**
  140215. * Returns true if the layer contains information to display, otherwise false.
  140216. */
  140217. shouldRender(): boolean;
  140218. /**
  140219. * Returns true if the mesh should render, otherwise false.
  140220. * @param mesh The mesh to render
  140221. * @returns true if it should render otherwise false
  140222. */
  140223. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140224. /**
  140225. * Returns true if the mesh can be rendered, otherwise false.
  140226. * @param mesh The mesh to render
  140227. * @param material The material used on the mesh
  140228. * @returns true if it can be rendered otherwise false
  140229. */
  140230. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140231. /**
  140232. * Adds specific effects defines.
  140233. * @param defines The defines to add specifics to.
  140234. */
  140235. protected _addCustomEffectDefines(defines: string[]): void;
  140236. /**
  140237. * Sets the required values for both the emissive texture and and the main color.
  140238. */
  140239. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140240. /**
  140241. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140242. * @param mesh The mesh to exclude from the highlight layer
  140243. */
  140244. addExcludedMesh(mesh: Mesh): void;
  140245. /**
  140246. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140247. * @param mesh The mesh to highlight
  140248. */
  140249. removeExcludedMesh(mesh: Mesh): void;
  140250. /**
  140251. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140252. * @param mesh mesh to test
  140253. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140254. */
  140255. hasMesh(mesh: AbstractMesh): boolean;
  140256. /**
  140257. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140258. * @param mesh The mesh to highlight
  140259. * @param color The color of the highlight
  140260. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140261. */
  140262. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140263. /**
  140264. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140265. * @param mesh The mesh to highlight
  140266. */
  140267. removeMesh(mesh: Mesh): void;
  140268. /**
  140269. * Remove all the meshes currently referenced in the highlight layer
  140270. */
  140271. removeAllMeshes(): void;
  140272. /**
  140273. * Force the stencil to the normal expected value for none glowing parts
  140274. */
  140275. private _defaultStencilReference;
  140276. /**
  140277. * Free any resources and references associated to a mesh.
  140278. * Internal use
  140279. * @param mesh The mesh to free.
  140280. * @hidden
  140281. */
  140282. _disposeMesh(mesh: Mesh): void;
  140283. /**
  140284. * Dispose the highlight layer and free resources.
  140285. */
  140286. dispose(): void;
  140287. /**
  140288. * Gets the class name of the effect layer
  140289. * @returns the string with the class name of the effect layer
  140290. */
  140291. getClassName(): string;
  140292. /**
  140293. * Serializes this Highlight layer
  140294. * @returns a serialized Highlight layer object
  140295. */
  140296. serialize(): any;
  140297. /**
  140298. * Creates a Highlight layer from parsed Highlight layer data
  140299. * @param parsedHightlightLayer defines the Highlight layer data
  140300. * @param scene defines the current scene
  140301. * @param rootUrl defines the root URL containing the Highlight layer information
  140302. * @returns a parsed Highlight layer
  140303. */
  140304. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140305. }
  140306. }
  140307. declare module BABYLON {
  140308. interface AbstractScene {
  140309. /**
  140310. * The list of layers (background and foreground) of the scene
  140311. */
  140312. layers: Array<Layer>;
  140313. }
  140314. /**
  140315. * Defines the layer scene component responsible to manage any layers
  140316. * in a given scene.
  140317. */
  140318. export class LayerSceneComponent implements ISceneComponent {
  140319. /**
  140320. * The component name helpfull to identify the component in the list of scene components.
  140321. */
  140322. readonly name: string;
  140323. /**
  140324. * The scene the component belongs to.
  140325. */
  140326. scene: Scene;
  140327. private _engine;
  140328. /**
  140329. * Creates a new instance of the component for the given scene
  140330. * @param scene Defines the scene to register the component in
  140331. */
  140332. constructor(scene: Scene);
  140333. /**
  140334. * Registers the component in a given scene
  140335. */
  140336. register(): void;
  140337. /**
  140338. * Rebuilds the elements related to this component in case of
  140339. * context lost for instance.
  140340. */
  140341. rebuild(): void;
  140342. /**
  140343. * Disposes the component and the associated ressources.
  140344. */
  140345. dispose(): void;
  140346. private _draw;
  140347. private _drawCameraPredicate;
  140348. private _drawCameraBackground;
  140349. private _drawCameraForeground;
  140350. private _drawRenderTargetPredicate;
  140351. private _drawRenderTargetBackground;
  140352. private _drawRenderTargetForeground;
  140353. /**
  140354. * Adds all the elements from the container to the scene
  140355. * @param container the container holding the elements
  140356. */
  140357. addFromContainer(container: AbstractScene): void;
  140358. /**
  140359. * Removes all the elements in the container from the scene
  140360. * @param container contains the elements to remove
  140361. * @param dispose if the removed element should be disposed (default: false)
  140362. */
  140363. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140364. }
  140365. }
  140366. declare module BABYLON {
  140367. /** @hidden */
  140368. export var layerPixelShader: {
  140369. name: string;
  140370. shader: string;
  140371. };
  140372. }
  140373. declare module BABYLON {
  140374. /** @hidden */
  140375. export var layerVertexShader: {
  140376. name: string;
  140377. shader: string;
  140378. };
  140379. }
  140380. declare module BABYLON {
  140381. /**
  140382. * This represents a full screen 2d layer.
  140383. * This can be useful to display a picture in the background of your scene for instance.
  140384. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140385. */
  140386. export class Layer {
  140387. /**
  140388. * Define the name of the layer.
  140389. */
  140390. name: string;
  140391. /**
  140392. * Define the texture the layer should display.
  140393. */
  140394. texture: Nullable<Texture>;
  140395. /**
  140396. * Is the layer in background or foreground.
  140397. */
  140398. isBackground: boolean;
  140399. /**
  140400. * Define the color of the layer (instead of texture).
  140401. */
  140402. color: Color4;
  140403. /**
  140404. * Define the scale of the layer in order to zoom in out of the texture.
  140405. */
  140406. scale: Vector2;
  140407. /**
  140408. * Define an offset for the layer in order to shift the texture.
  140409. */
  140410. offset: Vector2;
  140411. /**
  140412. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140413. */
  140414. alphaBlendingMode: number;
  140415. /**
  140416. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140417. * Alpha test will not mix with the background color in case of transparency.
  140418. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140419. */
  140420. alphaTest: boolean;
  140421. /**
  140422. * Define a mask to restrict the layer to only some of the scene cameras.
  140423. */
  140424. layerMask: number;
  140425. /**
  140426. * Define the list of render target the layer is visible into.
  140427. */
  140428. renderTargetTextures: RenderTargetTexture[];
  140429. /**
  140430. * Define if the layer is only used in renderTarget or if it also
  140431. * renders in the main frame buffer of the canvas.
  140432. */
  140433. renderOnlyInRenderTargetTextures: boolean;
  140434. private _scene;
  140435. private _vertexBuffers;
  140436. private _indexBuffer;
  140437. private _effect;
  140438. private _previousDefines;
  140439. /**
  140440. * An event triggered when the layer is disposed.
  140441. */
  140442. onDisposeObservable: Observable<Layer>;
  140443. private _onDisposeObserver;
  140444. /**
  140445. * Back compatibility with callback before the onDisposeObservable existed.
  140446. * The set callback will be triggered when the layer has been disposed.
  140447. */
  140448. set onDispose(callback: () => void);
  140449. /**
  140450. * An event triggered before rendering the scene
  140451. */
  140452. onBeforeRenderObservable: Observable<Layer>;
  140453. private _onBeforeRenderObserver;
  140454. /**
  140455. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140456. * The set callback will be triggered just before rendering the layer.
  140457. */
  140458. set onBeforeRender(callback: () => void);
  140459. /**
  140460. * An event triggered after rendering the scene
  140461. */
  140462. onAfterRenderObservable: Observable<Layer>;
  140463. private _onAfterRenderObserver;
  140464. /**
  140465. * Back compatibility with callback before the onAfterRenderObservable existed.
  140466. * The set callback will be triggered just after rendering the layer.
  140467. */
  140468. set onAfterRender(callback: () => void);
  140469. /**
  140470. * Instantiates a new layer.
  140471. * This represents a full screen 2d layer.
  140472. * This can be useful to display a picture in the background of your scene for instance.
  140473. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140474. * @param name Define the name of the layer in the scene
  140475. * @param imgUrl Define the url of the texture to display in the layer
  140476. * @param scene Define the scene the layer belongs to
  140477. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140478. * @param color Defines a color for the layer
  140479. */
  140480. constructor(
  140481. /**
  140482. * Define the name of the layer.
  140483. */
  140484. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140485. private _createIndexBuffer;
  140486. /** @hidden */
  140487. _rebuild(): void;
  140488. /**
  140489. * Renders the layer in the scene.
  140490. */
  140491. render(): void;
  140492. /**
  140493. * Disposes and releases the associated ressources.
  140494. */
  140495. dispose(): void;
  140496. }
  140497. }
  140498. declare module BABYLON {
  140499. /** @hidden */
  140500. export var lensFlarePixelShader: {
  140501. name: string;
  140502. shader: string;
  140503. };
  140504. }
  140505. declare module BABYLON {
  140506. /** @hidden */
  140507. export var lensFlareVertexShader: {
  140508. name: string;
  140509. shader: string;
  140510. };
  140511. }
  140512. declare module BABYLON {
  140513. /**
  140514. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140515. * It is usually composed of several `lensFlare`.
  140516. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140517. */
  140518. export class LensFlareSystem {
  140519. /**
  140520. * Define the name of the lens flare system
  140521. */
  140522. name: string;
  140523. /**
  140524. * List of lens flares used in this system.
  140525. */
  140526. lensFlares: LensFlare[];
  140527. /**
  140528. * Define a limit from the border the lens flare can be visible.
  140529. */
  140530. borderLimit: number;
  140531. /**
  140532. * Define a viewport border we do not want to see the lens flare in.
  140533. */
  140534. viewportBorder: number;
  140535. /**
  140536. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140537. */
  140538. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140539. /**
  140540. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140541. */
  140542. layerMask: number;
  140543. /**
  140544. * Define the id of the lens flare system in the scene.
  140545. * (equal to name by default)
  140546. */
  140547. id: string;
  140548. private _scene;
  140549. private _emitter;
  140550. private _vertexBuffers;
  140551. private _indexBuffer;
  140552. private _effect;
  140553. private _positionX;
  140554. private _positionY;
  140555. private _isEnabled;
  140556. /** @hidden */
  140557. static _SceneComponentInitialization: (scene: Scene) => void;
  140558. /**
  140559. * Instantiates a lens flare system.
  140560. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140561. * It is usually composed of several `lensFlare`.
  140562. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140563. * @param name Define the name of the lens flare system in the scene
  140564. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140565. * @param scene Define the scene the lens flare system belongs to
  140566. */
  140567. constructor(
  140568. /**
  140569. * Define the name of the lens flare system
  140570. */
  140571. name: string, emitter: any, scene: Scene);
  140572. /**
  140573. * Define if the lens flare system is enabled.
  140574. */
  140575. get isEnabled(): boolean;
  140576. set isEnabled(value: boolean);
  140577. /**
  140578. * Get the scene the effects belongs to.
  140579. * @returns the scene holding the lens flare system
  140580. */
  140581. getScene(): Scene;
  140582. /**
  140583. * Get the emitter of the lens flare system.
  140584. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140585. * @returns the emitter of the lens flare system
  140586. */
  140587. getEmitter(): any;
  140588. /**
  140589. * Set the emitter of the lens flare system.
  140590. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140591. * @param newEmitter Define the new emitter of the system
  140592. */
  140593. setEmitter(newEmitter: any): void;
  140594. /**
  140595. * Get the lens flare system emitter position.
  140596. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140597. * @returns the position
  140598. */
  140599. getEmitterPosition(): Vector3;
  140600. /**
  140601. * @hidden
  140602. */
  140603. computeEffectivePosition(globalViewport: Viewport): boolean;
  140604. /** @hidden */
  140605. _isVisible(): boolean;
  140606. /**
  140607. * @hidden
  140608. */
  140609. render(): boolean;
  140610. /**
  140611. * Dispose and release the lens flare with its associated resources.
  140612. */
  140613. dispose(): void;
  140614. /**
  140615. * Parse a lens flare system from a JSON repressentation
  140616. * @param parsedLensFlareSystem Define the JSON to parse
  140617. * @param scene Define the scene the parsed system should be instantiated in
  140618. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140619. * @returns the parsed system
  140620. */
  140621. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140622. /**
  140623. * Serialize the current Lens Flare System into a JSON representation.
  140624. * @returns the serialized JSON
  140625. */
  140626. serialize(): any;
  140627. }
  140628. }
  140629. declare module BABYLON {
  140630. /**
  140631. * This represents one of the lens effect in a `lensFlareSystem`.
  140632. * It controls one of the indiviual texture used in the effect.
  140633. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140634. */
  140635. export class LensFlare {
  140636. /**
  140637. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140638. */
  140639. size: number;
  140640. /**
  140641. * 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.
  140642. */
  140643. position: number;
  140644. /**
  140645. * Define the lens color.
  140646. */
  140647. color: Color3;
  140648. /**
  140649. * Define the lens texture.
  140650. */
  140651. texture: Nullable<Texture>;
  140652. /**
  140653. * Define the alpha mode to render this particular lens.
  140654. */
  140655. alphaMode: number;
  140656. private _system;
  140657. /**
  140658. * Creates a new Lens Flare.
  140659. * This represents one of the lens effect in a `lensFlareSystem`.
  140660. * It controls one of the indiviual texture used in the effect.
  140661. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140662. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140663. * @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.
  140664. * @param color Define the lens color
  140665. * @param imgUrl Define the lens texture url
  140666. * @param system Define the `lensFlareSystem` this flare is part of
  140667. * @returns The newly created Lens Flare
  140668. */
  140669. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140670. /**
  140671. * Instantiates a new Lens Flare.
  140672. * This represents one of the lens effect in a `lensFlareSystem`.
  140673. * It controls one of the indiviual texture used in the effect.
  140674. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140675. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140676. * @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.
  140677. * @param color Define the lens color
  140678. * @param imgUrl Define the lens texture url
  140679. * @param system Define the `lensFlareSystem` this flare is part of
  140680. */
  140681. constructor(
  140682. /**
  140683. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140684. */
  140685. size: number,
  140686. /**
  140687. * 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.
  140688. */
  140689. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140690. /**
  140691. * Dispose and release the lens flare with its associated resources.
  140692. */
  140693. dispose(): void;
  140694. }
  140695. }
  140696. declare module BABYLON {
  140697. interface AbstractScene {
  140698. /**
  140699. * The list of lens flare system added to the scene
  140700. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140701. */
  140702. lensFlareSystems: Array<LensFlareSystem>;
  140703. /**
  140704. * Removes the given lens flare system from this scene.
  140705. * @param toRemove The lens flare system to remove
  140706. * @returns The index of the removed lens flare system
  140707. */
  140708. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140709. /**
  140710. * Adds the given lens flare system to this scene
  140711. * @param newLensFlareSystem The lens flare system to add
  140712. */
  140713. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140714. /**
  140715. * Gets a lens flare system using its name
  140716. * @param name defines the name to look for
  140717. * @returns the lens flare system or null if not found
  140718. */
  140719. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140720. /**
  140721. * Gets a lens flare system using its id
  140722. * @param id defines the id to look for
  140723. * @returns the lens flare system or null if not found
  140724. */
  140725. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140726. }
  140727. /**
  140728. * Defines the lens flare scene component responsible to manage any lens flares
  140729. * in a given scene.
  140730. */
  140731. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140732. /**
  140733. * The component name helpfull to identify the component in the list of scene components.
  140734. */
  140735. readonly name: string;
  140736. /**
  140737. * The scene the component belongs to.
  140738. */
  140739. scene: Scene;
  140740. /**
  140741. * Creates a new instance of the component for the given scene
  140742. * @param scene Defines the scene to register the component in
  140743. */
  140744. constructor(scene: Scene);
  140745. /**
  140746. * Registers the component in a given scene
  140747. */
  140748. register(): void;
  140749. /**
  140750. * Rebuilds the elements related to this component in case of
  140751. * context lost for instance.
  140752. */
  140753. rebuild(): void;
  140754. /**
  140755. * Adds all the elements from the container to the scene
  140756. * @param container the container holding the elements
  140757. */
  140758. addFromContainer(container: AbstractScene): void;
  140759. /**
  140760. * Removes all the elements in the container from the scene
  140761. * @param container contains the elements to remove
  140762. * @param dispose if the removed element should be disposed (default: false)
  140763. */
  140764. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140765. /**
  140766. * Serializes the component data to the specified json object
  140767. * @param serializationObject The object to serialize to
  140768. */
  140769. serialize(serializationObject: any): void;
  140770. /**
  140771. * Disposes the component and the associated ressources.
  140772. */
  140773. dispose(): void;
  140774. private _draw;
  140775. }
  140776. }
  140777. declare module BABYLON {
  140778. /** @hidden */
  140779. export var depthPixelShader: {
  140780. name: string;
  140781. shader: string;
  140782. };
  140783. }
  140784. declare module BABYLON {
  140785. /** @hidden */
  140786. export var depthVertexShader: {
  140787. name: string;
  140788. shader: string;
  140789. };
  140790. }
  140791. declare module BABYLON {
  140792. /**
  140793. * This represents a depth renderer in Babylon.
  140794. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140795. */
  140796. export class DepthRenderer {
  140797. private _scene;
  140798. private _depthMap;
  140799. private _effect;
  140800. private readonly _storeNonLinearDepth;
  140801. private readonly _clearColor;
  140802. /** Get if the depth renderer is using packed depth or not */
  140803. readonly isPacked: boolean;
  140804. private _cachedDefines;
  140805. private _camera;
  140806. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140807. enabled: boolean;
  140808. /**
  140809. * Specifiess that the depth renderer will only be used within
  140810. * the camera it is created for.
  140811. * This can help forcing its rendering during the camera processing.
  140812. */
  140813. useOnlyInActiveCamera: boolean;
  140814. /** @hidden */
  140815. static _SceneComponentInitialization: (scene: Scene) => void;
  140816. /**
  140817. * Instantiates a depth renderer
  140818. * @param scene The scene the renderer belongs to
  140819. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140820. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140821. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140822. */
  140823. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140824. /**
  140825. * Creates the depth rendering effect and checks if the effect is ready.
  140826. * @param subMesh The submesh to be used to render the depth map of
  140827. * @param useInstances If multiple world instances should be used
  140828. * @returns if the depth renderer is ready to render the depth map
  140829. */
  140830. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140831. /**
  140832. * Gets the texture which the depth map will be written to.
  140833. * @returns The depth map texture
  140834. */
  140835. getDepthMap(): RenderTargetTexture;
  140836. /**
  140837. * Disposes of the depth renderer.
  140838. */
  140839. dispose(): void;
  140840. }
  140841. }
  140842. declare module BABYLON {
  140843. /** @hidden */
  140844. export var minmaxReduxPixelShader: {
  140845. name: string;
  140846. shader: string;
  140847. };
  140848. }
  140849. declare module BABYLON {
  140850. /**
  140851. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140852. * and maximum values from all values of the texture.
  140853. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140854. * The source values are read from the red channel of the texture.
  140855. */
  140856. export class MinMaxReducer {
  140857. /**
  140858. * Observable triggered when the computation has been performed
  140859. */
  140860. onAfterReductionPerformed: Observable<{
  140861. min: number;
  140862. max: number;
  140863. }>;
  140864. protected _camera: Camera;
  140865. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140866. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140867. protected _postProcessManager: PostProcessManager;
  140868. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140869. protected _forceFullscreenViewport: boolean;
  140870. /**
  140871. * Creates a min/max reducer
  140872. * @param camera The camera to use for the post processes
  140873. */
  140874. constructor(camera: Camera);
  140875. /**
  140876. * Gets the texture used to read the values from.
  140877. */
  140878. get sourceTexture(): Nullable<RenderTargetTexture>;
  140879. /**
  140880. * Sets the source texture to read the values from.
  140881. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140882. * because in such textures '1' value must not be taken into account to compute the maximum
  140883. * as this value is used to clear the texture.
  140884. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140885. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140886. * @param depthRedux Indicates if the texture is a depth texture or not
  140887. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140888. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140889. */
  140890. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140891. /**
  140892. * Defines the refresh rate of the computation.
  140893. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140894. */
  140895. get refreshRate(): number;
  140896. set refreshRate(value: number);
  140897. protected _activated: boolean;
  140898. /**
  140899. * Gets the activation status of the reducer
  140900. */
  140901. get activated(): boolean;
  140902. /**
  140903. * Activates the reduction computation.
  140904. * When activated, the observers registered in onAfterReductionPerformed are
  140905. * called after the compuation is performed
  140906. */
  140907. activate(): void;
  140908. /**
  140909. * Deactivates the reduction computation.
  140910. */
  140911. deactivate(): void;
  140912. /**
  140913. * Disposes the min/max reducer
  140914. * @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.
  140915. */
  140916. dispose(disposeAll?: boolean): void;
  140917. }
  140918. }
  140919. declare module BABYLON {
  140920. /**
  140921. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140922. */
  140923. export class DepthReducer extends MinMaxReducer {
  140924. private _depthRenderer;
  140925. private _depthRendererId;
  140926. /**
  140927. * Gets the depth renderer used for the computation.
  140928. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140929. */
  140930. get depthRenderer(): Nullable<DepthRenderer>;
  140931. /**
  140932. * Creates a depth reducer
  140933. * @param camera The camera used to render the depth texture
  140934. */
  140935. constructor(camera: Camera);
  140936. /**
  140937. * Sets the depth renderer to use to generate the depth map
  140938. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140939. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140940. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140941. */
  140942. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140943. /** @hidden */
  140944. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140945. /**
  140946. * Activates the reduction computation.
  140947. * When activated, the observers registered in onAfterReductionPerformed are
  140948. * called after the compuation is performed
  140949. */
  140950. activate(): void;
  140951. /**
  140952. * Deactivates the reduction computation.
  140953. */
  140954. deactivate(): void;
  140955. /**
  140956. * Disposes the depth reducer
  140957. * @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.
  140958. */
  140959. dispose(disposeAll?: boolean): void;
  140960. }
  140961. }
  140962. declare module BABYLON {
  140963. /**
  140964. * A CSM implementation allowing casting shadows on large scenes.
  140965. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140966. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140967. */
  140968. export class CascadedShadowGenerator extends ShadowGenerator {
  140969. private static readonly frustumCornersNDCSpace;
  140970. /**
  140971. * Name of the CSM class
  140972. */
  140973. static CLASSNAME: string;
  140974. /**
  140975. * Defines the default number of cascades used by the CSM.
  140976. */
  140977. static readonly DEFAULT_CASCADES_COUNT: number;
  140978. /**
  140979. * Defines the minimum number of cascades used by the CSM.
  140980. */
  140981. static readonly MIN_CASCADES_COUNT: number;
  140982. /**
  140983. * Defines the maximum number of cascades used by the CSM.
  140984. */
  140985. static readonly MAX_CASCADES_COUNT: number;
  140986. protected _validateFilter(filter: number): number;
  140987. /**
  140988. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140989. */
  140990. penumbraDarkness: number;
  140991. private _numCascades;
  140992. /**
  140993. * Gets or set the number of cascades used by the CSM.
  140994. */
  140995. get numCascades(): number;
  140996. set numCascades(value: number);
  140997. /**
  140998. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140999. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141000. */
  141001. stabilizeCascades: boolean;
  141002. private _freezeShadowCastersBoundingInfo;
  141003. private _freezeShadowCastersBoundingInfoObservable;
  141004. /**
  141005. * Enables or disables the shadow casters bounding info computation.
  141006. * If your shadow casters don't move, you can disable this feature.
  141007. * If it is enabled, the bounding box computation is done every frame.
  141008. */
  141009. get freezeShadowCastersBoundingInfo(): boolean;
  141010. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141011. private _scbiMin;
  141012. private _scbiMax;
  141013. protected _computeShadowCastersBoundingInfo(): void;
  141014. protected _shadowCastersBoundingInfo: BoundingInfo;
  141015. /**
  141016. * Gets or sets the shadow casters bounding info.
  141017. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141018. * so that the system won't overwrite the bounds you provide
  141019. */
  141020. get shadowCastersBoundingInfo(): BoundingInfo;
  141021. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141022. protected _breaksAreDirty: boolean;
  141023. protected _minDistance: number;
  141024. protected _maxDistance: number;
  141025. /**
  141026. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141027. *
  141028. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141029. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141030. * @param min minimal distance for the breaks (default to 0.)
  141031. * @param max maximal distance for the breaks (default to 1.)
  141032. */
  141033. setMinMaxDistance(min: number, max: number): void;
  141034. /** Gets the minimal distance used in the cascade break computation */
  141035. get minDistance(): number;
  141036. /** Gets the maximal distance used in the cascade break computation */
  141037. get maxDistance(): number;
  141038. /**
  141039. * Gets the class name of that object
  141040. * @returns "CascadedShadowGenerator"
  141041. */
  141042. getClassName(): string;
  141043. private _cascadeMinExtents;
  141044. private _cascadeMaxExtents;
  141045. /**
  141046. * Gets a cascade minimum extents
  141047. * @param cascadeIndex index of the cascade
  141048. * @returns the minimum cascade extents
  141049. */
  141050. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141051. /**
  141052. * Gets a cascade maximum extents
  141053. * @param cascadeIndex index of the cascade
  141054. * @returns the maximum cascade extents
  141055. */
  141056. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141057. private _cascades;
  141058. private _currentLayer;
  141059. private _viewSpaceFrustumsZ;
  141060. private _viewMatrices;
  141061. private _projectionMatrices;
  141062. private _transformMatrices;
  141063. private _transformMatricesAsArray;
  141064. private _frustumLengths;
  141065. private _lightSizeUVCorrection;
  141066. private _depthCorrection;
  141067. private _frustumCornersWorldSpace;
  141068. private _frustumCenter;
  141069. private _shadowCameraPos;
  141070. private _shadowMaxZ;
  141071. /**
  141072. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141073. * It defaults to camera.maxZ
  141074. */
  141075. get shadowMaxZ(): number;
  141076. /**
  141077. * Sets the shadow max z distance.
  141078. */
  141079. set shadowMaxZ(value: number);
  141080. protected _debug: boolean;
  141081. /**
  141082. * Gets or sets the debug flag.
  141083. * When enabled, the cascades are materialized by different colors on the screen.
  141084. */
  141085. get debug(): boolean;
  141086. set debug(dbg: boolean);
  141087. private _depthClamp;
  141088. /**
  141089. * Gets or sets the depth clamping value.
  141090. *
  141091. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141092. * to account for the shadow casters far away.
  141093. *
  141094. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141095. */
  141096. get depthClamp(): boolean;
  141097. set depthClamp(value: boolean);
  141098. private _cascadeBlendPercentage;
  141099. /**
  141100. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141101. * It defaults to 0.1 (10% blending).
  141102. */
  141103. get cascadeBlendPercentage(): number;
  141104. set cascadeBlendPercentage(value: number);
  141105. private _lambda;
  141106. /**
  141107. * Gets or set the lambda parameter.
  141108. * This parameter is used to split the camera frustum and create the cascades.
  141109. * 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.
  141110. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141111. */
  141112. get lambda(): number;
  141113. set lambda(value: number);
  141114. /**
  141115. * Gets the view matrix corresponding to a given cascade
  141116. * @param cascadeNum cascade to retrieve the view matrix from
  141117. * @returns the cascade view matrix
  141118. */
  141119. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141120. /**
  141121. * Gets the projection matrix corresponding to a given cascade
  141122. * @param cascadeNum cascade to retrieve the projection matrix from
  141123. * @returns the cascade projection matrix
  141124. */
  141125. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141126. /**
  141127. * Gets the transformation matrix corresponding to a given cascade
  141128. * @param cascadeNum cascade to retrieve the transformation matrix from
  141129. * @returns the cascade transformation matrix
  141130. */
  141131. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141132. private _depthRenderer;
  141133. /**
  141134. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141135. *
  141136. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141137. *
  141138. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141139. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141140. * @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
  141141. */
  141142. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141143. private _depthReducer;
  141144. private _autoCalcDepthBounds;
  141145. /**
  141146. * Gets or sets the autoCalcDepthBounds property.
  141147. *
  141148. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141149. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141150. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141151. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141152. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141153. */
  141154. get autoCalcDepthBounds(): boolean;
  141155. set autoCalcDepthBounds(value: boolean);
  141156. /**
  141157. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141158. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141159. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141160. * for setting the refresh rate on the renderer yourself!
  141161. */
  141162. get autoCalcDepthBoundsRefreshRate(): number;
  141163. set autoCalcDepthBoundsRefreshRate(value: number);
  141164. /**
  141165. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141166. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141167. * you change the camera near/far planes!
  141168. */
  141169. splitFrustum(): void;
  141170. private _splitFrustum;
  141171. private _computeMatrices;
  141172. private _computeFrustumInWorldSpace;
  141173. private _computeCascadeFrustum;
  141174. /**
  141175. * Support test.
  141176. */
  141177. static get IsSupported(): boolean;
  141178. /** @hidden */
  141179. static _SceneComponentInitialization: (scene: Scene) => void;
  141180. /**
  141181. * Creates a Cascaded Shadow Generator object.
  141182. * A ShadowGenerator is the required tool to use the shadows.
  141183. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141184. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141185. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141186. * @param light The directional light object generating the shadows.
  141187. * @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.
  141188. */
  141189. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141190. protected _initializeGenerator(): void;
  141191. protected _createTargetRenderTexture(): void;
  141192. protected _initializeShadowMap(): void;
  141193. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141194. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141195. /**
  141196. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141197. * @param defines Defines of the material we want to update
  141198. * @param lightIndex Index of the light in the enabled light list of the material
  141199. */
  141200. prepareDefines(defines: any, lightIndex: number): void;
  141201. /**
  141202. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141203. * defined in the generator but impacting the effect).
  141204. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141205. * @param effect The effect we are binfing the information for
  141206. */
  141207. bindShadowLight(lightIndex: string, effect: Effect): void;
  141208. /**
  141209. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141210. * (eq to view projection * shadow projection matrices)
  141211. * @returns The transform matrix used to create the shadow map
  141212. */
  141213. getTransformMatrix(): Matrix;
  141214. /**
  141215. * Disposes the ShadowGenerator.
  141216. * Returns nothing.
  141217. */
  141218. dispose(): void;
  141219. /**
  141220. * Serializes the shadow generator setup to a json object.
  141221. * @returns The serialized JSON object
  141222. */
  141223. serialize(): any;
  141224. /**
  141225. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141226. * @param parsedShadowGenerator The JSON object to parse
  141227. * @param scene The scene to create the shadow map for
  141228. * @returns The parsed shadow generator
  141229. */
  141230. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141231. }
  141232. }
  141233. declare module BABYLON {
  141234. /**
  141235. * Defines the shadow generator component responsible to manage any shadow generators
  141236. * in a given scene.
  141237. */
  141238. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141239. /**
  141240. * The component name helpfull to identify the component in the list of scene components.
  141241. */
  141242. readonly name: string;
  141243. /**
  141244. * The scene the component belongs to.
  141245. */
  141246. scene: Scene;
  141247. /**
  141248. * Creates a new instance of the component for the given scene
  141249. * @param scene Defines the scene to register the component in
  141250. */
  141251. constructor(scene: Scene);
  141252. /**
  141253. * Registers the component in a given scene
  141254. */
  141255. register(): void;
  141256. /**
  141257. * Rebuilds the elements related to this component in case of
  141258. * context lost for instance.
  141259. */
  141260. rebuild(): void;
  141261. /**
  141262. * Serializes the component data to the specified json object
  141263. * @param serializationObject The object to serialize to
  141264. */
  141265. serialize(serializationObject: any): void;
  141266. /**
  141267. * Adds all the elements from the container to the scene
  141268. * @param container the container holding the elements
  141269. */
  141270. addFromContainer(container: AbstractScene): void;
  141271. /**
  141272. * Removes all the elements in the container from the scene
  141273. * @param container contains the elements to remove
  141274. * @param dispose if the removed element should be disposed (default: false)
  141275. */
  141276. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141277. /**
  141278. * Rebuilds the elements related to this component in case of
  141279. * context lost for instance.
  141280. */
  141281. dispose(): void;
  141282. private _gatherRenderTargets;
  141283. }
  141284. }
  141285. declare module BABYLON {
  141286. /**
  141287. * A point light is a light defined by an unique point in world space.
  141288. * The light is emitted in every direction from this point.
  141289. * A good example of a point light is a standard light bulb.
  141290. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141291. */
  141292. export class PointLight extends ShadowLight {
  141293. private _shadowAngle;
  141294. /**
  141295. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141296. * This specifies what angle the shadow will use to be created.
  141297. *
  141298. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141299. */
  141300. get shadowAngle(): number;
  141301. /**
  141302. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141303. * This specifies what angle the shadow will use to be created.
  141304. *
  141305. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141306. */
  141307. set shadowAngle(value: number);
  141308. /**
  141309. * Gets the direction if it has been set.
  141310. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141311. */
  141312. get direction(): Vector3;
  141313. /**
  141314. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141315. */
  141316. set direction(value: Vector3);
  141317. /**
  141318. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141319. * A PointLight emits the light in every direction.
  141320. * It can cast shadows.
  141321. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141322. * ```javascript
  141323. * var pointLight = new PointLight("pl", camera.position, scene);
  141324. * ```
  141325. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141326. * @param name The light friendly name
  141327. * @param position The position of the point light in the scene
  141328. * @param scene The scene the lights belongs to
  141329. */
  141330. constructor(name: string, position: Vector3, scene: Scene);
  141331. /**
  141332. * Returns the string "PointLight"
  141333. * @returns the class name
  141334. */
  141335. getClassName(): string;
  141336. /**
  141337. * Returns the integer 0.
  141338. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141339. */
  141340. getTypeID(): number;
  141341. /**
  141342. * Specifies wether or not the shadowmap should be a cube texture.
  141343. * @returns true if the shadowmap needs to be a cube texture.
  141344. */
  141345. needCube(): boolean;
  141346. /**
  141347. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141348. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141349. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141350. */
  141351. getShadowDirection(faceIndex?: number): Vector3;
  141352. /**
  141353. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141354. * - fov = PI / 2
  141355. * - aspect ratio : 1.0
  141356. * - z-near and far equal to the active camera minZ and maxZ.
  141357. * Returns the PointLight.
  141358. */
  141359. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141360. protected _buildUniformLayout(): void;
  141361. /**
  141362. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141363. * @param effect The effect to update
  141364. * @param lightIndex The index of the light in the effect to update
  141365. * @returns The point light
  141366. */
  141367. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141368. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141369. /**
  141370. * Prepares the list of defines specific to the light type.
  141371. * @param defines the list of defines
  141372. * @param lightIndex defines the index of the light for the effect
  141373. */
  141374. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141375. }
  141376. }
  141377. declare module BABYLON {
  141378. /**
  141379. * Header information of HDR texture files.
  141380. */
  141381. export interface HDRInfo {
  141382. /**
  141383. * The height of the texture in pixels.
  141384. */
  141385. height: number;
  141386. /**
  141387. * The width of the texture in pixels.
  141388. */
  141389. width: number;
  141390. /**
  141391. * The index of the beginning of the data in the binary file.
  141392. */
  141393. dataPosition: number;
  141394. }
  141395. /**
  141396. * This groups tools to convert HDR texture to native colors array.
  141397. */
  141398. export class HDRTools {
  141399. private static Ldexp;
  141400. private static Rgbe2float;
  141401. private static readStringLine;
  141402. /**
  141403. * Reads header information from an RGBE texture stored in a native array.
  141404. * More information on this format are available here:
  141405. * https://en.wikipedia.org/wiki/RGBE_image_format
  141406. *
  141407. * @param uint8array The binary file stored in native array.
  141408. * @return The header information.
  141409. */
  141410. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141411. /**
  141412. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141413. * This RGBE texture needs to store the information as a panorama.
  141414. *
  141415. * More information on this format are available here:
  141416. * https://en.wikipedia.org/wiki/RGBE_image_format
  141417. *
  141418. * @param buffer The binary file stored in an array buffer.
  141419. * @param size The expected size of the extracted cubemap.
  141420. * @return The Cube Map information.
  141421. */
  141422. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141423. /**
  141424. * Returns the pixels data extracted from an RGBE texture.
  141425. * This pixels will be stored left to right up to down in the R G B order in one array.
  141426. *
  141427. * More information on this format are available here:
  141428. * https://en.wikipedia.org/wiki/RGBE_image_format
  141429. *
  141430. * @param uint8array The binary file stored in an array buffer.
  141431. * @param hdrInfo The header information of the file.
  141432. * @return The pixels data in RGB right to left up to down order.
  141433. */
  141434. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141435. private static RGBE_ReadPixels_RLE;
  141436. private static RGBE_ReadPixels_NOT_RLE;
  141437. }
  141438. }
  141439. declare module BABYLON {
  141440. /**
  141441. * Effect Render Options
  141442. */
  141443. export interface IEffectRendererOptions {
  141444. /**
  141445. * Defines the vertices positions.
  141446. */
  141447. positions?: number[];
  141448. /**
  141449. * Defines the indices.
  141450. */
  141451. indices?: number[];
  141452. }
  141453. /**
  141454. * Helper class to render one or more effects.
  141455. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141456. */
  141457. export class EffectRenderer {
  141458. private engine;
  141459. private static _DefaultOptions;
  141460. private _vertexBuffers;
  141461. private _indexBuffer;
  141462. private _fullscreenViewport;
  141463. /**
  141464. * Creates an effect renderer
  141465. * @param engine the engine to use for rendering
  141466. * @param options defines the options of the effect renderer
  141467. */
  141468. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141469. /**
  141470. * Sets the current viewport in normalized coordinates 0-1
  141471. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141472. */
  141473. setViewport(viewport?: Viewport): void;
  141474. /**
  141475. * Binds the embedded attributes buffer to the effect.
  141476. * @param effect Defines the effect to bind the attributes for
  141477. */
  141478. bindBuffers(effect: Effect): void;
  141479. /**
  141480. * Sets the current effect wrapper to use during draw.
  141481. * The effect needs to be ready before calling this api.
  141482. * This also sets the default full screen position attribute.
  141483. * @param effectWrapper Defines the effect to draw with
  141484. */
  141485. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141486. /**
  141487. * Restores engine states
  141488. */
  141489. restoreStates(): void;
  141490. /**
  141491. * Draws a full screen quad.
  141492. */
  141493. draw(): void;
  141494. private isRenderTargetTexture;
  141495. /**
  141496. * renders one or more effects to a specified texture
  141497. * @param effectWrapper the effect to renderer
  141498. * @param outputTexture texture to draw to, if null it will render to the screen.
  141499. */
  141500. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141501. /**
  141502. * Disposes of the effect renderer
  141503. */
  141504. dispose(): void;
  141505. }
  141506. /**
  141507. * Options to create an EffectWrapper
  141508. */
  141509. interface EffectWrapperCreationOptions {
  141510. /**
  141511. * Engine to use to create the effect
  141512. */
  141513. engine: ThinEngine;
  141514. /**
  141515. * Fragment shader for the effect
  141516. */
  141517. fragmentShader: string;
  141518. /**
  141519. * Use the shader store instead of direct source code
  141520. */
  141521. useShaderStore?: boolean;
  141522. /**
  141523. * Vertex shader for the effect
  141524. */
  141525. vertexShader?: string;
  141526. /**
  141527. * Attributes to use in the shader
  141528. */
  141529. attributeNames?: Array<string>;
  141530. /**
  141531. * Uniforms to use in the shader
  141532. */
  141533. uniformNames?: Array<string>;
  141534. /**
  141535. * Texture sampler names to use in the shader
  141536. */
  141537. samplerNames?: Array<string>;
  141538. /**
  141539. * Defines to use in the shader
  141540. */
  141541. defines?: Array<string>;
  141542. /**
  141543. * Callback when effect is compiled
  141544. */
  141545. onCompiled?: Nullable<(effect: Effect) => void>;
  141546. /**
  141547. * The friendly name of the effect displayed in Spector.
  141548. */
  141549. name?: string;
  141550. }
  141551. /**
  141552. * Wraps an effect to be used for rendering
  141553. */
  141554. export class EffectWrapper {
  141555. /**
  141556. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141557. */
  141558. onApplyObservable: Observable<{}>;
  141559. /**
  141560. * The underlying effect
  141561. */
  141562. effect: Effect;
  141563. /**
  141564. * Creates an effect to be renderer
  141565. * @param creationOptions options to create the effect
  141566. */
  141567. constructor(creationOptions: EffectWrapperCreationOptions);
  141568. /**
  141569. * Disposes of the effect wrapper
  141570. */
  141571. dispose(): void;
  141572. }
  141573. }
  141574. declare module BABYLON {
  141575. /** @hidden */
  141576. export var hdrFilteringVertexShader: {
  141577. name: string;
  141578. shader: string;
  141579. };
  141580. }
  141581. declare module BABYLON {
  141582. /** @hidden */
  141583. export var hdrFilteringPixelShader: {
  141584. name: string;
  141585. shader: string;
  141586. };
  141587. }
  141588. declare module BABYLON {
  141589. /**
  141590. * Options for texture filtering
  141591. */
  141592. interface IHDRFilteringOptions {
  141593. /**
  141594. * Scales pixel intensity for the input HDR map.
  141595. */
  141596. hdrScale?: number;
  141597. /**
  141598. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141599. */
  141600. quality?: number;
  141601. }
  141602. /**
  141603. * Filters HDR maps to get correct renderings of PBR reflections
  141604. */
  141605. export class HDRFiltering {
  141606. private _engine;
  141607. private _effectRenderer;
  141608. private _effectWrapper;
  141609. private _lodGenerationOffset;
  141610. private _lodGenerationScale;
  141611. /**
  141612. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141613. * you care about baking speed.
  141614. */
  141615. quality: number;
  141616. /**
  141617. * Scales pixel intensity for the input HDR map.
  141618. */
  141619. hdrScale: number;
  141620. /**
  141621. * Instantiates HDR filter for reflection maps
  141622. *
  141623. * @param engine Thin engine
  141624. * @param options Options
  141625. */
  141626. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141627. private _createRenderTarget;
  141628. private _prefilterInternal;
  141629. private _createEffect;
  141630. /**
  141631. * Get a value indicating if the filter is ready to be used
  141632. * @param texture Texture to filter
  141633. * @returns true if the filter is ready
  141634. */
  141635. isReady(texture: BaseTexture): boolean;
  141636. /**
  141637. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141638. * Prefiltering will be invoked at the end of next rendering pass.
  141639. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141640. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141641. * @param texture Texture to filter
  141642. * @param onFinished Callback when filtering is done
  141643. * @return Promise called when prefiltering is done
  141644. */
  141645. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141646. }
  141647. }
  141648. declare module BABYLON {
  141649. /**
  141650. * This represents a texture coming from an HDR input.
  141651. *
  141652. * The only supported format is currently panorama picture stored in RGBE format.
  141653. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141654. */
  141655. export class HDRCubeTexture extends BaseTexture {
  141656. private static _facesMapping;
  141657. private _generateHarmonics;
  141658. private _noMipmap;
  141659. private _prefilterOnLoad;
  141660. private _textureMatrix;
  141661. private _size;
  141662. private _onLoad;
  141663. private _onError;
  141664. /**
  141665. * The texture URL.
  141666. */
  141667. url: string;
  141668. protected _isBlocking: boolean;
  141669. /**
  141670. * Sets wether or not the texture is blocking during loading.
  141671. */
  141672. set isBlocking(value: boolean);
  141673. /**
  141674. * Gets wether or not the texture is blocking during loading.
  141675. */
  141676. get isBlocking(): boolean;
  141677. protected _rotationY: number;
  141678. /**
  141679. * Sets texture matrix rotation angle around Y axis in radians.
  141680. */
  141681. set rotationY(value: number);
  141682. /**
  141683. * Gets texture matrix rotation angle around Y axis radians.
  141684. */
  141685. get rotationY(): number;
  141686. /**
  141687. * Gets or sets the center of the bounding box associated with the cube texture
  141688. * It must define where the camera used to render the texture was set
  141689. */
  141690. boundingBoxPosition: Vector3;
  141691. private _boundingBoxSize;
  141692. /**
  141693. * Gets or sets the size of the bounding box associated with the cube texture
  141694. * When defined, the cubemap will switch to local mode
  141695. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141696. * @example https://www.babylonjs-playground.com/#RNASML
  141697. */
  141698. set boundingBoxSize(value: Vector3);
  141699. get boundingBoxSize(): Vector3;
  141700. /**
  141701. * Instantiates an HDRTexture from the following parameters.
  141702. *
  141703. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141704. * @param sceneOrEngine The scene or engine the texture will be used in
  141705. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141706. * @param noMipmap Forces to not generate the mipmap if true
  141707. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141708. * @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)
  141709. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141710. */
  141711. 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>);
  141712. /**
  141713. * Get the current class name of the texture useful for serialization or dynamic coding.
  141714. * @returns "HDRCubeTexture"
  141715. */
  141716. getClassName(): string;
  141717. /**
  141718. * Occurs when the file is raw .hdr file.
  141719. */
  141720. private loadTexture;
  141721. clone(): HDRCubeTexture;
  141722. delayLoad(): void;
  141723. /**
  141724. * Get the texture reflection matrix used to rotate/transform the reflection.
  141725. * @returns the reflection matrix
  141726. */
  141727. getReflectionTextureMatrix(): Matrix;
  141728. /**
  141729. * Set the texture reflection matrix used to rotate/transform the reflection.
  141730. * @param value Define the reflection matrix to set
  141731. */
  141732. setReflectionTextureMatrix(value: Matrix): void;
  141733. /**
  141734. * Parses a JSON representation of an HDR Texture in order to create the texture
  141735. * @param parsedTexture Define the JSON representation
  141736. * @param scene Define the scene the texture should be created in
  141737. * @param rootUrl Define the root url in case we need to load relative dependencies
  141738. * @returns the newly created texture after parsing
  141739. */
  141740. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141741. serialize(): any;
  141742. }
  141743. }
  141744. declare module BABYLON {
  141745. /**
  141746. * Class used to control physics engine
  141747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141748. */
  141749. export class PhysicsEngine implements IPhysicsEngine {
  141750. private _physicsPlugin;
  141751. /**
  141752. * Global value used to control the smallest number supported by the simulation
  141753. */
  141754. static Epsilon: number;
  141755. private _impostors;
  141756. private _joints;
  141757. private _subTimeStep;
  141758. /**
  141759. * Gets the gravity vector used by the simulation
  141760. */
  141761. gravity: Vector3;
  141762. /**
  141763. * Factory used to create the default physics plugin.
  141764. * @returns The default physics plugin
  141765. */
  141766. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141767. /**
  141768. * Creates a new Physics Engine
  141769. * @param gravity defines the gravity vector used by the simulation
  141770. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141771. */
  141772. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141773. /**
  141774. * Sets the gravity vector used by the simulation
  141775. * @param gravity defines the gravity vector to use
  141776. */
  141777. setGravity(gravity: Vector3): void;
  141778. /**
  141779. * Set the time step of the physics engine.
  141780. * Default is 1/60.
  141781. * To slow it down, enter 1/600 for example.
  141782. * To speed it up, 1/30
  141783. * @param newTimeStep defines the new timestep to apply to this world.
  141784. */
  141785. setTimeStep(newTimeStep?: number): void;
  141786. /**
  141787. * Get the time step of the physics engine.
  141788. * @returns the current time step
  141789. */
  141790. getTimeStep(): number;
  141791. /**
  141792. * Set the sub time step of the physics engine.
  141793. * Default is 0 meaning there is no sub steps
  141794. * To increase physics resolution precision, set a small value (like 1 ms)
  141795. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141796. */
  141797. setSubTimeStep(subTimeStep?: number): void;
  141798. /**
  141799. * Get the sub time step of the physics engine.
  141800. * @returns the current sub time step
  141801. */
  141802. getSubTimeStep(): number;
  141803. /**
  141804. * Release all resources
  141805. */
  141806. dispose(): void;
  141807. /**
  141808. * Gets the name of the current physics plugin
  141809. * @returns the name of the plugin
  141810. */
  141811. getPhysicsPluginName(): string;
  141812. /**
  141813. * Adding a new impostor for the impostor tracking.
  141814. * This will be done by the impostor itself.
  141815. * @param impostor the impostor to add
  141816. */
  141817. addImpostor(impostor: PhysicsImpostor): void;
  141818. /**
  141819. * Remove an impostor from the engine.
  141820. * This impostor and its mesh will not longer be updated by the physics engine.
  141821. * @param impostor the impostor to remove
  141822. */
  141823. removeImpostor(impostor: PhysicsImpostor): void;
  141824. /**
  141825. * Add a joint to the physics engine
  141826. * @param mainImpostor defines the main impostor to which the joint is added.
  141827. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141828. * @param joint defines the joint that will connect both impostors.
  141829. */
  141830. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141831. /**
  141832. * Removes a joint from the simulation
  141833. * @param mainImpostor defines the impostor used with the joint
  141834. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141835. * @param joint defines the joint to remove
  141836. */
  141837. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141838. /**
  141839. * Called by the scene. No need to call it.
  141840. * @param delta defines the timespam between frames
  141841. */
  141842. _step(delta: number): void;
  141843. /**
  141844. * Gets the current plugin used to run the simulation
  141845. * @returns current plugin
  141846. */
  141847. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141848. /**
  141849. * Gets the list of physic impostors
  141850. * @returns an array of PhysicsImpostor
  141851. */
  141852. getImpostors(): Array<PhysicsImpostor>;
  141853. /**
  141854. * Gets the impostor for a physics enabled object
  141855. * @param object defines the object impersonated by the impostor
  141856. * @returns the PhysicsImpostor or null if not found
  141857. */
  141858. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141859. /**
  141860. * Gets the impostor for a physics body object
  141861. * @param body defines physics body used by the impostor
  141862. * @returns the PhysicsImpostor or null if not found
  141863. */
  141864. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141865. /**
  141866. * Does a raycast in the physics world
  141867. * @param from when should the ray start?
  141868. * @param to when should the ray end?
  141869. * @returns PhysicsRaycastResult
  141870. */
  141871. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141872. }
  141873. }
  141874. declare module BABYLON {
  141875. /** @hidden */
  141876. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141877. private _useDeltaForWorldStep;
  141878. world: any;
  141879. name: string;
  141880. private _physicsMaterials;
  141881. private _fixedTimeStep;
  141882. private _cannonRaycastResult;
  141883. private _raycastResult;
  141884. private _physicsBodysToRemoveAfterStep;
  141885. private _firstFrame;
  141886. BJSCANNON: any;
  141887. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141888. setGravity(gravity: Vector3): void;
  141889. setTimeStep(timeStep: number): void;
  141890. getTimeStep(): number;
  141891. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141892. private _removeMarkedPhysicsBodiesFromWorld;
  141893. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141894. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141895. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141896. private _processChildMeshes;
  141897. removePhysicsBody(impostor: PhysicsImpostor): void;
  141898. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141899. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141900. private _addMaterial;
  141901. private _checkWithEpsilon;
  141902. private _createShape;
  141903. private _createHeightmap;
  141904. private _minus90X;
  141905. private _plus90X;
  141906. private _tmpPosition;
  141907. private _tmpDeltaPosition;
  141908. private _tmpUnityRotation;
  141909. private _updatePhysicsBodyTransformation;
  141910. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141911. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141912. isSupported(): boolean;
  141913. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141914. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141915. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141916. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141917. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141918. getBodyMass(impostor: PhysicsImpostor): number;
  141919. getBodyFriction(impostor: PhysicsImpostor): number;
  141920. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141921. getBodyRestitution(impostor: PhysicsImpostor): number;
  141922. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141923. sleepBody(impostor: PhysicsImpostor): void;
  141924. wakeUpBody(impostor: PhysicsImpostor): void;
  141925. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141926. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141927. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141928. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141929. getRadius(impostor: PhysicsImpostor): number;
  141930. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141931. dispose(): void;
  141932. private _extendNamespace;
  141933. /**
  141934. * Does a raycast in the physics world
  141935. * @param from when should the ray start?
  141936. * @param to when should the ray end?
  141937. * @returns PhysicsRaycastResult
  141938. */
  141939. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141940. }
  141941. }
  141942. declare module BABYLON {
  141943. /** @hidden */
  141944. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141945. private _useDeltaForWorldStep;
  141946. world: any;
  141947. name: string;
  141948. BJSOIMO: any;
  141949. private _raycastResult;
  141950. private _fixedTimeStep;
  141951. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141952. setGravity(gravity: Vector3): void;
  141953. setTimeStep(timeStep: number): void;
  141954. getTimeStep(): number;
  141955. private _tmpImpostorsArray;
  141956. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141957. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141958. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141959. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141960. private _tmpPositionVector;
  141961. removePhysicsBody(impostor: PhysicsImpostor): void;
  141962. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141963. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141964. isSupported(): boolean;
  141965. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141966. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141967. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141968. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141969. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141970. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141971. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141972. getBodyMass(impostor: PhysicsImpostor): number;
  141973. getBodyFriction(impostor: PhysicsImpostor): number;
  141974. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141975. getBodyRestitution(impostor: PhysicsImpostor): number;
  141976. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141977. sleepBody(impostor: PhysicsImpostor): void;
  141978. wakeUpBody(impostor: PhysicsImpostor): void;
  141979. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141980. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141981. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141982. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141983. getRadius(impostor: PhysicsImpostor): number;
  141984. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141985. dispose(): void;
  141986. /**
  141987. * Does a raycast in the physics world
  141988. * @param from when should the ray start?
  141989. * @param to when should the ray end?
  141990. * @returns PhysicsRaycastResult
  141991. */
  141992. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141993. }
  141994. }
  141995. declare module BABYLON {
  141996. /**
  141997. * AmmoJS Physics plugin
  141998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141999. * @see https://github.com/kripken/ammo.js/
  142000. */
  142001. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142002. private _useDeltaForWorldStep;
  142003. /**
  142004. * Reference to the Ammo library
  142005. */
  142006. bjsAMMO: any;
  142007. /**
  142008. * Created ammoJS world which physics bodies are added to
  142009. */
  142010. world: any;
  142011. /**
  142012. * Name of the plugin
  142013. */
  142014. name: string;
  142015. private _timeStep;
  142016. private _fixedTimeStep;
  142017. private _maxSteps;
  142018. private _tmpQuaternion;
  142019. private _tmpAmmoTransform;
  142020. private _tmpAmmoQuaternion;
  142021. private _tmpAmmoConcreteContactResultCallback;
  142022. private _collisionConfiguration;
  142023. private _dispatcher;
  142024. private _overlappingPairCache;
  142025. private _solver;
  142026. private _softBodySolver;
  142027. private _tmpAmmoVectorA;
  142028. private _tmpAmmoVectorB;
  142029. private _tmpAmmoVectorC;
  142030. private _tmpAmmoVectorD;
  142031. private _tmpContactCallbackResult;
  142032. private _tmpAmmoVectorRCA;
  142033. private _tmpAmmoVectorRCB;
  142034. private _raycastResult;
  142035. private static readonly DISABLE_COLLISION_FLAG;
  142036. private static readonly KINEMATIC_FLAG;
  142037. private static readonly DISABLE_DEACTIVATION_FLAG;
  142038. /**
  142039. * Initializes the ammoJS plugin
  142040. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142041. * @param ammoInjection can be used to inject your own ammo reference
  142042. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142043. */
  142044. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142045. /**
  142046. * Sets the gravity of the physics world (m/(s^2))
  142047. * @param gravity Gravity to set
  142048. */
  142049. setGravity(gravity: Vector3): void;
  142050. /**
  142051. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142052. * @param timeStep timestep to use in seconds
  142053. */
  142054. setTimeStep(timeStep: number): void;
  142055. /**
  142056. * 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)
  142057. * @param fixedTimeStep fixedTimeStep to use in seconds
  142058. */
  142059. setFixedTimeStep(fixedTimeStep: number): void;
  142060. /**
  142061. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142062. * @param maxSteps the maximum number of steps by the physics engine per frame
  142063. */
  142064. setMaxSteps(maxSteps: number): void;
  142065. /**
  142066. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142067. * @returns the current timestep in seconds
  142068. */
  142069. getTimeStep(): number;
  142070. /**
  142071. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142072. */
  142073. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142074. private _isImpostorInContact;
  142075. private _isImpostorPairInContact;
  142076. private _stepSimulation;
  142077. /**
  142078. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142079. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142080. * After the step the babylon meshes are set to the position of the physics imposters
  142081. * @param delta amount of time to step forward
  142082. * @param impostors array of imposters to update before/after the step
  142083. */
  142084. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142085. /**
  142086. * Update babylon mesh to match physics world object
  142087. * @param impostor imposter to match
  142088. */
  142089. private _afterSoftStep;
  142090. /**
  142091. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142092. * @param impostor imposter to match
  142093. */
  142094. private _ropeStep;
  142095. /**
  142096. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142097. * @param impostor imposter to match
  142098. */
  142099. private _softbodyOrClothStep;
  142100. private _tmpMatrix;
  142101. /**
  142102. * Applies an impulse on the imposter
  142103. * @param impostor imposter to apply impulse to
  142104. * @param force amount of force to be applied to the imposter
  142105. * @param contactPoint the location to apply the impulse on the imposter
  142106. */
  142107. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142108. /**
  142109. * Applies a force on the imposter
  142110. * @param impostor imposter to apply force
  142111. * @param force amount of force to be applied to the imposter
  142112. * @param contactPoint the location to apply the force on the imposter
  142113. */
  142114. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142115. /**
  142116. * Creates a physics body using the plugin
  142117. * @param impostor the imposter to create the physics body on
  142118. */
  142119. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142120. /**
  142121. * Removes the physics body from the imposter and disposes of the body's memory
  142122. * @param impostor imposter to remove the physics body from
  142123. */
  142124. removePhysicsBody(impostor: PhysicsImpostor): void;
  142125. /**
  142126. * Generates a joint
  142127. * @param impostorJoint the imposter joint to create the joint with
  142128. */
  142129. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142130. /**
  142131. * Removes a joint
  142132. * @param impostorJoint the imposter joint to remove the joint from
  142133. */
  142134. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142135. private _addMeshVerts;
  142136. /**
  142137. * Initialise the soft body vertices to match its object's (mesh) vertices
  142138. * Softbody vertices (nodes) are in world space and to match this
  142139. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142140. * @param impostor to create the softbody for
  142141. */
  142142. private _softVertexData;
  142143. /**
  142144. * Create an impostor's soft body
  142145. * @param impostor to create the softbody for
  142146. */
  142147. private _createSoftbody;
  142148. /**
  142149. * Create cloth for an impostor
  142150. * @param impostor to create the softbody for
  142151. */
  142152. private _createCloth;
  142153. /**
  142154. * Create rope for an impostor
  142155. * @param impostor to create the softbody for
  142156. */
  142157. private _createRope;
  142158. /**
  142159. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142160. * @param impostor to create the custom physics shape for
  142161. */
  142162. private _createCustom;
  142163. private _addHullVerts;
  142164. private _createShape;
  142165. /**
  142166. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142167. * @param impostor imposter containing the physics body and babylon object
  142168. */
  142169. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142170. /**
  142171. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142172. * @param impostor imposter containing the physics body and babylon object
  142173. * @param newPosition new position
  142174. * @param newRotation new rotation
  142175. */
  142176. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142177. /**
  142178. * If this plugin is supported
  142179. * @returns true if its supported
  142180. */
  142181. isSupported(): boolean;
  142182. /**
  142183. * Sets the linear velocity of the physics body
  142184. * @param impostor imposter to set the velocity on
  142185. * @param velocity velocity to set
  142186. */
  142187. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142188. /**
  142189. * Sets the angular velocity of the physics body
  142190. * @param impostor imposter to set the velocity on
  142191. * @param velocity velocity to set
  142192. */
  142193. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142194. /**
  142195. * gets the linear velocity
  142196. * @param impostor imposter to get linear velocity from
  142197. * @returns linear velocity
  142198. */
  142199. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142200. /**
  142201. * gets the angular velocity
  142202. * @param impostor imposter to get angular velocity from
  142203. * @returns angular velocity
  142204. */
  142205. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142206. /**
  142207. * Sets the mass of physics body
  142208. * @param impostor imposter to set the mass on
  142209. * @param mass mass to set
  142210. */
  142211. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142212. /**
  142213. * Gets the mass of the physics body
  142214. * @param impostor imposter to get the mass from
  142215. * @returns mass
  142216. */
  142217. getBodyMass(impostor: PhysicsImpostor): number;
  142218. /**
  142219. * Gets friction of the impostor
  142220. * @param impostor impostor to get friction from
  142221. * @returns friction value
  142222. */
  142223. getBodyFriction(impostor: PhysicsImpostor): number;
  142224. /**
  142225. * Sets friction of the impostor
  142226. * @param impostor impostor to set friction on
  142227. * @param friction friction value
  142228. */
  142229. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142230. /**
  142231. * Gets restitution of the impostor
  142232. * @param impostor impostor to get restitution from
  142233. * @returns restitution value
  142234. */
  142235. getBodyRestitution(impostor: PhysicsImpostor): number;
  142236. /**
  142237. * Sets resitution of the impostor
  142238. * @param impostor impostor to set resitution on
  142239. * @param restitution resitution value
  142240. */
  142241. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142242. /**
  142243. * Gets pressure inside the impostor
  142244. * @param impostor impostor to get pressure from
  142245. * @returns pressure value
  142246. */
  142247. getBodyPressure(impostor: PhysicsImpostor): number;
  142248. /**
  142249. * Sets pressure inside a soft body impostor
  142250. * Cloth and rope must remain 0 pressure
  142251. * @param impostor impostor to set pressure on
  142252. * @param pressure pressure value
  142253. */
  142254. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142255. /**
  142256. * Gets stiffness of the impostor
  142257. * @param impostor impostor to get stiffness from
  142258. * @returns pressure value
  142259. */
  142260. getBodyStiffness(impostor: PhysicsImpostor): number;
  142261. /**
  142262. * Sets stiffness of the impostor
  142263. * @param impostor impostor to set stiffness on
  142264. * @param stiffness stiffness value from 0 to 1
  142265. */
  142266. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142267. /**
  142268. * Gets velocityIterations of the impostor
  142269. * @param impostor impostor to get velocity iterations from
  142270. * @returns velocityIterations value
  142271. */
  142272. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142273. /**
  142274. * Sets velocityIterations of the impostor
  142275. * @param impostor impostor to set velocity iterations on
  142276. * @param velocityIterations velocityIterations value
  142277. */
  142278. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142279. /**
  142280. * Gets positionIterations of the impostor
  142281. * @param impostor impostor to get position iterations from
  142282. * @returns positionIterations value
  142283. */
  142284. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142285. /**
  142286. * Sets positionIterations of the impostor
  142287. * @param impostor impostor to set position on
  142288. * @param positionIterations positionIterations value
  142289. */
  142290. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142291. /**
  142292. * Append an anchor to a cloth object
  142293. * @param impostor is the cloth impostor to add anchor to
  142294. * @param otherImpostor is the rigid impostor to anchor to
  142295. * @param width ratio across width from 0 to 1
  142296. * @param height ratio up height from 0 to 1
  142297. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142298. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142299. */
  142300. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142301. /**
  142302. * Append an hook to a rope object
  142303. * @param impostor is the rope impostor to add hook to
  142304. * @param otherImpostor is the rigid impostor to hook to
  142305. * @param length ratio along the rope from 0 to 1
  142306. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142307. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142308. */
  142309. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142310. /**
  142311. * Sleeps the physics body and stops it from being active
  142312. * @param impostor impostor to sleep
  142313. */
  142314. sleepBody(impostor: PhysicsImpostor): void;
  142315. /**
  142316. * Activates the physics body
  142317. * @param impostor impostor to activate
  142318. */
  142319. wakeUpBody(impostor: PhysicsImpostor): void;
  142320. /**
  142321. * Updates the distance parameters of the joint
  142322. * @param joint joint to update
  142323. * @param maxDistance maximum distance of the joint
  142324. * @param minDistance minimum distance of the joint
  142325. */
  142326. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142327. /**
  142328. * Sets a motor on the joint
  142329. * @param joint joint to set motor on
  142330. * @param speed speed of the motor
  142331. * @param maxForce maximum force of the motor
  142332. * @param motorIndex index of the motor
  142333. */
  142334. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142335. /**
  142336. * Sets the motors limit
  142337. * @param joint joint to set limit on
  142338. * @param upperLimit upper limit
  142339. * @param lowerLimit lower limit
  142340. */
  142341. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142342. /**
  142343. * Syncs the position and rotation of a mesh with the impostor
  142344. * @param mesh mesh to sync
  142345. * @param impostor impostor to update the mesh with
  142346. */
  142347. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142348. /**
  142349. * Gets the radius of the impostor
  142350. * @param impostor impostor to get radius from
  142351. * @returns the radius
  142352. */
  142353. getRadius(impostor: PhysicsImpostor): number;
  142354. /**
  142355. * Gets the box size of the impostor
  142356. * @param impostor impostor to get box size from
  142357. * @param result the resulting box size
  142358. */
  142359. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142360. /**
  142361. * Disposes of the impostor
  142362. */
  142363. dispose(): void;
  142364. /**
  142365. * Does a raycast in the physics world
  142366. * @param from when should the ray start?
  142367. * @param to when should the ray end?
  142368. * @returns PhysicsRaycastResult
  142369. */
  142370. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142371. }
  142372. }
  142373. declare module BABYLON {
  142374. interface AbstractScene {
  142375. /**
  142376. * The list of reflection probes added to the scene
  142377. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142378. */
  142379. reflectionProbes: Array<ReflectionProbe>;
  142380. /**
  142381. * Removes the given reflection probe from this scene.
  142382. * @param toRemove The reflection probe to remove
  142383. * @returns The index of the removed reflection probe
  142384. */
  142385. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142386. /**
  142387. * Adds the given reflection probe to this scene.
  142388. * @param newReflectionProbe The reflection probe to add
  142389. */
  142390. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142391. }
  142392. /**
  142393. * Class used to generate realtime reflection / refraction cube textures
  142394. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142395. */
  142396. export class ReflectionProbe {
  142397. /** defines the name of the probe */
  142398. name: string;
  142399. private _scene;
  142400. private _renderTargetTexture;
  142401. private _projectionMatrix;
  142402. private _viewMatrix;
  142403. private _target;
  142404. private _add;
  142405. private _attachedMesh;
  142406. private _invertYAxis;
  142407. /** Gets or sets probe position (center of the cube map) */
  142408. position: Vector3;
  142409. /**
  142410. * Creates a new reflection probe
  142411. * @param name defines the name of the probe
  142412. * @param size defines the texture resolution (for each face)
  142413. * @param scene defines the hosting scene
  142414. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142415. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142416. */
  142417. constructor(
  142418. /** defines the name of the probe */
  142419. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142420. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142421. get samples(): number;
  142422. set samples(value: number);
  142423. /** Gets or sets the refresh rate to use (on every frame by default) */
  142424. get refreshRate(): number;
  142425. set refreshRate(value: number);
  142426. /**
  142427. * Gets the hosting scene
  142428. * @returns a Scene
  142429. */
  142430. getScene(): Scene;
  142431. /** Gets the internal CubeTexture used to render to */
  142432. get cubeTexture(): RenderTargetTexture;
  142433. /** Gets the list of meshes to render */
  142434. get renderList(): Nullable<AbstractMesh[]>;
  142435. /**
  142436. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142437. * @param mesh defines the mesh to attach to
  142438. */
  142439. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142440. /**
  142441. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142442. * @param renderingGroupId The rendering group id corresponding to its index
  142443. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142444. */
  142445. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142446. /**
  142447. * Clean all associated resources
  142448. */
  142449. dispose(): void;
  142450. /**
  142451. * Converts the reflection probe information to a readable string for debug purpose.
  142452. * @param fullDetails Supports for multiple levels of logging within scene loading
  142453. * @returns the human readable reflection probe info
  142454. */
  142455. toString(fullDetails?: boolean): string;
  142456. /**
  142457. * Get the class name of the relfection probe.
  142458. * @returns "ReflectionProbe"
  142459. */
  142460. getClassName(): string;
  142461. /**
  142462. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142463. * @returns The JSON representation of the texture
  142464. */
  142465. serialize(): any;
  142466. /**
  142467. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142468. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142469. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142470. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142471. * @returns The parsed reflection probe if successful
  142472. */
  142473. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142474. }
  142475. }
  142476. declare module BABYLON {
  142477. /** @hidden */
  142478. export var _BabylonLoaderRegistered: boolean;
  142479. /**
  142480. * Helps setting up some configuration for the babylon file loader.
  142481. */
  142482. export class BabylonFileLoaderConfiguration {
  142483. /**
  142484. * The loader does not allow injecting custom physix engine into the plugins.
  142485. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142486. * So you could set this variable to your engine import to make it work.
  142487. */
  142488. static LoaderInjectedPhysicsEngine: any;
  142489. }
  142490. }
  142491. declare module BABYLON {
  142492. /**
  142493. * The Physically based simple base material of BJS.
  142494. *
  142495. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142496. * It is used as the base class for both the specGloss and metalRough conventions.
  142497. */
  142498. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142499. /**
  142500. * Number of Simultaneous lights allowed on the material.
  142501. */
  142502. maxSimultaneousLights: number;
  142503. /**
  142504. * If sets to true, disables all the lights affecting the material.
  142505. */
  142506. disableLighting: boolean;
  142507. /**
  142508. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142509. */
  142510. environmentTexture: BaseTexture;
  142511. /**
  142512. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142513. */
  142514. invertNormalMapX: boolean;
  142515. /**
  142516. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142517. */
  142518. invertNormalMapY: boolean;
  142519. /**
  142520. * Normal map used in the model.
  142521. */
  142522. normalTexture: BaseTexture;
  142523. /**
  142524. * Emissivie color used to self-illuminate the model.
  142525. */
  142526. emissiveColor: Color3;
  142527. /**
  142528. * Emissivie texture used to self-illuminate the model.
  142529. */
  142530. emissiveTexture: BaseTexture;
  142531. /**
  142532. * Occlusion Channel Strenght.
  142533. */
  142534. occlusionStrength: number;
  142535. /**
  142536. * Occlusion Texture of the material (adding extra occlusion effects).
  142537. */
  142538. occlusionTexture: BaseTexture;
  142539. /**
  142540. * Defines the alpha limits in alpha test mode.
  142541. */
  142542. alphaCutOff: number;
  142543. /**
  142544. * Gets the current double sided mode.
  142545. */
  142546. get doubleSided(): boolean;
  142547. /**
  142548. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142549. */
  142550. set doubleSided(value: boolean);
  142551. /**
  142552. * Stores the pre-calculated light information of a mesh in a texture.
  142553. */
  142554. lightmapTexture: BaseTexture;
  142555. /**
  142556. * If true, the light map contains occlusion information instead of lighting info.
  142557. */
  142558. useLightmapAsShadowmap: boolean;
  142559. /**
  142560. * Instantiates a new PBRMaterial instance.
  142561. *
  142562. * @param name The material name
  142563. * @param scene The scene the material will be use in.
  142564. */
  142565. constructor(name: string, scene: Scene);
  142566. getClassName(): string;
  142567. }
  142568. }
  142569. declare module BABYLON {
  142570. /**
  142571. * The PBR material of BJS following the metal roughness convention.
  142572. *
  142573. * This fits to the PBR convention in the GLTF definition:
  142574. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142575. */
  142576. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142577. /**
  142578. * The base color has two different interpretations depending on the value of metalness.
  142579. * When the material is a metal, the base color is the specific measured reflectance value
  142580. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142581. * of the material.
  142582. */
  142583. baseColor: Color3;
  142584. /**
  142585. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142586. * well as opacity information in the alpha channel.
  142587. */
  142588. baseTexture: BaseTexture;
  142589. /**
  142590. * Specifies the metallic scalar value of the material.
  142591. * Can also be used to scale the metalness values of the metallic texture.
  142592. */
  142593. metallic: number;
  142594. /**
  142595. * Specifies the roughness scalar value of the material.
  142596. * Can also be used to scale the roughness values of the metallic texture.
  142597. */
  142598. roughness: number;
  142599. /**
  142600. * Texture containing both the metallic value in the B channel and the
  142601. * roughness value in the G channel to keep better precision.
  142602. */
  142603. metallicRoughnessTexture: BaseTexture;
  142604. /**
  142605. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142606. *
  142607. * @param name The material name
  142608. * @param scene The scene the material will be use in.
  142609. */
  142610. constructor(name: string, scene: Scene);
  142611. /**
  142612. * Return the currrent class name of the material.
  142613. */
  142614. getClassName(): string;
  142615. /**
  142616. * Makes a duplicate of the current material.
  142617. * @param name - name to use for the new material.
  142618. */
  142619. clone(name: string): PBRMetallicRoughnessMaterial;
  142620. /**
  142621. * Serialize the material to a parsable JSON object.
  142622. */
  142623. serialize(): any;
  142624. /**
  142625. * Parses a JSON object correponding to the serialize function.
  142626. */
  142627. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142628. }
  142629. }
  142630. declare module BABYLON {
  142631. /**
  142632. * The PBR material of BJS following the specular glossiness convention.
  142633. *
  142634. * This fits to the PBR convention in the GLTF definition:
  142635. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142636. */
  142637. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142638. /**
  142639. * Specifies the diffuse color of the material.
  142640. */
  142641. diffuseColor: Color3;
  142642. /**
  142643. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142644. * channel.
  142645. */
  142646. diffuseTexture: BaseTexture;
  142647. /**
  142648. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142649. */
  142650. specularColor: Color3;
  142651. /**
  142652. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142653. */
  142654. glossiness: number;
  142655. /**
  142656. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142657. */
  142658. specularGlossinessTexture: BaseTexture;
  142659. /**
  142660. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142661. *
  142662. * @param name The material name
  142663. * @param scene The scene the material will be use in.
  142664. */
  142665. constructor(name: string, scene: Scene);
  142666. /**
  142667. * Return the currrent class name of the material.
  142668. */
  142669. getClassName(): string;
  142670. /**
  142671. * Makes a duplicate of the current material.
  142672. * @param name - name to use for the new material.
  142673. */
  142674. clone(name: string): PBRSpecularGlossinessMaterial;
  142675. /**
  142676. * Serialize the material to a parsable JSON object.
  142677. */
  142678. serialize(): any;
  142679. /**
  142680. * Parses a JSON object correponding to the serialize function.
  142681. */
  142682. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142683. }
  142684. }
  142685. declare module BABYLON {
  142686. /**
  142687. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142688. * It can help converting any input color in a desired output one. This can then be used to create effects
  142689. * from sepia, black and white to sixties or futuristic rendering...
  142690. *
  142691. * The only supported format is currently 3dl.
  142692. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142693. */
  142694. export class ColorGradingTexture extends BaseTexture {
  142695. /**
  142696. * The texture URL.
  142697. */
  142698. url: string;
  142699. /**
  142700. * Empty line regex stored for GC.
  142701. */
  142702. private static _noneEmptyLineRegex;
  142703. private _textureMatrix;
  142704. private _onLoad;
  142705. /**
  142706. * Instantiates a ColorGradingTexture from the following parameters.
  142707. *
  142708. * @param url The location of the color gradind data (currently only supporting 3dl)
  142709. * @param sceneOrEngine The scene or engine the texture will be used in
  142710. * @param onLoad defines a callback triggered when the texture has been loaded
  142711. */
  142712. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142713. /**
  142714. * Fires the onload event from the constructor if requested.
  142715. */
  142716. private _triggerOnLoad;
  142717. /**
  142718. * Returns the texture matrix used in most of the material.
  142719. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142720. */
  142721. getTextureMatrix(): Matrix;
  142722. /**
  142723. * Occurs when the file being loaded is a .3dl LUT file.
  142724. */
  142725. private load3dlTexture;
  142726. /**
  142727. * Starts the loading process of the texture.
  142728. */
  142729. private loadTexture;
  142730. /**
  142731. * Clones the color gradind texture.
  142732. */
  142733. clone(): ColorGradingTexture;
  142734. /**
  142735. * Called during delayed load for textures.
  142736. */
  142737. delayLoad(): void;
  142738. /**
  142739. * Parses a color grading texture serialized by Babylon.
  142740. * @param parsedTexture The texture information being parsedTexture
  142741. * @param scene The scene to load the texture in
  142742. * @param rootUrl The root url of the data assets to load
  142743. * @return A color gradind texture
  142744. */
  142745. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142746. /**
  142747. * Serializes the LUT texture to json format.
  142748. */
  142749. serialize(): any;
  142750. }
  142751. }
  142752. declare module BABYLON {
  142753. /**
  142754. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142755. */
  142756. export class EquiRectangularCubeTexture extends BaseTexture {
  142757. /** The six faces of the cube. */
  142758. private static _FacesMapping;
  142759. private _noMipmap;
  142760. private _onLoad;
  142761. private _onError;
  142762. /** The size of the cubemap. */
  142763. private _size;
  142764. /** The buffer of the image. */
  142765. private _buffer;
  142766. /** The width of the input image. */
  142767. private _width;
  142768. /** The height of the input image. */
  142769. private _height;
  142770. /** The URL to the image. */
  142771. url: string;
  142772. /**
  142773. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142774. * @param url The location of the image
  142775. * @param scene The scene the texture will be used in
  142776. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142777. * @param noMipmap Forces to not generate the mipmap if true
  142778. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142779. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142780. * @param onLoad — defines a callback called when texture is loaded
  142781. * @param onError — defines a callback called if there is an error
  142782. */
  142783. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142784. /**
  142785. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142786. */
  142787. private loadImage;
  142788. /**
  142789. * Convert the image buffer into a cubemap and create a CubeTexture.
  142790. */
  142791. private loadTexture;
  142792. /**
  142793. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142794. * @param buffer The ArrayBuffer that should be converted.
  142795. * @returns The buffer as Float32Array.
  142796. */
  142797. private getFloat32ArrayFromArrayBuffer;
  142798. /**
  142799. * Get the current class name of the texture useful for serialization or dynamic coding.
  142800. * @returns "EquiRectangularCubeTexture"
  142801. */
  142802. getClassName(): string;
  142803. /**
  142804. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142805. * @returns A clone of the current EquiRectangularCubeTexture.
  142806. */
  142807. clone(): EquiRectangularCubeTexture;
  142808. }
  142809. }
  142810. declare module BABYLON {
  142811. /**
  142812. * Defines the options related to the creation of an HtmlElementTexture
  142813. */
  142814. export interface IHtmlElementTextureOptions {
  142815. /**
  142816. * Defines wether mip maps should be created or not.
  142817. */
  142818. generateMipMaps?: boolean;
  142819. /**
  142820. * Defines the sampling mode of the texture.
  142821. */
  142822. samplingMode?: number;
  142823. /**
  142824. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142825. */
  142826. engine: Nullable<ThinEngine>;
  142827. /**
  142828. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142829. */
  142830. scene: Nullable<Scene>;
  142831. }
  142832. /**
  142833. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142834. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142835. * is automatically managed.
  142836. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142837. * in your application.
  142838. *
  142839. * As the update is not automatic, you need to call them manually.
  142840. */
  142841. export class HtmlElementTexture extends BaseTexture {
  142842. /**
  142843. * The texture URL.
  142844. */
  142845. element: HTMLVideoElement | HTMLCanvasElement;
  142846. private static readonly DefaultOptions;
  142847. private _textureMatrix;
  142848. private _isVideo;
  142849. private _generateMipMaps;
  142850. private _samplingMode;
  142851. /**
  142852. * Instantiates a HtmlElementTexture from the following parameters.
  142853. *
  142854. * @param name Defines the name of the texture
  142855. * @param element Defines the video or canvas the texture is filled with
  142856. * @param options Defines the other none mandatory texture creation options
  142857. */
  142858. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142859. private _createInternalTexture;
  142860. /**
  142861. * Returns the texture matrix used in most of the material.
  142862. */
  142863. getTextureMatrix(): Matrix;
  142864. /**
  142865. * Updates the content of the texture.
  142866. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142867. */
  142868. update(invertY?: Nullable<boolean>): void;
  142869. }
  142870. }
  142871. declare module BABYLON {
  142872. /**
  142873. * Based on jsTGALoader - Javascript loader for TGA file
  142874. * By Vincent Thibault
  142875. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142876. */
  142877. export class TGATools {
  142878. private static _TYPE_INDEXED;
  142879. private static _TYPE_RGB;
  142880. private static _TYPE_GREY;
  142881. private static _TYPE_RLE_INDEXED;
  142882. private static _TYPE_RLE_RGB;
  142883. private static _TYPE_RLE_GREY;
  142884. private static _ORIGIN_MASK;
  142885. private static _ORIGIN_SHIFT;
  142886. private static _ORIGIN_BL;
  142887. private static _ORIGIN_BR;
  142888. private static _ORIGIN_UL;
  142889. private static _ORIGIN_UR;
  142890. /**
  142891. * Gets the header of a TGA file
  142892. * @param data defines the TGA data
  142893. * @returns the header
  142894. */
  142895. static GetTGAHeader(data: Uint8Array): any;
  142896. /**
  142897. * Uploads TGA content to a Babylon Texture
  142898. * @hidden
  142899. */
  142900. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142901. /** @hidden */
  142902. 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;
  142903. /** @hidden */
  142904. 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;
  142905. /** @hidden */
  142906. 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;
  142907. /** @hidden */
  142908. 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;
  142909. /** @hidden */
  142910. 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;
  142911. /** @hidden */
  142912. 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;
  142913. }
  142914. }
  142915. declare module BABYLON {
  142916. /**
  142917. * Implementation of the TGA Texture Loader.
  142918. * @hidden
  142919. */
  142920. export class _TGATextureLoader implements IInternalTextureLoader {
  142921. /**
  142922. * Defines wether the loader supports cascade loading the different faces.
  142923. */
  142924. readonly supportCascades: boolean;
  142925. /**
  142926. * This returns if the loader support the current file information.
  142927. * @param extension defines the file extension of the file being loaded
  142928. * @returns true if the loader can load the specified file
  142929. */
  142930. canLoad(extension: string): boolean;
  142931. /**
  142932. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142933. * @param data contains the texture data
  142934. * @param texture defines the BabylonJS internal texture
  142935. * @param createPolynomials will be true if polynomials have been requested
  142936. * @param onLoad defines the callback to trigger once the texture is ready
  142937. * @param onError defines the callback to trigger in case of error
  142938. */
  142939. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142940. /**
  142941. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142942. * @param data contains the texture data
  142943. * @param texture defines the BabylonJS internal texture
  142944. * @param callback defines the method to call once ready to upload
  142945. */
  142946. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142947. }
  142948. }
  142949. declare module BABYLON {
  142950. /**
  142951. * Info about the .basis files
  142952. */
  142953. class BasisFileInfo {
  142954. /**
  142955. * If the file has alpha
  142956. */
  142957. hasAlpha: boolean;
  142958. /**
  142959. * Info about each image of the basis file
  142960. */
  142961. images: Array<{
  142962. levels: Array<{
  142963. width: number;
  142964. height: number;
  142965. transcodedPixels: ArrayBufferView;
  142966. }>;
  142967. }>;
  142968. }
  142969. /**
  142970. * Result of transcoding a basis file
  142971. */
  142972. class TranscodeResult {
  142973. /**
  142974. * Info about the .basis file
  142975. */
  142976. fileInfo: BasisFileInfo;
  142977. /**
  142978. * Format to use when loading the file
  142979. */
  142980. format: number;
  142981. }
  142982. /**
  142983. * Configuration options for the Basis transcoder
  142984. */
  142985. export class BasisTranscodeConfiguration {
  142986. /**
  142987. * Supported compression formats used to determine the supported output format of the transcoder
  142988. */
  142989. supportedCompressionFormats?: {
  142990. /**
  142991. * etc1 compression format
  142992. */
  142993. etc1?: boolean;
  142994. /**
  142995. * s3tc compression format
  142996. */
  142997. s3tc?: boolean;
  142998. /**
  142999. * pvrtc compression format
  143000. */
  143001. pvrtc?: boolean;
  143002. /**
  143003. * etc2 compression format
  143004. */
  143005. etc2?: boolean;
  143006. };
  143007. /**
  143008. * If mipmap levels should be loaded for transcoded images (Default: true)
  143009. */
  143010. loadMipmapLevels?: boolean;
  143011. /**
  143012. * Index of a single image to load (Default: all images)
  143013. */
  143014. loadSingleImage?: number;
  143015. }
  143016. /**
  143017. * Used to load .Basis files
  143018. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143019. */
  143020. export class BasisTools {
  143021. private static _IgnoreSupportedFormats;
  143022. /**
  143023. * URL to use when loading the basis transcoder
  143024. */
  143025. static JSModuleURL: string;
  143026. /**
  143027. * URL to use when loading the wasm module for the transcoder
  143028. */
  143029. static WasmModuleURL: string;
  143030. /**
  143031. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143032. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143033. * @returns internal format corresponding to the Basis format
  143034. */
  143035. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143036. private static _WorkerPromise;
  143037. private static _Worker;
  143038. private static _actionId;
  143039. private static _CreateWorkerAsync;
  143040. /**
  143041. * Transcodes a loaded image file to compressed pixel data
  143042. * @param data image data to transcode
  143043. * @param config configuration options for the transcoding
  143044. * @returns a promise resulting in the transcoded image
  143045. */
  143046. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143047. /**
  143048. * Loads a texture from the transcode result
  143049. * @param texture texture load to
  143050. * @param transcodeResult the result of transcoding the basis file to load from
  143051. */
  143052. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143053. }
  143054. }
  143055. declare module BABYLON {
  143056. /**
  143057. * Loader for .basis file format
  143058. */
  143059. export class _BasisTextureLoader implements IInternalTextureLoader {
  143060. /**
  143061. * Defines whether the loader supports cascade loading the different faces.
  143062. */
  143063. readonly supportCascades: boolean;
  143064. /**
  143065. * This returns if the loader support the current file information.
  143066. * @param extension defines the file extension of the file being loaded
  143067. * @returns true if the loader can load the specified file
  143068. */
  143069. canLoad(extension: string): boolean;
  143070. /**
  143071. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143072. * @param data contains the texture data
  143073. * @param texture defines the BabylonJS internal texture
  143074. * @param createPolynomials will be true if polynomials have been requested
  143075. * @param onLoad defines the callback to trigger once the texture is ready
  143076. * @param onError defines the callback to trigger in case of error
  143077. */
  143078. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143079. /**
  143080. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143081. * @param data contains the texture data
  143082. * @param texture defines the BabylonJS internal texture
  143083. * @param callback defines the method to call once ready to upload
  143084. */
  143085. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143086. }
  143087. }
  143088. declare module BABYLON {
  143089. /**
  143090. * Defines the basic options interface of a TexturePacker Frame
  143091. */
  143092. export interface ITexturePackerFrame {
  143093. /**
  143094. * The frame ID
  143095. */
  143096. id: number;
  143097. /**
  143098. * The frames Scale
  143099. */
  143100. scale: Vector2;
  143101. /**
  143102. * The Frames offset
  143103. */
  143104. offset: Vector2;
  143105. }
  143106. /**
  143107. * This is a support class for frame Data on texture packer sets.
  143108. */
  143109. export class TexturePackerFrame implements ITexturePackerFrame {
  143110. /**
  143111. * The frame ID
  143112. */
  143113. id: number;
  143114. /**
  143115. * The frames Scale
  143116. */
  143117. scale: Vector2;
  143118. /**
  143119. * The Frames offset
  143120. */
  143121. offset: Vector2;
  143122. /**
  143123. * Initializes a texture package frame.
  143124. * @param id The numerical frame identifier
  143125. * @param scale Scalar Vector2 for UV frame
  143126. * @param offset Vector2 for the frame position in UV units.
  143127. * @returns TexturePackerFrame
  143128. */
  143129. constructor(id: number, scale: Vector2, offset: Vector2);
  143130. }
  143131. }
  143132. declare module BABYLON {
  143133. /**
  143134. * Defines the basic options interface of a TexturePacker
  143135. */
  143136. export interface ITexturePackerOptions {
  143137. /**
  143138. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143139. */
  143140. map?: string[];
  143141. /**
  143142. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143143. */
  143144. uvsIn?: string;
  143145. /**
  143146. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143147. */
  143148. uvsOut?: string;
  143149. /**
  143150. * number representing the layout style. Defaults to LAYOUT_STRIP
  143151. */
  143152. layout?: number;
  143153. /**
  143154. * number of columns if using custom column count layout(2). This defaults to 4.
  143155. */
  143156. colnum?: number;
  143157. /**
  143158. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143159. */
  143160. updateInputMeshes?: boolean;
  143161. /**
  143162. * boolean flag to dispose all the source textures. Defaults to true.
  143163. */
  143164. disposeSources?: boolean;
  143165. /**
  143166. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143167. */
  143168. fillBlanks?: boolean;
  143169. /**
  143170. * string value representing the context fill style color. Defaults to 'black'.
  143171. */
  143172. customFillColor?: string;
  143173. /**
  143174. * Width and Height Value of each Frame in the TexturePacker Sets
  143175. */
  143176. frameSize?: number;
  143177. /**
  143178. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143179. */
  143180. paddingRatio?: number;
  143181. /**
  143182. * Number that declares the fill method for the padding gutter.
  143183. */
  143184. paddingMode?: number;
  143185. /**
  143186. * If in SUBUV_COLOR padding mode what color to use.
  143187. */
  143188. paddingColor?: Color3 | Color4;
  143189. }
  143190. /**
  143191. * Defines the basic interface of a TexturePacker JSON File
  143192. */
  143193. export interface ITexturePackerJSON {
  143194. /**
  143195. * The frame ID
  143196. */
  143197. name: string;
  143198. /**
  143199. * The base64 channel data
  143200. */
  143201. sets: any;
  143202. /**
  143203. * The options of the Packer
  143204. */
  143205. options: ITexturePackerOptions;
  143206. /**
  143207. * The frame data of the Packer
  143208. */
  143209. frames: Array<number>;
  143210. }
  143211. /**
  143212. * This is a support class that generates a series of packed texture sets.
  143213. * @see https://doc.babylonjs.com/babylon101/materials
  143214. */
  143215. export class TexturePacker {
  143216. /** Packer Layout Constant 0 */
  143217. static readonly LAYOUT_STRIP: number;
  143218. /** Packer Layout Constant 1 */
  143219. static readonly LAYOUT_POWER2: number;
  143220. /** Packer Layout Constant 2 */
  143221. static readonly LAYOUT_COLNUM: number;
  143222. /** Packer Layout Constant 0 */
  143223. static readonly SUBUV_WRAP: number;
  143224. /** Packer Layout Constant 1 */
  143225. static readonly SUBUV_EXTEND: number;
  143226. /** Packer Layout Constant 2 */
  143227. static readonly SUBUV_COLOR: number;
  143228. /** The Name of the Texture Package */
  143229. name: string;
  143230. /** The scene scope of the TexturePacker */
  143231. scene: Scene;
  143232. /** The Meshes to target */
  143233. meshes: AbstractMesh[];
  143234. /** Arguments passed with the Constructor */
  143235. options: ITexturePackerOptions;
  143236. /** The promise that is started upon initialization */
  143237. promise: Nullable<Promise<TexturePacker | string>>;
  143238. /** The Container object for the channel sets that are generated */
  143239. sets: object;
  143240. /** The Container array for the frames that are generated */
  143241. frames: TexturePackerFrame[];
  143242. /** The expected number of textures the system is parsing. */
  143243. private _expecting;
  143244. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143245. private _paddingValue;
  143246. /**
  143247. * Initializes a texture package series from an array of meshes or a single mesh.
  143248. * @param name The name of the package
  143249. * @param meshes The target meshes to compose the package from
  143250. * @param options The arguments that texture packer should follow while building.
  143251. * @param scene The scene which the textures are scoped to.
  143252. * @returns TexturePacker
  143253. */
  143254. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143255. /**
  143256. * Starts the package process
  143257. * @param resolve The promises resolution function
  143258. * @returns TexturePacker
  143259. */
  143260. private _createFrames;
  143261. /**
  143262. * Calculates the Size of the Channel Sets
  143263. * @returns Vector2
  143264. */
  143265. private _calculateSize;
  143266. /**
  143267. * Calculates the UV data for the frames.
  143268. * @param baseSize the base frameSize
  143269. * @param padding the base frame padding
  143270. * @param dtSize size of the Dynamic Texture for that channel
  143271. * @param dtUnits is 1/dtSize
  143272. * @param update flag to update the input meshes
  143273. */
  143274. private _calculateMeshUVFrames;
  143275. /**
  143276. * Calculates the frames Offset.
  143277. * @param index of the frame
  143278. * @returns Vector2
  143279. */
  143280. private _getFrameOffset;
  143281. /**
  143282. * Updates a Mesh to the frame data
  143283. * @param mesh that is the target
  143284. * @param frameID or the frame index
  143285. */
  143286. private _updateMeshUV;
  143287. /**
  143288. * Updates a Meshes materials to use the texture packer channels
  143289. * @param m is the mesh to target
  143290. * @param force all channels on the packer to be set.
  143291. */
  143292. private _updateTextureReferences;
  143293. /**
  143294. * Public method to set a Mesh to a frame
  143295. * @param m that is the target
  143296. * @param frameID or the frame index
  143297. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143298. */
  143299. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143300. /**
  143301. * Starts the async promise to compile the texture packer.
  143302. * @returns Promise<void>
  143303. */
  143304. processAsync(): Promise<void>;
  143305. /**
  143306. * Disposes all textures associated with this packer
  143307. */
  143308. dispose(): void;
  143309. /**
  143310. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143311. * @param imageType is the image type to use.
  143312. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143313. */
  143314. download(imageType?: string, quality?: number): void;
  143315. /**
  143316. * Public method to load a texturePacker JSON file.
  143317. * @param data of the JSON file in string format.
  143318. */
  143319. updateFromJSON(data: string): void;
  143320. }
  143321. }
  143322. declare module BABYLON {
  143323. /**
  143324. * 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.
  143325. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143326. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143327. */
  143328. export class CustomProceduralTexture extends ProceduralTexture {
  143329. private _animate;
  143330. private _time;
  143331. private _config;
  143332. private _texturePath;
  143333. /**
  143334. * Instantiates a new Custom Procedural Texture.
  143335. * 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.
  143336. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143337. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143338. * @param name Define the name of the texture
  143339. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143340. * @param size Define the size of the texture to create
  143341. * @param scene Define the scene the texture belongs to
  143342. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143343. * @param generateMipMaps Define if the texture should creates mip maps or not
  143344. */
  143345. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143346. private _loadJson;
  143347. /**
  143348. * Is the texture ready to be used ? (rendered at least once)
  143349. * @returns true if ready, otherwise, false.
  143350. */
  143351. isReady(): boolean;
  143352. /**
  143353. * Render the texture to its associated render target.
  143354. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143355. */
  143356. render(useCameraPostProcess?: boolean): void;
  143357. /**
  143358. * Update the list of dependant textures samplers in the shader.
  143359. */
  143360. updateTextures(): void;
  143361. /**
  143362. * Update the uniform values of the procedural texture in the shader.
  143363. */
  143364. updateShaderUniforms(): void;
  143365. /**
  143366. * Define if the texture animates or not.
  143367. */
  143368. get animate(): boolean;
  143369. set animate(value: boolean);
  143370. }
  143371. }
  143372. declare module BABYLON {
  143373. /** @hidden */
  143374. export var noisePixelShader: {
  143375. name: string;
  143376. shader: string;
  143377. };
  143378. }
  143379. declare module BABYLON {
  143380. /**
  143381. * Class used to generate noise procedural textures
  143382. */
  143383. export class NoiseProceduralTexture extends ProceduralTexture {
  143384. /** Gets or sets the start time (default is 0) */
  143385. time: number;
  143386. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143387. brightness: number;
  143388. /** Defines the number of octaves to process */
  143389. octaves: number;
  143390. /** Defines the level of persistence (0.8 by default) */
  143391. persistence: number;
  143392. /** Gets or sets animation speed factor (default is 1) */
  143393. animationSpeedFactor: number;
  143394. /**
  143395. * Creates a new NoiseProceduralTexture
  143396. * @param name defines the name fo the texture
  143397. * @param size defines the size of the texture (default is 256)
  143398. * @param scene defines the hosting scene
  143399. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143400. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143401. */
  143402. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143403. private _updateShaderUniforms;
  143404. protected _getDefines(): string;
  143405. /** Generate the current state of the procedural texture */
  143406. render(useCameraPostProcess?: boolean): void;
  143407. /**
  143408. * Serializes this noise procedural texture
  143409. * @returns a serialized noise procedural texture object
  143410. */
  143411. serialize(): any;
  143412. /**
  143413. * Clone the texture.
  143414. * @returns the cloned texture
  143415. */
  143416. clone(): NoiseProceduralTexture;
  143417. /**
  143418. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143419. * @param parsedTexture defines parsed texture data
  143420. * @param scene defines the current scene
  143421. * @param rootUrl defines the root URL containing noise procedural texture information
  143422. * @returns a parsed NoiseProceduralTexture
  143423. */
  143424. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143425. }
  143426. }
  143427. declare module BABYLON {
  143428. /**
  143429. * Raw cube texture where the raw buffers are passed in
  143430. */
  143431. export class RawCubeTexture extends CubeTexture {
  143432. /**
  143433. * Creates a cube texture where the raw buffers are passed in.
  143434. * @param scene defines the scene the texture is attached to
  143435. * @param data defines the array of data to use to create each face
  143436. * @param size defines the size of the textures
  143437. * @param format defines the format of the data
  143438. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143439. * @param generateMipMaps defines if the engine should generate the mip levels
  143440. * @param invertY defines if data must be stored with Y axis inverted
  143441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143442. * @param compression defines the compression used (null by default)
  143443. */
  143444. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143445. /**
  143446. * Updates the raw cube texture.
  143447. * @param data defines the data to store
  143448. * @param format defines the data format
  143449. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143450. * @param invertY defines if data must be stored with Y axis inverted
  143451. * @param compression defines the compression used (null by default)
  143452. * @param level defines which level of the texture to update
  143453. */
  143454. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143455. /**
  143456. * Updates a raw cube texture with RGBD encoded data.
  143457. * @param data defines the array of data [mipmap][face] to use to create each face
  143458. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143459. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143460. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143461. * @returns a promsie that resolves when the operation is complete
  143462. */
  143463. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143464. /**
  143465. * Clones the raw cube texture.
  143466. * @return a new cube texture
  143467. */
  143468. clone(): CubeTexture;
  143469. /** @hidden */
  143470. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143471. }
  143472. }
  143473. declare module BABYLON {
  143474. /**
  143475. * Class used to store 2D array textures containing user data
  143476. */
  143477. export class RawTexture2DArray extends Texture {
  143478. /** Gets or sets the texture format to use */
  143479. format: number;
  143480. /**
  143481. * Create a new RawTexture2DArray
  143482. * @param data defines the data of the texture
  143483. * @param width defines the width of the texture
  143484. * @param height defines the height of the texture
  143485. * @param depth defines the number of layers of the texture
  143486. * @param format defines the texture format to use
  143487. * @param scene defines the hosting scene
  143488. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143489. * @param invertY defines if texture must be stored with Y axis inverted
  143490. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143491. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143492. */
  143493. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143494. /** Gets or sets the texture format to use */
  143495. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143496. /**
  143497. * Update the texture with new data
  143498. * @param data defines the data to store in the texture
  143499. */
  143500. update(data: ArrayBufferView): void;
  143501. }
  143502. }
  143503. declare module BABYLON {
  143504. /**
  143505. * Class used to store 3D textures containing user data
  143506. */
  143507. export class RawTexture3D extends Texture {
  143508. /** Gets or sets the texture format to use */
  143509. format: number;
  143510. /**
  143511. * Create a new RawTexture3D
  143512. * @param data defines the data of the texture
  143513. * @param width defines the width of the texture
  143514. * @param height defines the height of the texture
  143515. * @param depth defines the depth of the texture
  143516. * @param format defines the texture format to use
  143517. * @param scene defines the hosting scene
  143518. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143519. * @param invertY defines if texture must be stored with Y axis inverted
  143520. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143521. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143522. */
  143523. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143524. /** Gets or sets the texture format to use */
  143525. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143526. /**
  143527. * Update the texture with new data
  143528. * @param data defines the data to store in the texture
  143529. */
  143530. update(data: ArrayBufferView): void;
  143531. }
  143532. }
  143533. declare module BABYLON {
  143534. /**
  143535. * Creates a refraction texture used by refraction channel of the standard material.
  143536. * It is like a mirror but to see through a material.
  143537. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143538. */
  143539. export class RefractionTexture extends RenderTargetTexture {
  143540. /**
  143541. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143542. * 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.
  143543. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143544. */
  143545. refractionPlane: Plane;
  143546. /**
  143547. * Define how deep under the surface we should see.
  143548. */
  143549. depth: number;
  143550. /**
  143551. * Creates a refraction texture used by refraction channel of the standard material.
  143552. * It is like a mirror but to see through a material.
  143553. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143554. * @param name Define the texture name
  143555. * @param size Define the size of the underlying texture
  143556. * @param scene Define the scene the refraction belongs to
  143557. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143558. */
  143559. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143560. /**
  143561. * Clone the refraction texture.
  143562. * @returns the cloned texture
  143563. */
  143564. clone(): RefractionTexture;
  143565. /**
  143566. * Serialize the texture to a JSON representation you could use in Parse later on
  143567. * @returns the serialized JSON representation
  143568. */
  143569. serialize(): any;
  143570. }
  143571. }
  143572. declare module BABYLON {
  143573. /**
  143574. * Block used to add support for vertex skinning (bones)
  143575. */
  143576. export class BonesBlock extends NodeMaterialBlock {
  143577. /**
  143578. * Creates a new BonesBlock
  143579. * @param name defines the block name
  143580. */
  143581. constructor(name: string);
  143582. /**
  143583. * Initialize the block and prepare the context for build
  143584. * @param state defines the state that will be used for the build
  143585. */
  143586. initialize(state: NodeMaterialBuildState): void;
  143587. /**
  143588. * Gets the current class name
  143589. * @returns the class name
  143590. */
  143591. getClassName(): string;
  143592. /**
  143593. * Gets the matrix indices input component
  143594. */
  143595. get matricesIndices(): NodeMaterialConnectionPoint;
  143596. /**
  143597. * Gets the matrix weights input component
  143598. */
  143599. get matricesWeights(): NodeMaterialConnectionPoint;
  143600. /**
  143601. * Gets the extra matrix indices input component
  143602. */
  143603. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143604. /**
  143605. * Gets the extra matrix weights input component
  143606. */
  143607. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143608. /**
  143609. * Gets the world input component
  143610. */
  143611. get world(): NodeMaterialConnectionPoint;
  143612. /**
  143613. * Gets the output component
  143614. */
  143615. get output(): NodeMaterialConnectionPoint;
  143616. autoConfigure(material: NodeMaterial): void;
  143617. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143620. protected _buildBlock(state: NodeMaterialBuildState): this;
  143621. }
  143622. }
  143623. declare module BABYLON {
  143624. /**
  143625. * Block used to add support for instances
  143626. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143627. */
  143628. export class InstancesBlock extends NodeMaterialBlock {
  143629. /**
  143630. * Creates a new InstancesBlock
  143631. * @param name defines the block name
  143632. */
  143633. constructor(name: string);
  143634. /**
  143635. * Gets the current class name
  143636. * @returns the class name
  143637. */
  143638. getClassName(): string;
  143639. /**
  143640. * Gets the first world row input component
  143641. */
  143642. get world0(): NodeMaterialConnectionPoint;
  143643. /**
  143644. * Gets the second world row input component
  143645. */
  143646. get world1(): NodeMaterialConnectionPoint;
  143647. /**
  143648. * Gets the third world row input component
  143649. */
  143650. get world2(): NodeMaterialConnectionPoint;
  143651. /**
  143652. * Gets the forth world row input component
  143653. */
  143654. get world3(): NodeMaterialConnectionPoint;
  143655. /**
  143656. * Gets the world input component
  143657. */
  143658. get world(): NodeMaterialConnectionPoint;
  143659. /**
  143660. * Gets the output component
  143661. */
  143662. get output(): NodeMaterialConnectionPoint;
  143663. /**
  143664. * Gets the isntanceID component
  143665. */
  143666. get instanceID(): NodeMaterialConnectionPoint;
  143667. autoConfigure(material: NodeMaterial): void;
  143668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143669. protected _buildBlock(state: NodeMaterialBuildState): this;
  143670. }
  143671. }
  143672. declare module BABYLON {
  143673. /**
  143674. * Block used to add morph targets support to vertex shader
  143675. */
  143676. export class MorphTargetsBlock extends NodeMaterialBlock {
  143677. private _repeatableContentAnchor;
  143678. /**
  143679. * Create a new MorphTargetsBlock
  143680. * @param name defines the block name
  143681. */
  143682. constructor(name: string);
  143683. /**
  143684. * Gets the current class name
  143685. * @returns the class name
  143686. */
  143687. getClassName(): string;
  143688. /**
  143689. * Gets the position input component
  143690. */
  143691. get position(): NodeMaterialConnectionPoint;
  143692. /**
  143693. * Gets the normal input component
  143694. */
  143695. get normal(): NodeMaterialConnectionPoint;
  143696. /**
  143697. * Gets the tangent input component
  143698. */
  143699. get tangent(): NodeMaterialConnectionPoint;
  143700. /**
  143701. * Gets the tangent input component
  143702. */
  143703. get uv(): NodeMaterialConnectionPoint;
  143704. /**
  143705. * Gets the position output component
  143706. */
  143707. get positionOutput(): NodeMaterialConnectionPoint;
  143708. /**
  143709. * Gets the normal output component
  143710. */
  143711. get normalOutput(): NodeMaterialConnectionPoint;
  143712. /**
  143713. * Gets the tangent output component
  143714. */
  143715. get tangentOutput(): NodeMaterialConnectionPoint;
  143716. /**
  143717. * Gets the tangent output component
  143718. */
  143719. get uvOutput(): NodeMaterialConnectionPoint;
  143720. initialize(state: NodeMaterialBuildState): void;
  143721. autoConfigure(material: NodeMaterial): void;
  143722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143724. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143725. protected _buildBlock(state: NodeMaterialBuildState): this;
  143726. }
  143727. }
  143728. declare module BABYLON {
  143729. /**
  143730. * Block used to get data information from a light
  143731. */
  143732. export class LightInformationBlock extends NodeMaterialBlock {
  143733. private _lightDataUniformName;
  143734. private _lightColorUniformName;
  143735. private _lightTypeDefineName;
  143736. /**
  143737. * Gets or sets the light associated with this block
  143738. */
  143739. light: Nullable<Light>;
  143740. /**
  143741. * Creates a new LightInformationBlock
  143742. * @param name defines the block name
  143743. */
  143744. constructor(name: string);
  143745. /**
  143746. * Gets the current class name
  143747. * @returns the class name
  143748. */
  143749. getClassName(): string;
  143750. /**
  143751. * Gets the world position input component
  143752. */
  143753. get worldPosition(): NodeMaterialConnectionPoint;
  143754. /**
  143755. * Gets the direction output component
  143756. */
  143757. get direction(): NodeMaterialConnectionPoint;
  143758. /**
  143759. * Gets the direction output component
  143760. */
  143761. get color(): NodeMaterialConnectionPoint;
  143762. /**
  143763. * Gets the direction output component
  143764. */
  143765. get intensity(): NodeMaterialConnectionPoint;
  143766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143768. protected _buildBlock(state: NodeMaterialBuildState): this;
  143769. serialize(): any;
  143770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143771. }
  143772. }
  143773. declare module BABYLON {
  143774. /**
  143775. * Block used to add image processing support to fragment shader
  143776. */
  143777. export class ImageProcessingBlock extends NodeMaterialBlock {
  143778. /**
  143779. * Create a new ImageProcessingBlock
  143780. * @param name defines the block name
  143781. */
  143782. constructor(name: string);
  143783. /**
  143784. * Gets the current class name
  143785. * @returns the class name
  143786. */
  143787. getClassName(): string;
  143788. /**
  143789. * Gets the color input component
  143790. */
  143791. get color(): NodeMaterialConnectionPoint;
  143792. /**
  143793. * Gets the output component
  143794. */
  143795. get output(): NodeMaterialConnectionPoint;
  143796. /**
  143797. * Initialize the block and prepare the context for build
  143798. * @param state defines the state that will be used for the build
  143799. */
  143800. initialize(state: NodeMaterialBuildState): void;
  143801. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143802. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143803. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143804. protected _buildBlock(state: NodeMaterialBuildState): this;
  143805. }
  143806. }
  143807. declare module BABYLON {
  143808. /**
  143809. * Block used to pertub normals based on a normal map
  143810. */
  143811. export class PerturbNormalBlock extends NodeMaterialBlock {
  143812. private _tangentSpaceParameterName;
  143813. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143814. invertX: boolean;
  143815. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143816. invertY: boolean;
  143817. /**
  143818. * Create a new PerturbNormalBlock
  143819. * @param name defines the block name
  143820. */
  143821. constructor(name: string);
  143822. /**
  143823. * Gets the current class name
  143824. * @returns the class name
  143825. */
  143826. getClassName(): string;
  143827. /**
  143828. * Gets the world position input component
  143829. */
  143830. get worldPosition(): NodeMaterialConnectionPoint;
  143831. /**
  143832. * Gets the world normal input component
  143833. */
  143834. get worldNormal(): NodeMaterialConnectionPoint;
  143835. /**
  143836. * Gets the world tangent input component
  143837. */
  143838. get worldTangent(): NodeMaterialConnectionPoint;
  143839. /**
  143840. * Gets the uv input component
  143841. */
  143842. get uv(): NodeMaterialConnectionPoint;
  143843. /**
  143844. * Gets the normal map color input component
  143845. */
  143846. get normalMapColor(): NodeMaterialConnectionPoint;
  143847. /**
  143848. * Gets the strength input component
  143849. */
  143850. get strength(): NodeMaterialConnectionPoint;
  143851. /**
  143852. * Gets the output component
  143853. */
  143854. get output(): NodeMaterialConnectionPoint;
  143855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143857. autoConfigure(material: NodeMaterial): void;
  143858. protected _buildBlock(state: NodeMaterialBuildState): this;
  143859. protected _dumpPropertiesCode(): string;
  143860. serialize(): any;
  143861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143862. }
  143863. }
  143864. declare module BABYLON {
  143865. /**
  143866. * Block used to discard a pixel if a value is smaller than a cutoff
  143867. */
  143868. export class DiscardBlock extends NodeMaterialBlock {
  143869. /**
  143870. * Create a new DiscardBlock
  143871. * @param name defines the block name
  143872. */
  143873. constructor(name: string);
  143874. /**
  143875. * Gets the current class name
  143876. * @returns the class name
  143877. */
  143878. getClassName(): string;
  143879. /**
  143880. * Gets the color input component
  143881. */
  143882. get value(): NodeMaterialConnectionPoint;
  143883. /**
  143884. * Gets the cutoff input component
  143885. */
  143886. get cutoff(): NodeMaterialConnectionPoint;
  143887. protected _buildBlock(state: NodeMaterialBuildState): this;
  143888. }
  143889. }
  143890. declare module BABYLON {
  143891. /**
  143892. * Block used to test if the fragment shader is front facing
  143893. */
  143894. export class FrontFacingBlock extends NodeMaterialBlock {
  143895. /**
  143896. * Creates a new FrontFacingBlock
  143897. * @param name defines the block name
  143898. */
  143899. constructor(name: string);
  143900. /**
  143901. * Gets the current class name
  143902. * @returns the class name
  143903. */
  143904. getClassName(): string;
  143905. /**
  143906. * Gets the output component
  143907. */
  143908. get output(): NodeMaterialConnectionPoint;
  143909. protected _buildBlock(state: NodeMaterialBuildState): this;
  143910. }
  143911. }
  143912. declare module BABYLON {
  143913. /**
  143914. * Block used to get the derivative value on x and y of a given input
  143915. */
  143916. export class DerivativeBlock extends NodeMaterialBlock {
  143917. /**
  143918. * Create a new DerivativeBlock
  143919. * @param name defines the block name
  143920. */
  143921. constructor(name: string);
  143922. /**
  143923. * Gets the current class name
  143924. * @returns the class name
  143925. */
  143926. getClassName(): string;
  143927. /**
  143928. * Gets the input component
  143929. */
  143930. get input(): NodeMaterialConnectionPoint;
  143931. /**
  143932. * Gets the derivative output on x
  143933. */
  143934. get dx(): NodeMaterialConnectionPoint;
  143935. /**
  143936. * Gets the derivative output on y
  143937. */
  143938. get dy(): NodeMaterialConnectionPoint;
  143939. protected _buildBlock(state: NodeMaterialBuildState): this;
  143940. }
  143941. }
  143942. declare module BABYLON {
  143943. /**
  143944. * Block used to make gl_FragCoord available
  143945. */
  143946. export class FragCoordBlock extends NodeMaterialBlock {
  143947. /**
  143948. * Creates a new FragCoordBlock
  143949. * @param name defines the block name
  143950. */
  143951. constructor(name: string);
  143952. /**
  143953. * Gets the current class name
  143954. * @returns the class name
  143955. */
  143956. getClassName(): string;
  143957. /**
  143958. * Gets the xy component
  143959. */
  143960. get xy(): NodeMaterialConnectionPoint;
  143961. /**
  143962. * Gets the xyz component
  143963. */
  143964. get xyz(): NodeMaterialConnectionPoint;
  143965. /**
  143966. * Gets the xyzw component
  143967. */
  143968. get xyzw(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the x component
  143971. */
  143972. get x(): NodeMaterialConnectionPoint;
  143973. /**
  143974. * Gets the y component
  143975. */
  143976. get y(): NodeMaterialConnectionPoint;
  143977. /**
  143978. * Gets the z component
  143979. */
  143980. get z(): NodeMaterialConnectionPoint;
  143981. /**
  143982. * Gets the w component
  143983. */
  143984. get output(): NodeMaterialConnectionPoint;
  143985. protected writeOutputs(state: NodeMaterialBuildState): string;
  143986. protected _buildBlock(state: NodeMaterialBuildState): this;
  143987. }
  143988. }
  143989. declare module BABYLON {
  143990. /**
  143991. * Block used to get the screen sizes
  143992. */
  143993. export class ScreenSizeBlock extends NodeMaterialBlock {
  143994. private _varName;
  143995. private _scene;
  143996. /**
  143997. * Creates a new ScreenSizeBlock
  143998. * @param name defines the block name
  143999. */
  144000. constructor(name: string);
  144001. /**
  144002. * Gets the current class name
  144003. * @returns the class name
  144004. */
  144005. getClassName(): string;
  144006. /**
  144007. * Gets the xy component
  144008. */
  144009. get xy(): NodeMaterialConnectionPoint;
  144010. /**
  144011. * Gets the x component
  144012. */
  144013. get x(): NodeMaterialConnectionPoint;
  144014. /**
  144015. * Gets the y component
  144016. */
  144017. get y(): NodeMaterialConnectionPoint;
  144018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144019. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144020. protected _buildBlock(state: NodeMaterialBuildState): this;
  144021. }
  144022. }
  144023. declare module BABYLON {
  144024. /**
  144025. * Block used to add support for scene fog
  144026. */
  144027. export class FogBlock extends NodeMaterialBlock {
  144028. private _fogDistanceName;
  144029. private _fogParameters;
  144030. /**
  144031. * Create a new FogBlock
  144032. * @param name defines the block name
  144033. */
  144034. constructor(name: string);
  144035. /**
  144036. * Gets the current class name
  144037. * @returns the class name
  144038. */
  144039. getClassName(): string;
  144040. /**
  144041. * Gets the world position input component
  144042. */
  144043. get worldPosition(): NodeMaterialConnectionPoint;
  144044. /**
  144045. * Gets the view input component
  144046. */
  144047. get view(): NodeMaterialConnectionPoint;
  144048. /**
  144049. * Gets the color input component
  144050. */
  144051. get input(): NodeMaterialConnectionPoint;
  144052. /**
  144053. * Gets the fog color input component
  144054. */
  144055. get fogColor(): NodeMaterialConnectionPoint;
  144056. /**
  144057. * Gets the output component
  144058. */
  144059. get output(): NodeMaterialConnectionPoint;
  144060. autoConfigure(material: NodeMaterial): void;
  144061. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144062. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144063. protected _buildBlock(state: NodeMaterialBuildState): this;
  144064. }
  144065. }
  144066. declare module BABYLON {
  144067. /**
  144068. * Block used to add light in the fragment shader
  144069. */
  144070. export class LightBlock extends NodeMaterialBlock {
  144071. private _lightId;
  144072. /**
  144073. * Gets or sets the light associated with this block
  144074. */
  144075. light: Nullable<Light>;
  144076. /**
  144077. * Create a new LightBlock
  144078. * @param name defines the block name
  144079. */
  144080. constructor(name: string);
  144081. /**
  144082. * Gets the current class name
  144083. * @returns the class name
  144084. */
  144085. getClassName(): string;
  144086. /**
  144087. * Gets the world position input component
  144088. */
  144089. get worldPosition(): NodeMaterialConnectionPoint;
  144090. /**
  144091. * Gets the world normal input component
  144092. */
  144093. get worldNormal(): NodeMaterialConnectionPoint;
  144094. /**
  144095. * Gets the camera (or eye) position component
  144096. */
  144097. get cameraPosition(): NodeMaterialConnectionPoint;
  144098. /**
  144099. * Gets the glossiness component
  144100. */
  144101. get glossiness(): NodeMaterialConnectionPoint;
  144102. /**
  144103. * Gets the glossinness power component
  144104. */
  144105. get glossPower(): NodeMaterialConnectionPoint;
  144106. /**
  144107. * Gets the diffuse color component
  144108. */
  144109. get diffuseColor(): NodeMaterialConnectionPoint;
  144110. /**
  144111. * Gets the specular color component
  144112. */
  144113. get specularColor(): NodeMaterialConnectionPoint;
  144114. /**
  144115. * Gets the diffuse output component
  144116. */
  144117. get diffuseOutput(): NodeMaterialConnectionPoint;
  144118. /**
  144119. * Gets the specular output component
  144120. */
  144121. get specularOutput(): NodeMaterialConnectionPoint;
  144122. /**
  144123. * Gets the shadow output component
  144124. */
  144125. get shadow(): NodeMaterialConnectionPoint;
  144126. autoConfigure(material: NodeMaterial): void;
  144127. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144128. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144129. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144130. private _injectVertexCode;
  144131. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144132. serialize(): any;
  144133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144134. }
  144135. }
  144136. declare module BABYLON {
  144137. /**
  144138. * Block used to read a reflection texture from a sampler
  144139. */
  144140. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144141. /**
  144142. * Create a new ReflectionTextureBlock
  144143. * @param name defines the block name
  144144. */
  144145. constructor(name: string);
  144146. /**
  144147. * Gets the current class name
  144148. * @returns the class name
  144149. */
  144150. getClassName(): string;
  144151. /**
  144152. * Gets the world position input component
  144153. */
  144154. get position(): NodeMaterialConnectionPoint;
  144155. /**
  144156. * Gets the world position input component
  144157. */
  144158. get worldPosition(): NodeMaterialConnectionPoint;
  144159. /**
  144160. * Gets the world normal input component
  144161. */
  144162. get worldNormal(): NodeMaterialConnectionPoint;
  144163. /**
  144164. * Gets the world input component
  144165. */
  144166. get world(): NodeMaterialConnectionPoint;
  144167. /**
  144168. * Gets the camera (or eye) position component
  144169. */
  144170. get cameraPosition(): NodeMaterialConnectionPoint;
  144171. /**
  144172. * Gets the view input component
  144173. */
  144174. get view(): NodeMaterialConnectionPoint;
  144175. /**
  144176. * Gets the rgb output component
  144177. */
  144178. get rgb(): NodeMaterialConnectionPoint;
  144179. /**
  144180. * Gets the rgba output component
  144181. */
  144182. get rgba(): NodeMaterialConnectionPoint;
  144183. /**
  144184. * Gets the r output component
  144185. */
  144186. get r(): NodeMaterialConnectionPoint;
  144187. /**
  144188. * Gets the g output component
  144189. */
  144190. get g(): NodeMaterialConnectionPoint;
  144191. /**
  144192. * Gets the b output component
  144193. */
  144194. get b(): NodeMaterialConnectionPoint;
  144195. /**
  144196. * Gets the a output component
  144197. */
  144198. get a(): NodeMaterialConnectionPoint;
  144199. autoConfigure(material: NodeMaterial): void;
  144200. protected _buildBlock(state: NodeMaterialBuildState): this;
  144201. }
  144202. }
  144203. declare module BABYLON {
  144204. /**
  144205. * Block used to add 2 vectors
  144206. */
  144207. export class AddBlock extends NodeMaterialBlock {
  144208. /**
  144209. * Creates a new AddBlock
  144210. * @param name defines the block name
  144211. */
  144212. constructor(name: string);
  144213. /**
  144214. * Gets the current class name
  144215. * @returns the class name
  144216. */
  144217. getClassName(): string;
  144218. /**
  144219. * Gets the left operand input component
  144220. */
  144221. get left(): NodeMaterialConnectionPoint;
  144222. /**
  144223. * Gets the right operand input component
  144224. */
  144225. get right(): NodeMaterialConnectionPoint;
  144226. /**
  144227. * Gets the output component
  144228. */
  144229. get output(): NodeMaterialConnectionPoint;
  144230. protected _buildBlock(state: NodeMaterialBuildState): this;
  144231. }
  144232. }
  144233. declare module BABYLON {
  144234. /**
  144235. * Block used to scale a vector by a float
  144236. */
  144237. export class ScaleBlock extends NodeMaterialBlock {
  144238. /**
  144239. * Creates a new ScaleBlock
  144240. * @param name defines the block name
  144241. */
  144242. constructor(name: string);
  144243. /**
  144244. * Gets the current class name
  144245. * @returns the class name
  144246. */
  144247. getClassName(): string;
  144248. /**
  144249. * Gets the input component
  144250. */
  144251. get input(): NodeMaterialConnectionPoint;
  144252. /**
  144253. * Gets the factor input component
  144254. */
  144255. get factor(): NodeMaterialConnectionPoint;
  144256. /**
  144257. * Gets the output component
  144258. */
  144259. get output(): NodeMaterialConnectionPoint;
  144260. protected _buildBlock(state: NodeMaterialBuildState): this;
  144261. }
  144262. }
  144263. declare module BABYLON {
  144264. /**
  144265. * Block used to clamp a float
  144266. */
  144267. export class ClampBlock extends NodeMaterialBlock {
  144268. /** Gets or sets the minimum range */
  144269. minimum: number;
  144270. /** Gets or sets the maximum range */
  144271. maximum: number;
  144272. /**
  144273. * Creates a new ClampBlock
  144274. * @param name defines the block name
  144275. */
  144276. constructor(name: string);
  144277. /**
  144278. * Gets the current class name
  144279. * @returns the class name
  144280. */
  144281. getClassName(): string;
  144282. /**
  144283. * Gets the value input component
  144284. */
  144285. get value(): NodeMaterialConnectionPoint;
  144286. /**
  144287. * Gets the output component
  144288. */
  144289. get output(): NodeMaterialConnectionPoint;
  144290. protected _buildBlock(state: NodeMaterialBuildState): this;
  144291. protected _dumpPropertiesCode(): string;
  144292. serialize(): any;
  144293. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144294. }
  144295. }
  144296. declare module BABYLON {
  144297. /**
  144298. * Block used to apply a cross product between 2 vectors
  144299. */
  144300. export class CrossBlock extends NodeMaterialBlock {
  144301. /**
  144302. * Creates a new CrossBlock
  144303. * @param name defines the block name
  144304. */
  144305. constructor(name: string);
  144306. /**
  144307. * Gets the current class name
  144308. * @returns the class name
  144309. */
  144310. getClassName(): string;
  144311. /**
  144312. * Gets the left operand input component
  144313. */
  144314. get left(): NodeMaterialConnectionPoint;
  144315. /**
  144316. * Gets the right operand input component
  144317. */
  144318. get right(): NodeMaterialConnectionPoint;
  144319. /**
  144320. * Gets the output component
  144321. */
  144322. get output(): NodeMaterialConnectionPoint;
  144323. protected _buildBlock(state: NodeMaterialBuildState): this;
  144324. }
  144325. }
  144326. declare module BABYLON {
  144327. /**
  144328. * Block used to apply a dot product between 2 vectors
  144329. */
  144330. export class DotBlock extends NodeMaterialBlock {
  144331. /**
  144332. * Creates a new DotBlock
  144333. * @param name defines the block name
  144334. */
  144335. constructor(name: string);
  144336. /**
  144337. * Gets the current class name
  144338. * @returns the class name
  144339. */
  144340. getClassName(): string;
  144341. /**
  144342. * Gets the left operand input component
  144343. */
  144344. get left(): NodeMaterialConnectionPoint;
  144345. /**
  144346. * Gets the right operand input component
  144347. */
  144348. get right(): NodeMaterialConnectionPoint;
  144349. /**
  144350. * Gets the output component
  144351. */
  144352. get output(): NodeMaterialConnectionPoint;
  144353. protected _buildBlock(state: NodeMaterialBuildState): this;
  144354. }
  144355. }
  144356. declare module BABYLON {
  144357. /**
  144358. * Block used to normalize a vector
  144359. */
  144360. export class NormalizeBlock extends NodeMaterialBlock {
  144361. /**
  144362. * Creates a new NormalizeBlock
  144363. * @param name defines the block name
  144364. */
  144365. constructor(name: string);
  144366. /**
  144367. * Gets the current class name
  144368. * @returns the class name
  144369. */
  144370. getClassName(): string;
  144371. /**
  144372. * Gets the input component
  144373. */
  144374. get input(): NodeMaterialConnectionPoint;
  144375. /**
  144376. * Gets the output component
  144377. */
  144378. get output(): NodeMaterialConnectionPoint;
  144379. protected _buildBlock(state: NodeMaterialBuildState): this;
  144380. }
  144381. }
  144382. declare module BABYLON {
  144383. /**
  144384. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144385. */
  144386. export class ColorMergerBlock extends NodeMaterialBlock {
  144387. /**
  144388. * Create a new ColorMergerBlock
  144389. * @param name defines the block name
  144390. */
  144391. constructor(name: string);
  144392. /**
  144393. * Gets the current class name
  144394. * @returns the class name
  144395. */
  144396. getClassName(): string;
  144397. /**
  144398. * Gets the rgb component (input)
  144399. */
  144400. get rgbIn(): NodeMaterialConnectionPoint;
  144401. /**
  144402. * Gets the r component (input)
  144403. */
  144404. get r(): NodeMaterialConnectionPoint;
  144405. /**
  144406. * Gets the g component (input)
  144407. */
  144408. get g(): NodeMaterialConnectionPoint;
  144409. /**
  144410. * Gets the b component (input)
  144411. */
  144412. get b(): NodeMaterialConnectionPoint;
  144413. /**
  144414. * Gets the a component (input)
  144415. */
  144416. get a(): NodeMaterialConnectionPoint;
  144417. /**
  144418. * Gets the rgba component (output)
  144419. */
  144420. get rgba(): NodeMaterialConnectionPoint;
  144421. /**
  144422. * Gets the rgb component (output)
  144423. */
  144424. get rgbOut(): NodeMaterialConnectionPoint;
  144425. /**
  144426. * Gets the rgb component (output)
  144427. * @deprecated Please use rgbOut instead.
  144428. */
  144429. get rgb(): NodeMaterialConnectionPoint;
  144430. protected _buildBlock(state: NodeMaterialBuildState): this;
  144431. }
  144432. }
  144433. declare module BABYLON {
  144434. /**
  144435. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144436. */
  144437. export class VectorSplitterBlock extends NodeMaterialBlock {
  144438. /**
  144439. * Create a new VectorSplitterBlock
  144440. * @param name defines the block name
  144441. */
  144442. constructor(name: string);
  144443. /**
  144444. * Gets the current class name
  144445. * @returns the class name
  144446. */
  144447. getClassName(): string;
  144448. /**
  144449. * Gets the xyzw component (input)
  144450. */
  144451. get xyzw(): NodeMaterialConnectionPoint;
  144452. /**
  144453. * Gets the xyz component (input)
  144454. */
  144455. get xyzIn(): NodeMaterialConnectionPoint;
  144456. /**
  144457. * Gets the xy component (input)
  144458. */
  144459. get xyIn(): NodeMaterialConnectionPoint;
  144460. /**
  144461. * Gets the xyz component (output)
  144462. */
  144463. get xyzOut(): NodeMaterialConnectionPoint;
  144464. /**
  144465. * Gets the xy component (output)
  144466. */
  144467. get xyOut(): NodeMaterialConnectionPoint;
  144468. /**
  144469. * Gets the x component (output)
  144470. */
  144471. get x(): NodeMaterialConnectionPoint;
  144472. /**
  144473. * Gets the y component (output)
  144474. */
  144475. get y(): NodeMaterialConnectionPoint;
  144476. /**
  144477. * Gets the z component (output)
  144478. */
  144479. get z(): NodeMaterialConnectionPoint;
  144480. /**
  144481. * Gets the w component (output)
  144482. */
  144483. get w(): NodeMaterialConnectionPoint;
  144484. protected _inputRename(name: string): string;
  144485. protected _outputRename(name: string): string;
  144486. protected _buildBlock(state: NodeMaterialBuildState): this;
  144487. }
  144488. }
  144489. declare module BABYLON {
  144490. /**
  144491. * Block used to lerp between 2 values
  144492. */
  144493. export class LerpBlock extends NodeMaterialBlock {
  144494. /**
  144495. * Creates a new LerpBlock
  144496. * @param name defines the block name
  144497. */
  144498. constructor(name: string);
  144499. /**
  144500. * Gets the current class name
  144501. * @returns the class name
  144502. */
  144503. getClassName(): string;
  144504. /**
  144505. * Gets the left operand input component
  144506. */
  144507. get left(): NodeMaterialConnectionPoint;
  144508. /**
  144509. * Gets the right operand input component
  144510. */
  144511. get right(): NodeMaterialConnectionPoint;
  144512. /**
  144513. * Gets the gradient operand input component
  144514. */
  144515. get gradient(): NodeMaterialConnectionPoint;
  144516. /**
  144517. * Gets the output component
  144518. */
  144519. get output(): NodeMaterialConnectionPoint;
  144520. protected _buildBlock(state: NodeMaterialBuildState): this;
  144521. }
  144522. }
  144523. declare module BABYLON {
  144524. /**
  144525. * Block used to divide 2 vectors
  144526. */
  144527. export class DivideBlock extends NodeMaterialBlock {
  144528. /**
  144529. * Creates a new DivideBlock
  144530. * @param name defines the block name
  144531. */
  144532. constructor(name: string);
  144533. /**
  144534. * Gets the current class name
  144535. * @returns the class name
  144536. */
  144537. getClassName(): string;
  144538. /**
  144539. * Gets the left operand input component
  144540. */
  144541. get left(): NodeMaterialConnectionPoint;
  144542. /**
  144543. * Gets the right operand input component
  144544. */
  144545. get right(): NodeMaterialConnectionPoint;
  144546. /**
  144547. * Gets the output component
  144548. */
  144549. get output(): NodeMaterialConnectionPoint;
  144550. protected _buildBlock(state: NodeMaterialBuildState): this;
  144551. }
  144552. }
  144553. declare module BABYLON {
  144554. /**
  144555. * Block used to subtract 2 vectors
  144556. */
  144557. export class SubtractBlock extends NodeMaterialBlock {
  144558. /**
  144559. * Creates a new SubtractBlock
  144560. * @param name defines the block name
  144561. */
  144562. constructor(name: string);
  144563. /**
  144564. * Gets the current class name
  144565. * @returns the class name
  144566. */
  144567. getClassName(): string;
  144568. /**
  144569. * Gets the left operand input component
  144570. */
  144571. get left(): NodeMaterialConnectionPoint;
  144572. /**
  144573. * Gets the right operand input component
  144574. */
  144575. get right(): NodeMaterialConnectionPoint;
  144576. /**
  144577. * Gets the output component
  144578. */
  144579. get output(): NodeMaterialConnectionPoint;
  144580. protected _buildBlock(state: NodeMaterialBuildState): this;
  144581. }
  144582. }
  144583. declare module BABYLON {
  144584. /**
  144585. * Block used to step a value
  144586. */
  144587. export class StepBlock extends NodeMaterialBlock {
  144588. /**
  144589. * Creates a new StepBlock
  144590. * @param name defines the block name
  144591. */
  144592. constructor(name: string);
  144593. /**
  144594. * Gets the current class name
  144595. * @returns the class name
  144596. */
  144597. getClassName(): string;
  144598. /**
  144599. * Gets the value operand input component
  144600. */
  144601. get value(): NodeMaterialConnectionPoint;
  144602. /**
  144603. * Gets the edge operand input component
  144604. */
  144605. get edge(): NodeMaterialConnectionPoint;
  144606. /**
  144607. * Gets the output component
  144608. */
  144609. get output(): NodeMaterialConnectionPoint;
  144610. protected _buildBlock(state: NodeMaterialBuildState): this;
  144611. }
  144612. }
  144613. declare module BABYLON {
  144614. /**
  144615. * Block used to get the opposite (1 - x) of a value
  144616. */
  144617. export class OneMinusBlock extends NodeMaterialBlock {
  144618. /**
  144619. * Creates a new OneMinusBlock
  144620. * @param name defines the block name
  144621. */
  144622. constructor(name: string);
  144623. /**
  144624. * Gets the current class name
  144625. * @returns the class name
  144626. */
  144627. getClassName(): string;
  144628. /**
  144629. * Gets the input component
  144630. */
  144631. get input(): NodeMaterialConnectionPoint;
  144632. /**
  144633. * Gets the output component
  144634. */
  144635. get output(): NodeMaterialConnectionPoint;
  144636. protected _buildBlock(state: NodeMaterialBuildState): this;
  144637. }
  144638. }
  144639. declare module BABYLON {
  144640. /**
  144641. * Block used to get the view direction
  144642. */
  144643. export class ViewDirectionBlock extends NodeMaterialBlock {
  144644. /**
  144645. * Creates a new ViewDirectionBlock
  144646. * @param name defines the block name
  144647. */
  144648. constructor(name: string);
  144649. /**
  144650. * Gets the current class name
  144651. * @returns the class name
  144652. */
  144653. getClassName(): string;
  144654. /**
  144655. * Gets the world position component
  144656. */
  144657. get worldPosition(): NodeMaterialConnectionPoint;
  144658. /**
  144659. * Gets the camera position component
  144660. */
  144661. get cameraPosition(): NodeMaterialConnectionPoint;
  144662. /**
  144663. * Gets the output component
  144664. */
  144665. get output(): NodeMaterialConnectionPoint;
  144666. autoConfigure(material: NodeMaterial): void;
  144667. protected _buildBlock(state: NodeMaterialBuildState): this;
  144668. }
  144669. }
  144670. declare module BABYLON {
  144671. /**
  144672. * Block used to compute fresnel value
  144673. */
  144674. export class FresnelBlock extends NodeMaterialBlock {
  144675. /**
  144676. * Create a new FresnelBlock
  144677. * @param name defines the block name
  144678. */
  144679. constructor(name: string);
  144680. /**
  144681. * Gets the current class name
  144682. * @returns the class name
  144683. */
  144684. getClassName(): string;
  144685. /**
  144686. * Gets the world normal input component
  144687. */
  144688. get worldNormal(): NodeMaterialConnectionPoint;
  144689. /**
  144690. * Gets the view direction input component
  144691. */
  144692. get viewDirection(): NodeMaterialConnectionPoint;
  144693. /**
  144694. * Gets the bias input component
  144695. */
  144696. get bias(): NodeMaterialConnectionPoint;
  144697. /**
  144698. * Gets the camera (or eye) position component
  144699. */
  144700. get power(): NodeMaterialConnectionPoint;
  144701. /**
  144702. * Gets the fresnel output component
  144703. */
  144704. get fresnel(): NodeMaterialConnectionPoint;
  144705. autoConfigure(material: NodeMaterial): void;
  144706. protected _buildBlock(state: NodeMaterialBuildState): this;
  144707. }
  144708. }
  144709. declare module BABYLON {
  144710. /**
  144711. * Block used to get the max of 2 values
  144712. */
  144713. export class MaxBlock extends NodeMaterialBlock {
  144714. /**
  144715. * Creates a new MaxBlock
  144716. * @param name defines the block name
  144717. */
  144718. constructor(name: string);
  144719. /**
  144720. * Gets the current class name
  144721. * @returns the class name
  144722. */
  144723. getClassName(): string;
  144724. /**
  144725. * Gets the left operand input component
  144726. */
  144727. get left(): NodeMaterialConnectionPoint;
  144728. /**
  144729. * Gets the right operand input component
  144730. */
  144731. get right(): NodeMaterialConnectionPoint;
  144732. /**
  144733. * Gets the output component
  144734. */
  144735. get output(): NodeMaterialConnectionPoint;
  144736. protected _buildBlock(state: NodeMaterialBuildState): this;
  144737. }
  144738. }
  144739. declare module BABYLON {
  144740. /**
  144741. * Block used to get the min of 2 values
  144742. */
  144743. export class MinBlock extends NodeMaterialBlock {
  144744. /**
  144745. * Creates a new MinBlock
  144746. * @param name defines the block name
  144747. */
  144748. constructor(name: string);
  144749. /**
  144750. * Gets the current class name
  144751. * @returns the class name
  144752. */
  144753. getClassName(): string;
  144754. /**
  144755. * Gets the left operand input component
  144756. */
  144757. get left(): NodeMaterialConnectionPoint;
  144758. /**
  144759. * Gets the right operand input component
  144760. */
  144761. get right(): NodeMaterialConnectionPoint;
  144762. /**
  144763. * Gets the output component
  144764. */
  144765. get output(): NodeMaterialConnectionPoint;
  144766. protected _buildBlock(state: NodeMaterialBuildState): this;
  144767. }
  144768. }
  144769. declare module BABYLON {
  144770. /**
  144771. * Block used to get the distance between 2 values
  144772. */
  144773. export class DistanceBlock extends NodeMaterialBlock {
  144774. /**
  144775. * Creates a new DistanceBlock
  144776. * @param name defines the block name
  144777. */
  144778. constructor(name: string);
  144779. /**
  144780. * Gets the current class name
  144781. * @returns the class name
  144782. */
  144783. getClassName(): string;
  144784. /**
  144785. * Gets the left operand input component
  144786. */
  144787. get left(): NodeMaterialConnectionPoint;
  144788. /**
  144789. * Gets the right operand input component
  144790. */
  144791. get right(): NodeMaterialConnectionPoint;
  144792. /**
  144793. * Gets the output component
  144794. */
  144795. get output(): NodeMaterialConnectionPoint;
  144796. protected _buildBlock(state: NodeMaterialBuildState): this;
  144797. }
  144798. }
  144799. declare module BABYLON {
  144800. /**
  144801. * Block used to get the length of a vector
  144802. */
  144803. export class LengthBlock extends NodeMaterialBlock {
  144804. /**
  144805. * Creates a new LengthBlock
  144806. * @param name defines the block name
  144807. */
  144808. constructor(name: string);
  144809. /**
  144810. * Gets the current class name
  144811. * @returns the class name
  144812. */
  144813. getClassName(): string;
  144814. /**
  144815. * Gets the value input component
  144816. */
  144817. get value(): NodeMaterialConnectionPoint;
  144818. /**
  144819. * Gets the output component
  144820. */
  144821. get output(): NodeMaterialConnectionPoint;
  144822. protected _buildBlock(state: NodeMaterialBuildState): this;
  144823. }
  144824. }
  144825. declare module BABYLON {
  144826. /**
  144827. * Block used to get negative version of a value (i.e. x * -1)
  144828. */
  144829. export class NegateBlock extends NodeMaterialBlock {
  144830. /**
  144831. * Creates a new NegateBlock
  144832. * @param name defines the block name
  144833. */
  144834. constructor(name: string);
  144835. /**
  144836. * Gets the current class name
  144837. * @returns the class name
  144838. */
  144839. getClassName(): string;
  144840. /**
  144841. * Gets the value input component
  144842. */
  144843. get value(): NodeMaterialConnectionPoint;
  144844. /**
  144845. * Gets the output component
  144846. */
  144847. get output(): NodeMaterialConnectionPoint;
  144848. protected _buildBlock(state: NodeMaterialBuildState): this;
  144849. }
  144850. }
  144851. declare module BABYLON {
  144852. /**
  144853. * Block used to get the value of the first parameter raised to the power of the second
  144854. */
  144855. export class PowBlock extends NodeMaterialBlock {
  144856. /**
  144857. * Creates a new PowBlock
  144858. * @param name defines the block name
  144859. */
  144860. constructor(name: string);
  144861. /**
  144862. * Gets the current class name
  144863. * @returns the class name
  144864. */
  144865. getClassName(): string;
  144866. /**
  144867. * Gets the value operand input component
  144868. */
  144869. get value(): NodeMaterialConnectionPoint;
  144870. /**
  144871. * Gets the power operand input component
  144872. */
  144873. get power(): NodeMaterialConnectionPoint;
  144874. /**
  144875. * Gets the output component
  144876. */
  144877. get output(): NodeMaterialConnectionPoint;
  144878. protected _buildBlock(state: NodeMaterialBuildState): this;
  144879. }
  144880. }
  144881. declare module BABYLON {
  144882. /**
  144883. * Block used to get a random number
  144884. */
  144885. export class RandomNumberBlock extends NodeMaterialBlock {
  144886. /**
  144887. * Creates a new RandomNumberBlock
  144888. * @param name defines the block name
  144889. */
  144890. constructor(name: string);
  144891. /**
  144892. * Gets the current class name
  144893. * @returns the class name
  144894. */
  144895. getClassName(): string;
  144896. /**
  144897. * Gets the seed input component
  144898. */
  144899. get seed(): NodeMaterialConnectionPoint;
  144900. /**
  144901. * Gets the output component
  144902. */
  144903. get output(): NodeMaterialConnectionPoint;
  144904. protected _buildBlock(state: NodeMaterialBuildState): this;
  144905. }
  144906. }
  144907. declare module BABYLON {
  144908. /**
  144909. * Block used to compute arc tangent of 2 values
  144910. */
  144911. export class ArcTan2Block extends NodeMaterialBlock {
  144912. /**
  144913. * Creates a new ArcTan2Block
  144914. * @param name defines the block name
  144915. */
  144916. constructor(name: string);
  144917. /**
  144918. * Gets the current class name
  144919. * @returns the class name
  144920. */
  144921. getClassName(): string;
  144922. /**
  144923. * Gets the x operand input component
  144924. */
  144925. get x(): NodeMaterialConnectionPoint;
  144926. /**
  144927. * Gets the y operand input component
  144928. */
  144929. get y(): NodeMaterialConnectionPoint;
  144930. /**
  144931. * Gets the output component
  144932. */
  144933. get output(): NodeMaterialConnectionPoint;
  144934. protected _buildBlock(state: NodeMaterialBuildState): this;
  144935. }
  144936. }
  144937. declare module BABYLON {
  144938. /**
  144939. * Block used to smooth step a value
  144940. */
  144941. export class SmoothStepBlock extends NodeMaterialBlock {
  144942. /**
  144943. * Creates a new SmoothStepBlock
  144944. * @param name defines the block name
  144945. */
  144946. constructor(name: string);
  144947. /**
  144948. * Gets the current class name
  144949. * @returns the class name
  144950. */
  144951. getClassName(): string;
  144952. /**
  144953. * Gets the value operand input component
  144954. */
  144955. get value(): NodeMaterialConnectionPoint;
  144956. /**
  144957. * Gets the first edge operand input component
  144958. */
  144959. get edge0(): NodeMaterialConnectionPoint;
  144960. /**
  144961. * Gets the second edge operand input component
  144962. */
  144963. get edge1(): NodeMaterialConnectionPoint;
  144964. /**
  144965. * Gets the output component
  144966. */
  144967. get output(): NodeMaterialConnectionPoint;
  144968. protected _buildBlock(state: NodeMaterialBuildState): this;
  144969. }
  144970. }
  144971. declare module BABYLON {
  144972. /**
  144973. * Block used to get the reciprocal (1 / x) of a value
  144974. */
  144975. export class ReciprocalBlock extends NodeMaterialBlock {
  144976. /**
  144977. * Creates a new ReciprocalBlock
  144978. * @param name defines the block name
  144979. */
  144980. constructor(name: string);
  144981. /**
  144982. * Gets the current class name
  144983. * @returns the class name
  144984. */
  144985. getClassName(): string;
  144986. /**
  144987. * Gets the input component
  144988. */
  144989. get input(): NodeMaterialConnectionPoint;
  144990. /**
  144991. * Gets the output component
  144992. */
  144993. get output(): NodeMaterialConnectionPoint;
  144994. protected _buildBlock(state: NodeMaterialBuildState): this;
  144995. }
  144996. }
  144997. declare module BABYLON {
  144998. /**
  144999. * Block used to replace a color by another one
  145000. */
  145001. export class ReplaceColorBlock extends NodeMaterialBlock {
  145002. /**
  145003. * Creates a new ReplaceColorBlock
  145004. * @param name defines the block name
  145005. */
  145006. constructor(name: string);
  145007. /**
  145008. * Gets the current class name
  145009. * @returns the class name
  145010. */
  145011. getClassName(): string;
  145012. /**
  145013. * Gets the value input component
  145014. */
  145015. get value(): NodeMaterialConnectionPoint;
  145016. /**
  145017. * Gets the reference input component
  145018. */
  145019. get reference(): NodeMaterialConnectionPoint;
  145020. /**
  145021. * Gets the distance input component
  145022. */
  145023. get distance(): NodeMaterialConnectionPoint;
  145024. /**
  145025. * Gets the replacement input component
  145026. */
  145027. get replacement(): NodeMaterialConnectionPoint;
  145028. /**
  145029. * Gets the output component
  145030. */
  145031. get output(): NodeMaterialConnectionPoint;
  145032. protected _buildBlock(state: NodeMaterialBuildState): this;
  145033. }
  145034. }
  145035. declare module BABYLON {
  145036. /**
  145037. * Block used to posterize a value
  145038. * @see https://en.wikipedia.org/wiki/Posterization
  145039. */
  145040. export class PosterizeBlock extends NodeMaterialBlock {
  145041. /**
  145042. * Creates a new PosterizeBlock
  145043. * @param name defines the block name
  145044. */
  145045. constructor(name: string);
  145046. /**
  145047. * Gets the current class name
  145048. * @returns the class name
  145049. */
  145050. getClassName(): string;
  145051. /**
  145052. * Gets the value input component
  145053. */
  145054. get value(): NodeMaterialConnectionPoint;
  145055. /**
  145056. * Gets the steps input component
  145057. */
  145058. get steps(): NodeMaterialConnectionPoint;
  145059. /**
  145060. * Gets the output component
  145061. */
  145062. get output(): NodeMaterialConnectionPoint;
  145063. protected _buildBlock(state: NodeMaterialBuildState): this;
  145064. }
  145065. }
  145066. declare module BABYLON {
  145067. /**
  145068. * Operations supported by the Wave block
  145069. */
  145070. export enum WaveBlockKind {
  145071. /** SawTooth */
  145072. SawTooth = 0,
  145073. /** Square */
  145074. Square = 1,
  145075. /** Triangle */
  145076. Triangle = 2
  145077. }
  145078. /**
  145079. * Block used to apply wave operation to floats
  145080. */
  145081. export class WaveBlock extends NodeMaterialBlock {
  145082. /**
  145083. * Gets or sets the kibnd of wave to be applied by the block
  145084. */
  145085. kind: WaveBlockKind;
  145086. /**
  145087. * Creates a new WaveBlock
  145088. * @param name defines the block name
  145089. */
  145090. constructor(name: string);
  145091. /**
  145092. * Gets the current class name
  145093. * @returns the class name
  145094. */
  145095. getClassName(): string;
  145096. /**
  145097. * Gets the input component
  145098. */
  145099. get input(): NodeMaterialConnectionPoint;
  145100. /**
  145101. * Gets the output component
  145102. */
  145103. get output(): NodeMaterialConnectionPoint;
  145104. protected _buildBlock(state: NodeMaterialBuildState): this;
  145105. serialize(): any;
  145106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145107. }
  145108. }
  145109. declare module BABYLON {
  145110. /**
  145111. * Class used to store a color step for the GradientBlock
  145112. */
  145113. export class GradientBlockColorStep {
  145114. private _step;
  145115. /**
  145116. * Gets value indicating which step this color is associated with (between 0 and 1)
  145117. */
  145118. get step(): number;
  145119. /**
  145120. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145121. */
  145122. set step(val: number);
  145123. private _color;
  145124. /**
  145125. * Gets the color associated with this step
  145126. */
  145127. get color(): Color3;
  145128. /**
  145129. * Sets the color associated with this step
  145130. */
  145131. set color(val: Color3);
  145132. /**
  145133. * Creates a new GradientBlockColorStep
  145134. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145135. * @param color defines the color associated with this step
  145136. */
  145137. constructor(step: number, color: Color3);
  145138. }
  145139. /**
  145140. * Block used to return a color from a gradient based on an input value between 0 and 1
  145141. */
  145142. export class GradientBlock extends NodeMaterialBlock {
  145143. /**
  145144. * Gets or sets the list of color steps
  145145. */
  145146. colorSteps: GradientBlockColorStep[];
  145147. /** Gets an observable raised when the value is changed */
  145148. onValueChangedObservable: Observable<GradientBlock>;
  145149. /** calls observable when the value is changed*/
  145150. colorStepsUpdated(): void;
  145151. /**
  145152. * Creates a new GradientBlock
  145153. * @param name defines the block name
  145154. */
  145155. constructor(name: string);
  145156. /**
  145157. * Gets the current class name
  145158. * @returns the class name
  145159. */
  145160. getClassName(): string;
  145161. /**
  145162. * Gets the gradient input component
  145163. */
  145164. get gradient(): NodeMaterialConnectionPoint;
  145165. /**
  145166. * Gets the output component
  145167. */
  145168. get output(): NodeMaterialConnectionPoint;
  145169. private _writeColorConstant;
  145170. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145171. serialize(): any;
  145172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145173. protected _dumpPropertiesCode(): string;
  145174. }
  145175. }
  145176. declare module BABYLON {
  145177. /**
  145178. * Block used to normalize lerp between 2 values
  145179. */
  145180. export class NLerpBlock extends NodeMaterialBlock {
  145181. /**
  145182. * Creates a new NLerpBlock
  145183. * @param name defines the block name
  145184. */
  145185. constructor(name: string);
  145186. /**
  145187. * Gets the current class name
  145188. * @returns the class name
  145189. */
  145190. getClassName(): string;
  145191. /**
  145192. * Gets the left operand input component
  145193. */
  145194. get left(): NodeMaterialConnectionPoint;
  145195. /**
  145196. * Gets the right operand input component
  145197. */
  145198. get right(): NodeMaterialConnectionPoint;
  145199. /**
  145200. * Gets the gradient operand input component
  145201. */
  145202. get gradient(): NodeMaterialConnectionPoint;
  145203. /**
  145204. * Gets the output component
  145205. */
  145206. get output(): NodeMaterialConnectionPoint;
  145207. protected _buildBlock(state: NodeMaterialBuildState): this;
  145208. }
  145209. }
  145210. declare module BABYLON {
  145211. /**
  145212. * block used to Generate a Worley Noise 3D Noise Pattern
  145213. */
  145214. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145215. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145216. manhattanDistance: boolean;
  145217. /**
  145218. * Creates a new WorleyNoise3DBlock
  145219. * @param name defines the block name
  145220. */
  145221. constructor(name: string);
  145222. /**
  145223. * Gets the current class name
  145224. * @returns the class name
  145225. */
  145226. getClassName(): string;
  145227. /**
  145228. * Gets the seed input component
  145229. */
  145230. get seed(): NodeMaterialConnectionPoint;
  145231. /**
  145232. * Gets the jitter input component
  145233. */
  145234. get jitter(): NodeMaterialConnectionPoint;
  145235. /**
  145236. * Gets the output component
  145237. */
  145238. get output(): NodeMaterialConnectionPoint;
  145239. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145240. /**
  145241. * Exposes the properties to the UI?
  145242. */
  145243. protected _dumpPropertiesCode(): string;
  145244. /**
  145245. * Exposes the properties to the Seralize?
  145246. */
  145247. serialize(): any;
  145248. /**
  145249. * Exposes the properties to the deseralize?
  145250. */
  145251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145252. }
  145253. }
  145254. declare module BABYLON {
  145255. /**
  145256. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145257. */
  145258. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145259. /**
  145260. * Creates a new SimplexPerlin3DBlock
  145261. * @param name defines the block name
  145262. */
  145263. constructor(name: string);
  145264. /**
  145265. * Gets the current class name
  145266. * @returns the class name
  145267. */
  145268. getClassName(): string;
  145269. /**
  145270. * Gets the seed operand input component
  145271. */
  145272. get seed(): NodeMaterialConnectionPoint;
  145273. /**
  145274. * Gets the output component
  145275. */
  145276. get output(): NodeMaterialConnectionPoint;
  145277. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145278. }
  145279. }
  145280. declare module BABYLON {
  145281. /**
  145282. * Block used to blend normals
  145283. */
  145284. export class NormalBlendBlock extends NodeMaterialBlock {
  145285. /**
  145286. * Creates a new NormalBlendBlock
  145287. * @param name defines the block name
  145288. */
  145289. constructor(name: string);
  145290. /**
  145291. * Gets the current class name
  145292. * @returns the class name
  145293. */
  145294. getClassName(): string;
  145295. /**
  145296. * Gets the first input component
  145297. */
  145298. get normalMap0(): NodeMaterialConnectionPoint;
  145299. /**
  145300. * Gets the second input component
  145301. */
  145302. get normalMap1(): NodeMaterialConnectionPoint;
  145303. /**
  145304. * Gets the output component
  145305. */
  145306. get output(): NodeMaterialConnectionPoint;
  145307. protected _buildBlock(state: NodeMaterialBuildState): this;
  145308. }
  145309. }
  145310. declare module BABYLON {
  145311. /**
  145312. * Block used to rotate a 2d vector by a given angle
  145313. */
  145314. export class Rotate2dBlock extends NodeMaterialBlock {
  145315. /**
  145316. * Creates a new Rotate2dBlock
  145317. * @param name defines the block name
  145318. */
  145319. constructor(name: string);
  145320. /**
  145321. * Gets the current class name
  145322. * @returns the class name
  145323. */
  145324. getClassName(): string;
  145325. /**
  145326. * Gets the input vector
  145327. */
  145328. get input(): NodeMaterialConnectionPoint;
  145329. /**
  145330. * Gets the input angle
  145331. */
  145332. get angle(): NodeMaterialConnectionPoint;
  145333. /**
  145334. * Gets the output component
  145335. */
  145336. get output(): NodeMaterialConnectionPoint;
  145337. autoConfigure(material: NodeMaterial): void;
  145338. protected _buildBlock(state: NodeMaterialBuildState): this;
  145339. }
  145340. }
  145341. declare module BABYLON {
  145342. /**
  145343. * Block used to get the reflected vector from a direction and a normal
  145344. */
  145345. export class ReflectBlock extends NodeMaterialBlock {
  145346. /**
  145347. * Creates a new ReflectBlock
  145348. * @param name defines the block name
  145349. */
  145350. constructor(name: string);
  145351. /**
  145352. * Gets the current class name
  145353. * @returns the class name
  145354. */
  145355. getClassName(): string;
  145356. /**
  145357. * Gets the incident component
  145358. */
  145359. get incident(): NodeMaterialConnectionPoint;
  145360. /**
  145361. * Gets the normal component
  145362. */
  145363. get normal(): NodeMaterialConnectionPoint;
  145364. /**
  145365. * Gets the output component
  145366. */
  145367. get output(): NodeMaterialConnectionPoint;
  145368. protected _buildBlock(state: NodeMaterialBuildState): this;
  145369. }
  145370. }
  145371. declare module BABYLON {
  145372. /**
  145373. * Block used to get the refracted vector from a direction and a normal
  145374. */
  145375. export class RefractBlock extends NodeMaterialBlock {
  145376. /**
  145377. * Creates a new RefractBlock
  145378. * @param name defines the block name
  145379. */
  145380. constructor(name: string);
  145381. /**
  145382. * Gets the current class name
  145383. * @returns the class name
  145384. */
  145385. getClassName(): string;
  145386. /**
  145387. * Gets the incident component
  145388. */
  145389. get incident(): NodeMaterialConnectionPoint;
  145390. /**
  145391. * Gets the normal component
  145392. */
  145393. get normal(): NodeMaterialConnectionPoint;
  145394. /**
  145395. * Gets the index of refraction component
  145396. */
  145397. get ior(): NodeMaterialConnectionPoint;
  145398. /**
  145399. * Gets the output component
  145400. */
  145401. get output(): NodeMaterialConnectionPoint;
  145402. protected _buildBlock(state: NodeMaterialBuildState): this;
  145403. }
  145404. }
  145405. declare module BABYLON {
  145406. /**
  145407. * Block used to desaturate a color
  145408. */
  145409. export class DesaturateBlock extends NodeMaterialBlock {
  145410. /**
  145411. * Creates a new DesaturateBlock
  145412. * @param name defines the block name
  145413. */
  145414. constructor(name: string);
  145415. /**
  145416. * Gets the current class name
  145417. * @returns the class name
  145418. */
  145419. getClassName(): string;
  145420. /**
  145421. * Gets the color operand input component
  145422. */
  145423. get color(): NodeMaterialConnectionPoint;
  145424. /**
  145425. * Gets the level operand input component
  145426. */
  145427. get level(): NodeMaterialConnectionPoint;
  145428. /**
  145429. * Gets the output component
  145430. */
  145431. get output(): NodeMaterialConnectionPoint;
  145432. protected _buildBlock(state: NodeMaterialBuildState): this;
  145433. }
  145434. }
  145435. declare module BABYLON {
  145436. /**
  145437. * Block used to implement the ambient occlusion module of the PBR material
  145438. */
  145439. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145440. /**
  145441. * Create a new AmbientOcclusionBlock
  145442. * @param name defines the block name
  145443. */
  145444. constructor(name: string);
  145445. /**
  145446. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145447. */
  145448. useAmbientInGrayScale: boolean;
  145449. /**
  145450. * Initialize the block and prepare the context for build
  145451. * @param state defines the state that will be used for the build
  145452. */
  145453. initialize(state: NodeMaterialBuildState): void;
  145454. /**
  145455. * Gets the current class name
  145456. * @returns the class name
  145457. */
  145458. getClassName(): string;
  145459. /**
  145460. * Gets the texture input component
  145461. */
  145462. get texture(): NodeMaterialConnectionPoint;
  145463. /**
  145464. * Gets the texture intensity component
  145465. */
  145466. get intensity(): NodeMaterialConnectionPoint;
  145467. /**
  145468. * Gets the direct light intensity input component
  145469. */
  145470. get directLightIntensity(): NodeMaterialConnectionPoint;
  145471. /**
  145472. * Gets the ambient occlusion object output component
  145473. */
  145474. get ambientOcc(): NodeMaterialConnectionPoint;
  145475. /**
  145476. * Gets the main code of the block (fragment side)
  145477. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145478. * @returns the shader code
  145479. */
  145480. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145481. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145482. protected _buildBlock(state: NodeMaterialBuildState): this;
  145483. protected _dumpPropertiesCode(): string;
  145484. serialize(): any;
  145485. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145486. }
  145487. }
  145488. declare module BABYLON {
  145489. /**
  145490. * Block used to implement the reflection module of the PBR material
  145491. */
  145492. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145493. /** @hidden */
  145494. _defineLODReflectionAlpha: string;
  145495. /** @hidden */
  145496. _defineLinearSpecularReflection: string;
  145497. private _vEnvironmentIrradianceName;
  145498. /** @hidden */
  145499. _vReflectionMicrosurfaceInfosName: string;
  145500. /** @hidden */
  145501. _vReflectionInfosName: string;
  145502. /** @hidden */
  145503. _vReflectionFilteringInfoName: string;
  145504. private _scene;
  145505. /**
  145506. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145507. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145508. * It's less burden on the user side in the editor part.
  145509. */
  145510. /** @hidden */
  145511. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145512. /** @hidden */
  145513. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145514. /** @hidden */
  145515. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145516. /**
  145517. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145518. * diffuse part of the IBL.
  145519. */
  145520. useSphericalHarmonics: boolean;
  145521. /**
  145522. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145523. */
  145524. forceIrradianceInFragment: boolean;
  145525. /**
  145526. * Create a new ReflectionBlock
  145527. * @param name defines the block name
  145528. */
  145529. constructor(name: string);
  145530. /**
  145531. * Gets the current class name
  145532. * @returns the class name
  145533. */
  145534. getClassName(): string;
  145535. /**
  145536. * Gets the position input component
  145537. */
  145538. get position(): NodeMaterialConnectionPoint;
  145539. /**
  145540. * Gets the world position input component
  145541. */
  145542. get worldPosition(): NodeMaterialConnectionPoint;
  145543. /**
  145544. * Gets the world normal input component
  145545. */
  145546. get worldNormal(): NodeMaterialConnectionPoint;
  145547. /**
  145548. * Gets the world input component
  145549. */
  145550. get world(): NodeMaterialConnectionPoint;
  145551. /**
  145552. * Gets the camera (or eye) position component
  145553. */
  145554. get cameraPosition(): NodeMaterialConnectionPoint;
  145555. /**
  145556. * Gets the view input component
  145557. */
  145558. get view(): NodeMaterialConnectionPoint;
  145559. /**
  145560. * Gets the color input component
  145561. */
  145562. get color(): NodeMaterialConnectionPoint;
  145563. /**
  145564. * Gets the reflection object output component
  145565. */
  145566. get reflection(): NodeMaterialConnectionPoint;
  145567. /**
  145568. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145569. */
  145570. get hasTexture(): boolean;
  145571. /**
  145572. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145573. */
  145574. get reflectionColor(): string;
  145575. protected _getTexture(): Nullable<BaseTexture>;
  145576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145578. /**
  145579. * Gets the code to inject in the vertex shader
  145580. * @param state current state of the node material building
  145581. * @returns the shader code
  145582. */
  145583. handleVertexSide(state: NodeMaterialBuildState): string;
  145584. /**
  145585. * Gets the main code of the block (fragment side)
  145586. * @param state current state of the node material building
  145587. * @param normalVarName name of the existing variable corresponding to the normal
  145588. * @returns the shader code
  145589. */
  145590. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145591. protected _buildBlock(state: NodeMaterialBuildState): this;
  145592. protected _dumpPropertiesCode(): string;
  145593. serialize(): any;
  145594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145595. }
  145596. }
  145597. declare module BABYLON {
  145598. /**
  145599. * Block used to implement the sheen module of the PBR material
  145600. */
  145601. export class SheenBlock extends NodeMaterialBlock {
  145602. /**
  145603. * Create a new SheenBlock
  145604. * @param name defines the block name
  145605. */
  145606. constructor(name: string);
  145607. /**
  145608. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145609. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145610. * making it easier to setup and tweak the effect
  145611. */
  145612. albedoScaling: boolean;
  145613. /**
  145614. * Defines if the sheen is linked to the sheen color.
  145615. */
  145616. linkSheenWithAlbedo: boolean;
  145617. /**
  145618. * Initialize the block and prepare the context for build
  145619. * @param state defines the state that will be used for the build
  145620. */
  145621. initialize(state: NodeMaterialBuildState): void;
  145622. /**
  145623. * Gets the current class name
  145624. * @returns the class name
  145625. */
  145626. getClassName(): string;
  145627. /**
  145628. * Gets the intensity input component
  145629. */
  145630. get intensity(): NodeMaterialConnectionPoint;
  145631. /**
  145632. * Gets the color input component
  145633. */
  145634. get color(): NodeMaterialConnectionPoint;
  145635. /**
  145636. * Gets the roughness input component
  145637. */
  145638. get roughness(): NodeMaterialConnectionPoint;
  145639. /**
  145640. * Gets the sheen object output component
  145641. */
  145642. get sheen(): NodeMaterialConnectionPoint;
  145643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145644. /**
  145645. * Gets the main code of the block (fragment side)
  145646. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145647. * @returns the shader code
  145648. */
  145649. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145650. protected _buildBlock(state: NodeMaterialBuildState): this;
  145651. protected _dumpPropertiesCode(): string;
  145652. serialize(): any;
  145653. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145654. }
  145655. }
  145656. declare module BABYLON {
  145657. /**
  145658. * Block used to implement the reflectivity module of the PBR material
  145659. */
  145660. export class ReflectivityBlock extends NodeMaterialBlock {
  145661. private _metallicReflectanceColor;
  145662. private _metallicF0Factor;
  145663. /** @hidden */
  145664. _vMetallicReflectanceFactorsName: string;
  145665. /**
  145666. * The property below is set by the main PBR block prior to calling methods of this class.
  145667. */
  145668. /** @hidden */
  145669. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145670. /**
  145671. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145672. */
  145673. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145674. /**
  145675. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145676. */
  145677. useMetallnessFromMetallicTextureBlue: boolean;
  145678. /**
  145679. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145680. */
  145681. useRoughnessFromMetallicTextureAlpha: boolean;
  145682. /**
  145683. * Specifies if the metallic texture contains the roughness information in its green channel.
  145684. */
  145685. useRoughnessFromMetallicTextureGreen: boolean;
  145686. /**
  145687. * Create a new ReflectivityBlock
  145688. * @param name defines the block name
  145689. */
  145690. constructor(name: string);
  145691. /**
  145692. * Initialize the block and prepare the context for build
  145693. * @param state defines the state that will be used for the build
  145694. */
  145695. initialize(state: NodeMaterialBuildState): void;
  145696. /**
  145697. * Gets the current class name
  145698. * @returns the class name
  145699. */
  145700. getClassName(): string;
  145701. /**
  145702. * Gets the metallic input component
  145703. */
  145704. get metallic(): NodeMaterialConnectionPoint;
  145705. /**
  145706. * Gets the roughness input component
  145707. */
  145708. get roughness(): NodeMaterialConnectionPoint;
  145709. /**
  145710. * Gets the texture input component
  145711. */
  145712. get texture(): NodeMaterialConnectionPoint;
  145713. /**
  145714. * Gets the reflectivity object output component
  145715. */
  145716. get reflectivity(): NodeMaterialConnectionPoint;
  145717. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145718. /**
  145719. * Gets the main code of the block (fragment side)
  145720. * @param state current state of the node material building
  145721. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145722. * @returns the shader code
  145723. */
  145724. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145726. protected _buildBlock(state: NodeMaterialBuildState): this;
  145727. protected _dumpPropertiesCode(): string;
  145728. serialize(): any;
  145729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145730. }
  145731. }
  145732. declare module BABYLON {
  145733. /**
  145734. * Block used to implement the anisotropy module of the PBR material
  145735. */
  145736. export class AnisotropyBlock extends NodeMaterialBlock {
  145737. /**
  145738. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145739. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145740. * It's less burden on the user side in the editor part.
  145741. */
  145742. /** @hidden */
  145743. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145744. /** @hidden */
  145745. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145746. /**
  145747. * Create a new AnisotropyBlock
  145748. * @param name defines the block name
  145749. */
  145750. constructor(name: string);
  145751. /**
  145752. * Initialize the block and prepare the context for build
  145753. * @param state defines the state that will be used for the build
  145754. */
  145755. initialize(state: NodeMaterialBuildState): void;
  145756. /**
  145757. * Gets the current class name
  145758. * @returns the class name
  145759. */
  145760. getClassName(): string;
  145761. /**
  145762. * Gets the intensity input component
  145763. */
  145764. get intensity(): NodeMaterialConnectionPoint;
  145765. /**
  145766. * Gets the direction input component
  145767. */
  145768. get direction(): NodeMaterialConnectionPoint;
  145769. /**
  145770. * Gets the texture input component
  145771. */
  145772. get texture(): NodeMaterialConnectionPoint;
  145773. /**
  145774. * Gets the uv input component
  145775. */
  145776. get uv(): NodeMaterialConnectionPoint;
  145777. /**
  145778. * Gets the worldTangent input component
  145779. */
  145780. get worldTangent(): NodeMaterialConnectionPoint;
  145781. /**
  145782. * Gets the anisotropy object output component
  145783. */
  145784. get anisotropy(): NodeMaterialConnectionPoint;
  145785. private _generateTBNSpace;
  145786. /**
  145787. * Gets the main code of the block (fragment side)
  145788. * @param state current state of the node material building
  145789. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145790. * @returns the shader code
  145791. */
  145792. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145794. protected _buildBlock(state: NodeMaterialBuildState): this;
  145795. }
  145796. }
  145797. declare module BABYLON {
  145798. /**
  145799. * Block used to implement the clear coat module of the PBR material
  145800. */
  145801. export class ClearCoatBlock extends NodeMaterialBlock {
  145802. private _scene;
  145803. /**
  145804. * Create a new ClearCoatBlock
  145805. * @param name defines the block name
  145806. */
  145807. constructor(name: string);
  145808. /**
  145809. * Initialize the block and prepare the context for build
  145810. * @param state defines the state that will be used for the build
  145811. */
  145812. initialize(state: NodeMaterialBuildState): void;
  145813. /**
  145814. * Gets the current class name
  145815. * @returns the class name
  145816. */
  145817. getClassName(): string;
  145818. /**
  145819. * Gets the intensity input component
  145820. */
  145821. get intensity(): NodeMaterialConnectionPoint;
  145822. /**
  145823. * Gets the roughness input component
  145824. */
  145825. get roughness(): NodeMaterialConnectionPoint;
  145826. /**
  145827. * Gets the ior input component
  145828. */
  145829. get ior(): NodeMaterialConnectionPoint;
  145830. /**
  145831. * Gets the texture input component
  145832. */
  145833. get texture(): NodeMaterialConnectionPoint;
  145834. /**
  145835. * Gets the bump texture input component
  145836. */
  145837. get bumpTexture(): NodeMaterialConnectionPoint;
  145838. /**
  145839. * Gets the uv input component
  145840. */
  145841. get uv(): NodeMaterialConnectionPoint;
  145842. /**
  145843. * Gets the tint color input component
  145844. */
  145845. get tintColor(): NodeMaterialConnectionPoint;
  145846. /**
  145847. * Gets the tint "at distance" input component
  145848. */
  145849. get tintAtDistance(): NodeMaterialConnectionPoint;
  145850. /**
  145851. * Gets the tint thickness input component
  145852. */
  145853. get tintThickness(): NodeMaterialConnectionPoint;
  145854. /**
  145855. * Gets the world tangent input component
  145856. */
  145857. get worldTangent(): NodeMaterialConnectionPoint;
  145858. /**
  145859. * Gets the clear coat object output component
  145860. */
  145861. get clearcoat(): NodeMaterialConnectionPoint;
  145862. autoConfigure(material: NodeMaterial): void;
  145863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145864. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145865. private _generateTBNSpace;
  145866. /**
  145867. * Gets the main code of the block (fragment side)
  145868. * @param state current state of the node material building
  145869. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145870. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145871. * @param worldPosVarName name of the variable holding the world position
  145872. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145873. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145874. * @param worldNormalVarName name of the variable holding the world normal
  145875. * @returns the shader code
  145876. */
  145877. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145878. protected _buildBlock(state: NodeMaterialBuildState): this;
  145879. }
  145880. }
  145881. declare module BABYLON {
  145882. /**
  145883. * Block used to implement the sub surface module of the PBR material
  145884. */
  145885. export class SubSurfaceBlock extends NodeMaterialBlock {
  145886. /**
  145887. * Create a new SubSurfaceBlock
  145888. * @param name defines the block name
  145889. */
  145890. constructor(name: string);
  145891. /**
  145892. * Stores the intensity of the different subsurface effects in the thickness texture.
  145893. * * the green channel is the translucency intensity.
  145894. * * the blue channel is the scattering intensity.
  145895. * * the alpha channel is the refraction intensity.
  145896. */
  145897. useMaskFromThicknessTexture: boolean;
  145898. /**
  145899. * Initialize the block and prepare the context for build
  145900. * @param state defines the state that will be used for the build
  145901. */
  145902. initialize(state: NodeMaterialBuildState): void;
  145903. /**
  145904. * Gets the current class name
  145905. * @returns the class name
  145906. */
  145907. getClassName(): string;
  145908. /**
  145909. * Gets the min thickness input component
  145910. */
  145911. get minThickness(): NodeMaterialConnectionPoint;
  145912. /**
  145913. * Gets the max thickness input component
  145914. */
  145915. get maxThickness(): NodeMaterialConnectionPoint;
  145916. /**
  145917. * Gets the thickness texture component
  145918. */
  145919. get thicknessTexture(): NodeMaterialConnectionPoint;
  145920. /**
  145921. * Gets the tint color input component
  145922. */
  145923. get tintColor(): NodeMaterialConnectionPoint;
  145924. /**
  145925. * Gets the translucency intensity input component
  145926. */
  145927. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145928. /**
  145929. * Gets the translucency diffusion distance input component
  145930. */
  145931. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145932. /**
  145933. * Gets the refraction object parameters
  145934. */
  145935. get refraction(): NodeMaterialConnectionPoint;
  145936. /**
  145937. * Gets the sub surface object output component
  145938. */
  145939. get subsurface(): NodeMaterialConnectionPoint;
  145940. autoConfigure(material: NodeMaterial): void;
  145941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145942. /**
  145943. * Gets the main code of the block (fragment side)
  145944. * @param state current state of the node material building
  145945. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145946. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145947. * @param worldPosVarName name of the variable holding the world position
  145948. * @returns the shader code
  145949. */
  145950. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145951. protected _buildBlock(state: NodeMaterialBuildState): this;
  145952. }
  145953. }
  145954. declare module BABYLON {
  145955. /**
  145956. * Block used to implement the PBR metallic/roughness model
  145957. */
  145958. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145959. /**
  145960. * Gets or sets the light associated with this block
  145961. */
  145962. light: Nullable<Light>;
  145963. private _lightId;
  145964. private _scene;
  145965. private _environmentBRDFTexture;
  145966. private _environmentBrdfSamplerName;
  145967. private _vNormalWName;
  145968. private _invertNormalName;
  145969. /**
  145970. * Create a new ReflectionBlock
  145971. * @param name defines the block name
  145972. */
  145973. constructor(name: string);
  145974. /**
  145975. * Intensity of the direct lights e.g. the four lights available in your scene.
  145976. * This impacts both the direct diffuse and specular highlights.
  145977. */
  145978. directIntensity: number;
  145979. /**
  145980. * Intensity of the environment e.g. how much the environment will light the object
  145981. * either through harmonics for rough material or through the refelction for shiny ones.
  145982. */
  145983. environmentIntensity: number;
  145984. /**
  145985. * This is a special control allowing the reduction of the specular highlights coming from the
  145986. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145987. */
  145988. specularIntensity: number;
  145989. /**
  145990. * Defines the falloff type used in this material.
  145991. * It by default is Physical.
  145992. */
  145993. lightFalloff: number;
  145994. /**
  145995. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145996. */
  145997. useAlphaFromAlbedoTexture: boolean;
  145998. /**
  145999. * Specifies that alpha test should be used
  146000. */
  146001. useAlphaTest: boolean;
  146002. /**
  146003. * Defines the alpha limits in alpha test mode.
  146004. */
  146005. alphaTestCutoff: number;
  146006. /**
  146007. * Specifies that alpha blending should be used
  146008. */
  146009. useAlphaBlending: boolean;
  146010. /**
  146011. * Defines if the alpha value should be determined via the rgb values.
  146012. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146013. */
  146014. opacityRGB: boolean;
  146015. /**
  146016. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146017. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146018. */
  146019. useRadianceOverAlpha: boolean;
  146020. /**
  146021. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146022. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146023. */
  146024. useSpecularOverAlpha: boolean;
  146025. /**
  146026. * Enables specular anti aliasing in the PBR shader.
  146027. * It will both interacts on the Geometry for analytical and IBL lighting.
  146028. * It also prefilter the roughness map based on the bump values.
  146029. */
  146030. enableSpecularAntiAliasing: boolean;
  146031. /**
  146032. * Enables realtime filtering on the texture.
  146033. */
  146034. realTimeFiltering: boolean;
  146035. /**
  146036. * Quality switch for realtime filtering
  146037. */
  146038. realTimeFilteringQuality: number;
  146039. /**
  146040. * Defines if the material uses energy conservation.
  146041. */
  146042. useEnergyConservation: boolean;
  146043. /**
  146044. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146045. * too much the area relying on ambient texture to define their ambient occlusion.
  146046. */
  146047. useRadianceOcclusion: boolean;
  146048. /**
  146049. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146050. * makes the reflect vector face the model (under horizon).
  146051. */
  146052. useHorizonOcclusion: boolean;
  146053. /**
  146054. * If set to true, no lighting calculations will be applied.
  146055. */
  146056. unlit: boolean;
  146057. /**
  146058. * Force normal to face away from face.
  146059. */
  146060. forceNormalForward: boolean;
  146061. /**
  146062. * Defines the material debug mode.
  146063. * It helps seeing only some components of the material while troubleshooting.
  146064. */
  146065. debugMode: number;
  146066. /**
  146067. * Specify from where on screen the debug mode should start.
  146068. * The value goes from -1 (full screen) to 1 (not visible)
  146069. * It helps with side by side comparison against the final render
  146070. * This defaults to 0
  146071. */
  146072. debugLimit: number;
  146073. /**
  146074. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146075. * You can use the factor to better multiply the final value.
  146076. */
  146077. debugFactor: number;
  146078. /**
  146079. * Initialize the block and prepare the context for build
  146080. * @param state defines the state that will be used for the build
  146081. */
  146082. initialize(state: NodeMaterialBuildState): void;
  146083. /**
  146084. * Gets the current class name
  146085. * @returns the class name
  146086. */
  146087. getClassName(): string;
  146088. /**
  146089. * Gets the world position input component
  146090. */
  146091. get worldPosition(): NodeMaterialConnectionPoint;
  146092. /**
  146093. * Gets the world normal input component
  146094. */
  146095. get worldNormal(): NodeMaterialConnectionPoint;
  146096. /**
  146097. * Gets the perturbed normal input component
  146098. */
  146099. get perturbedNormal(): NodeMaterialConnectionPoint;
  146100. /**
  146101. * Gets the camera position input component
  146102. */
  146103. get cameraPosition(): NodeMaterialConnectionPoint;
  146104. /**
  146105. * Gets the base color input component
  146106. */
  146107. get baseColor(): NodeMaterialConnectionPoint;
  146108. /**
  146109. * Gets the opacity texture input component
  146110. */
  146111. get opacityTexture(): NodeMaterialConnectionPoint;
  146112. /**
  146113. * Gets the ambient color input component
  146114. */
  146115. get ambientColor(): NodeMaterialConnectionPoint;
  146116. /**
  146117. * Gets the reflectivity object parameters
  146118. */
  146119. get reflectivity(): NodeMaterialConnectionPoint;
  146120. /**
  146121. * Gets the ambient occlusion object parameters
  146122. */
  146123. get ambientOcc(): NodeMaterialConnectionPoint;
  146124. /**
  146125. * Gets the reflection object parameters
  146126. */
  146127. get reflection(): NodeMaterialConnectionPoint;
  146128. /**
  146129. * Gets the sheen object parameters
  146130. */
  146131. get sheen(): NodeMaterialConnectionPoint;
  146132. /**
  146133. * Gets the clear coat object parameters
  146134. */
  146135. get clearcoat(): NodeMaterialConnectionPoint;
  146136. /**
  146137. * Gets the sub surface object parameters
  146138. */
  146139. get subsurface(): NodeMaterialConnectionPoint;
  146140. /**
  146141. * Gets the anisotropy object parameters
  146142. */
  146143. get anisotropy(): NodeMaterialConnectionPoint;
  146144. /**
  146145. * Gets the ambient output component
  146146. */
  146147. get ambient(): NodeMaterialConnectionPoint;
  146148. /**
  146149. * Gets the diffuse output component
  146150. */
  146151. get diffuse(): NodeMaterialConnectionPoint;
  146152. /**
  146153. * Gets the specular output component
  146154. */
  146155. get specular(): NodeMaterialConnectionPoint;
  146156. /**
  146157. * Gets the sheen output component
  146158. */
  146159. get sheenDir(): NodeMaterialConnectionPoint;
  146160. /**
  146161. * Gets the clear coat output component
  146162. */
  146163. get clearcoatDir(): NodeMaterialConnectionPoint;
  146164. /**
  146165. * Gets the indirect diffuse output component
  146166. */
  146167. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146168. /**
  146169. * Gets the indirect specular output component
  146170. */
  146171. get specularIndirect(): NodeMaterialConnectionPoint;
  146172. /**
  146173. * Gets the indirect sheen output component
  146174. */
  146175. get sheenIndirect(): NodeMaterialConnectionPoint;
  146176. /**
  146177. * Gets the indirect clear coat output component
  146178. */
  146179. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146180. /**
  146181. * Gets the refraction output component
  146182. */
  146183. get refraction(): NodeMaterialConnectionPoint;
  146184. /**
  146185. * Gets the global lighting output component
  146186. */
  146187. get lighting(): NodeMaterialConnectionPoint;
  146188. /**
  146189. * Gets the shadow output component
  146190. */
  146191. get shadow(): NodeMaterialConnectionPoint;
  146192. /**
  146193. * Gets the alpha output component
  146194. */
  146195. get alpha(): NodeMaterialConnectionPoint;
  146196. autoConfigure(material: NodeMaterial): void;
  146197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146198. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146200. private _injectVertexCode;
  146201. /**
  146202. * Gets the code corresponding to the albedo/opacity module
  146203. * @returns the shader code
  146204. */
  146205. getAlbedoOpacityCode(): string;
  146206. protected _buildBlock(state: NodeMaterialBuildState): this;
  146207. protected _dumpPropertiesCode(): string;
  146208. serialize(): any;
  146209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146210. }
  146211. }
  146212. declare module BABYLON {
  146213. /**
  146214. * Block used to compute value of one parameter modulo another
  146215. */
  146216. export class ModBlock extends NodeMaterialBlock {
  146217. /**
  146218. * Creates a new ModBlock
  146219. * @param name defines the block name
  146220. */
  146221. constructor(name: string);
  146222. /**
  146223. * Gets the current class name
  146224. * @returns the class name
  146225. */
  146226. getClassName(): string;
  146227. /**
  146228. * Gets the left operand input component
  146229. */
  146230. get left(): NodeMaterialConnectionPoint;
  146231. /**
  146232. * Gets the right operand input component
  146233. */
  146234. get right(): NodeMaterialConnectionPoint;
  146235. /**
  146236. * Gets the output component
  146237. */
  146238. get output(): NodeMaterialConnectionPoint;
  146239. protected _buildBlock(state: NodeMaterialBuildState): this;
  146240. }
  146241. }
  146242. declare module BABYLON {
  146243. /**
  146244. * Configuration for Draco compression
  146245. */
  146246. export interface IDracoCompressionConfiguration {
  146247. /**
  146248. * Configuration for the decoder.
  146249. */
  146250. decoder: {
  146251. /**
  146252. * The url to the WebAssembly module.
  146253. */
  146254. wasmUrl?: string;
  146255. /**
  146256. * The url to the WebAssembly binary.
  146257. */
  146258. wasmBinaryUrl?: string;
  146259. /**
  146260. * The url to the fallback JavaScript module.
  146261. */
  146262. fallbackUrl?: string;
  146263. };
  146264. }
  146265. /**
  146266. * Draco compression (https://google.github.io/draco/)
  146267. *
  146268. * This class wraps the Draco module.
  146269. *
  146270. * **Encoder**
  146271. *
  146272. * The encoder is not currently implemented.
  146273. *
  146274. * **Decoder**
  146275. *
  146276. * 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.
  146277. *
  146278. * To update the configuration, use the following code:
  146279. * ```javascript
  146280. * DracoCompression.Configuration = {
  146281. * decoder: {
  146282. * wasmUrl: "<url to the WebAssembly library>",
  146283. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146284. * fallbackUrl: "<url to the fallback JavaScript library>",
  146285. * }
  146286. * };
  146287. * ```
  146288. *
  146289. * 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.
  146290. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146291. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146292. *
  146293. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146294. * ```javascript
  146295. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146296. * ```
  146297. *
  146298. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146299. */
  146300. export class DracoCompression implements IDisposable {
  146301. private _workerPoolPromise?;
  146302. private _decoderModulePromise?;
  146303. /**
  146304. * The configuration. Defaults to the following urls:
  146305. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146306. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146307. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146308. */
  146309. static Configuration: IDracoCompressionConfiguration;
  146310. /**
  146311. * Returns true if the decoder configuration is available.
  146312. */
  146313. static get DecoderAvailable(): boolean;
  146314. /**
  146315. * Default number of workers to create when creating the draco compression object.
  146316. */
  146317. static DefaultNumWorkers: number;
  146318. private static GetDefaultNumWorkers;
  146319. private static _Default;
  146320. /**
  146321. * Default instance for the draco compression object.
  146322. */
  146323. static get Default(): DracoCompression;
  146324. /**
  146325. * Constructor
  146326. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146327. */
  146328. constructor(numWorkers?: number);
  146329. /**
  146330. * Stop all async operations and release resources.
  146331. */
  146332. dispose(): void;
  146333. /**
  146334. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146335. * @returns a promise that resolves when ready
  146336. */
  146337. whenReadyAsync(): Promise<void>;
  146338. /**
  146339. * Decode Draco compressed mesh data to vertex data.
  146340. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146341. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146342. * @returns A promise that resolves with the decoded vertex data
  146343. */
  146344. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146345. [kind: string]: number;
  146346. }): Promise<VertexData>;
  146347. }
  146348. }
  146349. declare module BABYLON {
  146350. /**
  146351. * Class for building Constructive Solid Geometry
  146352. */
  146353. export class CSG {
  146354. private polygons;
  146355. /**
  146356. * The world matrix
  146357. */
  146358. matrix: Matrix;
  146359. /**
  146360. * Stores the position
  146361. */
  146362. position: Vector3;
  146363. /**
  146364. * Stores the rotation
  146365. */
  146366. rotation: Vector3;
  146367. /**
  146368. * Stores the rotation quaternion
  146369. */
  146370. rotationQuaternion: Nullable<Quaternion>;
  146371. /**
  146372. * Stores the scaling vector
  146373. */
  146374. scaling: Vector3;
  146375. /**
  146376. * Convert the Mesh to CSG
  146377. * @param mesh The Mesh to convert to CSG
  146378. * @returns A new CSG from the Mesh
  146379. */
  146380. static FromMesh(mesh: Mesh): CSG;
  146381. /**
  146382. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146383. * @param polygons Polygons used to construct a CSG solid
  146384. */
  146385. private static FromPolygons;
  146386. /**
  146387. * Clones, or makes a deep copy, of the CSG
  146388. * @returns A new CSG
  146389. */
  146390. clone(): CSG;
  146391. /**
  146392. * Unions this CSG with another CSG
  146393. * @param csg The CSG to union against this CSG
  146394. * @returns The unioned CSG
  146395. */
  146396. union(csg: CSG): CSG;
  146397. /**
  146398. * Unions this CSG with another CSG in place
  146399. * @param csg The CSG to union against this CSG
  146400. */
  146401. unionInPlace(csg: CSG): void;
  146402. /**
  146403. * Subtracts this CSG with another CSG
  146404. * @param csg The CSG to subtract against this CSG
  146405. * @returns A new CSG
  146406. */
  146407. subtract(csg: CSG): CSG;
  146408. /**
  146409. * Subtracts this CSG with another CSG in place
  146410. * @param csg The CSG to subtact against this CSG
  146411. */
  146412. subtractInPlace(csg: CSG): void;
  146413. /**
  146414. * Intersect this CSG with another CSG
  146415. * @param csg The CSG to intersect against this CSG
  146416. * @returns A new CSG
  146417. */
  146418. intersect(csg: CSG): CSG;
  146419. /**
  146420. * Intersects this CSG with another CSG in place
  146421. * @param csg The CSG to intersect against this CSG
  146422. */
  146423. intersectInPlace(csg: CSG): void;
  146424. /**
  146425. * Return a new CSG solid with solid and empty space switched. This solid is
  146426. * not modified.
  146427. * @returns A new CSG solid with solid and empty space switched
  146428. */
  146429. inverse(): CSG;
  146430. /**
  146431. * Inverses the CSG in place
  146432. */
  146433. inverseInPlace(): void;
  146434. /**
  146435. * This is used to keep meshes transformations so they can be restored
  146436. * when we build back a Babylon Mesh
  146437. * NB : All CSG operations are performed in world coordinates
  146438. * @param csg The CSG to copy the transform attributes from
  146439. * @returns This CSG
  146440. */
  146441. copyTransformAttributes(csg: CSG): CSG;
  146442. /**
  146443. * Build Raw mesh from CSG
  146444. * Coordinates here are in world space
  146445. * @param name The name of the mesh geometry
  146446. * @param scene The Scene
  146447. * @param keepSubMeshes Specifies if the submeshes should be kept
  146448. * @returns A new Mesh
  146449. */
  146450. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146451. /**
  146452. * Build Mesh from CSG taking material and transforms into account
  146453. * @param name The name of the Mesh
  146454. * @param material The material of the Mesh
  146455. * @param scene The Scene
  146456. * @param keepSubMeshes Specifies if submeshes should be kept
  146457. * @returns The new Mesh
  146458. */
  146459. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146460. }
  146461. }
  146462. declare module BABYLON {
  146463. /**
  146464. * Class used to create a trail following a mesh
  146465. */
  146466. export class TrailMesh extends Mesh {
  146467. private _generator;
  146468. private _autoStart;
  146469. private _running;
  146470. private _diameter;
  146471. private _length;
  146472. private _sectionPolygonPointsCount;
  146473. private _sectionVectors;
  146474. private _sectionNormalVectors;
  146475. private _beforeRenderObserver;
  146476. /**
  146477. * @constructor
  146478. * @param name The value used by scene.getMeshByName() to do a lookup.
  146479. * @param generator The mesh or transform node to generate a trail.
  146480. * @param scene The scene to add this mesh to.
  146481. * @param diameter Diameter of trailing mesh. Default is 1.
  146482. * @param length Length of trailing mesh. Default is 60.
  146483. * @param autoStart Automatically start trailing mesh. Default true.
  146484. */
  146485. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146486. /**
  146487. * "TrailMesh"
  146488. * @returns "TrailMesh"
  146489. */
  146490. getClassName(): string;
  146491. private _createMesh;
  146492. /**
  146493. * Start trailing mesh.
  146494. */
  146495. start(): void;
  146496. /**
  146497. * Stop trailing mesh.
  146498. */
  146499. stop(): void;
  146500. /**
  146501. * Update trailing mesh geometry.
  146502. */
  146503. update(): void;
  146504. /**
  146505. * Returns a new TrailMesh object.
  146506. * @param name is a string, the name given to the new mesh
  146507. * @param newGenerator use new generator object for cloned trail mesh
  146508. * @returns a new mesh
  146509. */
  146510. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146511. /**
  146512. * Serializes this trail mesh
  146513. * @param serializationObject object to write serialization to
  146514. */
  146515. serialize(serializationObject: any): void;
  146516. /**
  146517. * Parses a serialized trail mesh
  146518. * @param parsedMesh the serialized mesh
  146519. * @param scene the scene to create the trail mesh in
  146520. * @returns the created trail mesh
  146521. */
  146522. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146523. }
  146524. }
  146525. declare module BABYLON {
  146526. /**
  146527. * Class containing static functions to help procedurally build meshes
  146528. */
  146529. export class TiledBoxBuilder {
  146530. /**
  146531. * Creates a box mesh
  146532. * 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)
  146533. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146537. * @param name defines the name of the mesh
  146538. * @param options defines the options used to create the mesh
  146539. * @param scene defines the hosting scene
  146540. * @returns the box mesh
  146541. */
  146542. static CreateTiledBox(name: string, options: {
  146543. pattern?: number;
  146544. width?: number;
  146545. height?: number;
  146546. depth?: number;
  146547. tileSize?: number;
  146548. tileWidth?: number;
  146549. tileHeight?: number;
  146550. alignHorizontal?: number;
  146551. alignVertical?: number;
  146552. faceUV?: Vector4[];
  146553. faceColors?: Color4[];
  146554. sideOrientation?: number;
  146555. updatable?: boolean;
  146556. }, scene?: Nullable<Scene>): Mesh;
  146557. }
  146558. }
  146559. declare module BABYLON {
  146560. /**
  146561. * Class containing static functions to help procedurally build meshes
  146562. */
  146563. export class TorusKnotBuilder {
  146564. /**
  146565. * Creates a torus knot mesh
  146566. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146567. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146568. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146569. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146573. * @param name defines the name of the mesh
  146574. * @param options defines the options used to create the mesh
  146575. * @param scene defines the hosting scene
  146576. * @returns the torus knot mesh
  146577. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146578. */
  146579. static CreateTorusKnot(name: string, options: {
  146580. radius?: number;
  146581. tube?: number;
  146582. radialSegments?: number;
  146583. tubularSegments?: number;
  146584. p?: number;
  146585. q?: number;
  146586. updatable?: boolean;
  146587. sideOrientation?: number;
  146588. frontUVs?: Vector4;
  146589. backUVs?: Vector4;
  146590. }, scene: any): Mesh;
  146591. }
  146592. }
  146593. declare module BABYLON {
  146594. /**
  146595. * Polygon
  146596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146597. */
  146598. export class Polygon {
  146599. /**
  146600. * Creates a rectangle
  146601. * @param xmin bottom X coord
  146602. * @param ymin bottom Y coord
  146603. * @param xmax top X coord
  146604. * @param ymax top Y coord
  146605. * @returns points that make the resulting rectation
  146606. */
  146607. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146608. /**
  146609. * Creates a circle
  146610. * @param radius radius of circle
  146611. * @param cx scale in x
  146612. * @param cy scale in y
  146613. * @param numberOfSides number of sides that make up the circle
  146614. * @returns points that make the resulting circle
  146615. */
  146616. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146617. /**
  146618. * Creates a polygon from input string
  146619. * @param input Input polygon data
  146620. * @returns the parsed points
  146621. */
  146622. static Parse(input: string): Vector2[];
  146623. /**
  146624. * Starts building a polygon from x and y coordinates
  146625. * @param x x coordinate
  146626. * @param y y coordinate
  146627. * @returns the started path2
  146628. */
  146629. static StartingAt(x: number, y: number): Path2;
  146630. }
  146631. /**
  146632. * Builds a polygon
  146633. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146634. */
  146635. export class PolygonMeshBuilder {
  146636. private _points;
  146637. private _outlinepoints;
  146638. private _holes;
  146639. private _name;
  146640. private _scene;
  146641. private _epoints;
  146642. private _eholes;
  146643. private _addToepoint;
  146644. /**
  146645. * Babylon reference to the earcut plugin.
  146646. */
  146647. bjsEarcut: any;
  146648. /**
  146649. * Creates a PolygonMeshBuilder
  146650. * @param name name of the builder
  146651. * @param contours Path of the polygon
  146652. * @param scene scene to add to when creating the mesh
  146653. * @param earcutInjection can be used to inject your own earcut reference
  146654. */
  146655. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146656. /**
  146657. * Adds a whole within the polygon
  146658. * @param hole Array of points defining the hole
  146659. * @returns this
  146660. */
  146661. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146662. /**
  146663. * Creates the polygon
  146664. * @param updatable If the mesh should be updatable
  146665. * @param depth The depth of the mesh created
  146666. * @returns the created mesh
  146667. */
  146668. build(updatable?: boolean, depth?: number): Mesh;
  146669. /**
  146670. * Creates the polygon
  146671. * @param depth The depth of the mesh created
  146672. * @returns the created VertexData
  146673. */
  146674. buildVertexData(depth?: number): VertexData;
  146675. /**
  146676. * Adds a side to the polygon
  146677. * @param positions points that make the polygon
  146678. * @param normals normals of the polygon
  146679. * @param uvs uvs of the polygon
  146680. * @param indices indices of the polygon
  146681. * @param bounds bounds of the polygon
  146682. * @param points points of the polygon
  146683. * @param depth depth of the polygon
  146684. * @param flip flip of the polygon
  146685. */
  146686. private addSide;
  146687. }
  146688. }
  146689. declare module BABYLON {
  146690. /**
  146691. * Class containing static functions to help procedurally build meshes
  146692. */
  146693. export class PolygonBuilder {
  146694. /**
  146695. * Creates a polygon mesh
  146696. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146697. * * 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
  146698. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146701. * * Remember you can only change the shape positions, not their number when updating a polygon
  146702. * @param name defines the name of the mesh
  146703. * @param options defines the options used to create the mesh
  146704. * @param scene defines the hosting scene
  146705. * @param earcutInjection can be used to inject your own earcut reference
  146706. * @returns the polygon mesh
  146707. */
  146708. static CreatePolygon(name: string, options: {
  146709. shape: Vector3[];
  146710. holes?: Vector3[][];
  146711. depth?: number;
  146712. faceUV?: Vector4[];
  146713. faceColors?: Color4[];
  146714. updatable?: boolean;
  146715. sideOrientation?: number;
  146716. frontUVs?: Vector4;
  146717. backUVs?: Vector4;
  146718. wrap?: boolean;
  146719. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146720. /**
  146721. * Creates an extruded polygon mesh, with depth in the Y direction.
  146722. * * 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)
  146723. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146724. * @param name defines the name of the mesh
  146725. * @param options defines the options used to create the mesh
  146726. * @param scene defines the hosting scene
  146727. * @param earcutInjection can be used to inject your own earcut reference
  146728. * @returns the polygon mesh
  146729. */
  146730. static ExtrudePolygon(name: string, options: {
  146731. shape: Vector3[];
  146732. holes?: Vector3[][];
  146733. depth?: number;
  146734. faceUV?: Vector4[];
  146735. faceColors?: Color4[];
  146736. updatable?: boolean;
  146737. sideOrientation?: number;
  146738. frontUVs?: Vector4;
  146739. backUVs?: Vector4;
  146740. wrap?: boolean;
  146741. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146742. }
  146743. }
  146744. declare module BABYLON {
  146745. /**
  146746. * Class containing static functions to help procedurally build meshes
  146747. */
  146748. export class LatheBuilder {
  146749. /**
  146750. * Creates lathe mesh.
  146751. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146752. * * 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
  146753. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146754. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146755. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146756. * * 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
  146757. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146758. * * 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
  146759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146761. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146763. * @param name defines the name of the mesh
  146764. * @param options defines the options used to create the mesh
  146765. * @param scene defines the hosting scene
  146766. * @returns the lathe mesh
  146767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146768. */
  146769. static CreateLathe(name: string, options: {
  146770. shape: Vector3[];
  146771. radius?: number;
  146772. tessellation?: number;
  146773. clip?: number;
  146774. arc?: number;
  146775. closed?: boolean;
  146776. updatable?: boolean;
  146777. sideOrientation?: number;
  146778. frontUVs?: Vector4;
  146779. backUVs?: Vector4;
  146780. cap?: number;
  146781. invertUV?: boolean;
  146782. }, scene?: Nullable<Scene>): Mesh;
  146783. }
  146784. }
  146785. declare module BABYLON {
  146786. /**
  146787. * Class containing static functions to help procedurally build meshes
  146788. */
  146789. export class TiledPlaneBuilder {
  146790. /**
  146791. * Creates a tiled plane mesh
  146792. * * The parameter `pattern` will, depending on value, do nothing or
  146793. * * * flip (reflect about central vertical) alternate tiles across and up
  146794. * * * flip every tile on alternate rows
  146795. * * * rotate (180 degs) alternate tiles across and up
  146796. * * * rotate every tile on alternate rows
  146797. * * * flip and rotate alternate tiles across and up
  146798. * * * flip and rotate every tile on alternate rows
  146799. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146800. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146802. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146803. * * 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)
  146804. * * 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)
  146805. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146806. * @param name defines the name of the mesh
  146807. * @param options defines the options used to create the mesh
  146808. * @param scene defines the hosting scene
  146809. * @returns the box mesh
  146810. */
  146811. static CreateTiledPlane(name: string, options: {
  146812. pattern?: number;
  146813. tileSize?: number;
  146814. tileWidth?: number;
  146815. tileHeight?: number;
  146816. size?: number;
  146817. width?: number;
  146818. height?: number;
  146819. alignHorizontal?: number;
  146820. alignVertical?: number;
  146821. sideOrientation?: number;
  146822. frontUVs?: Vector4;
  146823. backUVs?: Vector4;
  146824. updatable?: boolean;
  146825. }, scene?: Nullable<Scene>): Mesh;
  146826. }
  146827. }
  146828. declare module BABYLON {
  146829. /**
  146830. * Class containing static functions to help procedurally build meshes
  146831. */
  146832. export class TubeBuilder {
  146833. /**
  146834. * Creates a tube mesh.
  146835. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146836. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146837. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146838. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146839. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146840. * * 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)
  146841. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146842. * * 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
  146843. * * 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
  146844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146846. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146848. * @param name defines the name of the mesh
  146849. * @param options defines the options used to create the mesh
  146850. * @param scene defines the hosting scene
  146851. * @returns the tube mesh
  146852. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146853. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146854. */
  146855. static CreateTube(name: string, options: {
  146856. path: Vector3[];
  146857. radius?: number;
  146858. tessellation?: number;
  146859. radiusFunction?: {
  146860. (i: number, distance: number): number;
  146861. };
  146862. cap?: number;
  146863. arc?: number;
  146864. updatable?: boolean;
  146865. sideOrientation?: number;
  146866. frontUVs?: Vector4;
  146867. backUVs?: Vector4;
  146868. instance?: Mesh;
  146869. invertUV?: boolean;
  146870. }, scene?: Nullable<Scene>): Mesh;
  146871. }
  146872. }
  146873. declare module BABYLON {
  146874. /**
  146875. * Class containing static functions to help procedurally build meshes
  146876. */
  146877. export class IcoSphereBuilder {
  146878. /**
  146879. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146880. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146881. * * 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`)
  146882. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146883. * * 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
  146884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146887. * @param name defines the name of the mesh
  146888. * @param options defines the options used to create the mesh
  146889. * @param scene defines the hosting scene
  146890. * @returns the icosahedron mesh
  146891. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146892. */
  146893. static CreateIcoSphere(name: string, options: {
  146894. radius?: number;
  146895. radiusX?: number;
  146896. radiusY?: number;
  146897. radiusZ?: number;
  146898. flat?: boolean;
  146899. subdivisions?: number;
  146900. sideOrientation?: number;
  146901. frontUVs?: Vector4;
  146902. backUVs?: Vector4;
  146903. updatable?: boolean;
  146904. }, scene?: Nullable<Scene>): Mesh;
  146905. }
  146906. }
  146907. declare module BABYLON {
  146908. /**
  146909. * Class containing static functions to help procedurally build meshes
  146910. */
  146911. export class DecalBuilder {
  146912. /**
  146913. * Creates a decal mesh.
  146914. * 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
  146915. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146916. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146917. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146918. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146919. * @param name defines the name of the mesh
  146920. * @param sourceMesh defines the mesh where the decal must be applied
  146921. * @param options defines the options used to create the mesh
  146922. * @param scene defines the hosting scene
  146923. * @returns the decal mesh
  146924. * @see https://doc.babylonjs.com/how_to/decals
  146925. */
  146926. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146927. position?: Vector3;
  146928. normal?: Vector3;
  146929. size?: Vector3;
  146930. angle?: number;
  146931. }): Mesh;
  146932. }
  146933. }
  146934. declare module BABYLON {
  146935. /**
  146936. * Class containing static functions to help procedurally build meshes
  146937. */
  146938. export class MeshBuilder {
  146939. /**
  146940. * Creates a box mesh
  146941. * * The parameter `size` sets the size (float) of each box side (default 1)
  146942. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146943. * * 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)
  146944. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146948. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146949. * @param name defines the name of the mesh
  146950. * @param options defines the options used to create the mesh
  146951. * @param scene defines the hosting scene
  146952. * @returns the box mesh
  146953. */
  146954. static CreateBox(name: string, options: {
  146955. size?: number;
  146956. width?: number;
  146957. height?: number;
  146958. depth?: number;
  146959. faceUV?: Vector4[];
  146960. faceColors?: Color4[];
  146961. sideOrientation?: number;
  146962. frontUVs?: Vector4;
  146963. backUVs?: Vector4;
  146964. wrap?: boolean;
  146965. topBaseAt?: number;
  146966. bottomBaseAt?: number;
  146967. updatable?: boolean;
  146968. }, scene?: Nullable<Scene>): Mesh;
  146969. /**
  146970. * Creates a tiled box mesh
  146971. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146973. * @param name defines the name of the mesh
  146974. * @param options defines the options used to create the mesh
  146975. * @param scene defines the hosting scene
  146976. * @returns the tiled box mesh
  146977. */
  146978. static CreateTiledBox(name: string, options: {
  146979. pattern?: number;
  146980. size?: number;
  146981. width?: number;
  146982. height?: number;
  146983. depth: number;
  146984. tileSize?: number;
  146985. tileWidth?: number;
  146986. tileHeight?: number;
  146987. faceUV?: Vector4[];
  146988. faceColors?: Color4[];
  146989. alignHorizontal?: number;
  146990. alignVertical?: number;
  146991. sideOrientation?: number;
  146992. updatable?: boolean;
  146993. }, scene?: Nullable<Scene>): Mesh;
  146994. /**
  146995. * Creates a sphere mesh
  146996. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146997. * * 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`)
  146998. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146999. * * 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
  147000. * * 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)
  147001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147004. * @param name defines the name of the mesh
  147005. * @param options defines the options used to create the mesh
  147006. * @param scene defines the hosting scene
  147007. * @returns the sphere mesh
  147008. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147009. */
  147010. static CreateSphere(name: string, options: {
  147011. segments?: number;
  147012. diameter?: number;
  147013. diameterX?: number;
  147014. diameterY?: number;
  147015. diameterZ?: number;
  147016. arc?: number;
  147017. slice?: number;
  147018. sideOrientation?: number;
  147019. frontUVs?: Vector4;
  147020. backUVs?: Vector4;
  147021. updatable?: boolean;
  147022. }, scene?: Nullable<Scene>): Mesh;
  147023. /**
  147024. * Creates a plane polygonal mesh. By default, this is a disc
  147025. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147026. * * 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
  147027. * * 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
  147028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147031. * @param name defines the name of the mesh
  147032. * @param options defines the options used to create the mesh
  147033. * @param scene defines the hosting scene
  147034. * @returns the plane polygonal mesh
  147035. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147036. */
  147037. static CreateDisc(name: string, options: {
  147038. radius?: number;
  147039. tessellation?: number;
  147040. arc?: number;
  147041. updatable?: boolean;
  147042. sideOrientation?: number;
  147043. frontUVs?: Vector4;
  147044. backUVs?: Vector4;
  147045. }, scene?: Nullable<Scene>): Mesh;
  147046. /**
  147047. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147048. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147049. * * 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`)
  147050. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147051. * * 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
  147052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147055. * @param name defines the name of the mesh
  147056. * @param options defines the options used to create the mesh
  147057. * @param scene defines the hosting scene
  147058. * @returns the icosahedron mesh
  147059. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147060. */
  147061. static CreateIcoSphere(name: string, options: {
  147062. radius?: number;
  147063. radiusX?: number;
  147064. radiusY?: number;
  147065. radiusZ?: number;
  147066. flat?: boolean;
  147067. subdivisions?: number;
  147068. sideOrientation?: number;
  147069. frontUVs?: Vector4;
  147070. backUVs?: Vector4;
  147071. updatable?: boolean;
  147072. }, scene?: Nullable<Scene>): Mesh;
  147073. /**
  147074. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147075. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147076. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147077. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147078. * * 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
  147079. * * 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
  147080. * * 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
  147081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147083. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147084. * * 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
  147085. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147086. * * 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
  147087. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147089. * @param name defines the name of the mesh
  147090. * @param options defines the options used to create the mesh
  147091. * @param scene defines the hosting scene
  147092. * @returns the ribbon mesh
  147093. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147094. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147095. */
  147096. static CreateRibbon(name: string, options: {
  147097. pathArray: Vector3[][];
  147098. closeArray?: boolean;
  147099. closePath?: boolean;
  147100. offset?: number;
  147101. updatable?: boolean;
  147102. sideOrientation?: number;
  147103. frontUVs?: Vector4;
  147104. backUVs?: Vector4;
  147105. instance?: Mesh;
  147106. invertUV?: boolean;
  147107. uvs?: Vector2[];
  147108. colors?: Color4[];
  147109. }, scene?: Nullable<Scene>): Mesh;
  147110. /**
  147111. * Creates a cylinder or a cone mesh
  147112. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147113. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147114. * * 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.
  147115. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147116. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147117. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147118. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147119. * * 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).
  147120. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147121. * * 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).
  147122. * * 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
  147123. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147124. * * 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
  147125. * * 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.
  147126. * * If `enclose` is false, a ring surface is one element.
  147127. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147128. * * 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
  147129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147132. * @param name defines the name of the mesh
  147133. * @param options defines the options used to create the mesh
  147134. * @param scene defines the hosting scene
  147135. * @returns the cylinder mesh
  147136. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147137. */
  147138. static CreateCylinder(name: string, options: {
  147139. height?: number;
  147140. diameterTop?: number;
  147141. diameterBottom?: number;
  147142. diameter?: number;
  147143. tessellation?: number;
  147144. subdivisions?: number;
  147145. arc?: number;
  147146. faceColors?: Color4[];
  147147. faceUV?: Vector4[];
  147148. updatable?: boolean;
  147149. hasRings?: boolean;
  147150. enclose?: boolean;
  147151. cap?: number;
  147152. sideOrientation?: number;
  147153. frontUVs?: Vector4;
  147154. backUVs?: Vector4;
  147155. }, scene?: Nullable<Scene>): Mesh;
  147156. /**
  147157. * Creates a torus mesh
  147158. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147159. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147160. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147164. * @param name defines the name of the mesh
  147165. * @param options defines the options used to create the mesh
  147166. * @param scene defines the hosting scene
  147167. * @returns the torus mesh
  147168. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147169. */
  147170. static CreateTorus(name: string, options: {
  147171. diameter?: number;
  147172. thickness?: number;
  147173. tessellation?: number;
  147174. updatable?: boolean;
  147175. sideOrientation?: number;
  147176. frontUVs?: Vector4;
  147177. backUVs?: Vector4;
  147178. }, scene?: Nullable<Scene>): Mesh;
  147179. /**
  147180. * Creates a torus knot mesh
  147181. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147182. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147183. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147184. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147188. * @param name defines the name of the mesh
  147189. * @param options defines the options used to create the mesh
  147190. * @param scene defines the hosting scene
  147191. * @returns the torus knot mesh
  147192. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147193. */
  147194. static CreateTorusKnot(name: string, options: {
  147195. radius?: number;
  147196. tube?: number;
  147197. radialSegments?: number;
  147198. tubularSegments?: number;
  147199. p?: number;
  147200. q?: number;
  147201. updatable?: boolean;
  147202. sideOrientation?: number;
  147203. frontUVs?: Vector4;
  147204. backUVs?: Vector4;
  147205. }, scene?: Nullable<Scene>): Mesh;
  147206. /**
  147207. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147208. * * 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
  147209. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147210. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147211. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147212. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147213. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147214. * * 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
  147215. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147218. * @param name defines the name of the new line system
  147219. * @param options defines the options used to create the line system
  147220. * @param scene defines the hosting scene
  147221. * @returns a new line system mesh
  147222. */
  147223. static CreateLineSystem(name: string, options: {
  147224. lines: Vector3[][];
  147225. updatable?: boolean;
  147226. instance?: Nullable<LinesMesh>;
  147227. colors?: Nullable<Color4[][]>;
  147228. useVertexAlpha?: boolean;
  147229. }, scene: Nullable<Scene>): LinesMesh;
  147230. /**
  147231. * Creates a line mesh
  147232. * 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
  147233. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147234. * * The parameter `points` is an array successive Vector3
  147235. * * 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
  147236. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147237. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147238. * * When updating an instance, remember that only point positions can change, not the number of points
  147239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147241. * @param name defines the name of the new line system
  147242. * @param options defines the options used to create the line system
  147243. * @param scene defines the hosting scene
  147244. * @returns a new line mesh
  147245. */
  147246. static CreateLines(name: string, options: {
  147247. points: Vector3[];
  147248. updatable?: boolean;
  147249. instance?: Nullable<LinesMesh>;
  147250. colors?: Color4[];
  147251. useVertexAlpha?: boolean;
  147252. }, scene?: Nullable<Scene>): LinesMesh;
  147253. /**
  147254. * Creates a dashed line mesh
  147255. * * 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
  147256. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147257. * * The parameter `points` is an array successive Vector3
  147258. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147259. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147260. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147261. * * 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
  147262. * * When updating an instance, remember that only point positions can change, not the number of points
  147263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147264. * @param name defines the name of the mesh
  147265. * @param options defines the options used to create the mesh
  147266. * @param scene defines the hosting scene
  147267. * @returns the dashed line mesh
  147268. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147269. */
  147270. static CreateDashedLines(name: string, options: {
  147271. points: Vector3[];
  147272. dashSize?: number;
  147273. gapSize?: number;
  147274. dashNb?: number;
  147275. updatable?: boolean;
  147276. instance?: LinesMesh;
  147277. }, scene?: Nullable<Scene>): LinesMesh;
  147278. /**
  147279. * 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.
  147280. * * 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.
  147281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147282. * * 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.
  147283. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147284. * * 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
  147285. * * 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
  147286. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147291. * @param name defines the name of the mesh
  147292. * @param options defines the options used to create the mesh
  147293. * @param scene defines the hosting scene
  147294. * @returns the extruded shape mesh
  147295. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147297. */
  147298. static ExtrudeShape(name: string, options: {
  147299. shape: Vector3[];
  147300. path: Vector3[];
  147301. scale?: number;
  147302. rotation?: number;
  147303. cap?: number;
  147304. updatable?: boolean;
  147305. sideOrientation?: number;
  147306. frontUVs?: Vector4;
  147307. backUVs?: Vector4;
  147308. instance?: Mesh;
  147309. invertUV?: boolean;
  147310. }, scene?: Nullable<Scene>): Mesh;
  147311. /**
  147312. * Creates an custom extruded shape mesh.
  147313. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147314. * * 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.
  147315. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147316. * * 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
  147317. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147318. * * 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
  147319. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147320. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147321. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147322. * * 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
  147323. * * 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
  147324. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147327. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147329. * @param name defines the name of the mesh
  147330. * @param options defines the options used to create the mesh
  147331. * @param scene defines the hosting scene
  147332. * @returns the custom extruded shape mesh
  147333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147334. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147336. */
  147337. static ExtrudeShapeCustom(name: string, options: {
  147338. shape: Vector3[];
  147339. path: Vector3[];
  147340. scaleFunction?: any;
  147341. rotationFunction?: any;
  147342. ribbonCloseArray?: boolean;
  147343. ribbonClosePath?: boolean;
  147344. cap?: number;
  147345. updatable?: boolean;
  147346. sideOrientation?: number;
  147347. frontUVs?: Vector4;
  147348. backUVs?: Vector4;
  147349. instance?: Mesh;
  147350. invertUV?: boolean;
  147351. }, scene?: Nullable<Scene>): Mesh;
  147352. /**
  147353. * Creates lathe mesh.
  147354. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147355. * * 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
  147356. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147357. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147358. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147359. * * 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
  147360. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147361. * * 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
  147362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147366. * @param name defines the name of the mesh
  147367. * @param options defines the options used to create the mesh
  147368. * @param scene defines the hosting scene
  147369. * @returns the lathe mesh
  147370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147371. */
  147372. static CreateLathe(name: string, options: {
  147373. shape: Vector3[];
  147374. radius?: number;
  147375. tessellation?: number;
  147376. clip?: number;
  147377. arc?: number;
  147378. closed?: boolean;
  147379. updatable?: boolean;
  147380. sideOrientation?: number;
  147381. frontUVs?: Vector4;
  147382. backUVs?: Vector4;
  147383. cap?: number;
  147384. invertUV?: boolean;
  147385. }, scene?: Nullable<Scene>): Mesh;
  147386. /**
  147387. * Creates a tiled plane mesh
  147388. * * You can set a limited pattern arrangement with the tiles
  147389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147392. * @param name defines the name of the mesh
  147393. * @param options defines the options used to create the mesh
  147394. * @param scene defines the hosting scene
  147395. * @returns the plane mesh
  147396. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147397. */
  147398. static CreateTiledPlane(name: string, options: {
  147399. pattern?: number;
  147400. tileSize?: number;
  147401. tileWidth?: number;
  147402. tileHeight?: number;
  147403. size?: number;
  147404. width?: number;
  147405. height?: number;
  147406. alignHorizontal?: number;
  147407. alignVertical?: number;
  147408. sideOrientation?: number;
  147409. frontUVs?: Vector4;
  147410. backUVs?: Vector4;
  147411. updatable?: boolean;
  147412. }, scene?: Nullable<Scene>): Mesh;
  147413. /**
  147414. * Creates a plane mesh
  147415. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147416. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147417. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147421. * @param name defines the name of the mesh
  147422. * @param options defines the options used to create the mesh
  147423. * @param scene defines the hosting scene
  147424. * @returns the plane mesh
  147425. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147426. */
  147427. static CreatePlane(name: string, options: {
  147428. size?: number;
  147429. width?: number;
  147430. height?: number;
  147431. sideOrientation?: number;
  147432. frontUVs?: Vector4;
  147433. backUVs?: Vector4;
  147434. updatable?: boolean;
  147435. sourcePlane?: Plane;
  147436. }, scene?: Nullable<Scene>): Mesh;
  147437. /**
  147438. * Creates a ground mesh
  147439. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147440. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147442. * @param name defines the name of the mesh
  147443. * @param options defines the options used to create the mesh
  147444. * @param scene defines the hosting scene
  147445. * @returns the ground mesh
  147446. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147447. */
  147448. static CreateGround(name: string, options: {
  147449. width?: number;
  147450. height?: number;
  147451. subdivisions?: number;
  147452. subdivisionsX?: number;
  147453. subdivisionsY?: number;
  147454. updatable?: boolean;
  147455. }, scene?: Nullable<Scene>): Mesh;
  147456. /**
  147457. * Creates a tiled ground mesh
  147458. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147459. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147460. * * 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
  147461. * * 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
  147462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147463. * @param name defines the name of the mesh
  147464. * @param options defines the options used to create the mesh
  147465. * @param scene defines the hosting scene
  147466. * @returns the tiled ground mesh
  147467. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147468. */
  147469. static CreateTiledGround(name: string, options: {
  147470. xmin: number;
  147471. zmin: number;
  147472. xmax: number;
  147473. zmax: number;
  147474. subdivisions?: {
  147475. w: number;
  147476. h: number;
  147477. };
  147478. precision?: {
  147479. w: number;
  147480. h: number;
  147481. };
  147482. updatable?: boolean;
  147483. }, scene?: Nullable<Scene>): Mesh;
  147484. /**
  147485. * Creates a ground mesh from a height map
  147486. * * The parameter `url` sets the URL of the height map image resource.
  147487. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147488. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147489. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147490. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147491. * * 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.
  147492. * * 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).
  147493. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147495. * @param name defines the name of the mesh
  147496. * @param url defines the url to the height map
  147497. * @param options defines the options used to create the mesh
  147498. * @param scene defines the hosting scene
  147499. * @returns the ground mesh
  147500. * @see https://doc.babylonjs.com/babylon101/height_map
  147501. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147502. */
  147503. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147504. width?: number;
  147505. height?: number;
  147506. subdivisions?: number;
  147507. minHeight?: number;
  147508. maxHeight?: number;
  147509. colorFilter?: Color3;
  147510. alphaFilter?: number;
  147511. updatable?: boolean;
  147512. onReady?: (mesh: GroundMesh) => void;
  147513. }, scene?: Nullable<Scene>): GroundMesh;
  147514. /**
  147515. * Creates a polygon mesh
  147516. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147517. * * 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
  147518. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147521. * * Remember you can only change the shape positions, not their number when updating a polygon
  147522. * @param name defines the name of the mesh
  147523. * @param options defines the options used to create the mesh
  147524. * @param scene defines the hosting scene
  147525. * @param earcutInjection can be used to inject your own earcut reference
  147526. * @returns the polygon mesh
  147527. */
  147528. static CreatePolygon(name: string, options: {
  147529. shape: Vector3[];
  147530. holes?: Vector3[][];
  147531. depth?: number;
  147532. faceUV?: Vector4[];
  147533. faceColors?: Color4[];
  147534. updatable?: boolean;
  147535. sideOrientation?: number;
  147536. frontUVs?: Vector4;
  147537. backUVs?: Vector4;
  147538. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147539. /**
  147540. * Creates an extruded polygon mesh, with depth in the Y direction.
  147541. * * 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)
  147542. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147543. * @param name defines the name of the mesh
  147544. * @param options defines the options used to create the mesh
  147545. * @param scene defines the hosting scene
  147546. * @param earcutInjection can be used to inject your own earcut reference
  147547. * @returns the polygon mesh
  147548. */
  147549. static ExtrudePolygon(name: string, options: {
  147550. shape: Vector3[];
  147551. holes?: Vector3[][];
  147552. depth?: number;
  147553. faceUV?: Vector4[];
  147554. faceColors?: Color4[];
  147555. updatable?: boolean;
  147556. sideOrientation?: number;
  147557. frontUVs?: Vector4;
  147558. backUVs?: Vector4;
  147559. wrap?: boolean;
  147560. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147561. /**
  147562. * Creates a tube mesh.
  147563. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147564. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147565. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147566. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147567. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147568. * * 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)
  147569. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147570. * * 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
  147571. * * 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
  147572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147574. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147576. * @param name defines the name of the mesh
  147577. * @param options defines the options used to create the mesh
  147578. * @param scene defines the hosting scene
  147579. * @returns the tube mesh
  147580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147581. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147582. */
  147583. static CreateTube(name: string, options: {
  147584. path: Vector3[];
  147585. radius?: number;
  147586. tessellation?: number;
  147587. radiusFunction?: {
  147588. (i: number, distance: number): number;
  147589. };
  147590. cap?: number;
  147591. arc?: number;
  147592. updatable?: boolean;
  147593. sideOrientation?: number;
  147594. frontUVs?: Vector4;
  147595. backUVs?: Vector4;
  147596. instance?: Mesh;
  147597. invertUV?: boolean;
  147598. }, scene?: Nullable<Scene>): Mesh;
  147599. /**
  147600. * Creates a polyhedron mesh
  147601. * * 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
  147602. * * The parameter `size` (positive float, default 1) sets the polygon size
  147603. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147604. * * 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`
  147605. * * 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
  147606. * * 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)`)
  147607. * * 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
  147608. * * 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
  147609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147612. * @param name defines the name of the mesh
  147613. * @param options defines the options used to create the mesh
  147614. * @param scene defines the hosting scene
  147615. * @returns the polyhedron mesh
  147616. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147617. */
  147618. static CreatePolyhedron(name: string, options: {
  147619. type?: number;
  147620. size?: number;
  147621. sizeX?: number;
  147622. sizeY?: number;
  147623. sizeZ?: number;
  147624. custom?: any;
  147625. faceUV?: Vector4[];
  147626. faceColors?: Color4[];
  147627. flat?: boolean;
  147628. updatable?: boolean;
  147629. sideOrientation?: number;
  147630. frontUVs?: Vector4;
  147631. backUVs?: Vector4;
  147632. }, scene?: Nullable<Scene>): Mesh;
  147633. /**
  147634. * Creates a decal mesh.
  147635. * 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
  147636. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147637. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147638. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147639. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147640. * @param name defines the name of the mesh
  147641. * @param sourceMesh defines the mesh where the decal must be applied
  147642. * @param options defines the options used to create the mesh
  147643. * @param scene defines the hosting scene
  147644. * @returns the decal mesh
  147645. * @see https://doc.babylonjs.com/how_to/decals
  147646. */
  147647. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147648. position?: Vector3;
  147649. normal?: Vector3;
  147650. size?: Vector3;
  147651. angle?: number;
  147652. }): Mesh;
  147653. /**
  147654. * Creates a Capsule Mesh
  147655. * @param name defines the name of the mesh.
  147656. * @param options the constructors options used to shape the mesh.
  147657. * @param scene defines the scene the mesh is scoped to.
  147658. * @returns the capsule mesh
  147659. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147660. */
  147661. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147662. }
  147663. }
  147664. declare module BABYLON {
  147665. /**
  147666. * A simplifier interface for future simplification implementations
  147667. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147668. */
  147669. export interface ISimplifier {
  147670. /**
  147671. * Simplification of a given mesh according to the given settings.
  147672. * Since this requires computation, it is assumed that the function runs async.
  147673. * @param settings The settings of the simplification, including quality and distance
  147674. * @param successCallback A callback that will be called after the mesh was simplified.
  147675. * @param errorCallback in case of an error, this callback will be called. optional.
  147676. */
  147677. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147678. }
  147679. /**
  147680. * Expected simplification settings.
  147681. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147682. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147683. */
  147684. export interface ISimplificationSettings {
  147685. /**
  147686. * Gets or sets the expected quality
  147687. */
  147688. quality: number;
  147689. /**
  147690. * Gets or sets the distance when this optimized version should be used
  147691. */
  147692. distance: number;
  147693. /**
  147694. * Gets an already optimized mesh
  147695. */
  147696. optimizeMesh?: boolean;
  147697. }
  147698. /**
  147699. * Class used to specify simplification options
  147700. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147701. */
  147702. export class SimplificationSettings implements ISimplificationSettings {
  147703. /** expected quality */
  147704. quality: number;
  147705. /** distance when this optimized version should be used */
  147706. distance: number;
  147707. /** already optimized mesh */
  147708. optimizeMesh?: boolean | undefined;
  147709. /**
  147710. * Creates a SimplificationSettings
  147711. * @param quality expected quality
  147712. * @param distance distance when this optimized version should be used
  147713. * @param optimizeMesh already optimized mesh
  147714. */
  147715. constructor(
  147716. /** expected quality */
  147717. quality: number,
  147718. /** distance when this optimized version should be used */
  147719. distance: number,
  147720. /** already optimized mesh */
  147721. optimizeMesh?: boolean | undefined);
  147722. }
  147723. /**
  147724. * Interface used to define a simplification task
  147725. */
  147726. export interface ISimplificationTask {
  147727. /**
  147728. * Array of settings
  147729. */
  147730. settings: Array<ISimplificationSettings>;
  147731. /**
  147732. * Simplification type
  147733. */
  147734. simplificationType: SimplificationType;
  147735. /**
  147736. * Mesh to simplify
  147737. */
  147738. mesh: Mesh;
  147739. /**
  147740. * Callback called on success
  147741. */
  147742. successCallback?: () => void;
  147743. /**
  147744. * Defines if parallel processing can be used
  147745. */
  147746. parallelProcessing: boolean;
  147747. }
  147748. /**
  147749. * Queue used to order the simplification tasks
  147750. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147751. */
  147752. export class SimplificationQueue {
  147753. private _simplificationArray;
  147754. /**
  147755. * Gets a boolean indicating that the process is still running
  147756. */
  147757. running: boolean;
  147758. /**
  147759. * Creates a new queue
  147760. */
  147761. constructor();
  147762. /**
  147763. * Adds a new simplification task
  147764. * @param task defines a task to add
  147765. */
  147766. addTask(task: ISimplificationTask): void;
  147767. /**
  147768. * Execute next task
  147769. */
  147770. executeNext(): void;
  147771. /**
  147772. * Execute a simplification task
  147773. * @param task defines the task to run
  147774. */
  147775. runSimplification(task: ISimplificationTask): void;
  147776. private getSimplifier;
  147777. }
  147778. /**
  147779. * The implemented types of simplification
  147780. * At the moment only Quadratic Error Decimation is implemented
  147781. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147782. */
  147783. export enum SimplificationType {
  147784. /** Quadratic error decimation */
  147785. QUADRATIC = 0
  147786. }
  147787. /**
  147788. * An implementation of the Quadratic Error simplification algorithm.
  147789. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147790. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147791. * @author RaananW
  147792. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147793. */
  147794. export class QuadraticErrorSimplification implements ISimplifier {
  147795. private _mesh;
  147796. private triangles;
  147797. private vertices;
  147798. private references;
  147799. private _reconstructedMesh;
  147800. /** Gets or sets the number pf sync interations */
  147801. syncIterations: number;
  147802. /** Gets or sets the aggressiveness of the simplifier */
  147803. aggressiveness: number;
  147804. /** Gets or sets the number of allowed iterations for decimation */
  147805. decimationIterations: number;
  147806. /** Gets or sets the espilon to use for bounding box computation */
  147807. boundingBoxEpsilon: number;
  147808. /**
  147809. * Creates a new QuadraticErrorSimplification
  147810. * @param _mesh defines the target mesh
  147811. */
  147812. constructor(_mesh: Mesh);
  147813. /**
  147814. * Simplification of a given mesh according to the given settings.
  147815. * Since this requires computation, it is assumed that the function runs async.
  147816. * @param settings The settings of the simplification, including quality and distance
  147817. * @param successCallback A callback that will be called after the mesh was simplified.
  147818. */
  147819. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147820. private runDecimation;
  147821. private initWithMesh;
  147822. private init;
  147823. private reconstructMesh;
  147824. private initDecimatedMesh;
  147825. private isFlipped;
  147826. private updateTriangles;
  147827. private identifyBorder;
  147828. private updateMesh;
  147829. private vertexError;
  147830. private calculateError;
  147831. }
  147832. }
  147833. declare module BABYLON {
  147834. interface Scene {
  147835. /** @hidden (Backing field) */
  147836. _simplificationQueue: SimplificationQueue;
  147837. /**
  147838. * Gets or sets the simplification queue attached to the scene
  147839. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147840. */
  147841. simplificationQueue: SimplificationQueue;
  147842. }
  147843. interface Mesh {
  147844. /**
  147845. * Simplify the mesh according to the given array of settings.
  147846. * Function will return immediately and will simplify async
  147847. * @param settings a collection of simplification settings
  147848. * @param parallelProcessing should all levels calculate parallel or one after the other
  147849. * @param simplificationType the type of simplification to run
  147850. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147851. * @returns the current mesh
  147852. */
  147853. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147854. }
  147855. /**
  147856. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147857. * created in a scene
  147858. */
  147859. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147860. /**
  147861. * The component name helpfull to identify the component in the list of scene components.
  147862. */
  147863. readonly name: string;
  147864. /**
  147865. * The scene the component belongs to.
  147866. */
  147867. scene: Scene;
  147868. /**
  147869. * Creates a new instance of the component for the given scene
  147870. * @param scene Defines the scene to register the component in
  147871. */
  147872. constructor(scene: Scene);
  147873. /**
  147874. * Registers the component in a given scene
  147875. */
  147876. register(): void;
  147877. /**
  147878. * Rebuilds the elements related to this component in case of
  147879. * context lost for instance.
  147880. */
  147881. rebuild(): void;
  147882. /**
  147883. * Disposes the component and the associated ressources
  147884. */
  147885. dispose(): void;
  147886. private _beforeCameraUpdate;
  147887. }
  147888. }
  147889. declare module BABYLON {
  147890. interface Mesh {
  147891. /**
  147892. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147893. */
  147894. thinInstanceEnablePicking: boolean;
  147895. /**
  147896. * Creates a new thin instance
  147897. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147898. * @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
  147899. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147900. */
  147901. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147902. /**
  147903. * Adds the transformation (matrix) of the current mesh as a thin instance
  147904. * @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
  147905. * @returns the thin instance index number
  147906. */
  147907. thinInstanceAddSelf(refresh: boolean): number;
  147908. /**
  147909. * Registers a custom attribute to be used with thin instances
  147910. * @param kind name of the attribute
  147911. * @param stride size in floats of the attribute
  147912. */
  147913. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147914. /**
  147915. * Sets the matrix of a thin instance
  147916. * @param index index of the thin instance
  147917. * @param matrix matrix to set
  147918. * @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
  147919. */
  147920. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147921. /**
  147922. * Sets the value of a custom attribute for a thin instance
  147923. * @param kind name of the attribute
  147924. * @param index index of the thin instance
  147925. * @param value value to set
  147926. * @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
  147927. */
  147928. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147929. /**
  147930. * 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.
  147931. */
  147932. thinInstanceCount: number;
  147933. /**
  147934. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147935. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147936. * @param buffer buffer to set
  147937. * @param stride size in floats of each value of the buffer
  147938. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147939. */
  147940. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147941. /**
  147942. * Gets the list of world matrices
  147943. * @return an array containing all the world matrices from the thin instances
  147944. */
  147945. thinInstanceGetWorldMatrices(): Matrix[];
  147946. /**
  147947. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147948. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147949. */
  147950. thinInstanceBufferUpdated(kind: string): void;
  147951. /**
  147952. * Applies a partial update to a buffer directly on the GPU
  147953. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  147954. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147955. * @param data the data to set in the GPU buffer
  147956. * @param offset the offset in the GPU buffer where to update the data
  147957. */
  147958. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147959. /**
  147960. * Refreshes the bounding info, taking into account all the thin instances defined
  147961. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147962. */
  147963. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147964. /** @hidden */
  147965. _thinInstanceInitializeUserStorage(): void;
  147966. /** @hidden */
  147967. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147968. /** @hidden */
  147969. _userThinInstanceBuffersStorage: {
  147970. data: {
  147971. [key: string]: Float32Array;
  147972. };
  147973. sizes: {
  147974. [key: string]: number;
  147975. };
  147976. vertexBuffers: {
  147977. [key: string]: Nullable<VertexBuffer>;
  147978. };
  147979. strides: {
  147980. [key: string]: number;
  147981. };
  147982. };
  147983. }
  147984. }
  147985. declare module BABYLON {
  147986. /**
  147987. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147988. */
  147989. export interface INavigationEnginePlugin {
  147990. /**
  147991. * plugin name
  147992. */
  147993. name: string;
  147994. /**
  147995. * Creates a navigation mesh
  147996. * @param meshes array of all the geometry used to compute the navigatio mesh
  147997. * @param parameters bunch of parameters used to filter geometry
  147998. */
  147999. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148000. /**
  148001. * Create a navigation mesh debug mesh
  148002. * @param scene is where the mesh will be added
  148003. * @returns debug display mesh
  148004. */
  148005. createDebugNavMesh(scene: Scene): Mesh;
  148006. /**
  148007. * Get a navigation mesh constrained position, closest to the parameter position
  148008. * @param position world position
  148009. * @returns the closest point to position constrained by the navigation mesh
  148010. */
  148011. getClosestPoint(position: Vector3): Vector3;
  148012. /**
  148013. * Get a navigation mesh constrained position, closest to the parameter position
  148014. * @param position world position
  148015. * @param result output the closest point to position constrained by the navigation mesh
  148016. */
  148017. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148018. /**
  148019. * Get a navigation mesh constrained position, within a particular radius
  148020. * @param position world position
  148021. * @param maxRadius the maximum distance to the constrained world position
  148022. * @returns the closest point to position constrained by the navigation mesh
  148023. */
  148024. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148025. /**
  148026. * Get a navigation mesh constrained position, within a particular radius
  148027. * @param position world position
  148028. * @param maxRadius the maximum distance to the constrained world position
  148029. * @param result output the closest point to position constrained by the navigation mesh
  148030. */
  148031. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148032. /**
  148033. * Compute the final position from a segment made of destination-position
  148034. * @param position world position
  148035. * @param destination world position
  148036. * @returns the resulting point along the navmesh
  148037. */
  148038. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148039. /**
  148040. * Compute the final position from a segment made of destination-position
  148041. * @param position world position
  148042. * @param destination world position
  148043. * @param result output the resulting point along the navmesh
  148044. */
  148045. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148046. /**
  148047. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148048. * @param start world position
  148049. * @param end world position
  148050. * @returns array containing world position composing the path
  148051. */
  148052. computePath(start: Vector3, end: Vector3): Vector3[];
  148053. /**
  148054. * If this plugin is supported
  148055. * @returns true if plugin is supported
  148056. */
  148057. isSupported(): boolean;
  148058. /**
  148059. * Create a new Crowd so you can add agents
  148060. * @param maxAgents the maximum agent count in the crowd
  148061. * @param maxAgentRadius the maximum radius an agent can have
  148062. * @param scene to attach the crowd to
  148063. * @returns the crowd you can add agents to
  148064. */
  148065. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148066. /**
  148067. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148068. * The queries will try to find a solution within those bounds
  148069. * default is (1,1,1)
  148070. * @param extent x,y,z value that define the extent around the queries point of reference
  148071. */
  148072. setDefaultQueryExtent(extent: Vector3): void;
  148073. /**
  148074. * Get the Bounding box extent specified by setDefaultQueryExtent
  148075. * @returns the box extent values
  148076. */
  148077. getDefaultQueryExtent(): Vector3;
  148078. /**
  148079. * build the navmesh from a previously saved state using getNavmeshData
  148080. * @param data the Uint8Array returned by getNavmeshData
  148081. */
  148082. buildFromNavmeshData(data: Uint8Array): void;
  148083. /**
  148084. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148085. * @returns data the Uint8Array that can be saved and reused
  148086. */
  148087. getNavmeshData(): Uint8Array;
  148088. /**
  148089. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148090. * @param result output the box extent values
  148091. */
  148092. getDefaultQueryExtentToRef(result: Vector3): void;
  148093. /**
  148094. * Release all resources
  148095. */
  148096. dispose(): void;
  148097. }
  148098. /**
  148099. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148100. */
  148101. export interface ICrowd {
  148102. /**
  148103. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148104. * You can attach anything to that node. The node position is updated in the scene update tick.
  148105. * @param pos world position that will be constrained by the navigation mesh
  148106. * @param parameters agent parameters
  148107. * @param transform hooked to the agent that will be update by the scene
  148108. * @returns agent index
  148109. */
  148110. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148111. /**
  148112. * Returns the agent position in world space
  148113. * @param index agent index returned by addAgent
  148114. * @returns world space position
  148115. */
  148116. getAgentPosition(index: number): Vector3;
  148117. /**
  148118. * Gets the agent position result in world space
  148119. * @param index agent index returned by addAgent
  148120. * @param result output world space position
  148121. */
  148122. getAgentPositionToRef(index: number, result: Vector3): void;
  148123. /**
  148124. * Gets the agent velocity in world space
  148125. * @param index agent index returned by addAgent
  148126. * @returns world space velocity
  148127. */
  148128. getAgentVelocity(index: number): Vector3;
  148129. /**
  148130. * Gets the agent velocity result in world space
  148131. * @param index agent index returned by addAgent
  148132. * @param result output world space velocity
  148133. */
  148134. getAgentVelocityToRef(index: number, result: Vector3): void;
  148135. /**
  148136. * remove a particular agent previously created
  148137. * @param index agent index returned by addAgent
  148138. */
  148139. removeAgent(index: number): void;
  148140. /**
  148141. * get the list of all agents attached to this crowd
  148142. * @returns list of agent indices
  148143. */
  148144. getAgents(): number[];
  148145. /**
  148146. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148147. * @param deltaTime in seconds
  148148. */
  148149. update(deltaTime: number): void;
  148150. /**
  148151. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148152. * @param index agent index returned by addAgent
  148153. * @param destination targeted world position
  148154. */
  148155. agentGoto(index: number, destination: Vector3): void;
  148156. /**
  148157. * Teleport the agent to a new position
  148158. * @param index agent index returned by addAgent
  148159. * @param destination targeted world position
  148160. */
  148161. agentTeleport(index: number, destination: Vector3): void;
  148162. /**
  148163. * Update agent parameters
  148164. * @param index agent index returned by addAgent
  148165. * @param parameters agent parameters
  148166. */
  148167. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148168. /**
  148169. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148170. * The queries will try to find a solution within those bounds
  148171. * default is (1,1,1)
  148172. * @param extent x,y,z value that define the extent around the queries point of reference
  148173. */
  148174. setDefaultQueryExtent(extent: Vector3): void;
  148175. /**
  148176. * Get the Bounding box extent specified by setDefaultQueryExtent
  148177. * @returns the box extent values
  148178. */
  148179. getDefaultQueryExtent(): Vector3;
  148180. /**
  148181. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148182. * @param result output the box extent values
  148183. */
  148184. getDefaultQueryExtentToRef(result: Vector3): void;
  148185. /**
  148186. * Release all resources
  148187. */
  148188. dispose(): void;
  148189. }
  148190. /**
  148191. * Configures an agent
  148192. */
  148193. export interface IAgentParameters {
  148194. /**
  148195. * Agent radius. [Limit: >= 0]
  148196. */
  148197. radius: number;
  148198. /**
  148199. * Agent height. [Limit: > 0]
  148200. */
  148201. height: number;
  148202. /**
  148203. * Maximum allowed acceleration. [Limit: >= 0]
  148204. */
  148205. maxAcceleration: number;
  148206. /**
  148207. * Maximum allowed speed. [Limit: >= 0]
  148208. */
  148209. maxSpeed: number;
  148210. /**
  148211. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148212. */
  148213. collisionQueryRange: number;
  148214. /**
  148215. * The path visibility optimization range. [Limit: > 0]
  148216. */
  148217. pathOptimizationRange: number;
  148218. /**
  148219. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148220. */
  148221. separationWeight: number;
  148222. }
  148223. /**
  148224. * Configures the navigation mesh creation
  148225. */
  148226. export interface INavMeshParameters {
  148227. /**
  148228. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148229. */
  148230. cs: number;
  148231. /**
  148232. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148233. */
  148234. ch: number;
  148235. /**
  148236. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148237. */
  148238. walkableSlopeAngle: number;
  148239. /**
  148240. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148241. * be considered walkable. [Limit: >= 3] [Units: vx]
  148242. */
  148243. walkableHeight: number;
  148244. /**
  148245. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148246. */
  148247. walkableClimb: number;
  148248. /**
  148249. * The distance to erode/shrink the walkable area of the heightfield away from
  148250. * obstructions. [Limit: >=0] [Units: vx]
  148251. */
  148252. walkableRadius: number;
  148253. /**
  148254. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148255. */
  148256. maxEdgeLen: number;
  148257. /**
  148258. * The maximum distance a simplfied contour's border edges should deviate
  148259. * the original raw contour. [Limit: >=0] [Units: vx]
  148260. */
  148261. maxSimplificationError: number;
  148262. /**
  148263. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148264. */
  148265. minRegionArea: number;
  148266. /**
  148267. * Any regions with a span count smaller than this value will, if possible,
  148268. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148269. */
  148270. mergeRegionArea: number;
  148271. /**
  148272. * The maximum number of vertices allowed for polygons generated during the
  148273. * contour to polygon conversion process. [Limit: >= 3]
  148274. */
  148275. maxVertsPerPoly: number;
  148276. /**
  148277. * Sets the sampling distance to use when generating the detail mesh.
  148278. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148279. */
  148280. detailSampleDist: number;
  148281. /**
  148282. * The maximum distance the detail mesh surface should deviate from heightfield
  148283. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148284. */
  148285. detailSampleMaxError: number;
  148286. }
  148287. }
  148288. declare module BABYLON {
  148289. /**
  148290. * RecastJS navigation plugin
  148291. */
  148292. export class RecastJSPlugin implements INavigationEnginePlugin {
  148293. /**
  148294. * Reference to the Recast library
  148295. */
  148296. bjsRECAST: any;
  148297. /**
  148298. * plugin name
  148299. */
  148300. name: string;
  148301. /**
  148302. * the first navmesh created. We might extend this to support multiple navmeshes
  148303. */
  148304. navMesh: any;
  148305. /**
  148306. * Initializes the recastJS plugin
  148307. * @param recastInjection can be used to inject your own recast reference
  148308. */
  148309. constructor(recastInjection?: any);
  148310. /**
  148311. * Creates a navigation mesh
  148312. * @param meshes array of all the geometry used to compute the navigatio mesh
  148313. * @param parameters bunch of parameters used to filter geometry
  148314. */
  148315. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148316. /**
  148317. * Create a navigation mesh debug mesh
  148318. * @param scene is where the mesh will be added
  148319. * @returns debug display mesh
  148320. */
  148321. createDebugNavMesh(scene: Scene): Mesh;
  148322. /**
  148323. * Get a navigation mesh constrained position, closest to the parameter position
  148324. * @param position world position
  148325. * @returns the closest point to position constrained by the navigation mesh
  148326. */
  148327. getClosestPoint(position: Vector3): Vector3;
  148328. /**
  148329. * Get a navigation mesh constrained position, closest to the parameter position
  148330. * @param position world position
  148331. * @param result output the closest point to position constrained by the navigation mesh
  148332. */
  148333. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148334. /**
  148335. * Get a navigation mesh constrained position, within a particular radius
  148336. * @param position world position
  148337. * @param maxRadius the maximum distance to the constrained world position
  148338. * @returns the closest point to position constrained by the navigation mesh
  148339. */
  148340. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148341. /**
  148342. * Get a navigation mesh constrained position, within a particular radius
  148343. * @param position world position
  148344. * @param maxRadius the maximum distance to the constrained world position
  148345. * @param result output the closest point to position constrained by the navigation mesh
  148346. */
  148347. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148348. /**
  148349. * Compute the final position from a segment made of destination-position
  148350. * @param position world position
  148351. * @param destination world position
  148352. * @returns the resulting point along the navmesh
  148353. */
  148354. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148355. /**
  148356. * Compute the final position from a segment made of destination-position
  148357. * @param position world position
  148358. * @param destination world position
  148359. * @param result output the resulting point along the navmesh
  148360. */
  148361. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148362. /**
  148363. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148364. * @param start world position
  148365. * @param end world position
  148366. * @returns array containing world position composing the path
  148367. */
  148368. computePath(start: Vector3, end: Vector3): Vector3[];
  148369. /**
  148370. * Create a new Crowd so you can add agents
  148371. * @param maxAgents the maximum agent count in the crowd
  148372. * @param maxAgentRadius the maximum radius an agent can have
  148373. * @param scene to attach the crowd to
  148374. * @returns the crowd you can add agents to
  148375. */
  148376. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148377. /**
  148378. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148379. * The queries will try to find a solution within those bounds
  148380. * default is (1,1,1)
  148381. * @param extent x,y,z value that define the extent around the queries point of reference
  148382. */
  148383. setDefaultQueryExtent(extent: Vector3): void;
  148384. /**
  148385. * Get the Bounding box extent specified by setDefaultQueryExtent
  148386. * @returns the box extent values
  148387. */
  148388. getDefaultQueryExtent(): Vector3;
  148389. /**
  148390. * build the navmesh from a previously saved state using getNavmeshData
  148391. * @param data the Uint8Array returned by getNavmeshData
  148392. */
  148393. buildFromNavmeshData(data: Uint8Array): void;
  148394. /**
  148395. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148396. * @returns data the Uint8Array that can be saved and reused
  148397. */
  148398. getNavmeshData(): Uint8Array;
  148399. /**
  148400. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148401. * @param result output the box extent values
  148402. */
  148403. getDefaultQueryExtentToRef(result: Vector3): void;
  148404. /**
  148405. * Disposes
  148406. */
  148407. dispose(): void;
  148408. /**
  148409. * If this plugin is supported
  148410. * @returns true if plugin is supported
  148411. */
  148412. isSupported(): boolean;
  148413. }
  148414. /**
  148415. * Recast detour crowd implementation
  148416. */
  148417. export class RecastJSCrowd implements ICrowd {
  148418. /**
  148419. * Recast/detour plugin
  148420. */
  148421. bjsRECASTPlugin: RecastJSPlugin;
  148422. /**
  148423. * Link to the detour crowd
  148424. */
  148425. recastCrowd: any;
  148426. /**
  148427. * One transform per agent
  148428. */
  148429. transforms: TransformNode[];
  148430. /**
  148431. * All agents created
  148432. */
  148433. agents: number[];
  148434. /**
  148435. * Link to the scene is kept to unregister the crowd from the scene
  148436. */
  148437. private _scene;
  148438. /**
  148439. * Observer for crowd updates
  148440. */
  148441. private _onBeforeAnimationsObserver;
  148442. /**
  148443. * Constructor
  148444. * @param plugin recastJS plugin
  148445. * @param maxAgents the maximum agent count in the crowd
  148446. * @param maxAgentRadius the maximum radius an agent can have
  148447. * @param scene to attach the crowd to
  148448. * @returns the crowd you can add agents to
  148449. */
  148450. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148451. /**
  148452. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148453. * You can attach anything to that node. The node position is updated in the scene update tick.
  148454. * @param pos world position that will be constrained by the navigation mesh
  148455. * @param parameters agent parameters
  148456. * @param transform hooked to the agent that will be update by the scene
  148457. * @returns agent index
  148458. */
  148459. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148460. /**
  148461. * Returns the agent position in world space
  148462. * @param index agent index returned by addAgent
  148463. * @returns world space position
  148464. */
  148465. getAgentPosition(index: number): Vector3;
  148466. /**
  148467. * Returns the agent position result in world space
  148468. * @param index agent index returned by addAgent
  148469. * @param result output world space position
  148470. */
  148471. getAgentPositionToRef(index: number, result: Vector3): void;
  148472. /**
  148473. * Returns the agent velocity in world space
  148474. * @param index agent index returned by addAgent
  148475. * @returns world space velocity
  148476. */
  148477. getAgentVelocity(index: number): Vector3;
  148478. /**
  148479. * Returns the agent velocity result in world space
  148480. * @param index agent index returned by addAgent
  148481. * @param result output world space velocity
  148482. */
  148483. getAgentVelocityToRef(index: number, result: Vector3): void;
  148484. /**
  148485. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148486. * @param index agent index returned by addAgent
  148487. * @param destination targeted world position
  148488. */
  148489. agentGoto(index: number, destination: Vector3): void;
  148490. /**
  148491. * Teleport the agent to a new position
  148492. * @param index agent index returned by addAgent
  148493. * @param destination targeted world position
  148494. */
  148495. agentTeleport(index: number, destination: Vector3): void;
  148496. /**
  148497. * Update agent parameters
  148498. * @param index agent index returned by addAgent
  148499. * @param parameters agent parameters
  148500. */
  148501. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148502. /**
  148503. * remove a particular agent previously created
  148504. * @param index agent index returned by addAgent
  148505. */
  148506. removeAgent(index: number): void;
  148507. /**
  148508. * get the list of all agents attached to this crowd
  148509. * @returns list of agent indices
  148510. */
  148511. getAgents(): number[];
  148512. /**
  148513. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148514. * @param deltaTime in seconds
  148515. */
  148516. update(deltaTime: number): void;
  148517. /**
  148518. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148519. * The queries will try to find a solution within those bounds
  148520. * default is (1,1,1)
  148521. * @param extent x,y,z value that define the extent around the queries point of reference
  148522. */
  148523. setDefaultQueryExtent(extent: Vector3): void;
  148524. /**
  148525. * Get the Bounding box extent specified by setDefaultQueryExtent
  148526. * @returns the box extent values
  148527. */
  148528. getDefaultQueryExtent(): Vector3;
  148529. /**
  148530. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148531. * @param result output the box extent values
  148532. */
  148533. getDefaultQueryExtentToRef(result: Vector3): void;
  148534. /**
  148535. * Release all resources
  148536. */
  148537. dispose(): void;
  148538. }
  148539. }
  148540. declare module BABYLON {
  148541. /**
  148542. * Class used to enable access to IndexedDB
  148543. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148544. */
  148545. export class Database implements IOfflineProvider {
  148546. private _callbackManifestChecked;
  148547. private _currentSceneUrl;
  148548. private _db;
  148549. private _enableSceneOffline;
  148550. private _enableTexturesOffline;
  148551. private _manifestVersionFound;
  148552. private _mustUpdateRessources;
  148553. private _hasReachedQuota;
  148554. private _isSupported;
  148555. private _idbFactory;
  148556. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148557. private static IsUASupportingBlobStorage;
  148558. /**
  148559. * Gets a boolean indicating if Database storate is enabled (off by default)
  148560. */
  148561. static IDBStorageEnabled: boolean;
  148562. /**
  148563. * Gets a boolean indicating if scene must be saved in the database
  148564. */
  148565. get enableSceneOffline(): boolean;
  148566. /**
  148567. * Gets a boolean indicating if textures must be saved in the database
  148568. */
  148569. get enableTexturesOffline(): boolean;
  148570. /**
  148571. * Creates a new Database
  148572. * @param urlToScene defines the url to load the scene
  148573. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148574. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148575. */
  148576. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148577. private static _ParseURL;
  148578. private static _ReturnFullUrlLocation;
  148579. private _checkManifestFile;
  148580. /**
  148581. * Open the database and make it available
  148582. * @param successCallback defines the callback to call on success
  148583. * @param errorCallback defines the callback to call on error
  148584. */
  148585. open(successCallback: () => void, errorCallback: () => void): void;
  148586. /**
  148587. * Loads an image from the database
  148588. * @param url defines the url to load from
  148589. * @param image defines the target DOM image
  148590. */
  148591. loadImage(url: string, image: HTMLImageElement): void;
  148592. private _loadImageFromDBAsync;
  148593. private _saveImageIntoDBAsync;
  148594. private _checkVersionFromDB;
  148595. private _loadVersionFromDBAsync;
  148596. private _saveVersionIntoDBAsync;
  148597. /**
  148598. * Loads a file from database
  148599. * @param url defines the URL to load from
  148600. * @param sceneLoaded defines a callback to call on success
  148601. * @param progressCallBack defines a callback to call when progress changed
  148602. * @param errorCallback defines a callback to call on error
  148603. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148604. */
  148605. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148606. private _loadFileAsync;
  148607. private _saveFileAsync;
  148608. /**
  148609. * Validates if xhr data is correct
  148610. * @param xhr defines the request to validate
  148611. * @param dataType defines the expected data type
  148612. * @returns true if data is correct
  148613. */
  148614. private static _ValidateXHRData;
  148615. }
  148616. }
  148617. declare module BABYLON {
  148618. /** @hidden */
  148619. export var gpuUpdateParticlesPixelShader: {
  148620. name: string;
  148621. shader: string;
  148622. };
  148623. }
  148624. declare module BABYLON {
  148625. /** @hidden */
  148626. export var gpuUpdateParticlesVertexShader: {
  148627. name: string;
  148628. shader: string;
  148629. };
  148630. }
  148631. declare module BABYLON {
  148632. /** @hidden */
  148633. export var clipPlaneFragmentDeclaration2: {
  148634. name: string;
  148635. shader: string;
  148636. };
  148637. }
  148638. declare module BABYLON {
  148639. /** @hidden */
  148640. export var gpuRenderParticlesPixelShader: {
  148641. name: string;
  148642. shader: string;
  148643. };
  148644. }
  148645. declare module BABYLON {
  148646. /** @hidden */
  148647. export var clipPlaneVertexDeclaration2: {
  148648. name: string;
  148649. shader: string;
  148650. };
  148651. }
  148652. declare module BABYLON {
  148653. /** @hidden */
  148654. export var gpuRenderParticlesVertexShader: {
  148655. name: string;
  148656. shader: string;
  148657. };
  148658. }
  148659. declare module BABYLON {
  148660. /**
  148661. * This represents a GPU particle system in Babylon
  148662. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148663. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148664. */
  148665. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148666. /**
  148667. * The layer mask we are rendering the particles through.
  148668. */
  148669. layerMask: number;
  148670. private _capacity;
  148671. private _activeCount;
  148672. private _currentActiveCount;
  148673. private _accumulatedCount;
  148674. private _renderEffect;
  148675. private _updateEffect;
  148676. private _buffer0;
  148677. private _buffer1;
  148678. private _spriteBuffer;
  148679. private _updateVAO;
  148680. private _renderVAO;
  148681. private _targetIndex;
  148682. private _sourceBuffer;
  148683. private _targetBuffer;
  148684. private _currentRenderId;
  148685. private _started;
  148686. private _stopped;
  148687. private _timeDelta;
  148688. private _randomTexture;
  148689. private _randomTexture2;
  148690. private _attributesStrideSize;
  148691. private _updateEffectOptions;
  148692. private _randomTextureSize;
  148693. private _actualFrame;
  148694. private _customEffect;
  148695. private readonly _rawTextureWidth;
  148696. /**
  148697. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148698. */
  148699. static get IsSupported(): boolean;
  148700. /**
  148701. * An event triggered when the system is disposed.
  148702. */
  148703. onDisposeObservable: Observable<IParticleSystem>;
  148704. /**
  148705. * An event triggered when the system is stopped
  148706. */
  148707. onStoppedObservable: Observable<IParticleSystem>;
  148708. /**
  148709. * Gets the maximum number of particles active at the same time.
  148710. * @returns The max number of active particles.
  148711. */
  148712. getCapacity(): number;
  148713. /**
  148714. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148715. * to override the particles.
  148716. */
  148717. forceDepthWrite: boolean;
  148718. /**
  148719. * Gets or set the number of active particles
  148720. */
  148721. get activeParticleCount(): number;
  148722. set activeParticleCount(value: number);
  148723. private _preWarmDone;
  148724. /**
  148725. * Specifies if the particles are updated in emitter local space or world space.
  148726. */
  148727. isLocal: boolean;
  148728. /** Gets or sets a matrix to use to compute projection */
  148729. defaultProjectionMatrix: Matrix;
  148730. /**
  148731. * Is this system ready to be used/rendered
  148732. * @return true if the system is ready
  148733. */
  148734. isReady(): boolean;
  148735. /**
  148736. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148737. * @returns True if it has been started, otherwise false.
  148738. */
  148739. isStarted(): boolean;
  148740. /**
  148741. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148742. * @returns True if it has been stopped, otherwise false.
  148743. */
  148744. isStopped(): boolean;
  148745. /**
  148746. * Gets a boolean indicating that the system is stopping
  148747. * @returns true if the system is currently stopping
  148748. */
  148749. isStopping(): boolean;
  148750. /**
  148751. * Gets the number of particles active at the same time.
  148752. * @returns The number of active particles.
  148753. */
  148754. getActiveCount(): number;
  148755. /**
  148756. * Starts the particle system and begins to emit
  148757. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148758. */
  148759. start(delay?: number): void;
  148760. /**
  148761. * Stops the particle system.
  148762. */
  148763. stop(): void;
  148764. /**
  148765. * Remove all active particles
  148766. */
  148767. reset(): void;
  148768. /**
  148769. * Returns the string "GPUParticleSystem"
  148770. * @returns a string containing the class name
  148771. */
  148772. getClassName(): string;
  148773. /**
  148774. * Gets the custom effect used to render the particles
  148775. * @param blendMode Blend mode for which the effect should be retrieved
  148776. * @returns The effect
  148777. */
  148778. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148779. /**
  148780. * Sets the custom effect used to render the particles
  148781. * @param effect The effect to set
  148782. * @param blendMode Blend mode for which the effect should be set
  148783. */
  148784. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148785. /** @hidden */
  148786. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148787. /**
  148788. * Observable that will be called just before the particles are drawn
  148789. */
  148790. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148791. /**
  148792. * Gets the name of the particle vertex shader
  148793. */
  148794. get vertexShaderName(): string;
  148795. private _colorGradientsTexture;
  148796. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148797. /**
  148798. * Adds a new color gradient
  148799. * @param gradient defines the gradient to use (between 0 and 1)
  148800. * @param color1 defines the color to affect to the specified gradient
  148801. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148802. * @returns the current particle system
  148803. */
  148804. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148805. private _refreshColorGradient;
  148806. /** Force the system to rebuild all gradients that need to be resync */
  148807. forceRefreshGradients(): void;
  148808. /**
  148809. * Remove a specific color gradient
  148810. * @param gradient defines the gradient to remove
  148811. * @returns the current particle system
  148812. */
  148813. removeColorGradient(gradient: number): GPUParticleSystem;
  148814. private _angularSpeedGradientsTexture;
  148815. private _sizeGradientsTexture;
  148816. private _velocityGradientsTexture;
  148817. private _limitVelocityGradientsTexture;
  148818. private _dragGradientsTexture;
  148819. private _addFactorGradient;
  148820. /**
  148821. * Adds a new size gradient
  148822. * @param gradient defines the gradient to use (between 0 and 1)
  148823. * @param factor defines the size factor to affect to the specified gradient
  148824. * @returns the current particle system
  148825. */
  148826. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148827. /**
  148828. * Remove a specific size gradient
  148829. * @param gradient defines the gradient to remove
  148830. * @returns the current particle system
  148831. */
  148832. removeSizeGradient(gradient: number): GPUParticleSystem;
  148833. private _refreshFactorGradient;
  148834. /**
  148835. * Adds a new angular speed gradient
  148836. * @param gradient defines the gradient to use (between 0 and 1)
  148837. * @param factor defines the angular speed to affect to the specified gradient
  148838. * @returns the current particle system
  148839. */
  148840. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148841. /**
  148842. * Remove a specific angular speed gradient
  148843. * @param gradient defines the gradient to remove
  148844. * @returns the current particle system
  148845. */
  148846. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148847. /**
  148848. * Adds a new velocity gradient
  148849. * @param gradient defines the gradient to use (between 0 and 1)
  148850. * @param factor defines the velocity to affect to the specified gradient
  148851. * @returns the current particle system
  148852. */
  148853. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148854. /**
  148855. * Remove a specific velocity gradient
  148856. * @param gradient defines the gradient to remove
  148857. * @returns the current particle system
  148858. */
  148859. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148860. /**
  148861. * Adds a new limit velocity gradient
  148862. * @param gradient defines the gradient to use (between 0 and 1)
  148863. * @param factor defines the limit velocity value to affect to the specified gradient
  148864. * @returns the current particle system
  148865. */
  148866. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148867. /**
  148868. * Remove a specific limit velocity gradient
  148869. * @param gradient defines the gradient to remove
  148870. * @returns the current particle system
  148871. */
  148872. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148873. /**
  148874. * Adds a new drag gradient
  148875. * @param gradient defines the gradient to use (between 0 and 1)
  148876. * @param factor defines the drag value to affect to the specified gradient
  148877. * @returns the current particle system
  148878. */
  148879. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148880. /**
  148881. * Remove a specific drag gradient
  148882. * @param gradient defines the gradient to remove
  148883. * @returns the current particle system
  148884. */
  148885. removeDragGradient(gradient: number): GPUParticleSystem;
  148886. /**
  148887. * Not supported by GPUParticleSystem
  148888. * @param gradient defines the gradient to use (between 0 and 1)
  148889. * @param factor defines the emit rate value to affect to the specified gradient
  148890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148891. * @returns the current particle system
  148892. */
  148893. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148894. /**
  148895. * Not supported by GPUParticleSystem
  148896. * @param gradient defines the gradient to remove
  148897. * @returns the current particle system
  148898. */
  148899. removeEmitRateGradient(gradient: number): IParticleSystem;
  148900. /**
  148901. * Not supported by GPUParticleSystem
  148902. * @param gradient defines the gradient to use (between 0 and 1)
  148903. * @param factor defines the start size value to affect to the specified gradient
  148904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148905. * @returns the current particle system
  148906. */
  148907. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148908. /**
  148909. * Not supported by GPUParticleSystem
  148910. * @param gradient defines the gradient to remove
  148911. * @returns the current particle system
  148912. */
  148913. removeStartSizeGradient(gradient: number): IParticleSystem;
  148914. /**
  148915. * Not supported by GPUParticleSystem
  148916. * @param gradient defines the gradient to use (between 0 and 1)
  148917. * @param min defines the color remap minimal range
  148918. * @param max defines the color remap maximal range
  148919. * @returns the current particle system
  148920. */
  148921. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148922. /**
  148923. * Not supported by GPUParticleSystem
  148924. * @param gradient defines the gradient to remove
  148925. * @returns the current particle system
  148926. */
  148927. removeColorRemapGradient(): IParticleSystem;
  148928. /**
  148929. * Not supported by GPUParticleSystem
  148930. * @param gradient defines the gradient to use (between 0 and 1)
  148931. * @param min defines the alpha remap minimal range
  148932. * @param max defines the alpha remap maximal range
  148933. * @returns the current particle system
  148934. */
  148935. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148936. /**
  148937. * Not supported by GPUParticleSystem
  148938. * @param gradient defines the gradient to remove
  148939. * @returns the current particle system
  148940. */
  148941. removeAlphaRemapGradient(): IParticleSystem;
  148942. /**
  148943. * Not supported by GPUParticleSystem
  148944. * @param gradient defines the gradient to use (between 0 and 1)
  148945. * @param color defines the color to affect to the specified gradient
  148946. * @returns the current particle system
  148947. */
  148948. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148949. /**
  148950. * Not supported by GPUParticleSystem
  148951. * @param gradient defines the gradient to remove
  148952. * @returns the current particle system
  148953. */
  148954. removeRampGradient(): IParticleSystem;
  148955. /**
  148956. * Not supported by GPUParticleSystem
  148957. * @returns the list of ramp gradients
  148958. */
  148959. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148960. /**
  148961. * Not supported by GPUParticleSystem
  148962. * Gets or sets a boolean indicating that ramp gradients must be used
  148963. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148964. */
  148965. get useRampGradients(): boolean;
  148966. set useRampGradients(value: boolean);
  148967. /**
  148968. * Not supported by GPUParticleSystem
  148969. * @param gradient defines the gradient to use (between 0 and 1)
  148970. * @param factor defines the life time factor to affect to the specified gradient
  148971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148972. * @returns the current particle system
  148973. */
  148974. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148975. /**
  148976. * Not supported by GPUParticleSystem
  148977. * @param gradient defines the gradient to remove
  148978. * @returns the current particle system
  148979. */
  148980. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148981. /**
  148982. * Instantiates a GPU particle system.
  148983. * 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.
  148984. * @param name The name of the particle system
  148985. * @param options The options used to create the system
  148986. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148987. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148988. * @param customEffect a custom effect used to change the way particles are rendered by default
  148989. */
  148990. constructor(name: string, options: Partial<{
  148991. capacity: number;
  148992. randomTextureSize: number;
  148993. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148994. protected _reset(): void;
  148995. private _createUpdateVAO;
  148996. private _createRenderVAO;
  148997. private _initialize;
  148998. /** @hidden */
  148999. _recreateUpdateEffect(): void;
  149000. private _getEffect;
  149001. /**
  149002. * Fill the defines array according to the current settings of the particle system
  149003. * @param defines Array to be updated
  149004. * @param blendMode blend mode to take into account when updating the array
  149005. */
  149006. fillDefines(defines: Array<string>, blendMode?: number): void;
  149007. /**
  149008. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149009. * @param uniforms Uniforms array to fill
  149010. * @param attributes Attributes array to fill
  149011. * @param samplers Samplers array to fill
  149012. */
  149013. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149014. /** @hidden */
  149015. _recreateRenderEffect(): Effect;
  149016. /**
  149017. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149018. * @param preWarm defines if we are in the pre-warmimg phase
  149019. */
  149020. animate(preWarm?: boolean): void;
  149021. private _createFactorGradientTexture;
  149022. private _createSizeGradientTexture;
  149023. private _createAngularSpeedGradientTexture;
  149024. private _createVelocityGradientTexture;
  149025. private _createLimitVelocityGradientTexture;
  149026. private _createDragGradientTexture;
  149027. private _createColorGradientTexture;
  149028. /**
  149029. * Renders the particle system in its current state
  149030. * @param preWarm defines if the system should only update the particles but not render them
  149031. * @returns the current number of particles
  149032. */
  149033. render(preWarm?: boolean): number;
  149034. /**
  149035. * Rebuilds the particle system
  149036. */
  149037. rebuild(): void;
  149038. private _releaseBuffers;
  149039. private _releaseVAOs;
  149040. /**
  149041. * Disposes the particle system and free the associated resources
  149042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149043. */
  149044. dispose(disposeTexture?: boolean): void;
  149045. /**
  149046. * Clones the particle system.
  149047. * @param name The name of the cloned object
  149048. * @param newEmitter The new emitter to use
  149049. * @returns the cloned particle system
  149050. */
  149051. clone(name: string, newEmitter: any): GPUParticleSystem;
  149052. /**
  149053. * Serializes the particle system to a JSON object
  149054. * @param serializeTexture defines if the texture must be serialized as well
  149055. * @returns the JSON object
  149056. */
  149057. serialize(serializeTexture?: boolean): any;
  149058. /**
  149059. * Parses a JSON object to create a GPU particle system.
  149060. * @param parsedParticleSystem The JSON object to parse
  149061. * @param sceneOrEngine The scene or the engine to create the particle system in
  149062. * @param rootUrl The root url to use to load external dependencies like texture
  149063. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149064. * @returns the parsed GPU particle system
  149065. */
  149066. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149067. }
  149068. }
  149069. declare module BABYLON {
  149070. /**
  149071. * Represents a set of particle systems working together to create a specific effect
  149072. */
  149073. export class ParticleSystemSet implements IDisposable {
  149074. /**
  149075. * Gets or sets base Assets URL
  149076. */
  149077. static BaseAssetsUrl: string;
  149078. private _emitterCreationOptions;
  149079. private _emitterNode;
  149080. /**
  149081. * Gets the particle system list
  149082. */
  149083. systems: IParticleSystem[];
  149084. /**
  149085. * Gets the emitter node used with this set
  149086. */
  149087. get emitterNode(): Nullable<TransformNode>;
  149088. /**
  149089. * Creates a new emitter mesh as a sphere
  149090. * @param options defines the options used to create the sphere
  149091. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149092. * @param scene defines the hosting scene
  149093. */
  149094. setEmitterAsSphere(options: {
  149095. diameter: number;
  149096. segments: number;
  149097. color: Color3;
  149098. }, renderingGroupId: number, scene: Scene): void;
  149099. /**
  149100. * Starts all particle systems of the set
  149101. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149102. */
  149103. start(emitter?: AbstractMesh): void;
  149104. /**
  149105. * Release all associated resources
  149106. */
  149107. dispose(): void;
  149108. /**
  149109. * Serialize the set into a JSON compatible object
  149110. * @param serializeTexture defines if the texture must be serialized as well
  149111. * @returns a JSON compatible representation of the set
  149112. */
  149113. serialize(serializeTexture?: boolean): any;
  149114. /**
  149115. * Parse a new ParticleSystemSet from a serialized source
  149116. * @param data defines a JSON compatible representation of the set
  149117. * @param scene defines the hosting scene
  149118. * @param gpu defines if we want GPU particles or CPU particles
  149119. * @returns a new ParticleSystemSet
  149120. */
  149121. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149122. }
  149123. }
  149124. declare module BABYLON {
  149125. /**
  149126. * This class is made for on one-liner static method to help creating particle system set.
  149127. */
  149128. export class ParticleHelper {
  149129. /**
  149130. * Gets or sets base Assets URL
  149131. */
  149132. static BaseAssetsUrl: string;
  149133. /** Define the Url to load snippets */
  149134. static SnippetUrl: string;
  149135. /**
  149136. * Create a default particle system that you can tweak
  149137. * @param emitter defines the emitter to use
  149138. * @param capacity defines the system capacity (default is 500 particles)
  149139. * @param scene defines the hosting scene
  149140. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149141. * @returns the new Particle system
  149142. */
  149143. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149144. /**
  149145. * This is the main static method (one-liner) of this helper to create different particle systems
  149146. * @param type This string represents the type to the particle system to create
  149147. * @param scene The scene where the particle system should live
  149148. * @param gpu If the system will use gpu
  149149. * @returns the ParticleSystemSet created
  149150. */
  149151. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149152. /**
  149153. * Static function used to export a particle system to a ParticleSystemSet variable.
  149154. * Please note that the emitter shape is not exported
  149155. * @param systems defines the particle systems to export
  149156. * @returns the created particle system set
  149157. */
  149158. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149159. /**
  149160. * Creates a particle system from a snippet saved in a remote file
  149161. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149162. * @param url defines the url to load from
  149163. * @param scene defines the hosting scene
  149164. * @param gpu If the system will use gpu
  149165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149166. * @returns a promise that will resolve to the new particle system
  149167. */
  149168. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149169. /**
  149170. * Creates a particle system from a snippet saved by the particle system editor
  149171. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149172. * @param scene defines the hosting scene
  149173. * @param gpu If the system will use gpu
  149174. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149175. * @returns a promise that will resolve to the new particle system
  149176. */
  149177. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149178. }
  149179. }
  149180. declare module BABYLON {
  149181. interface Engine {
  149182. /**
  149183. * Create an effect to use with particle systems.
  149184. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149185. * the particle system for which you want to create a custom effect in the last parameter
  149186. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149187. * @param uniformsNames defines a list of attribute names
  149188. * @param samplers defines an array of string used to represent textures
  149189. * @param defines defines the string containing the defines to use to compile the shaders
  149190. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149191. * @param onCompiled defines a function to call when the effect creation is successful
  149192. * @param onError defines a function to call when the effect creation has failed
  149193. * @param particleSystem the particle system you want to create the effect for
  149194. * @returns the new Effect
  149195. */
  149196. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149197. }
  149198. interface Mesh {
  149199. /**
  149200. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149201. * @returns an array of IParticleSystem
  149202. */
  149203. getEmittedParticleSystems(): IParticleSystem[];
  149204. /**
  149205. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149206. * @returns an array of IParticleSystem
  149207. */
  149208. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149209. }
  149210. }
  149211. declare module BABYLON {
  149212. /** Defines the 4 color options */
  149213. export enum PointColor {
  149214. /** color value */
  149215. Color = 2,
  149216. /** uv value */
  149217. UV = 1,
  149218. /** random value */
  149219. Random = 0,
  149220. /** stated value */
  149221. Stated = 3
  149222. }
  149223. /**
  149224. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149225. * 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.
  149226. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149227. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149228. *
  149229. * Full documentation here : TO BE ENTERED
  149230. */
  149231. export class PointsCloudSystem implements IDisposable {
  149232. /**
  149233. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149234. * Example : var p = SPS.particles[i];
  149235. */
  149236. particles: CloudPoint[];
  149237. /**
  149238. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149239. */
  149240. nbParticles: number;
  149241. /**
  149242. * This a counter for your own usage. It's not set by any SPS functions.
  149243. */
  149244. counter: number;
  149245. /**
  149246. * The PCS name. This name is also given to the underlying mesh.
  149247. */
  149248. name: string;
  149249. /**
  149250. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149251. */
  149252. mesh: Mesh;
  149253. /**
  149254. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149255. * Please read :
  149256. */
  149257. vars: any;
  149258. /**
  149259. * @hidden
  149260. */
  149261. _size: number;
  149262. private _scene;
  149263. private _promises;
  149264. private _positions;
  149265. private _indices;
  149266. private _normals;
  149267. private _colors;
  149268. private _uvs;
  149269. private _indices32;
  149270. private _positions32;
  149271. private _colors32;
  149272. private _uvs32;
  149273. private _updatable;
  149274. private _isVisibilityBoxLocked;
  149275. private _alwaysVisible;
  149276. private _groups;
  149277. private _groupCounter;
  149278. private _computeParticleColor;
  149279. private _computeParticleTexture;
  149280. private _computeParticleRotation;
  149281. private _computeBoundingBox;
  149282. private _isReady;
  149283. /**
  149284. * Creates a PCS (Points Cloud System) object
  149285. * @param name (String) is the PCS name, this will be the underlying mesh name
  149286. * @param pointSize (number) is the size for each point
  149287. * @param scene (Scene) is the scene in which the PCS is added
  149288. * @param options defines the options of the PCS e.g.
  149289. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149290. */
  149291. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149292. updatable?: boolean;
  149293. });
  149294. /**
  149295. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149296. * If no points were added to the PCS, the returned mesh is just a single point.
  149297. * @returns a promise for the created mesh
  149298. */
  149299. buildMeshAsync(): Promise<Mesh>;
  149300. /**
  149301. * @hidden
  149302. */
  149303. private _buildMesh;
  149304. private _addParticle;
  149305. private _randomUnitVector;
  149306. private _getColorIndicesForCoord;
  149307. private _setPointsColorOrUV;
  149308. private _colorFromTexture;
  149309. private _calculateDensity;
  149310. /**
  149311. * Adds points to the PCS in random positions within a unit sphere
  149312. * @param nb (positive integer) the number of particles to be created from this model
  149313. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149314. * @returns the number of groups in the system
  149315. */
  149316. addPoints(nb: number, pointFunction?: any): number;
  149317. /**
  149318. * Adds points to the PCS from the surface of the model shape
  149319. * @param mesh is any Mesh object that will be used as a surface model for the points
  149320. * @param nb (positive integer) the number of particles to be created from this model
  149321. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149322. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149323. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149324. * @returns the number of groups in the system
  149325. */
  149326. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149327. /**
  149328. * Adds points to the PCS inside the model shape
  149329. * @param mesh is any Mesh object that will be used as a surface model for the points
  149330. * @param nb (positive integer) the number of particles to be created from this model
  149331. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149332. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149333. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149334. * @returns the number of groups in the system
  149335. */
  149336. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149337. /**
  149338. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149339. * This method calls `updateParticle()` for each particle of the SPS.
  149340. * For an animated SPS, it is usually called within the render loop.
  149341. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149342. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149343. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149344. * @returns the PCS.
  149345. */
  149346. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149347. /**
  149348. * Disposes the PCS.
  149349. */
  149350. dispose(): void;
  149351. /**
  149352. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149353. * doc :
  149354. * @returns the PCS.
  149355. */
  149356. refreshVisibleSize(): PointsCloudSystem;
  149357. /**
  149358. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149359. * @param size the size (float) of the visibility box
  149360. * note : this doesn't lock the PCS mesh bounding box.
  149361. * doc :
  149362. */
  149363. setVisibilityBox(size: number): void;
  149364. /**
  149365. * Gets whether the PCS is always visible or not
  149366. * doc :
  149367. */
  149368. get isAlwaysVisible(): boolean;
  149369. /**
  149370. * Sets the PCS as always visible or not
  149371. * doc :
  149372. */
  149373. set isAlwaysVisible(val: boolean);
  149374. /**
  149375. * Tells to `setParticles()` to compute the particle rotations or not
  149376. * Default value : false. The PCS is faster when it's set to false
  149377. * Note : particle rotations are only applied to parent particles
  149378. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149379. */
  149380. set computeParticleRotation(val: boolean);
  149381. /**
  149382. * Tells to `setParticles()` to compute the particle colors or not.
  149383. * Default value : true. The PCS is faster when it's set to false.
  149384. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149385. */
  149386. set computeParticleColor(val: boolean);
  149387. set computeParticleTexture(val: boolean);
  149388. /**
  149389. * Gets if `setParticles()` computes the particle colors or not.
  149390. * Default value : false. The PCS is faster when it's set to false.
  149391. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149392. */
  149393. get computeParticleColor(): boolean;
  149394. /**
  149395. * Gets if `setParticles()` computes the particle textures or not.
  149396. * Default value : false. The PCS is faster when it's set to false.
  149397. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149398. */
  149399. get computeParticleTexture(): boolean;
  149400. /**
  149401. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149402. */
  149403. set computeBoundingBox(val: boolean);
  149404. /**
  149405. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149406. */
  149407. get computeBoundingBox(): boolean;
  149408. /**
  149409. * This function does nothing. It may be overwritten to set all the particle first values.
  149410. * The PCS doesn't call this function, you may have to call it by your own.
  149411. * doc :
  149412. */
  149413. initParticles(): void;
  149414. /**
  149415. * This function does nothing. It may be overwritten to recycle a particle
  149416. * The PCS doesn't call this function, you can to call it
  149417. * doc :
  149418. * @param particle The particle to recycle
  149419. * @returns the recycled particle
  149420. */
  149421. recycleParticle(particle: CloudPoint): CloudPoint;
  149422. /**
  149423. * Updates a particle : this function should be overwritten by the user.
  149424. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149425. * doc :
  149426. * @example : just set a particle position or velocity and recycle conditions
  149427. * @param particle The particle to update
  149428. * @returns the updated particle
  149429. */
  149430. updateParticle(particle: CloudPoint): CloudPoint;
  149431. /**
  149432. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149433. * This does nothing and may be overwritten by the user.
  149434. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149435. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149436. * @param update the boolean update value actually passed to setParticles()
  149437. */
  149438. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149439. /**
  149440. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149441. * This will be passed three parameters.
  149442. * This does nothing and may be overwritten by the user.
  149443. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149444. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149445. * @param update the boolean update value actually passed to setParticles()
  149446. */
  149447. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149448. }
  149449. }
  149450. declare module BABYLON {
  149451. /**
  149452. * Represents one particle of a points cloud system.
  149453. */
  149454. export class CloudPoint {
  149455. /**
  149456. * particle global index
  149457. */
  149458. idx: number;
  149459. /**
  149460. * The color of the particle
  149461. */
  149462. color: Nullable<Color4>;
  149463. /**
  149464. * The world space position of the particle.
  149465. */
  149466. position: Vector3;
  149467. /**
  149468. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149469. */
  149470. rotation: Vector3;
  149471. /**
  149472. * The world space rotation quaternion of the particle.
  149473. */
  149474. rotationQuaternion: Nullable<Quaternion>;
  149475. /**
  149476. * The uv of the particle.
  149477. */
  149478. uv: Nullable<Vector2>;
  149479. /**
  149480. * The current speed of the particle.
  149481. */
  149482. velocity: Vector3;
  149483. /**
  149484. * The pivot point in the particle local space.
  149485. */
  149486. pivot: Vector3;
  149487. /**
  149488. * Must the particle be translated from its pivot point in its local space ?
  149489. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149490. * Default : false
  149491. */
  149492. translateFromPivot: boolean;
  149493. /**
  149494. * Index of this particle in the global "positions" array (Internal use)
  149495. * @hidden
  149496. */
  149497. _pos: number;
  149498. /**
  149499. * @hidden Index of this particle in the global "indices" array (Internal use)
  149500. */
  149501. _ind: number;
  149502. /**
  149503. * Group this particle belongs to
  149504. */
  149505. _group: PointsGroup;
  149506. /**
  149507. * Group id of this particle
  149508. */
  149509. groupId: number;
  149510. /**
  149511. * Index of the particle in its group id (Internal use)
  149512. */
  149513. idxInGroup: number;
  149514. /**
  149515. * @hidden Particle BoundingInfo object (Internal use)
  149516. */
  149517. _boundingInfo: BoundingInfo;
  149518. /**
  149519. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149520. */
  149521. _pcs: PointsCloudSystem;
  149522. /**
  149523. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149524. */
  149525. _stillInvisible: boolean;
  149526. /**
  149527. * @hidden Last computed particle rotation matrix
  149528. */
  149529. _rotationMatrix: number[];
  149530. /**
  149531. * Parent particle Id, if any.
  149532. * Default null.
  149533. */
  149534. parentId: Nullable<number>;
  149535. /**
  149536. * @hidden Internal global position in the PCS.
  149537. */
  149538. _globalPosition: Vector3;
  149539. /**
  149540. * Creates a Point Cloud object.
  149541. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149542. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149543. * @param group (PointsGroup) is the group the particle belongs to
  149544. * @param groupId (integer) is the group identifier in the PCS.
  149545. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149546. * @param pcs defines the PCS it is associated to
  149547. */
  149548. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149549. /**
  149550. * get point size
  149551. */
  149552. get size(): Vector3;
  149553. /**
  149554. * Set point size
  149555. */
  149556. set size(scale: Vector3);
  149557. /**
  149558. * Legacy support, changed quaternion to rotationQuaternion
  149559. */
  149560. get quaternion(): Nullable<Quaternion>;
  149561. /**
  149562. * Legacy support, changed quaternion to rotationQuaternion
  149563. */
  149564. set quaternion(q: Nullable<Quaternion>);
  149565. /**
  149566. * Returns a boolean. True if the particle intersects a mesh, else false
  149567. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149568. * @param target is the object (point or mesh) what the intersection is computed against
  149569. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149570. * @returns true if it intersects
  149571. */
  149572. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149573. /**
  149574. * get the rotation matrix of the particle
  149575. * @hidden
  149576. */
  149577. getRotationMatrix(m: Matrix): void;
  149578. }
  149579. /**
  149580. * Represents a group of points in a points cloud system
  149581. * * PCS internal tool, don't use it manually.
  149582. */
  149583. export class PointsGroup {
  149584. /**
  149585. * The group id
  149586. * @hidden
  149587. */
  149588. groupID: number;
  149589. /**
  149590. * image data for group (internal use)
  149591. * @hidden
  149592. */
  149593. _groupImageData: Nullable<ArrayBufferView>;
  149594. /**
  149595. * Image Width (internal use)
  149596. * @hidden
  149597. */
  149598. _groupImgWidth: number;
  149599. /**
  149600. * Image Height (internal use)
  149601. * @hidden
  149602. */
  149603. _groupImgHeight: number;
  149604. /**
  149605. * Custom position function (internal use)
  149606. * @hidden
  149607. */
  149608. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149609. /**
  149610. * density per facet for surface points
  149611. * @hidden
  149612. */
  149613. _groupDensity: number[];
  149614. /**
  149615. * Only when points are colored by texture carries pointer to texture list array
  149616. * @hidden
  149617. */
  149618. _textureNb: number;
  149619. /**
  149620. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149621. * PCS internal tool, don't use it manually.
  149622. * @hidden
  149623. */
  149624. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149625. }
  149626. }
  149627. declare module BABYLON {
  149628. interface Scene {
  149629. /** @hidden (Backing field) */
  149630. _physicsEngine: Nullable<IPhysicsEngine>;
  149631. /** @hidden */
  149632. _physicsTimeAccumulator: number;
  149633. /**
  149634. * Gets the current physics engine
  149635. * @returns a IPhysicsEngine or null if none attached
  149636. */
  149637. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149638. /**
  149639. * Enables physics to the current scene
  149640. * @param gravity defines the scene's gravity for the physics engine
  149641. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149642. * @return a boolean indicating if the physics engine was initialized
  149643. */
  149644. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149645. /**
  149646. * Disables and disposes the physics engine associated with the scene
  149647. */
  149648. disablePhysicsEngine(): void;
  149649. /**
  149650. * Gets a boolean indicating if there is an active physics engine
  149651. * @returns a boolean indicating if there is an active physics engine
  149652. */
  149653. isPhysicsEnabled(): boolean;
  149654. /**
  149655. * Deletes a physics compound impostor
  149656. * @param compound defines the compound to delete
  149657. */
  149658. deleteCompoundImpostor(compound: any): void;
  149659. /**
  149660. * An event triggered when physic simulation is about to be run
  149661. */
  149662. onBeforePhysicsObservable: Observable<Scene>;
  149663. /**
  149664. * An event triggered when physic simulation has been done
  149665. */
  149666. onAfterPhysicsObservable: Observable<Scene>;
  149667. }
  149668. interface AbstractMesh {
  149669. /** @hidden */
  149670. _physicsImpostor: Nullable<PhysicsImpostor>;
  149671. /**
  149672. * Gets or sets impostor used for physic simulation
  149673. * @see https://doc.babylonjs.com/features/physics_engine
  149674. */
  149675. physicsImpostor: Nullable<PhysicsImpostor>;
  149676. /**
  149677. * Gets the current physics impostor
  149678. * @see https://doc.babylonjs.com/features/physics_engine
  149679. * @returns a physics impostor or null
  149680. */
  149681. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149682. /** Apply a physic impulse to the mesh
  149683. * @param force defines the force to apply
  149684. * @param contactPoint defines where to apply the force
  149685. * @returns the current mesh
  149686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149687. */
  149688. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149689. /**
  149690. * Creates a physic joint between two meshes
  149691. * @param otherMesh defines the other mesh to use
  149692. * @param pivot1 defines the pivot to use on this mesh
  149693. * @param pivot2 defines the pivot to use on the other mesh
  149694. * @param options defines additional options (can be plugin dependent)
  149695. * @returns the current mesh
  149696. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149697. */
  149698. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149699. /** @hidden */
  149700. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149701. }
  149702. /**
  149703. * Defines the physics engine scene component responsible to manage a physics engine
  149704. */
  149705. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149706. /**
  149707. * The component name helpful to identify the component in the list of scene components.
  149708. */
  149709. readonly name: string;
  149710. /**
  149711. * The scene the component belongs to.
  149712. */
  149713. scene: Scene;
  149714. /**
  149715. * Creates a new instance of the component for the given scene
  149716. * @param scene Defines the scene to register the component in
  149717. */
  149718. constructor(scene: Scene);
  149719. /**
  149720. * Registers the component in a given scene
  149721. */
  149722. register(): void;
  149723. /**
  149724. * Rebuilds the elements related to this component in case of
  149725. * context lost for instance.
  149726. */
  149727. rebuild(): void;
  149728. /**
  149729. * Disposes the component and the associated ressources
  149730. */
  149731. dispose(): void;
  149732. }
  149733. }
  149734. declare module BABYLON {
  149735. /**
  149736. * A helper for physics simulations
  149737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149738. */
  149739. export class PhysicsHelper {
  149740. private _scene;
  149741. private _physicsEngine;
  149742. /**
  149743. * Initializes the Physics helper
  149744. * @param scene Babylon.js scene
  149745. */
  149746. constructor(scene: Scene);
  149747. /**
  149748. * Applies a radial explosion impulse
  149749. * @param origin the origin of the explosion
  149750. * @param radiusOrEventOptions the radius or the options of radial explosion
  149751. * @param strength the explosion strength
  149752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149753. * @returns A physics radial explosion event, or null
  149754. */
  149755. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149756. /**
  149757. * Applies a radial explosion force
  149758. * @param origin the origin of the explosion
  149759. * @param radiusOrEventOptions the radius or the options of radial explosion
  149760. * @param strength the explosion strength
  149761. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149762. * @returns A physics radial explosion event, or null
  149763. */
  149764. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149765. /**
  149766. * Creates a gravitational field
  149767. * @param origin the origin of the explosion
  149768. * @param radiusOrEventOptions the radius or the options of radial explosion
  149769. * @param strength the explosion strength
  149770. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149771. * @returns A physics gravitational field event, or null
  149772. */
  149773. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149774. /**
  149775. * Creates a physics updraft event
  149776. * @param origin the origin of the updraft
  149777. * @param radiusOrEventOptions the radius or the options of the updraft
  149778. * @param strength the strength of the updraft
  149779. * @param height the height of the updraft
  149780. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149781. * @returns A physics updraft event, or null
  149782. */
  149783. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149784. /**
  149785. * Creates a physics vortex event
  149786. * @param origin the of the vortex
  149787. * @param radiusOrEventOptions the radius or the options of the vortex
  149788. * @param strength the strength of the vortex
  149789. * @param height the height of the vortex
  149790. * @returns a Physics vortex event, or null
  149791. * A physics vortex event or null
  149792. */
  149793. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149794. }
  149795. /**
  149796. * Represents a physics radial explosion event
  149797. */
  149798. class PhysicsRadialExplosionEvent {
  149799. private _scene;
  149800. private _options;
  149801. private _sphere;
  149802. private _dataFetched;
  149803. /**
  149804. * Initializes a radial explosioin event
  149805. * @param _scene BabylonJS scene
  149806. * @param _options The options for the vortex event
  149807. */
  149808. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149809. /**
  149810. * Returns the data related to the radial explosion event (sphere).
  149811. * @returns The radial explosion event data
  149812. */
  149813. getData(): PhysicsRadialExplosionEventData;
  149814. /**
  149815. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149816. * @param impostor A physics imposter
  149817. * @param origin the origin of the explosion
  149818. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149819. */
  149820. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149821. /**
  149822. * Triggers affecterd impostors callbacks
  149823. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149824. */
  149825. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149826. /**
  149827. * Disposes the sphere.
  149828. * @param force Specifies if the sphere should be disposed by force
  149829. */
  149830. dispose(force?: boolean): void;
  149831. /*** Helpers ***/
  149832. private _prepareSphere;
  149833. private _intersectsWithSphere;
  149834. }
  149835. /**
  149836. * Represents a gravitational field event
  149837. */
  149838. class PhysicsGravitationalFieldEvent {
  149839. private _physicsHelper;
  149840. private _scene;
  149841. private _origin;
  149842. private _options;
  149843. private _tickCallback;
  149844. private _sphere;
  149845. private _dataFetched;
  149846. /**
  149847. * Initializes the physics gravitational field event
  149848. * @param _physicsHelper A physics helper
  149849. * @param _scene BabylonJS scene
  149850. * @param _origin The origin position of the gravitational field event
  149851. * @param _options The options for the vortex event
  149852. */
  149853. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149854. /**
  149855. * Returns the data related to the gravitational field event (sphere).
  149856. * @returns A gravitational field event
  149857. */
  149858. getData(): PhysicsGravitationalFieldEventData;
  149859. /**
  149860. * Enables the gravitational field.
  149861. */
  149862. enable(): void;
  149863. /**
  149864. * Disables the gravitational field.
  149865. */
  149866. disable(): void;
  149867. /**
  149868. * Disposes the sphere.
  149869. * @param force The force to dispose from the gravitational field event
  149870. */
  149871. dispose(force?: boolean): void;
  149872. private _tick;
  149873. }
  149874. /**
  149875. * Represents a physics updraft event
  149876. */
  149877. class PhysicsUpdraftEvent {
  149878. private _scene;
  149879. private _origin;
  149880. private _options;
  149881. private _physicsEngine;
  149882. private _originTop;
  149883. private _originDirection;
  149884. private _tickCallback;
  149885. private _cylinder;
  149886. private _cylinderPosition;
  149887. private _dataFetched;
  149888. /**
  149889. * Initializes the physics updraft event
  149890. * @param _scene BabylonJS scene
  149891. * @param _origin The origin position of the updraft
  149892. * @param _options The options for the updraft event
  149893. */
  149894. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149895. /**
  149896. * Returns the data related to the updraft event (cylinder).
  149897. * @returns A physics updraft event
  149898. */
  149899. getData(): PhysicsUpdraftEventData;
  149900. /**
  149901. * Enables the updraft.
  149902. */
  149903. enable(): void;
  149904. /**
  149905. * Disables the updraft.
  149906. */
  149907. disable(): void;
  149908. /**
  149909. * Disposes the cylinder.
  149910. * @param force Specifies if the updraft should be disposed by force
  149911. */
  149912. dispose(force?: boolean): void;
  149913. private getImpostorHitData;
  149914. private _tick;
  149915. /*** Helpers ***/
  149916. private _prepareCylinder;
  149917. private _intersectsWithCylinder;
  149918. }
  149919. /**
  149920. * Represents a physics vortex event
  149921. */
  149922. class PhysicsVortexEvent {
  149923. private _scene;
  149924. private _origin;
  149925. private _options;
  149926. private _physicsEngine;
  149927. private _originTop;
  149928. private _tickCallback;
  149929. private _cylinder;
  149930. private _cylinderPosition;
  149931. private _dataFetched;
  149932. /**
  149933. * Initializes the physics vortex event
  149934. * @param _scene The BabylonJS scene
  149935. * @param _origin The origin position of the vortex
  149936. * @param _options The options for the vortex event
  149937. */
  149938. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149939. /**
  149940. * Returns the data related to the vortex event (cylinder).
  149941. * @returns The physics vortex event data
  149942. */
  149943. getData(): PhysicsVortexEventData;
  149944. /**
  149945. * Enables the vortex.
  149946. */
  149947. enable(): void;
  149948. /**
  149949. * Disables the cortex.
  149950. */
  149951. disable(): void;
  149952. /**
  149953. * Disposes the sphere.
  149954. * @param force
  149955. */
  149956. dispose(force?: boolean): void;
  149957. private getImpostorHitData;
  149958. private _tick;
  149959. /*** Helpers ***/
  149960. private _prepareCylinder;
  149961. private _intersectsWithCylinder;
  149962. }
  149963. /**
  149964. * Options fot the radial explosion event
  149965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149966. */
  149967. export class PhysicsRadialExplosionEventOptions {
  149968. /**
  149969. * The radius of the sphere for the radial explosion.
  149970. */
  149971. radius: number;
  149972. /**
  149973. * The strenth of the explosion.
  149974. */
  149975. strength: number;
  149976. /**
  149977. * The strenght of the force in correspondence to the distance of the affected object
  149978. */
  149979. falloff: PhysicsRadialImpulseFalloff;
  149980. /**
  149981. * Sphere options for the radial explosion.
  149982. */
  149983. sphere: {
  149984. segments: number;
  149985. diameter: number;
  149986. };
  149987. /**
  149988. * Sphere options for the radial explosion.
  149989. */
  149990. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149991. }
  149992. /**
  149993. * Options fot the updraft event
  149994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149995. */
  149996. export class PhysicsUpdraftEventOptions {
  149997. /**
  149998. * The radius of the cylinder for the vortex
  149999. */
  150000. radius: number;
  150001. /**
  150002. * The strenth of the updraft.
  150003. */
  150004. strength: number;
  150005. /**
  150006. * The height of the cylinder for the updraft.
  150007. */
  150008. height: number;
  150009. /**
  150010. * The mode for the the updraft.
  150011. */
  150012. updraftMode: PhysicsUpdraftMode;
  150013. }
  150014. /**
  150015. * Options fot the vortex event
  150016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150017. */
  150018. export class PhysicsVortexEventOptions {
  150019. /**
  150020. * The radius of the cylinder for the vortex
  150021. */
  150022. radius: number;
  150023. /**
  150024. * The strenth of the vortex.
  150025. */
  150026. strength: number;
  150027. /**
  150028. * The height of the cylinder for the vortex.
  150029. */
  150030. height: number;
  150031. /**
  150032. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150033. */
  150034. centripetalForceThreshold: number;
  150035. /**
  150036. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150037. */
  150038. centripetalForceMultiplier: number;
  150039. /**
  150040. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150041. */
  150042. centrifugalForceMultiplier: number;
  150043. /**
  150044. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150045. */
  150046. updraftForceMultiplier: number;
  150047. }
  150048. /**
  150049. * The strenght of the force in correspondence to the distance of the affected object
  150050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150051. */
  150052. export enum PhysicsRadialImpulseFalloff {
  150053. /** Defines that impulse is constant in strength across it's whole radius */
  150054. Constant = 0,
  150055. /** Defines that impulse gets weaker if it's further from the origin */
  150056. Linear = 1
  150057. }
  150058. /**
  150059. * The strength of the force in correspondence to the distance of the affected object
  150060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150061. */
  150062. export enum PhysicsUpdraftMode {
  150063. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150064. Center = 0,
  150065. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150066. Perpendicular = 1
  150067. }
  150068. /**
  150069. * Interface for a physics hit data
  150070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150071. */
  150072. export interface PhysicsHitData {
  150073. /**
  150074. * The force applied at the contact point
  150075. */
  150076. force: Vector3;
  150077. /**
  150078. * The contact point
  150079. */
  150080. contactPoint: Vector3;
  150081. /**
  150082. * The distance from the origin to the contact point
  150083. */
  150084. distanceFromOrigin: number;
  150085. }
  150086. /**
  150087. * Interface for radial explosion event data
  150088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150089. */
  150090. export interface PhysicsRadialExplosionEventData {
  150091. /**
  150092. * A sphere used for the radial explosion event
  150093. */
  150094. sphere: Mesh;
  150095. }
  150096. /**
  150097. * Interface for gravitational field event data
  150098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150099. */
  150100. export interface PhysicsGravitationalFieldEventData {
  150101. /**
  150102. * A sphere mesh used for the gravitational field event
  150103. */
  150104. sphere: Mesh;
  150105. }
  150106. /**
  150107. * Interface for updraft event data
  150108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150109. */
  150110. export interface PhysicsUpdraftEventData {
  150111. /**
  150112. * A cylinder used for the updraft event
  150113. */
  150114. cylinder: Mesh;
  150115. }
  150116. /**
  150117. * Interface for vortex event data
  150118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150119. */
  150120. export interface PhysicsVortexEventData {
  150121. /**
  150122. * A cylinder used for the vortex event
  150123. */
  150124. cylinder: Mesh;
  150125. }
  150126. /**
  150127. * Interface for an affected physics impostor
  150128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150129. */
  150130. export interface PhysicsAffectedImpostorWithData {
  150131. /**
  150132. * The impostor affected by the effect
  150133. */
  150134. impostor: PhysicsImpostor;
  150135. /**
  150136. * The data about the hit/horce from the explosion
  150137. */
  150138. hitData: PhysicsHitData;
  150139. }
  150140. }
  150141. declare module BABYLON {
  150142. /** @hidden */
  150143. export var blackAndWhitePixelShader: {
  150144. name: string;
  150145. shader: string;
  150146. };
  150147. }
  150148. declare module BABYLON {
  150149. /**
  150150. * Post process used to render in black and white
  150151. */
  150152. export class BlackAndWhitePostProcess extends PostProcess {
  150153. /**
  150154. * Linear about to convert he result to black and white (default: 1)
  150155. */
  150156. degree: number;
  150157. /**
  150158. * Gets a string identifying the name of the class
  150159. * @returns "BlackAndWhitePostProcess" string
  150160. */
  150161. getClassName(): string;
  150162. /**
  150163. * Creates a black and white post process
  150164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150165. * @param name The name of the effect.
  150166. * @param options The required width/height ratio to downsize to before computing the render pass.
  150167. * @param camera The camera to apply the render pass to.
  150168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150169. * @param engine The engine which the post process will be applied. (default: current engine)
  150170. * @param reusable If the post process can be reused on the same frame. (default: false)
  150171. */
  150172. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150173. /** @hidden */
  150174. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150175. }
  150176. }
  150177. declare module BABYLON {
  150178. /**
  150179. * This represents a set of one or more post processes in Babylon.
  150180. * A post process can be used to apply a shader to a texture after it is rendered.
  150181. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150182. */
  150183. export class PostProcessRenderEffect {
  150184. private _postProcesses;
  150185. private _getPostProcesses;
  150186. private _singleInstance;
  150187. private _cameras;
  150188. private _indicesForCamera;
  150189. /**
  150190. * Name of the effect
  150191. * @hidden
  150192. */
  150193. _name: string;
  150194. /**
  150195. * Instantiates a post process render effect.
  150196. * A post process can be used to apply a shader to a texture after it is rendered.
  150197. * @param engine The engine the effect is tied to
  150198. * @param name The name of the effect
  150199. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150200. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150201. */
  150202. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150203. /**
  150204. * Checks if all the post processes in the effect are supported.
  150205. */
  150206. get isSupported(): boolean;
  150207. /**
  150208. * Updates the current state of the effect
  150209. * @hidden
  150210. */
  150211. _update(): void;
  150212. /**
  150213. * Attaches the effect on cameras
  150214. * @param cameras The camera to attach to.
  150215. * @hidden
  150216. */
  150217. _attachCameras(cameras: Camera): void;
  150218. /**
  150219. * Attaches the effect on cameras
  150220. * @param cameras The camera to attach to.
  150221. * @hidden
  150222. */
  150223. _attachCameras(cameras: Camera[]): void;
  150224. /**
  150225. * Detaches the effect on cameras
  150226. * @param cameras The camera to detatch from.
  150227. * @hidden
  150228. */
  150229. _detachCameras(cameras: Camera): void;
  150230. /**
  150231. * Detatches the effect on cameras
  150232. * @param cameras The camera to detatch from.
  150233. * @hidden
  150234. */
  150235. _detachCameras(cameras: Camera[]): void;
  150236. /**
  150237. * Enables the effect on given cameras
  150238. * @param cameras The camera to enable.
  150239. * @hidden
  150240. */
  150241. _enable(cameras: Camera): void;
  150242. /**
  150243. * Enables the effect on given cameras
  150244. * @param cameras The camera to enable.
  150245. * @hidden
  150246. */
  150247. _enable(cameras: Nullable<Camera[]>): void;
  150248. /**
  150249. * Disables the effect on the given cameras
  150250. * @param cameras The camera to disable.
  150251. * @hidden
  150252. */
  150253. _disable(cameras: Camera): void;
  150254. /**
  150255. * Disables the effect on the given cameras
  150256. * @param cameras The camera to disable.
  150257. * @hidden
  150258. */
  150259. _disable(cameras: Nullable<Camera[]>): void;
  150260. /**
  150261. * Gets a list of the post processes contained in the effect.
  150262. * @param camera The camera to get the post processes on.
  150263. * @returns The list of the post processes in the effect.
  150264. */
  150265. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150266. }
  150267. }
  150268. declare module BABYLON {
  150269. /** @hidden */
  150270. export var extractHighlightsPixelShader: {
  150271. name: string;
  150272. shader: string;
  150273. };
  150274. }
  150275. declare module BABYLON {
  150276. /**
  150277. * 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.
  150278. */
  150279. export class ExtractHighlightsPostProcess extends PostProcess {
  150280. /**
  150281. * The luminance threshold, pixels below this value will be set to black.
  150282. */
  150283. threshold: number;
  150284. /** @hidden */
  150285. _exposure: number;
  150286. /**
  150287. * Post process which has the input texture to be used when performing highlight extraction
  150288. * @hidden
  150289. */
  150290. _inputPostProcess: Nullable<PostProcess>;
  150291. /**
  150292. * Gets a string identifying the name of the class
  150293. * @returns "ExtractHighlightsPostProcess" string
  150294. */
  150295. getClassName(): string;
  150296. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150297. }
  150298. }
  150299. declare module BABYLON {
  150300. /** @hidden */
  150301. export var bloomMergePixelShader: {
  150302. name: string;
  150303. shader: string;
  150304. };
  150305. }
  150306. declare module BABYLON {
  150307. /**
  150308. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150309. */
  150310. export class BloomMergePostProcess extends PostProcess {
  150311. /** Weight of the bloom to be added to the original input. */
  150312. weight: number;
  150313. /**
  150314. * Gets a string identifying the name of the class
  150315. * @returns "BloomMergePostProcess" string
  150316. */
  150317. getClassName(): string;
  150318. /**
  150319. * Creates a new instance of @see BloomMergePostProcess
  150320. * @param name The name of the effect.
  150321. * @param originalFromInput Post process which's input will be used for the merge.
  150322. * @param blurred Blurred highlights post process which's output will be used.
  150323. * @param weight Weight of the bloom to be added to the original input.
  150324. * @param options The required width/height ratio to downsize to before computing the render pass.
  150325. * @param camera The camera to apply the render pass to.
  150326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150327. * @param engine The engine which the post process will be applied. (default: current engine)
  150328. * @param reusable If the post process can be reused on the same frame. (default: false)
  150329. * @param textureType Type of textures used when performing the post process. (default: 0)
  150330. * @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)
  150331. */
  150332. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150333. /** Weight of the bloom to be added to the original input. */
  150334. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150335. }
  150336. }
  150337. declare module BABYLON {
  150338. /**
  150339. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150340. */
  150341. export class BloomEffect extends PostProcessRenderEffect {
  150342. private bloomScale;
  150343. /**
  150344. * @hidden Internal
  150345. */
  150346. _effects: Array<PostProcess>;
  150347. /**
  150348. * @hidden Internal
  150349. */
  150350. _downscale: ExtractHighlightsPostProcess;
  150351. private _blurX;
  150352. private _blurY;
  150353. private _merge;
  150354. /**
  150355. * The luminance threshold to find bright areas of the image to bloom.
  150356. */
  150357. get threshold(): number;
  150358. set threshold(value: number);
  150359. /**
  150360. * The strength of the bloom.
  150361. */
  150362. get weight(): number;
  150363. set weight(value: number);
  150364. /**
  150365. * Specifies the size of the bloom blur kernel, relative to the final output size
  150366. */
  150367. get kernel(): number;
  150368. set kernel(value: number);
  150369. /**
  150370. * Creates a new instance of @see BloomEffect
  150371. * @param scene The scene the effect belongs to.
  150372. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150373. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150374. * @param bloomWeight The the strength of bloom.
  150375. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150376. * @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)
  150377. */
  150378. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150379. /**
  150380. * Disposes each of the internal effects for a given camera.
  150381. * @param camera The camera to dispose the effect on.
  150382. */
  150383. disposeEffects(camera: Camera): void;
  150384. /**
  150385. * @hidden Internal
  150386. */
  150387. _updateEffects(): void;
  150388. /**
  150389. * Internal
  150390. * @returns if all the contained post processes are ready.
  150391. * @hidden
  150392. */
  150393. _isReady(): boolean;
  150394. }
  150395. }
  150396. declare module BABYLON {
  150397. /** @hidden */
  150398. export var chromaticAberrationPixelShader: {
  150399. name: string;
  150400. shader: string;
  150401. };
  150402. }
  150403. declare module BABYLON {
  150404. /**
  150405. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150406. */
  150407. export class ChromaticAberrationPostProcess extends PostProcess {
  150408. /**
  150409. * The amount of seperation of rgb channels (default: 30)
  150410. */
  150411. aberrationAmount: number;
  150412. /**
  150413. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150414. */
  150415. radialIntensity: number;
  150416. /**
  150417. * 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))
  150418. */
  150419. direction: Vector2;
  150420. /**
  150421. * 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))
  150422. */
  150423. centerPosition: Vector2;
  150424. /** The width of the screen to apply the effect on */
  150425. screenWidth: number;
  150426. /** The height of the screen to apply the effect on */
  150427. screenHeight: number;
  150428. /**
  150429. * Gets a string identifying the name of the class
  150430. * @returns "ChromaticAberrationPostProcess" string
  150431. */
  150432. getClassName(): string;
  150433. /**
  150434. * Creates a new instance ChromaticAberrationPostProcess
  150435. * @param name The name of the effect.
  150436. * @param screenWidth The width of the screen to apply the effect on.
  150437. * @param screenHeight The height of the screen to apply the effect on.
  150438. * @param options The required width/height ratio to downsize to before computing the render pass.
  150439. * @param camera The camera to apply the render pass to.
  150440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150441. * @param engine The engine which the post process will be applied. (default: current engine)
  150442. * @param reusable If the post process can be reused on the same frame. (default: false)
  150443. * @param textureType Type of textures used when performing the post process. (default: 0)
  150444. * @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)
  150445. */
  150446. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150447. /** @hidden */
  150448. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150449. }
  150450. }
  150451. declare module BABYLON {
  150452. /** @hidden */
  150453. export var circleOfConfusionPixelShader: {
  150454. name: string;
  150455. shader: string;
  150456. };
  150457. }
  150458. declare module BABYLON {
  150459. /**
  150460. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150461. */
  150462. export class CircleOfConfusionPostProcess extends PostProcess {
  150463. /**
  150464. * 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.
  150465. */
  150466. lensSize: number;
  150467. /**
  150468. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150469. */
  150470. fStop: number;
  150471. /**
  150472. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150473. */
  150474. focusDistance: number;
  150475. /**
  150476. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150477. */
  150478. focalLength: number;
  150479. /**
  150480. * Gets a string identifying the name of the class
  150481. * @returns "CircleOfConfusionPostProcess" string
  150482. */
  150483. getClassName(): string;
  150484. private _depthTexture;
  150485. /**
  150486. * Creates a new instance CircleOfConfusionPostProcess
  150487. * @param name The name of the effect.
  150488. * @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.
  150489. * @param options The required width/height ratio to downsize to before computing the render pass.
  150490. * @param camera The camera to apply the render pass to.
  150491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150492. * @param engine The engine which the post process will be applied. (default: current engine)
  150493. * @param reusable If the post process can be reused on the same frame. (default: false)
  150494. * @param textureType Type of textures used when performing the post process. (default: 0)
  150495. * @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)
  150496. */
  150497. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150498. /**
  150499. * 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.
  150500. */
  150501. set depthTexture(value: RenderTargetTexture);
  150502. }
  150503. }
  150504. declare module BABYLON {
  150505. /** @hidden */
  150506. export var colorCorrectionPixelShader: {
  150507. name: string;
  150508. shader: string;
  150509. };
  150510. }
  150511. declare module BABYLON {
  150512. /**
  150513. *
  150514. * This post-process allows the modification of rendered colors by using
  150515. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150516. *
  150517. * The object needs to be provided an url to a texture containing the color
  150518. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150519. * Use an image editing software to tweak the LUT to match your needs.
  150520. *
  150521. * For an example of a color LUT, see here:
  150522. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150523. * For explanations on color grading, see here:
  150524. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150525. *
  150526. */
  150527. export class ColorCorrectionPostProcess extends PostProcess {
  150528. private _colorTableTexture;
  150529. /**
  150530. * Gets the color table url used to create the LUT texture
  150531. */
  150532. colorTableUrl: string;
  150533. /**
  150534. * Gets a string identifying the name of the class
  150535. * @returns "ColorCorrectionPostProcess" string
  150536. */
  150537. getClassName(): string;
  150538. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150539. /** @hidden */
  150540. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150541. }
  150542. }
  150543. declare module BABYLON {
  150544. /** @hidden */
  150545. export var convolutionPixelShader: {
  150546. name: string;
  150547. shader: string;
  150548. };
  150549. }
  150550. declare module BABYLON {
  150551. /**
  150552. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150553. * input texture to perform effects such as edge detection or sharpening
  150554. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150555. */
  150556. export class ConvolutionPostProcess extends PostProcess {
  150557. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150558. kernel: number[];
  150559. /**
  150560. * Gets a string identifying the name of the class
  150561. * @returns "ConvolutionPostProcess" string
  150562. */
  150563. getClassName(): string;
  150564. /**
  150565. * Creates a new instance ConvolutionPostProcess
  150566. * @param name The name of the effect.
  150567. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150568. * @param options The required width/height ratio to downsize to before computing the render pass.
  150569. * @param camera The camera to apply the render pass to.
  150570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150571. * @param engine The engine which the post process will be applied. (default: current engine)
  150572. * @param reusable If the post process can be reused on the same frame. (default: false)
  150573. * @param textureType Type of textures used when performing the post process. (default: 0)
  150574. */
  150575. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150576. /** @hidden */
  150577. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150578. /**
  150579. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150580. */
  150581. static EdgeDetect0Kernel: number[];
  150582. /**
  150583. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150584. */
  150585. static EdgeDetect1Kernel: number[];
  150586. /**
  150587. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150588. */
  150589. static EdgeDetect2Kernel: number[];
  150590. /**
  150591. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150592. */
  150593. static SharpenKernel: number[];
  150594. /**
  150595. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150596. */
  150597. static EmbossKernel: number[];
  150598. /**
  150599. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150600. */
  150601. static GaussianKernel: number[];
  150602. }
  150603. }
  150604. declare module BABYLON {
  150605. /**
  150606. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150607. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150608. * based on samples that have a large difference in distance than the center pixel.
  150609. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150610. */
  150611. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150612. /**
  150613. * The direction the blur should be applied
  150614. */
  150615. direction: Vector2;
  150616. /**
  150617. * Gets a string identifying the name of the class
  150618. * @returns "DepthOfFieldBlurPostProcess" string
  150619. */
  150620. getClassName(): string;
  150621. /**
  150622. * Creates a new instance CircleOfConfusionPostProcess
  150623. * @param name The name of the effect.
  150624. * @param scene The scene the effect belongs to.
  150625. * @param direction The direction the blur should be applied.
  150626. * @param kernel The size of the kernel used to blur.
  150627. * @param options The required width/height ratio to downsize to before computing the render pass.
  150628. * @param camera The camera to apply the render pass to.
  150629. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150630. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150632. * @param engine The engine which the post process will be applied. (default: current engine)
  150633. * @param reusable If the post process can be reused on the same frame. (default: false)
  150634. * @param textureType Type of textures used when performing the post process. (default: 0)
  150635. * @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)
  150636. */
  150637. 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);
  150638. }
  150639. }
  150640. declare module BABYLON {
  150641. /** @hidden */
  150642. export var depthOfFieldMergePixelShader: {
  150643. name: string;
  150644. shader: string;
  150645. };
  150646. }
  150647. declare module BABYLON {
  150648. /**
  150649. * Options to be set when merging outputs from the default pipeline.
  150650. */
  150651. export class DepthOfFieldMergePostProcessOptions {
  150652. /**
  150653. * The original image to merge on top of
  150654. */
  150655. originalFromInput: PostProcess;
  150656. /**
  150657. * Parameters to perform the merge of the depth of field effect
  150658. */
  150659. depthOfField?: {
  150660. circleOfConfusion: PostProcess;
  150661. blurSteps: Array<PostProcess>;
  150662. };
  150663. /**
  150664. * Parameters to perform the merge of bloom effect
  150665. */
  150666. bloom?: {
  150667. blurred: PostProcess;
  150668. weight: number;
  150669. };
  150670. }
  150671. /**
  150672. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150673. */
  150674. export class DepthOfFieldMergePostProcess extends PostProcess {
  150675. private blurSteps;
  150676. /**
  150677. * Gets a string identifying the name of the class
  150678. * @returns "DepthOfFieldMergePostProcess" string
  150679. */
  150680. getClassName(): string;
  150681. /**
  150682. * Creates a new instance of DepthOfFieldMergePostProcess
  150683. * @param name The name of the effect.
  150684. * @param originalFromInput Post process which's input will be used for the merge.
  150685. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150686. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150687. * @param options The required width/height ratio to downsize to before computing the render pass.
  150688. * @param camera The camera to apply the render pass to.
  150689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150690. * @param engine The engine which the post process will be applied. (default: current engine)
  150691. * @param reusable If the post process can be reused on the same frame. (default: false)
  150692. * @param textureType Type of textures used when performing the post process. (default: 0)
  150693. * @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)
  150694. */
  150695. 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);
  150696. /**
  150697. * Updates the effect with the current post process compile time values and recompiles the shader.
  150698. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150699. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150700. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150701. * @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
  150702. * @param onCompiled Called when the shader has been compiled.
  150703. * @param onError Called if there is an error when compiling a shader.
  150704. */
  150705. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150706. }
  150707. }
  150708. declare module BABYLON {
  150709. /**
  150710. * Specifies the level of max blur that should be applied when using the depth of field effect
  150711. */
  150712. export enum DepthOfFieldEffectBlurLevel {
  150713. /**
  150714. * Subtle blur
  150715. */
  150716. Low = 0,
  150717. /**
  150718. * Medium blur
  150719. */
  150720. Medium = 1,
  150721. /**
  150722. * Large blur
  150723. */
  150724. High = 2
  150725. }
  150726. /**
  150727. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150728. */
  150729. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150730. private _circleOfConfusion;
  150731. /**
  150732. * @hidden Internal, blurs from high to low
  150733. */
  150734. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150735. private _depthOfFieldBlurY;
  150736. private _dofMerge;
  150737. /**
  150738. * @hidden Internal post processes in depth of field effect
  150739. */
  150740. _effects: Array<PostProcess>;
  150741. /**
  150742. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150743. */
  150744. set focalLength(value: number);
  150745. get focalLength(): number;
  150746. /**
  150747. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150748. */
  150749. set fStop(value: number);
  150750. get fStop(): number;
  150751. /**
  150752. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150753. */
  150754. set focusDistance(value: number);
  150755. get focusDistance(): number;
  150756. /**
  150757. * 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.
  150758. */
  150759. set lensSize(value: number);
  150760. get lensSize(): number;
  150761. /**
  150762. * Creates a new instance DepthOfFieldEffect
  150763. * @param scene The scene the effect belongs to.
  150764. * @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.
  150765. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150766. * @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)
  150767. */
  150768. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150769. /**
  150770. * Get the current class name of the current effet
  150771. * @returns "DepthOfFieldEffect"
  150772. */
  150773. getClassName(): string;
  150774. /**
  150775. * 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.
  150776. */
  150777. set depthTexture(value: RenderTargetTexture);
  150778. /**
  150779. * Disposes each of the internal effects for a given camera.
  150780. * @param camera The camera to dispose the effect on.
  150781. */
  150782. disposeEffects(camera: Camera): void;
  150783. /**
  150784. * @hidden Internal
  150785. */
  150786. _updateEffects(): void;
  150787. /**
  150788. * Internal
  150789. * @returns if all the contained post processes are ready.
  150790. * @hidden
  150791. */
  150792. _isReady(): boolean;
  150793. }
  150794. }
  150795. declare module BABYLON {
  150796. /** @hidden */
  150797. export var displayPassPixelShader: {
  150798. name: string;
  150799. shader: string;
  150800. };
  150801. }
  150802. declare module BABYLON {
  150803. /**
  150804. * DisplayPassPostProcess which produces an output the same as it's input
  150805. */
  150806. export class DisplayPassPostProcess extends PostProcess {
  150807. /**
  150808. * Gets a string identifying the name of the class
  150809. * @returns "DisplayPassPostProcess" string
  150810. */
  150811. getClassName(): string;
  150812. /**
  150813. * Creates the DisplayPassPostProcess
  150814. * @param name The name of the effect.
  150815. * @param options The required width/height ratio to downsize to before computing the render pass.
  150816. * @param camera The camera to apply the render pass to.
  150817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150818. * @param engine The engine which the post process will be applied. (default: current engine)
  150819. * @param reusable If the post process can be reused on the same frame. (default: false)
  150820. */
  150821. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150822. /** @hidden */
  150823. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150824. }
  150825. }
  150826. declare module BABYLON {
  150827. /** @hidden */
  150828. export var filterPixelShader: {
  150829. name: string;
  150830. shader: string;
  150831. };
  150832. }
  150833. declare module BABYLON {
  150834. /**
  150835. * Applies a kernel filter to the image
  150836. */
  150837. export class FilterPostProcess extends PostProcess {
  150838. /** The matrix to be applied to the image */
  150839. kernelMatrix: Matrix;
  150840. /**
  150841. * Gets a string identifying the name of the class
  150842. * @returns "FilterPostProcess" string
  150843. */
  150844. getClassName(): string;
  150845. /**
  150846. *
  150847. * @param name The name of the effect.
  150848. * @param kernelMatrix The matrix to be applied to the image
  150849. * @param options The required width/height ratio to downsize to before computing the render pass.
  150850. * @param camera The camera to apply the render pass to.
  150851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150852. * @param engine The engine which the post process will be applied. (default: current engine)
  150853. * @param reusable If the post process can be reused on the same frame. (default: false)
  150854. */
  150855. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150856. /** @hidden */
  150857. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150858. }
  150859. }
  150860. declare module BABYLON {
  150861. /** @hidden */
  150862. export var fxaaPixelShader: {
  150863. name: string;
  150864. shader: string;
  150865. };
  150866. }
  150867. declare module BABYLON {
  150868. /** @hidden */
  150869. export var fxaaVertexShader: {
  150870. name: string;
  150871. shader: string;
  150872. };
  150873. }
  150874. declare module BABYLON {
  150875. /**
  150876. * Fxaa post process
  150877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150878. */
  150879. export class FxaaPostProcess extends PostProcess {
  150880. /**
  150881. * Gets a string identifying the name of the class
  150882. * @returns "FxaaPostProcess" string
  150883. */
  150884. getClassName(): string;
  150885. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150886. private _getDefines;
  150887. /** @hidden */
  150888. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150889. }
  150890. }
  150891. declare module BABYLON {
  150892. /** @hidden */
  150893. export var grainPixelShader: {
  150894. name: string;
  150895. shader: string;
  150896. };
  150897. }
  150898. declare module BABYLON {
  150899. /**
  150900. * The GrainPostProcess adds noise to the image at mid luminance levels
  150901. */
  150902. export class GrainPostProcess extends PostProcess {
  150903. /**
  150904. * The intensity of the grain added (default: 30)
  150905. */
  150906. intensity: number;
  150907. /**
  150908. * If the grain should be randomized on every frame
  150909. */
  150910. animated: boolean;
  150911. /**
  150912. * Gets a string identifying the name of the class
  150913. * @returns "GrainPostProcess" string
  150914. */
  150915. getClassName(): string;
  150916. /**
  150917. * Creates a new instance of @see GrainPostProcess
  150918. * @param name The name of the effect.
  150919. * @param options The required width/height ratio to downsize to before computing the render pass.
  150920. * @param camera The camera to apply the render pass to.
  150921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150922. * @param engine The engine which the post process will be applied. (default: current engine)
  150923. * @param reusable If the post process can be reused on the same frame. (default: false)
  150924. * @param textureType Type of textures used when performing the post process. (default: 0)
  150925. * @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)
  150926. */
  150927. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150928. /** @hidden */
  150929. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150930. }
  150931. }
  150932. declare module BABYLON {
  150933. /** @hidden */
  150934. export var highlightsPixelShader: {
  150935. name: string;
  150936. shader: string;
  150937. };
  150938. }
  150939. declare module BABYLON {
  150940. /**
  150941. * Extracts highlights from the image
  150942. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150943. */
  150944. export class HighlightsPostProcess extends PostProcess {
  150945. /**
  150946. * Gets a string identifying the name of the class
  150947. * @returns "HighlightsPostProcess" string
  150948. */
  150949. getClassName(): string;
  150950. /**
  150951. * Extracts highlights from the image
  150952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150953. * @param name The name of the effect.
  150954. * @param options The required width/height ratio to downsize to before computing the render pass.
  150955. * @param camera The camera to apply the render pass to.
  150956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150957. * @param engine The engine which the post process will be applied. (default: current engine)
  150958. * @param reusable If the post process can be reused on the same frame. (default: false)
  150959. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150960. */
  150961. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150962. }
  150963. }
  150964. declare module BABYLON {
  150965. /**
  150966. * Contains all parameters needed for the prepass to perform
  150967. * motion blur
  150968. */
  150969. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  150970. /**
  150971. * Is motion blur enabled
  150972. */
  150973. enabled: boolean;
  150974. /**
  150975. * Name of the configuration
  150976. */
  150977. name: string;
  150978. /**
  150979. * Textures that should be present in the MRT for this effect to work
  150980. */
  150981. readonly texturesRequired: number[];
  150982. }
  150983. }
  150984. declare module BABYLON {
  150985. interface Scene {
  150986. /** @hidden (Backing field) */
  150987. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150988. /**
  150989. * Gets or Sets the current geometry buffer associated to the scene.
  150990. */
  150991. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150992. /**
  150993. * Enables a GeometryBufferRender and associates it with the scene
  150994. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150995. * @returns the GeometryBufferRenderer
  150996. */
  150997. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150998. /**
  150999. * Disables the GeometryBufferRender associated with the scene
  151000. */
  151001. disableGeometryBufferRenderer(): void;
  151002. }
  151003. /**
  151004. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151005. * in several rendering techniques.
  151006. */
  151007. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151008. /**
  151009. * The component name helpful to identify the component in the list of scene components.
  151010. */
  151011. readonly name: string;
  151012. /**
  151013. * The scene the component belongs to.
  151014. */
  151015. scene: Scene;
  151016. /**
  151017. * Creates a new instance of the component for the given scene
  151018. * @param scene Defines the scene to register the component in
  151019. */
  151020. constructor(scene: Scene);
  151021. /**
  151022. * Registers the component in a given scene
  151023. */
  151024. register(): void;
  151025. /**
  151026. * Rebuilds the elements related to this component in case of
  151027. * context lost for instance.
  151028. */
  151029. rebuild(): void;
  151030. /**
  151031. * Disposes the component and the associated ressources
  151032. */
  151033. dispose(): void;
  151034. private _gatherRenderTargets;
  151035. }
  151036. }
  151037. declare module BABYLON {
  151038. /** @hidden */
  151039. export var motionBlurPixelShader: {
  151040. name: string;
  151041. shader: string;
  151042. };
  151043. }
  151044. declare module BABYLON {
  151045. /**
  151046. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151047. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151048. * As an example, all you have to do is to create the post-process:
  151049. * var mb = new BABYLON.MotionBlurPostProcess(
  151050. * 'mb', // The name of the effect.
  151051. * scene, // The scene containing the objects to blur according to their velocity.
  151052. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151053. * camera // The camera to apply the render pass to.
  151054. * );
  151055. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151056. */
  151057. export class MotionBlurPostProcess extends PostProcess {
  151058. /**
  151059. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151060. */
  151061. motionStrength: number;
  151062. /**
  151063. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151064. */
  151065. get motionBlurSamples(): number;
  151066. /**
  151067. * Sets the number of iterations to be used for motion blur quality
  151068. */
  151069. set motionBlurSamples(samples: number);
  151070. private _motionBlurSamples;
  151071. private _forceGeometryBuffer;
  151072. private _geometryBufferRenderer;
  151073. private _prePassRenderer;
  151074. /**
  151075. * Gets a string identifying the name of the class
  151076. * @returns "MotionBlurPostProcess" string
  151077. */
  151078. getClassName(): string;
  151079. /**
  151080. * Creates a new instance MotionBlurPostProcess
  151081. * @param name The name of the effect.
  151082. * @param scene The scene containing the objects to blur according to their velocity.
  151083. * @param options The required width/height ratio to downsize to before computing the render pass.
  151084. * @param camera The camera to apply the render pass to.
  151085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151086. * @param engine The engine which the post process will be applied. (default: current engine)
  151087. * @param reusable If the post process can be reused on the same frame. (default: false)
  151088. * @param textureType Type of textures used when performing the post process. (default: 0)
  151089. * @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)
  151090. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151091. */
  151092. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151093. /**
  151094. * Excludes the given skinned mesh from computing bones velocities.
  151095. * 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.
  151096. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151097. */
  151098. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151099. /**
  151100. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151101. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151102. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151103. */
  151104. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151105. /**
  151106. * Disposes the post process.
  151107. * @param camera The camera to dispose the post process on.
  151108. */
  151109. dispose(camera?: Camera): void;
  151110. /** @hidden */
  151111. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151112. }
  151113. }
  151114. declare module BABYLON {
  151115. /** @hidden */
  151116. export var refractionPixelShader: {
  151117. name: string;
  151118. shader: string;
  151119. };
  151120. }
  151121. declare module BABYLON {
  151122. /**
  151123. * Post process which applies a refractin texture
  151124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151125. */
  151126. export class RefractionPostProcess extends PostProcess {
  151127. private _refTexture;
  151128. private _ownRefractionTexture;
  151129. /** the base color of the refraction (used to taint the rendering) */
  151130. color: Color3;
  151131. /** simulated refraction depth */
  151132. depth: number;
  151133. /** the coefficient of the base color (0 to remove base color tainting) */
  151134. colorLevel: number;
  151135. /** Gets the url used to load the refraction texture */
  151136. refractionTextureUrl: string;
  151137. /**
  151138. * Gets or sets the refraction texture
  151139. * Please note that you are responsible for disposing the texture if you set it manually
  151140. */
  151141. get refractionTexture(): Texture;
  151142. set refractionTexture(value: Texture);
  151143. /**
  151144. * Gets a string identifying the name of the class
  151145. * @returns "RefractionPostProcess" string
  151146. */
  151147. getClassName(): string;
  151148. /**
  151149. * Initializes the RefractionPostProcess
  151150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151151. * @param name The name of the effect.
  151152. * @param refractionTextureUrl Url of the refraction texture to use
  151153. * @param color the base color of the refraction (used to taint the rendering)
  151154. * @param depth simulated refraction depth
  151155. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151156. * @param camera The camera to apply the render pass to.
  151157. * @param options The required width/height ratio to downsize to before computing the render pass.
  151158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151159. * @param engine The engine which the post process will be applied. (default: current engine)
  151160. * @param reusable If the post process can be reused on the same frame. (default: false)
  151161. */
  151162. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151163. /**
  151164. * Disposes of the post process
  151165. * @param camera Camera to dispose post process on
  151166. */
  151167. dispose(camera: Camera): void;
  151168. /** @hidden */
  151169. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151170. }
  151171. }
  151172. declare module BABYLON {
  151173. /** @hidden */
  151174. export var sharpenPixelShader: {
  151175. name: string;
  151176. shader: string;
  151177. };
  151178. }
  151179. declare module BABYLON {
  151180. /**
  151181. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151182. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151183. */
  151184. export class SharpenPostProcess extends PostProcess {
  151185. /**
  151186. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151187. */
  151188. colorAmount: number;
  151189. /**
  151190. * How much sharpness should be applied (default: 0.3)
  151191. */
  151192. edgeAmount: number;
  151193. /**
  151194. * Gets a string identifying the name of the class
  151195. * @returns "SharpenPostProcess" string
  151196. */
  151197. getClassName(): string;
  151198. /**
  151199. * Creates a new instance ConvolutionPostProcess
  151200. * @param name The name of the effect.
  151201. * @param options The required width/height ratio to downsize to before computing the render pass.
  151202. * @param camera The camera to apply the render pass to.
  151203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151204. * @param engine The engine which the post process will be applied. (default: current engine)
  151205. * @param reusable If the post process can be reused on the same frame. (default: false)
  151206. * @param textureType Type of textures used when performing the post process. (default: 0)
  151207. * @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)
  151208. */
  151209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151210. /** @hidden */
  151211. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151212. }
  151213. }
  151214. declare module BABYLON {
  151215. /**
  151216. * PostProcessRenderPipeline
  151217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151218. */
  151219. export class PostProcessRenderPipeline {
  151220. private engine;
  151221. private _renderEffects;
  151222. private _renderEffectsForIsolatedPass;
  151223. /**
  151224. * List of inspectable custom properties (used by the Inspector)
  151225. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151226. */
  151227. inspectableCustomProperties: IInspectable[];
  151228. /**
  151229. * @hidden
  151230. */
  151231. protected _cameras: Camera[];
  151232. /** @hidden */
  151233. _name: string;
  151234. /**
  151235. * Gets pipeline name
  151236. */
  151237. get name(): string;
  151238. /** Gets the list of attached cameras */
  151239. get cameras(): Camera[];
  151240. /**
  151241. * Initializes a PostProcessRenderPipeline
  151242. * @param engine engine to add the pipeline to
  151243. * @param name name of the pipeline
  151244. */
  151245. constructor(engine: Engine, name: string);
  151246. /**
  151247. * Gets the class name
  151248. * @returns "PostProcessRenderPipeline"
  151249. */
  151250. getClassName(): string;
  151251. /**
  151252. * If all the render effects in the pipeline are supported
  151253. */
  151254. get isSupported(): boolean;
  151255. /**
  151256. * Adds an effect to the pipeline
  151257. * @param renderEffect the effect to add
  151258. */
  151259. addEffect(renderEffect: PostProcessRenderEffect): void;
  151260. /** @hidden */
  151261. _rebuild(): void;
  151262. /** @hidden */
  151263. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151264. /** @hidden */
  151265. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151266. /** @hidden */
  151267. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151268. /** @hidden */
  151269. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151270. /** @hidden */
  151271. _attachCameras(cameras: Camera, unique: boolean): void;
  151272. /** @hidden */
  151273. _attachCameras(cameras: Camera[], unique: boolean): void;
  151274. /** @hidden */
  151275. _detachCameras(cameras: Camera): void;
  151276. /** @hidden */
  151277. _detachCameras(cameras: Nullable<Camera[]>): void;
  151278. /** @hidden */
  151279. _update(): void;
  151280. /** @hidden */
  151281. _reset(): void;
  151282. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151283. /**
  151284. * Sets the required values to the prepass renderer.
  151285. * @param prePassRenderer defines the prepass renderer to setup.
  151286. * @returns true if the pre pass is needed.
  151287. */
  151288. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151289. /**
  151290. * Disposes of the pipeline
  151291. */
  151292. dispose(): void;
  151293. }
  151294. }
  151295. declare module BABYLON {
  151296. /**
  151297. * PostProcessRenderPipelineManager class
  151298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151299. */
  151300. export class PostProcessRenderPipelineManager {
  151301. private _renderPipelines;
  151302. /**
  151303. * Initializes a PostProcessRenderPipelineManager
  151304. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151305. */
  151306. constructor();
  151307. /**
  151308. * Gets the list of supported render pipelines
  151309. */
  151310. get supportedPipelines(): PostProcessRenderPipeline[];
  151311. /**
  151312. * Adds a pipeline to the manager
  151313. * @param renderPipeline The pipeline to add
  151314. */
  151315. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151316. /**
  151317. * Attaches a camera to the pipeline
  151318. * @param renderPipelineName The name of the pipeline to attach to
  151319. * @param cameras the camera to attach
  151320. * @param unique if the camera can be attached multiple times to the pipeline
  151321. */
  151322. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151323. /**
  151324. * Detaches a camera from the pipeline
  151325. * @param renderPipelineName The name of the pipeline to detach from
  151326. * @param cameras the camera to detach
  151327. */
  151328. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151329. /**
  151330. * Enables an effect by name on a pipeline
  151331. * @param renderPipelineName the name of the pipeline to enable the effect in
  151332. * @param renderEffectName the name of the effect to enable
  151333. * @param cameras the cameras that the effect should be enabled on
  151334. */
  151335. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151336. /**
  151337. * Disables an effect by name on a pipeline
  151338. * @param renderPipelineName the name of the pipeline to disable the effect in
  151339. * @param renderEffectName the name of the effect to disable
  151340. * @param cameras the cameras that the effect should be disabled on
  151341. */
  151342. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151343. /**
  151344. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151345. */
  151346. update(): void;
  151347. /** @hidden */
  151348. _rebuild(): void;
  151349. /**
  151350. * Disposes of the manager and pipelines
  151351. */
  151352. dispose(): void;
  151353. }
  151354. }
  151355. declare module BABYLON {
  151356. interface Scene {
  151357. /** @hidden (Backing field) */
  151358. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151359. /**
  151360. * Gets the postprocess render pipeline manager
  151361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151362. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151363. */
  151364. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151365. }
  151366. /**
  151367. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151368. */
  151369. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151370. /**
  151371. * The component name helpfull to identify the component in the list of scene components.
  151372. */
  151373. readonly name: string;
  151374. /**
  151375. * The scene the component belongs to.
  151376. */
  151377. scene: Scene;
  151378. /**
  151379. * Creates a new instance of the component for the given scene
  151380. * @param scene Defines the scene to register the component in
  151381. */
  151382. constructor(scene: Scene);
  151383. /**
  151384. * Registers the component in a given scene
  151385. */
  151386. register(): void;
  151387. /**
  151388. * Rebuilds the elements related to this component in case of
  151389. * context lost for instance.
  151390. */
  151391. rebuild(): void;
  151392. /**
  151393. * Disposes the component and the associated ressources
  151394. */
  151395. dispose(): void;
  151396. private _gatherRenderTargets;
  151397. }
  151398. }
  151399. declare module BABYLON {
  151400. /**
  151401. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151402. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151403. */
  151404. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151405. private _scene;
  151406. private _camerasToBeAttached;
  151407. /**
  151408. * ID of the sharpen post process,
  151409. */
  151410. private readonly SharpenPostProcessId;
  151411. /**
  151412. * @ignore
  151413. * ID of the image processing post process;
  151414. */
  151415. readonly ImageProcessingPostProcessId: string;
  151416. /**
  151417. * @ignore
  151418. * ID of the Fast Approximate Anti-Aliasing post process;
  151419. */
  151420. readonly FxaaPostProcessId: string;
  151421. /**
  151422. * ID of the chromatic aberration post process,
  151423. */
  151424. private readonly ChromaticAberrationPostProcessId;
  151425. /**
  151426. * ID of the grain post process
  151427. */
  151428. private readonly GrainPostProcessId;
  151429. /**
  151430. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151431. */
  151432. sharpen: SharpenPostProcess;
  151433. private _sharpenEffect;
  151434. private bloom;
  151435. /**
  151436. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151437. */
  151438. depthOfField: DepthOfFieldEffect;
  151439. /**
  151440. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151441. */
  151442. fxaa: FxaaPostProcess;
  151443. /**
  151444. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151445. */
  151446. imageProcessing: ImageProcessingPostProcess;
  151447. /**
  151448. * Chromatic aberration post process which will shift rgb colors in the image
  151449. */
  151450. chromaticAberration: ChromaticAberrationPostProcess;
  151451. private _chromaticAberrationEffect;
  151452. /**
  151453. * Grain post process which add noise to the image
  151454. */
  151455. grain: GrainPostProcess;
  151456. private _grainEffect;
  151457. /**
  151458. * Glow post process which adds a glow to emissive areas of the image
  151459. */
  151460. private _glowLayer;
  151461. /**
  151462. * Animations which can be used to tweak settings over a period of time
  151463. */
  151464. animations: Animation[];
  151465. private _imageProcessingConfigurationObserver;
  151466. private _sharpenEnabled;
  151467. private _bloomEnabled;
  151468. private _depthOfFieldEnabled;
  151469. private _depthOfFieldBlurLevel;
  151470. private _fxaaEnabled;
  151471. private _imageProcessingEnabled;
  151472. private _defaultPipelineTextureType;
  151473. private _bloomScale;
  151474. private _chromaticAberrationEnabled;
  151475. private _grainEnabled;
  151476. private _buildAllowed;
  151477. /**
  151478. * Gets active scene
  151479. */
  151480. get scene(): Scene;
  151481. /**
  151482. * Enable or disable the sharpen process from the pipeline
  151483. */
  151484. set sharpenEnabled(enabled: boolean);
  151485. get sharpenEnabled(): boolean;
  151486. private _resizeObserver;
  151487. private _hardwareScaleLevel;
  151488. private _bloomKernel;
  151489. /**
  151490. * Specifies the size of the bloom blur kernel, relative to the final output size
  151491. */
  151492. get bloomKernel(): number;
  151493. set bloomKernel(value: number);
  151494. /**
  151495. * Specifies the weight of the bloom in the final rendering
  151496. */
  151497. private _bloomWeight;
  151498. /**
  151499. * Specifies the luma threshold for the area that will be blurred by the bloom
  151500. */
  151501. private _bloomThreshold;
  151502. private _hdr;
  151503. /**
  151504. * The strength of the bloom.
  151505. */
  151506. set bloomWeight(value: number);
  151507. get bloomWeight(): number;
  151508. /**
  151509. * The strength of the bloom.
  151510. */
  151511. set bloomThreshold(value: number);
  151512. get bloomThreshold(): number;
  151513. /**
  151514. * The scale of the bloom, lower value will provide better performance.
  151515. */
  151516. set bloomScale(value: number);
  151517. get bloomScale(): number;
  151518. /**
  151519. * Enable or disable the bloom from the pipeline
  151520. */
  151521. set bloomEnabled(enabled: boolean);
  151522. get bloomEnabled(): boolean;
  151523. private _rebuildBloom;
  151524. /**
  151525. * If the depth of field is enabled.
  151526. */
  151527. get depthOfFieldEnabled(): boolean;
  151528. set depthOfFieldEnabled(enabled: boolean);
  151529. /**
  151530. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151531. */
  151532. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151533. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151534. /**
  151535. * If the anti aliasing is enabled.
  151536. */
  151537. set fxaaEnabled(enabled: boolean);
  151538. get fxaaEnabled(): boolean;
  151539. private _samples;
  151540. /**
  151541. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151542. */
  151543. set samples(sampleCount: number);
  151544. get samples(): number;
  151545. /**
  151546. * If image processing is enabled.
  151547. */
  151548. set imageProcessingEnabled(enabled: boolean);
  151549. get imageProcessingEnabled(): boolean;
  151550. /**
  151551. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151552. */
  151553. set glowLayerEnabled(enabled: boolean);
  151554. get glowLayerEnabled(): boolean;
  151555. /**
  151556. * Gets the glow layer (or null if not defined)
  151557. */
  151558. get glowLayer(): Nullable<GlowLayer>;
  151559. /**
  151560. * Enable or disable the chromaticAberration process from the pipeline
  151561. */
  151562. set chromaticAberrationEnabled(enabled: boolean);
  151563. get chromaticAberrationEnabled(): boolean;
  151564. /**
  151565. * Enable or disable the grain process from the pipeline
  151566. */
  151567. set grainEnabled(enabled: boolean);
  151568. get grainEnabled(): boolean;
  151569. /**
  151570. * @constructor
  151571. * @param name - The rendering pipeline name (default: "")
  151572. * @param hdr - If high dynamic range textures should be used (default: true)
  151573. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151574. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151575. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151576. */
  151577. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151578. /**
  151579. * Get the class name
  151580. * @returns "DefaultRenderingPipeline"
  151581. */
  151582. getClassName(): string;
  151583. /**
  151584. * Force the compilation of the entire pipeline.
  151585. */
  151586. prepare(): void;
  151587. private _hasCleared;
  151588. private _prevPostProcess;
  151589. private _prevPrevPostProcess;
  151590. private _setAutoClearAndTextureSharing;
  151591. private _depthOfFieldSceneObserver;
  151592. private _buildPipeline;
  151593. private _disposePostProcesses;
  151594. /**
  151595. * Adds a camera to the pipeline
  151596. * @param camera the camera to be added
  151597. */
  151598. addCamera(camera: Camera): void;
  151599. /**
  151600. * Removes a camera from the pipeline
  151601. * @param camera the camera to remove
  151602. */
  151603. removeCamera(camera: Camera): void;
  151604. /**
  151605. * Dispose of the pipeline and stop all post processes
  151606. */
  151607. dispose(): void;
  151608. /**
  151609. * Serialize the rendering pipeline (Used when exporting)
  151610. * @returns the serialized object
  151611. */
  151612. serialize(): any;
  151613. /**
  151614. * Parse the serialized pipeline
  151615. * @param source Source pipeline.
  151616. * @param scene The scene to load the pipeline to.
  151617. * @param rootUrl The URL of the serialized pipeline.
  151618. * @returns An instantiated pipeline from the serialized object.
  151619. */
  151620. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151621. }
  151622. }
  151623. declare module BABYLON {
  151624. /** @hidden */
  151625. export var lensHighlightsPixelShader: {
  151626. name: string;
  151627. shader: string;
  151628. };
  151629. }
  151630. declare module BABYLON {
  151631. /** @hidden */
  151632. export var depthOfFieldPixelShader: {
  151633. name: string;
  151634. shader: string;
  151635. };
  151636. }
  151637. declare module BABYLON {
  151638. /**
  151639. * BABYLON.JS Chromatic Aberration GLSL Shader
  151640. * Author: Olivier Guyot
  151641. * Separates very slightly R, G and B colors on the edges of the screen
  151642. * Inspired by Francois Tarlier & Martins Upitis
  151643. */
  151644. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151645. /**
  151646. * @ignore
  151647. * The chromatic aberration PostProcess id in the pipeline
  151648. */
  151649. LensChromaticAberrationEffect: string;
  151650. /**
  151651. * @ignore
  151652. * The highlights enhancing PostProcess id in the pipeline
  151653. */
  151654. HighlightsEnhancingEffect: string;
  151655. /**
  151656. * @ignore
  151657. * The depth-of-field PostProcess id in the pipeline
  151658. */
  151659. LensDepthOfFieldEffect: string;
  151660. private _scene;
  151661. private _depthTexture;
  151662. private _grainTexture;
  151663. private _chromaticAberrationPostProcess;
  151664. private _highlightsPostProcess;
  151665. private _depthOfFieldPostProcess;
  151666. private _edgeBlur;
  151667. private _grainAmount;
  151668. private _chromaticAberration;
  151669. private _distortion;
  151670. private _highlightsGain;
  151671. private _highlightsThreshold;
  151672. private _dofDistance;
  151673. private _dofAperture;
  151674. private _dofDarken;
  151675. private _dofPentagon;
  151676. private _blurNoise;
  151677. /**
  151678. * @constructor
  151679. *
  151680. * Effect parameters are as follow:
  151681. * {
  151682. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151683. * edge_blur: number; // from 0 to x (1 for realism)
  151684. * distortion: number; // from 0 to x (1 for realism)
  151685. * grain_amount: number; // from 0 to 1
  151686. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151687. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151688. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151689. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151690. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151691. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151692. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151693. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151694. * }
  151695. * Note: if an effect parameter is unset, effect is disabled
  151696. *
  151697. * @param name The rendering pipeline name
  151698. * @param parameters - An object containing all parameters (see above)
  151699. * @param scene The scene linked to this pipeline
  151700. * @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)
  151701. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151702. */
  151703. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151704. /**
  151705. * Get the class name
  151706. * @returns "LensRenderingPipeline"
  151707. */
  151708. getClassName(): string;
  151709. /**
  151710. * Gets associated scene
  151711. */
  151712. get scene(): Scene;
  151713. /**
  151714. * Gets or sets the edge blur
  151715. */
  151716. get edgeBlur(): number;
  151717. set edgeBlur(value: number);
  151718. /**
  151719. * Gets or sets the grain amount
  151720. */
  151721. get grainAmount(): number;
  151722. set grainAmount(value: number);
  151723. /**
  151724. * Gets or sets the chromatic aberration amount
  151725. */
  151726. get chromaticAberration(): number;
  151727. set chromaticAberration(value: number);
  151728. /**
  151729. * Gets or sets the depth of field aperture
  151730. */
  151731. get dofAperture(): number;
  151732. set dofAperture(value: number);
  151733. /**
  151734. * Gets or sets the edge distortion
  151735. */
  151736. get edgeDistortion(): number;
  151737. set edgeDistortion(value: number);
  151738. /**
  151739. * Gets or sets the depth of field distortion
  151740. */
  151741. get dofDistortion(): number;
  151742. set dofDistortion(value: number);
  151743. /**
  151744. * Gets or sets the darken out of focus amount
  151745. */
  151746. get darkenOutOfFocus(): number;
  151747. set darkenOutOfFocus(value: number);
  151748. /**
  151749. * Gets or sets a boolean indicating if blur noise is enabled
  151750. */
  151751. get blurNoise(): boolean;
  151752. set blurNoise(value: boolean);
  151753. /**
  151754. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151755. */
  151756. get pentagonBokeh(): boolean;
  151757. set pentagonBokeh(value: boolean);
  151758. /**
  151759. * Gets or sets the highlight grain amount
  151760. */
  151761. get highlightsGain(): number;
  151762. set highlightsGain(value: number);
  151763. /**
  151764. * Gets or sets the highlight threshold
  151765. */
  151766. get highlightsThreshold(): number;
  151767. set highlightsThreshold(value: number);
  151768. /**
  151769. * Sets the amount of blur at the edges
  151770. * @param amount blur amount
  151771. */
  151772. setEdgeBlur(amount: number): void;
  151773. /**
  151774. * Sets edge blur to 0
  151775. */
  151776. disableEdgeBlur(): void;
  151777. /**
  151778. * Sets the amout of grain
  151779. * @param amount Amount of grain
  151780. */
  151781. setGrainAmount(amount: number): void;
  151782. /**
  151783. * Set grain amount to 0
  151784. */
  151785. disableGrain(): void;
  151786. /**
  151787. * Sets the chromatic aberration amount
  151788. * @param amount amount of chromatic aberration
  151789. */
  151790. setChromaticAberration(amount: number): void;
  151791. /**
  151792. * Sets chromatic aberration amount to 0
  151793. */
  151794. disableChromaticAberration(): void;
  151795. /**
  151796. * Sets the EdgeDistortion amount
  151797. * @param amount amount of EdgeDistortion
  151798. */
  151799. setEdgeDistortion(amount: number): void;
  151800. /**
  151801. * Sets edge distortion to 0
  151802. */
  151803. disableEdgeDistortion(): void;
  151804. /**
  151805. * Sets the FocusDistance amount
  151806. * @param amount amount of FocusDistance
  151807. */
  151808. setFocusDistance(amount: number): void;
  151809. /**
  151810. * Disables depth of field
  151811. */
  151812. disableDepthOfField(): void;
  151813. /**
  151814. * Sets the Aperture amount
  151815. * @param amount amount of Aperture
  151816. */
  151817. setAperture(amount: number): void;
  151818. /**
  151819. * Sets the DarkenOutOfFocus amount
  151820. * @param amount amount of DarkenOutOfFocus
  151821. */
  151822. setDarkenOutOfFocus(amount: number): void;
  151823. private _pentagonBokehIsEnabled;
  151824. /**
  151825. * Creates a pentagon bokeh effect
  151826. */
  151827. enablePentagonBokeh(): void;
  151828. /**
  151829. * Disables the pentagon bokeh effect
  151830. */
  151831. disablePentagonBokeh(): void;
  151832. /**
  151833. * Enables noise blur
  151834. */
  151835. enableNoiseBlur(): void;
  151836. /**
  151837. * Disables noise blur
  151838. */
  151839. disableNoiseBlur(): void;
  151840. /**
  151841. * Sets the HighlightsGain amount
  151842. * @param amount amount of HighlightsGain
  151843. */
  151844. setHighlightsGain(amount: number): void;
  151845. /**
  151846. * Sets the HighlightsThreshold amount
  151847. * @param amount amount of HighlightsThreshold
  151848. */
  151849. setHighlightsThreshold(amount: number): void;
  151850. /**
  151851. * Disables highlights
  151852. */
  151853. disableHighlights(): void;
  151854. /**
  151855. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151856. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151857. */
  151858. dispose(disableDepthRender?: boolean): void;
  151859. private _createChromaticAberrationPostProcess;
  151860. private _createHighlightsPostProcess;
  151861. private _createDepthOfFieldPostProcess;
  151862. private _createGrainTexture;
  151863. }
  151864. }
  151865. declare module BABYLON {
  151866. /**
  151867. * Contains all parameters needed for the prepass to perform
  151868. * screen space subsurface scattering
  151869. */
  151870. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151871. /**
  151872. * Is subsurface enabled
  151873. */
  151874. enabled: boolean;
  151875. /**
  151876. * Name of the configuration
  151877. */
  151878. name: string;
  151879. /**
  151880. * Textures that should be present in the MRT for this effect to work
  151881. */
  151882. readonly texturesRequired: number[];
  151883. }
  151884. }
  151885. declare module BABYLON {
  151886. /** @hidden */
  151887. export var ssao2PixelShader: {
  151888. name: string;
  151889. shader: string;
  151890. };
  151891. }
  151892. declare module BABYLON {
  151893. /** @hidden */
  151894. export var ssaoCombinePixelShader: {
  151895. name: string;
  151896. shader: string;
  151897. };
  151898. }
  151899. declare module BABYLON {
  151900. /**
  151901. * Render pipeline to produce ssao effect
  151902. */
  151903. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151904. /**
  151905. * @ignore
  151906. * The PassPostProcess id in the pipeline that contains the original scene color
  151907. */
  151908. SSAOOriginalSceneColorEffect: string;
  151909. /**
  151910. * @ignore
  151911. * The SSAO PostProcess id in the pipeline
  151912. */
  151913. SSAORenderEffect: string;
  151914. /**
  151915. * @ignore
  151916. * The horizontal blur PostProcess id in the pipeline
  151917. */
  151918. SSAOBlurHRenderEffect: string;
  151919. /**
  151920. * @ignore
  151921. * The vertical blur PostProcess id in the pipeline
  151922. */
  151923. SSAOBlurVRenderEffect: string;
  151924. /**
  151925. * @ignore
  151926. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151927. */
  151928. SSAOCombineRenderEffect: string;
  151929. /**
  151930. * The output strength of the SSAO post-process. Default value is 1.0.
  151931. */
  151932. totalStrength: number;
  151933. /**
  151934. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151935. */
  151936. maxZ: number;
  151937. /**
  151938. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151939. */
  151940. minZAspect: number;
  151941. private _samples;
  151942. /**
  151943. * Number of samples used for the SSAO calculations. Default value is 8
  151944. */
  151945. set samples(n: number);
  151946. get samples(): number;
  151947. private _textureSamples;
  151948. /**
  151949. * Number of samples to use for antialiasing
  151950. */
  151951. set textureSamples(n: number);
  151952. get textureSamples(): number;
  151953. /**
  151954. * Force rendering the geometry through geometry buffer
  151955. */
  151956. private _forceGeometryBuffer;
  151957. /**
  151958. * Ratio object used for SSAO ratio and blur ratio
  151959. */
  151960. private _ratio;
  151961. /**
  151962. * Dynamically generated sphere sampler.
  151963. */
  151964. private _sampleSphere;
  151965. /**
  151966. * Blur filter offsets
  151967. */
  151968. private _samplerOffsets;
  151969. private _expensiveBlur;
  151970. /**
  151971. * If bilateral blur should be used
  151972. */
  151973. set expensiveBlur(b: boolean);
  151974. get expensiveBlur(): boolean;
  151975. /**
  151976. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151977. */
  151978. radius: number;
  151979. /**
  151980. * The base color of the SSAO post-process
  151981. * The final result is "base + ssao" between [0, 1]
  151982. */
  151983. base: number;
  151984. /**
  151985. * Support test.
  151986. */
  151987. static get IsSupported(): boolean;
  151988. private _scene;
  151989. private _randomTexture;
  151990. private _originalColorPostProcess;
  151991. private _ssaoPostProcess;
  151992. private _blurHPostProcess;
  151993. private _blurVPostProcess;
  151994. private _ssaoCombinePostProcess;
  151995. private _prePassRenderer;
  151996. /**
  151997. * Gets active scene
  151998. */
  151999. get scene(): Scene;
  152000. /**
  152001. * @constructor
  152002. * @param name The rendering pipeline name
  152003. * @param scene The scene linked to this pipeline
  152004. * @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 }
  152005. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152006. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152007. */
  152008. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152009. /**
  152010. * Get the class name
  152011. * @returns "SSAO2RenderingPipeline"
  152012. */
  152013. getClassName(): string;
  152014. /**
  152015. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152016. */
  152017. dispose(disableGeometryBufferRenderer?: boolean): void;
  152018. private _createBlurPostProcess;
  152019. /** @hidden */
  152020. _rebuild(): void;
  152021. private _bits;
  152022. private _radicalInverse_VdC;
  152023. private _hammersley;
  152024. private _hemisphereSample_uniform;
  152025. private _generateHemisphere;
  152026. private _getDefinesForSSAO;
  152027. private _createSSAOPostProcess;
  152028. private _createSSAOCombinePostProcess;
  152029. private _createRandomTexture;
  152030. /**
  152031. * Serialize the rendering pipeline (Used when exporting)
  152032. * @returns the serialized object
  152033. */
  152034. serialize(): any;
  152035. /**
  152036. * Parse the serialized pipeline
  152037. * @param source Source pipeline.
  152038. * @param scene The scene to load the pipeline to.
  152039. * @param rootUrl The URL of the serialized pipeline.
  152040. * @returns An instantiated pipeline from the serialized object.
  152041. */
  152042. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152043. }
  152044. }
  152045. declare module BABYLON {
  152046. /** @hidden */
  152047. export var ssaoPixelShader: {
  152048. name: string;
  152049. shader: string;
  152050. };
  152051. }
  152052. declare module BABYLON {
  152053. /**
  152054. * Render pipeline to produce ssao effect
  152055. */
  152056. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152057. /**
  152058. * @ignore
  152059. * The PassPostProcess id in the pipeline that contains the original scene color
  152060. */
  152061. SSAOOriginalSceneColorEffect: string;
  152062. /**
  152063. * @ignore
  152064. * The SSAO PostProcess id in the pipeline
  152065. */
  152066. SSAORenderEffect: string;
  152067. /**
  152068. * @ignore
  152069. * The horizontal blur PostProcess id in the pipeline
  152070. */
  152071. SSAOBlurHRenderEffect: string;
  152072. /**
  152073. * @ignore
  152074. * The vertical blur PostProcess id in the pipeline
  152075. */
  152076. SSAOBlurVRenderEffect: string;
  152077. /**
  152078. * @ignore
  152079. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152080. */
  152081. SSAOCombineRenderEffect: string;
  152082. /**
  152083. * The output strength of the SSAO post-process. Default value is 1.0.
  152084. */
  152085. totalStrength: number;
  152086. /**
  152087. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152088. */
  152089. radius: number;
  152090. /**
  152091. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152092. * Must not be equal to fallOff and superior to fallOff.
  152093. * Default value is 0.0075
  152094. */
  152095. area: number;
  152096. /**
  152097. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152098. * Must not be equal to area and inferior to area.
  152099. * Default value is 0.000001
  152100. */
  152101. fallOff: number;
  152102. /**
  152103. * The base color of the SSAO post-process
  152104. * The final result is "base + ssao" between [0, 1]
  152105. */
  152106. base: number;
  152107. private _scene;
  152108. private _depthTexture;
  152109. private _randomTexture;
  152110. private _originalColorPostProcess;
  152111. private _ssaoPostProcess;
  152112. private _blurHPostProcess;
  152113. private _blurVPostProcess;
  152114. private _ssaoCombinePostProcess;
  152115. private _firstUpdate;
  152116. /**
  152117. * Gets active scene
  152118. */
  152119. get scene(): Scene;
  152120. /**
  152121. * @constructor
  152122. * @param name - The rendering pipeline name
  152123. * @param scene - The scene linked to this pipeline
  152124. * @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 }
  152125. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152126. */
  152127. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152128. /**
  152129. * Get the class name
  152130. * @returns "SSAORenderingPipeline"
  152131. */
  152132. getClassName(): string;
  152133. /**
  152134. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152135. */
  152136. dispose(disableDepthRender?: boolean): void;
  152137. private _createBlurPostProcess;
  152138. /** @hidden */
  152139. _rebuild(): void;
  152140. private _createSSAOPostProcess;
  152141. private _createSSAOCombinePostProcess;
  152142. private _createRandomTexture;
  152143. }
  152144. }
  152145. declare module BABYLON {
  152146. /**
  152147. * Contains all parameters needed for the prepass to perform
  152148. * screen space reflections
  152149. */
  152150. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152151. /**
  152152. * Is ssr enabled
  152153. */
  152154. enabled: boolean;
  152155. /**
  152156. * Name of the configuration
  152157. */
  152158. name: string;
  152159. /**
  152160. * Textures that should be present in the MRT for this effect to work
  152161. */
  152162. readonly texturesRequired: number[];
  152163. }
  152164. }
  152165. declare module BABYLON {
  152166. /** @hidden */
  152167. export var screenSpaceReflectionPixelShader: {
  152168. name: string;
  152169. shader: string;
  152170. };
  152171. }
  152172. declare module BABYLON {
  152173. /**
  152174. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152175. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152176. */
  152177. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152178. /**
  152179. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152180. */
  152181. threshold: number;
  152182. /**
  152183. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152184. */
  152185. strength: number;
  152186. /**
  152187. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152188. */
  152189. reflectionSpecularFalloffExponent: number;
  152190. /**
  152191. * 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]
  152192. */
  152193. step: number;
  152194. /**
  152195. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152196. */
  152197. roughnessFactor: number;
  152198. private _forceGeometryBuffer;
  152199. private _geometryBufferRenderer;
  152200. private _prePassRenderer;
  152201. private _enableSmoothReflections;
  152202. private _reflectionSamples;
  152203. private _smoothSteps;
  152204. /**
  152205. * Gets a string identifying the name of the class
  152206. * @returns "ScreenSpaceReflectionPostProcess" string
  152207. */
  152208. getClassName(): string;
  152209. /**
  152210. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152211. * @param name The name of the effect.
  152212. * @param scene The scene containing the objects to calculate reflections.
  152213. * @param options The required width/height ratio to downsize to before computing the render pass.
  152214. * @param camera The camera to apply the render pass to.
  152215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152216. * @param engine The engine which the post process will be applied. (default: current engine)
  152217. * @param reusable If the post process can be reused on the same frame. (default: false)
  152218. * @param textureType Type of textures used when performing the post process. (default: 0)
  152219. * @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)
  152220. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152221. */
  152222. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152223. /**
  152224. * Gets wether or not smoothing reflections is enabled.
  152225. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152226. */
  152227. get enableSmoothReflections(): boolean;
  152228. /**
  152229. * Sets wether or not smoothing reflections is enabled.
  152230. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152231. */
  152232. set enableSmoothReflections(enabled: boolean);
  152233. /**
  152234. * Gets the number of samples taken while computing reflections. More samples count is high,
  152235. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152236. */
  152237. get reflectionSamples(): number;
  152238. /**
  152239. * Sets the number of samples taken while computing reflections. More samples count is high,
  152240. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152241. */
  152242. set reflectionSamples(samples: number);
  152243. /**
  152244. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152245. * more the post-process will require GPU power and can generate a drop in FPS.
  152246. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152247. */
  152248. get smoothSteps(): number;
  152249. set smoothSteps(steps: number);
  152250. private _updateEffectDefines;
  152251. /** @hidden */
  152252. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152253. }
  152254. }
  152255. declare module BABYLON {
  152256. /** @hidden */
  152257. export var standardPixelShader: {
  152258. name: string;
  152259. shader: string;
  152260. };
  152261. }
  152262. declare module BABYLON {
  152263. /**
  152264. * Standard rendering pipeline
  152265. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152266. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152267. */
  152268. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152269. /**
  152270. * Public members
  152271. */
  152272. /**
  152273. * Post-process which contains the original scene color before the pipeline applies all the effects
  152274. */
  152275. originalPostProcess: Nullable<PostProcess>;
  152276. /**
  152277. * Post-process used to down scale an image x4
  152278. */
  152279. downSampleX4PostProcess: Nullable<PostProcess>;
  152280. /**
  152281. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152282. */
  152283. brightPassPostProcess: Nullable<PostProcess>;
  152284. /**
  152285. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152286. */
  152287. blurHPostProcesses: PostProcess[];
  152288. /**
  152289. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152290. */
  152291. blurVPostProcesses: PostProcess[];
  152292. /**
  152293. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152294. */
  152295. textureAdderPostProcess: Nullable<PostProcess>;
  152296. /**
  152297. * Post-process used to create volumetric lighting effect
  152298. */
  152299. volumetricLightPostProcess: Nullable<PostProcess>;
  152300. /**
  152301. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152302. */
  152303. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152304. /**
  152305. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152306. */
  152307. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152308. /**
  152309. * Post-process used to merge the volumetric light effect and the real scene color
  152310. */
  152311. volumetricLightMergePostProces: Nullable<PostProcess>;
  152312. /**
  152313. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152314. */
  152315. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152316. /**
  152317. * Base post-process used to calculate the average luminance of the final image for HDR
  152318. */
  152319. luminancePostProcess: Nullable<PostProcess>;
  152320. /**
  152321. * Post-processes used to create down sample post-processes in order to get
  152322. * the average luminance of the final image for HDR
  152323. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152324. */
  152325. luminanceDownSamplePostProcesses: PostProcess[];
  152326. /**
  152327. * Post-process used to create a HDR effect (light adaptation)
  152328. */
  152329. hdrPostProcess: Nullable<PostProcess>;
  152330. /**
  152331. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152332. */
  152333. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152334. /**
  152335. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152336. */
  152337. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152338. /**
  152339. * Post-process used to merge the final HDR post-process and the real scene color
  152340. */
  152341. hdrFinalPostProcess: Nullable<PostProcess>;
  152342. /**
  152343. * Post-process used to create a lens flare effect
  152344. */
  152345. lensFlarePostProcess: Nullable<PostProcess>;
  152346. /**
  152347. * Post-process that merges the result of the lens flare post-process and the real scene color
  152348. */
  152349. lensFlareComposePostProcess: Nullable<PostProcess>;
  152350. /**
  152351. * Post-process used to create a motion blur effect
  152352. */
  152353. motionBlurPostProcess: Nullable<PostProcess>;
  152354. /**
  152355. * Post-process used to create a depth of field effect
  152356. */
  152357. depthOfFieldPostProcess: Nullable<PostProcess>;
  152358. /**
  152359. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152360. */
  152361. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152362. /**
  152363. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152364. */
  152365. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152366. /**
  152367. * Represents the brightness threshold in order to configure the illuminated surfaces
  152368. */
  152369. brightThreshold: number;
  152370. /**
  152371. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152372. */
  152373. blurWidth: number;
  152374. /**
  152375. * Sets if the blur for highlighted surfaces must be only horizontal
  152376. */
  152377. horizontalBlur: boolean;
  152378. /**
  152379. * Gets the overall exposure used by the pipeline
  152380. */
  152381. get exposure(): number;
  152382. /**
  152383. * Sets the overall exposure used by the pipeline
  152384. */
  152385. set exposure(value: number);
  152386. /**
  152387. * Texture used typically to simulate "dirty" on camera lens
  152388. */
  152389. lensTexture: Nullable<Texture>;
  152390. /**
  152391. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152392. */
  152393. volumetricLightCoefficient: number;
  152394. /**
  152395. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152396. */
  152397. volumetricLightPower: number;
  152398. /**
  152399. * Used the set the blur intensity to smooth the volumetric lights
  152400. */
  152401. volumetricLightBlurScale: number;
  152402. /**
  152403. * Light (spot or directional) used to generate the volumetric lights rays
  152404. * The source light must have a shadow generate so the pipeline can get its
  152405. * depth map
  152406. */
  152407. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152408. /**
  152409. * For eye adaptation, represents the minimum luminance the eye can see
  152410. */
  152411. hdrMinimumLuminance: number;
  152412. /**
  152413. * For eye adaptation, represents the decrease luminance speed
  152414. */
  152415. hdrDecreaseRate: number;
  152416. /**
  152417. * For eye adaptation, represents the increase luminance speed
  152418. */
  152419. hdrIncreaseRate: number;
  152420. /**
  152421. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152422. */
  152423. get hdrAutoExposure(): boolean;
  152424. /**
  152425. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152426. */
  152427. set hdrAutoExposure(value: boolean);
  152428. /**
  152429. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152430. */
  152431. lensColorTexture: Nullable<Texture>;
  152432. /**
  152433. * The overall strengh for the lens flare effect
  152434. */
  152435. lensFlareStrength: number;
  152436. /**
  152437. * Dispersion coefficient for lens flare ghosts
  152438. */
  152439. lensFlareGhostDispersal: number;
  152440. /**
  152441. * Main lens flare halo width
  152442. */
  152443. lensFlareHaloWidth: number;
  152444. /**
  152445. * Based on the lens distortion effect, defines how much the lens flare result
  152446. * is distorted
  152447. */
  152448. lensFlareDistortionStrength: number;
  152449. /**
  152450. * Configures the blur intensity used for for lens flare (halo)
  152451. */
  152452. lensFlareBlurWidth: number;
  152453. /**
  152454. * Lens star texture must be used to simulate rays on the flares and is available
  152455. * in the documentation
  152456. */
  152457. lensStarTexture: Nullable<Texture>;
  152458. /**
  152459. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152460. * flare effect by taking account of the dirt texture
  152461. */
  152462. lensFlareDirtTexture: Nullable<Texture>;
  152463. /**
  152464. * Represents the focal length for the depth of field effect
  152465. */
  152466. depthOfFieldDistance: number;
  152467. /**
  152468. * Represents the blur intensity for the blurred part of the depth of field effect
  152469. */
  152470. depthOfFieldBlurWidth: number;
  152471. /**
  152472. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152473. */
  152474. get motionStrength(): number;
  152475. /**
  152476. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152477. */
  152478. set motionStrength(strength: number);
  152479. /**
  152480. * Gets wether or not the motion blur post-process is object based or screen based.
  152481. */
  152482. get objectBasedMotionBlur(): boolean;
  152483. /**
  152484. * Sets wether or not the motion blur post-process should be object based or screen based
  152485. */
  152486. set objectBasedMotionBlur(value: boolean);
  152487. /**
  152488. * List of animations for the pipeline (IAnimatable implementation)
  152489. */
  152490. animations: Animation[];
  152491. /**
  152492. * Private members
  152493. */
  152494. private _scene;
  152495. private _currentDepthOfFieldSource;
  152496. private _basePostProcess;
  152497. private _fixedExposure;
  152498. private _currentExposure;
  152499. private _hdrAutoExposure;
  152500. private _hdrCurrentLuminance;
  152501. private _motionStrength;
  152502. private _isObjectBasedMotionBlur;
  152503. private _floatTextureType;
  152504. private _camerasToBeAttached;
  152505. private _ratio;
  152506. private _bloomEnabled;
  152507. private _depthOfFieldEnabled;
  152508. private _vlsEnabled;
  152509. private _lensFlareEnabled;
  152510. private _hdrEnabled;
  152511. private _motionBlurEnabled;
  152512. private _fxaaEnabled;
  152513. private _screenSpaceReflectionsEnabled;
  152514. private _motionBlurSamples;
  152515. private _volumetricLightStepsCount;
  152516. private _samples;
  152517. /**
  152518. * @ignore
  152519. * Specifies if the bloom pipeline is enabled
  152520. */
  152521. get BloomEnabled(): boolean;
  152522. set BloomEnabled(enabled: boolean);
  152523. /**
  152524. * @ignore
  152525. * Specifies if the depth of field pipeline is enabed
  152526. */
  152527. get DepthOfFieldEnabled(): boolean;
  152528. set DepthOfFieldEnabled(enabled: boolean);
  152529. /**
  152530. * @ignore
  152531. * Specifies if the lens flare pipeline is enabed
  152532. */
  152533. get LensFlareEnabled(): boolean;
  152534. set LensFlareEnabled(enabled: boolean);
  152535. /**
  152536. * @ignore
  152537. * Specifies if the HDR pipeline is enabled
  152538. */
  152539. get HDREnabled(): boolean;
  152540. set HDREnabled(enabled: boolean);
  152541. /**
  152542. * @ignore
  152543. * Specifies if the volumetric lights scattering effect is enabled
  152544. */
  152545. get VLSEnabled(): boolean;
  152546. set VLSEnabled(enabled: boolean);
  152547. /**
  152548. * @ignore
  152549. * Specifies if the motion blur effect is enabled
  152550. */
  152551. get MotionBlurEnabled(): boolean;
  152552. set MotionBlurEnabled(enabled: boolean);
  152553. /**
  152554. * Specifies if anti-aliasing is enabled
  152555. */
  152556. get fxaaEnabled(): boolean;
  152557. set fxaaEnabled(enabled: boolean);
  152558. /**
  152559. * Specifies if screen space reflections are enabled.
  152560. */
  152561. get screenSpaceReflectionsEnabled(): boolean;
  152562. set screenSpaceReflectionsEnabled(enabled: boolean);
  152563. /**
  152564. * Specifies the number of steps used to calculate the volumetric lights
  152565. * Typically in interval [50, 200]
  152566. */
  152567. get volumetricLightStepsCount(): number;
  152568. set volumetricLightStepsCount(count: number);
  152569. /**
  152570. * Specifies the number of samples used for the motion blur effect
  152571. * Typically in interval [16, 64]
  152572. */
  152573. get motionBlurSamples(): number;
  152574. set motionBlurSamples(samples: number);
  152575. /**
  152576. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152577. */
  152578. get samples(): number;
  152579. set samples(sampleCount: number);
  152580. /**
  152581. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152582. * @constructor
  152583. * @param name The rendering pipeline name
  152584. * @param scene The scene linked to this pipeline
  152585. * @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)
  152586. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152587. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152588. */
  152589. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152590. private _buildPipeline;
  152591. private _createDownSampleX4PostProcess;
  152592. private _createBrightPassPostProcess;
  152593. private _createBlurPostProcesses;
  152594. private _createTextureAdderPostProcess;
  152595. private _createVolumetricLightPostProcess;
  152596. private _createLuminancePostProcesses;
  152597. private _createHdrPostProcess;
  152598. private _createLensFlarePostProcess;
  152599. private _createDepthOfFieldPostProcess;
  152600. private _createMotionBlurPostProcess;
  152601. private _getDepthTexture;
  152602. private _disposePostProcesses;
  152603. /**
  152604. * Dispose of the pipeline and stop all post processes
  152605. */
  152606. dispose(): void;
  152607. /**
  152608. * Serialize the rendering pipeline (Used when exporting)
  152609. * @returns the serialized object
  152610. */
  152611. serialize(): any;
  152612. /**
  152613. * Parse the serialized pipeline
  152614. * @param source Source pipeline.
  152615. * @param scene The scene to load the pipeline to.
  152616. * @param rootUrl The URL of the serialized pipeline.
  152617. * @returns An instantiated pipeline from the serialized object.
  152618. */
  152619. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152620. /**
  152621. * Luminance steps
  152622. */
  152623. static LuminanceSteps: number;
  152624. }
  152625. }
  152626. declare module BABYLON {
  152627. /** @hidden */
  152628. export var stereoscopicInterlacePixelShader: {
  152629. name: string;
  152630. shader: string;
  152631. };
  152632. }
  152633. declare module BABYLON {
  152634. /**
  152635. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152636. */
  152637. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152638. private _stepSize;
  152639. private _passedProcess;
  152640. /**
  152641. * Gets a string identifying the name of the class
  152642. * @returns "StereoscopicInterlacePostProcessI" string
  152643. */
  152644. getClassName(): string;
  152645. /**
  152646. * Initializes a StereoscopicInterlacePostProcessI
  152647. * @param name The name of the effect.
  152648. * @param rigCameras The rig cameras to be appled to the post process
  152649. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152650. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152652. * @param engine The engine which the post process will be applied. (default: current engine)
  152653. * @param reusable If the post process can be reused on the same frame. (default: false)
  152654. */
  152655. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152656. }
  152657. /**
  152658. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152659. */
  152660. export class StereoscopicInterlacePostProcess extends PostProcess {
  152661. private _stepSize;
  152662. private _passedProcess;
  152663. /**
  152664. * Gets a string identifying the name of the class
  152665. * @returns "StereoscopicInterlacePostProcess" string
  152666. */
  152667. getClassName(): string;
  152668. /**
  152669. * Initializes a StereoscopicInterlacePostProcess
  152670. * @param name The name of the effect.
  152671. * @param rigCameras The rig cameras to be appled to the post process
  152672. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152674. * @param engine The engine which the post process will be applied. (default: current engine)
  152675. * @param reusable If the post process can be reused on the same frame. (default: false)
  152676. */
  152677. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152678. }
  152679. }
  152680. declare module BABYLON {
  152681. /** @hidden */
  152682. export var tonemapPixelShader: {
  152683. name: string;
  152684. shader: string;
  152685. };
  152686. }
  152687. declare module BABYLON {
  152688. /** Defines operator used for tonemapping */
  152689. export enum TonemappingOperator {
  152690. /** Hable */
  152691. Hable = 0,
  152692. /** Reinhard */
  152693. Reinhard = 1,
  152694. /** HejiDawson */
  152695. HejiDawson = 2,
  152696. /** Photographic */
  152697. Photographic = 3
  152698. }
  152699. /**
  152700. * Defines a post process to apply tone mapping
  152701. */
  152702. export class TonemapPostProcess extends PostProcess {
  152703. private _operator;
  152704. /** Defines the required exposure adjustement */
  152705. exposureAdjustment: number;
  152706. /**
  152707. * Gets a string identifying the name of the class
  152708. * @returns "TonemapPostProcess" string
  152709. */
  152710. getClassName(): string;
  152711. /**
  152712. * Creates a new TonemapPostProcess
  152713. * @param name defines the name of the postprocess
  152714. * @param _operator defines the operator to use
  152715. * @param exposureAdjustment defines the required exposure adjustement
  152716. * @param camera defines the camera to use (can be null)
  152717. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152718. * @param engine defines the hosting engine (can be ignore if camera is set)
  152719. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152720. */
  152721. constructor(name: string, _operator: TonemappingOperator,
  152722. /** Defines the required exposure adjustement */
  152723. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152724. }
  152725. }
  152726. declare module BABYLON {
  152727. /** @hidden */
  152728. export var volumetricLightScatteringPixelShader: {
  152729. name: string;
  152730. shader: string;
  152731. };
  152732. }
  152733. declare module BABYLON {
  152734. /** @hidden */
  152735. export var volumetricLightScatteringPassVertexShader: {
  152736. name: string;
  152737. shader: string;
  152738. };
  152739. }
  152740. declare module BABYLON {
  152741. /** @hidden */
  152742. export var volumetricLightScatteringPassPixelShader: {
  152743. name: string;
  152744. shader: string;
  152745. };
  152746. }
  152747. declare module BABYLON {
  152748. /**
  152749. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152750. */
  152751. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152752. private _volumetricLightScatteringPass;
  152753. private _volumetricLightScatteringRTT;
  152754. private _viewPort;
  152755. private _screenCoordinates;
  152756. private _cachedDefines;
  152757. /**
  152758. * If not undefined, the mesh position is computed from the attached node position
  152759. */
  152760. attachedNode: {
  152761. position: Vector3;
  152762. };
  152763. /**
  152764. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152765. */
  152766. customMeshPosition: Vector3;
  152767. /**
  152768. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152769. */
  152770. useCustomMeshPosition: boolean;
  152771. /**
  152772. * If the post-process should inverse the light scattering direction
  152773. */
  152774. invert: boolean;
  152775. /**
  152776. * The internal mesh used by the post-process
  152777. */
  152778. mesh: Mesh;
  152779. /**
  152780. * @hidden
  152781. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152782. */
  152783. get useDiffuseColor(): boolean;
  152784. set useDiffuseColor(useDiffuseColor: boolean);
  152785. /**
  152786. * Array containing the excluded meshes not rendered in the internal pass
  152787. */
  152788. excludedMeshes: AbstractMesh[];
  152789. /**
  152790. * Controls the overall intensity of the post-process
  152791. */
  152792. exposure: number;
  152793. /**
  152794. * Dissipates each sample's contribution in range [0, 1]
  152795. */
  152796. decay: number;
  152797. /**
  152798. * Controls the overall intensity of each sample
  152799. */
  152800. weight: number;
  152801. /**
  152802. * Controls the density of each sample
  152803. */
  152804. density: number;
  152805. /**
  152806. * @constructor
  152807. * @param name The post-process name
  152808. * @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)
  152809. * @param camera The camera that the post-process will be attached to
  152810. * @param mesh The mesh used to create the light scattering
  152811. * @param samples The post-process quality, default 100
  152812. * @param samplingModeThe post-process filtering mode
  152813. * @param engine The babylon engine
  152814. * @param reusable If the post-process is reusable
  152815. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152816. */
  152817. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152818. /**
  152819. * Returns the string "VolumetricLightScatteringPostProcess"
  152820. * @returns "VolumetricLightScatteringPostProcess"
  152821. */
  152822. getClassName(): string;
  152823. private _isReady;
  152824. /**
  152825. * Sets the new light position for light scattering effect
  152826. * @param position The new custom light position
  152827. */
  152828. setCustomMeshPosition(position: Vector3): void;
  152829. /**
  152830. * Returns the light position for light scattering effect
  152831. * @return Vector3 The custom light position
  152832. */
  152833. getCustomMeshPosition(): Vector3;
  152834. /**
  152835. * Disposes the internal assets and detaches the post-process from the camera
  152836. */
  152837. dispose(camera: Camera): void;
  152838. /**
  152839. * Returns the render target texture used by the post-process
  152840. * @return the render target texture used by the post-process
  152841. */
  152842. getPass(): RenderTargetTexture;
  152843. private _meshExcluded;
  152844. private _createPass;
  152845. private _updateMeshScreenCoordinates;
  152846. /**
  152847. * Creates a default mesh for the Volumeric Light Scattering post-process
  152848. * @param name The mesh name
  152849. * @param scene The scene where to create the mesh
  152850. * @return the default mesh
  152851. */
  152852. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152853. }
  152854. }
  152855. declare module BABYLON {
  152856. /** @hidden */
  152857. export var screenSpaceCurvaturePixelShader: {
  152858. name: string;
  152859. shader: string;
  152860. };
  152861. }
  152862. declare module BABYLON {
  152863. /**
  152864. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152865. */
  152866. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152867. /**
  152868. * Defines how much ridge the curvature effect displays.
  152869. */
  152870. ridge: number;
  152871. /**
  152872. * Defines how much valley the curvature effect displays.
  152873. */
  152874. valley: number;
  152875. private _geometryBufferRenderer;
  152876. /**
  152877. * Gets a string identifying the name of the class
  152878. * @returns "ScreenSpaceCurvaturePostProcess" string
  152879. */
  152880. getClassName(): string;
  152881. /**
  152882. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152883. * @param name The name of the effect.
  152884. * @param scene The scene containing the objects to blur according to their velocity.
  152885. * @param options The required width/height ratio to downsize to before computing the render pass.
  152886. * @param camera The camera to apply the render pass to.
  152887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152888. * @param engine The engine which the post process will be applied. (default: current engine)
  152889. * @param reusable If the post process can be reused on the same frame. (default: false)
  152890. * @param textureType Type of textures used when performing the post process. (default: 0)
  152891. * @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)
  152892. */
  152893. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152894. /**
  152895. * Support test.
  152896. */
  152897. static get IsSupported(): boolean;
  152898. /** @hidden */
  152899. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152900. }
  152901. }
  152902. declare module BABYLON {
  152903. interface Scene {
  152904. /** @hidden (Backing field) */
  152905. _boundingBoxRenderer: BoundingBoxRenderer;
  152906. /** @hidden (Backing field) */
  152907. _forceShowBoundingBoxes: boolean;
  152908. /**
  152909. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152910. */
  152911. forceShowBoundingBoxes: boolean;
  152912. /**
  152913. * Gets the bounding box renderer associated with the scene
  152914. * @returns a BoundingBoxRenderer
  152915. */
  152916. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152917. }
  152918. interface AbstractMesh {
  152919. /** @hidden (Backing field) */
  152920. _showBoundingBox: boolean;
  152921. /**
  152922. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152923. */
  152924. showBoundingBox: boolean;
  152925. }
  152926. /**
  152927. * Component responsible of rendering the bounding box of the meshes in a scene.
  152928. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152929. */
  152930. export class BoundingBoxRenderer implements ISceneComponent {
  152931. /**
  152932. * The component name helpfull to identify the component in the list of scene components.
  152933. */
  152934. readonly name: string;
  152935. /**
  152936. * The scene the component belongs to.
  152937. */
  152938. scene: Scene;
  152939. /**
  152940. * Color of the bounding box lines placed in front of an object
  152941. */
  152942. frontColor: Color3;
  152943. /**
  152944. * Color of the bounding box lines placed behind an object
  152945. */
  152946. backColor: Color3;
  152947. /**
  152948. * Defines if the renderer should show the back lines or not
  152949. */
  152950. showBackLines: boolean;
  152951. /**
  152952. * Observable raised before rendering a bounding box
  152953. */
  152954. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152955. /**
  152956. * Observable raised after rendering a bounding box
  152957. */
  152958. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152959. /**
  152960. * @hidden
  152961. */
  152962. renderList: SmartArray<BoundingBox>;
  152963. private _colorShader;
  152964. private _vertexBuffers;
  152965. private _indexBuffer;
  152966. private _fillIndexBuffer;
  152967. private _fillIndexData;
  152968. /**
  152969. * Instantiates a new bounding box renderer in a scene.
  152970. * @param scene the scene the renderer renders in
  152971. */
  152972. constructor(scene: Scene);
  152973. /**
  152974. * Registers the component in a given scene
  152975. */
  152976. register(): void;
  152977. private _evaluateSubMesh;
  152978. private _activeMesh;
  152979. private _prepareRessources;
  152980. private _createIndexBuffer;
  152981. /**
  152982. * Rebuilds the elements related to this component in case of
  152983. * context lost for instance.
  152984. */
  152985. rebuild(): void;
  152986. /**
  152987. * @hidden
  152988. */
  152989. reset(): void;
  152990. /**
  152991. * Render the bounding boxes of a specific rendering group
  152992. * @param renderingGroupId defines the rendering group to render
  152993. */
  152994. render(renderingGroupId: number): void;
  152995. /**
  152996. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152997. * @param mesh Define the mesh to render the occlusion bounding box for
  152998. */
  152999. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153000. /**
  153001. * Dispose and release the resources attached to this renderer.
  153002. */
  153003. dispose(): void;
  153004. }
  153005. }
  153006. declare module BABYLON {
  153007. interface Scene {
  153008. /** @hidden (Backing field) */
  153009. _depthRenderer: {
  153010. [id: string]: DepthRenderer;
  153011. };
  153012. /**
  153013. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153014. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153015. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153016. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153017. * @returns the created depth renderer
  153018. */
  153019. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153020. /**
  153021. * Disables a depth renderer for a given camera
  153022. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153023. */
  153024. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153025. }
  153026. /**
  153027. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153028. * in several rendering techniques.
  153029. */
  153030. export class DepthRendererSceneComponent implements ISceneComponent {
  153031. /**
  153032. * The component name helpfull to identify the component in the list of scene components.
  153033. */
  153034. readonly name: string;
  153035. /**
  153036. * The scene the component belongs to.
  153037. */
  153038. scene: Scene;
  153039. /**
  153040. * Creates a new instance of the component for the given scene
  153041. * @param scene Defines the scene to register the component in
  153042. */
  153043. constructor(scene: Scene);
  153044. /**
  153045. * Registers the component in a given scene
  153046. */
  153047. register(): void;
  153048. /**
  153049. * Rebuilds the elements related to this component in case of
  153050. * context lost for instance.
  153051. */
  153052. rebuild(): void;
  153053. /**
  153054. * Disposes the component and the associated ressources
  153055. */
  153056. dispose(): void;
  153057. private _gatherRenderTargets;
  153058. private _gatherActiveCameraRenderTargets;
  153059. }
  153060. }
  153061. declare module BABYLON {
  153062. interface AbstractScene {
  153063. /** @hidden (Backing field) */
  153064. _prePassRenderer: Nullable<PrePassRenderer>;
  153065. /**
  153066. * Gets or Sets the current prepass renderer associated to the scene.
  153067. */
  153068. prePassRenderer: Nullable<PrePassRenderer>;
  153069. /**
  153070. * Enables the prepass and associates it with the scene
  153071. * @returns the PrePassRenderer
  153072. */
  153073. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153074. /**
  153075. * Disables the prepass associated with the scene
  153076. */
  153077. disablePrePassRenderer(): void;
  153078. }
  153079. /**
  153080. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153081. * in several rendering techniques.
  153082. */
  153083. export class PrePassRendererSceneComponent implements ISceneComponent {
  153084. /**
  153085. * The component name helpful to identify the component in the list of scene components.
  153086. */
  153087. readonly name: string;
  153088. /**
  153089. * The scene the component belongs to.
  153090. */
  153091. scene: Scene;
  153092. /**
  153093. * Creates a new instance of the component for the given scene
  153094. * @param scene Defines the scene to register the component in
  153095. */
  153096. constructor(scene: Scene);
  153097. /**
  153098. * Registers the component in a given scene
  153099. */
  153100. register(): void;
  153101. private _beforeCameraDraw;
  153102. private _afterCameraDraw;
  153103. private _beforeClearStage;
  153104. /**
  153105. * Rebuilds the elements related to this component in case of
  153106. * context lost for instance.
  153107. */
  153108. rebuild(): void;
  153109. /**
  153110. * Disposes the component and the associated ressources
  153111. */
  153112. dispose(): void;
  153113. }
  153114. }
  153115. declare module BABYLON {
  153116. /** @hidden */
  153117. export var fibonacci: {
  153118. name: string;
  153119. shader: string;
  153120. };
  153121. }
  153122. declare module BABYLON {
  153123. /** @hidden */
  153124. export var diffusionProfile: {
  153125. name: string;
  153126. shader: string;
  153127. };
  153128. }
  153129. declare module BABYLON {
  153130. /** @hidden */
  153131. export var subSurfaceScatteringPixelShader: {
  153132. name: string;
  153133. shader: string;
  153134. };
  153135. }
  153136. declare module BABYLON {
  153137. /**
  153138. * Sub surface scattering post process
  153139. */
  153140. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153141. /**
  153142. * Gets a string identifying the name of the class
  153143. * @returns "SubSurfaceScatteringPostProcess" string
  153144. */
  153145. getClassName(): string;
  153146. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153147. }
  153148. }
  153149. declare module BABYLON {
  153150. /**
  153151. * Contains all parameters needed for the prepass to perform
  153152. * screen space subsurface scattering
  153153. */
  153154. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153155. /** @hidden */
  153156. static _SceneComponentInitialization: (scene: Scene) => void;
  153157. private _ssDiffusionS;
  153158. private _ssFilterRadii;
  153159. private _ssDiffusionD;
  153160. /**
  153161. * Post process to attach for screen space subsurface scattering
  153162. */
  153163. postProcess: SubSurfaceScatteringPostProcess;
  153164. /**
  153165. * Diffusion profile color for subsurface scattering
  153166. */
  153167. get ssDiffusionS(): number[];
  153168. /**
  153169. * Diffusion profile max color channel value for subsurface scattering
  153170. */
  153171. get ssDiffusionD(): number[];
  153172. /**
  153173. * Diffusion profile filter radius for subsurface scattering
  153174. */
  153175. get ssFilterRadii(): number[];
  153176. /**
  153177. * Is subsurface enabled
  153178. */
  153179. enabled: boolean;
  153180. /**
  153181. * Name of the configuration
  153182. */
  153183. name: string;
  153184. /**
  153185. * Diffusion profile colors for subsurface scattering
  153186. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153187. * See ...
  153188. * Note that you can only store up to 5 of them
  153189. */
  153190. ssDiffusionProfileColors: Color3[];
  153191. /**
  153192. * Defines the ratio real world => scene units.
  153193. * Used for subsurface scattering
  153194. */
  153195. metersPerUnit: number;
  153196. /**
  153197. * Textures that should be present in the MRT for this effect to work
  153198. */
  153199. readonly texturesRequired: number[];
  153200. private _scene;
  153201. /**
  153202. * Builds a subsurface configuration object
  153203. * @param scene The scene
  153204. */
  153205. constructor(scene: Scene);
  153206. /**
  153207. * Adds a new diffusion profile.
  153208. * Useful for more realistic subsurface scattering on diverse materials.
  153209. * @param color The color of the diffusion profile. Should be the average color of the material.
  153210. * @return The index of the diffusion profile for the material subsurface configuration
  153211. */
  153212. addDiffusionProfile(color: Color3): number;
  153213. /**
  153214. * Creates the sss post process
  153215. * @return The created post process
  153216. */
  153217. createPostProcess(): SubSurfaceScatteringPostProcess;
  153218. /**
  153219. * Deletes all diffusion profiles.
  153220. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153221. */
  153222. clearAllDiffusionProfiles(): void;
  153223. /**
  153224. * Disposes this object
  153225. */
  153226. dispose(): void;
  153227. /**
  153228. * @hidden
  153229. * https://zero-radiance.github.io/post/sampling-diffusion/
  153230. *
  153231. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153232. * ------------------------------------------------------------------------------------
  153233. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153234. * PDF[r, phi, s] = r * R[r, phi, s]
  153235. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153236. * ------------------------------------------------------------------------------------
  153237. * We importance sample the color channel with the widest scattering distance.
  153238. */
  153239. getDiffusionProfileParameters(color: Color3): number;
  153240. /**
  153241. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153242. * 'u' is the random number (the value of the CDF): [0, 1).
  153243. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153244. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153245. */
  153246. private _sampleBurleyDiffusionProfile;
  153247. }
  153248. }
  153249. declare module BABYLON {
  153250. interface AbstractScene {
  153251. /** @hidden (Backing field) */
  153252. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153253. /**
  153254. * Gets or Sets the current prepass renderer associated to the scene.
  153255. */
  153256. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153257. /**
  153258. * Enables the subsurface effect for prepass
  153259. * @returns the SubSurfaceConfiguration
  153260. */
  153261. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153262. /**
  153263. * Disables the subsurface effect for prepass
  153264. */
  153265. disableSubSurfaceForPrePass(): void;
  153266. }
  153267. /**
  153268. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153269. * in several rendering techniques.
  153270. */
  153271. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153272. /**
  153273. * The component name helpful to identify the component in the list of scene components.
  153274. */
  153275. readonly name: string;
  153276. /**
  153277. * The scene the component belongs to.
  153278. */
  153279. scene: Scene;
  153280. /**
  153281. * Creates a new instance of the component for the given scene
  153282. * @param scene Defines the scene to register the component in
  153283. */
  153284. constructor(scene: Scene);
  153285. /**
  153286. * Registers the component in a given scene
  153287. */
  153288. register(): void;
  153289. /**
  153290. * Serializes the component data to the specified json object
  153291. * @param serializationObject The object to serialize to
  153292. */
  153293. serialize(serializationObject: any): void;
  153294. /**
  153295. * Adds all the elements from the container to the scene
  153296. * @param container the container holding the elements
  153297. */
  153298. addFromContainer(container: AbstractScene): void;
  153299. /**
  153300. * Removes all the elements in the container from the scene
  153301. * @param container contains the elements to remove
  153302. * @param dispose if the removed element should be disposed (default: false)
  153303. */
  153304. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153305. /**
  153306. * Rebuilds the elements related to this component in case of
  153307. * context lost for instance.
  153308. */
  153309. rebuild(): void;
  153310. /**
  153311. * Disposes the component and the associated ressources
  153312. */
  153313. dispose(): void;
  153314. }
  153315. }
  153316. declare module BABYLON {
  153317. /** @hidden */
  153318. export var outlinePixelShader: {
  153319. name: string;
  153320. shader: string;
  153321. };
  153322. }
  153323. declare module BABYLON {
  153324. /** @hidden */
  153325. export var outlineVertexShader: {
  153326. name: string;
  153327. shader: string;
  153328. };
  153329. }
  153330. declare module BABYLON {
  153331. interface Scene {
  153332. /** @hidden */
  153333. _outlineRenderer: OutlineRenderer;
  153334. /**
  153335. * Gets the outline renderer associated with the scene
  153336. * @returns a OutlineRenderer
  153337. */
  153338. getOutlineRenderer(): OutlineRenderer;
  153339. }
  153340. interface AbstractMesh {
  153341. /** @hidden (Backing field) */
  153342. _renderOutline: boolean;
  153343. /**
  153344. * Gets or sets a boolean indicating if the outline must be rendered as well
  153345. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153346. */
  153347. renderOutline: boolean;
  153348. /** @hidden (Backing field) */
  153349. _renderOverlay: boolean;
  153350. /**
  153351. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153352. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153353. */
  153354. renderOverlay: boolean;
  153355. }
  153356. /**
  153357. * This class is responsible to draw bothe outline/overlay of meshes.
  153358. * It should not be used directly but through the available method on mesh.
  153359. */
  153360. export class OutlineRenderer implements ISceneComponent {
  153361. /**
  153362. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153363. */
  153364. private static _StencilReference;
  153365. /**
  153366. * The name of the component. Each component must have a unique name.
  153367. */
  153368. name: string;
  153369. /**
  153370. * The scene the component belongs to.
  153371. */
  153372. scene: Scene;
  153373. /**
  153374. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153375. */
  153376. zOffset: number;
  153377. private _engine;
  153378. private _effect;
  153379. private _cachedDefines;
  153380. private _savedDepthWrite;
  153381. /**
  153382. * Instantiates a new outline renderer. (There could be only one per scene).
  153383. * @param scene Defines the scene it belongs to
  153384. */
  153385. constructor(scene: Scene);
  153386. /**
  153387. * Register the component to one instance of a scene.
  153388. */
  153389. register(): void;
  153390. /**
  153391. * Rebuilds the elements related to this component in case of
  153392. * context lost for instance.
  153393. */
  153394. rebuild(): void;
  153395. /**
  153396. * Disposes the component and the associated ressources.
  153397. */
  153398. dispose(): void;
  153399. /**
  153400. * Renders the outline in the canvas.
  153401. * @param subMesh Defines the sumesh to render
  153402. * @param batch Defines the batch of meshes in case of instances
  153403. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153404. */
  153405. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153406. /**
  153407. * Returns whether or not the outline renderer is ready for a given submesh.
  153408. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153409. * @param subMesh Defines the submesh to check readyness for
  153410. * @param useInstances Defines wheter wee are trying to render instances or not
  153411. * @returns true if ready otherwise false
  153412. */
  153413. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153414. private _beforeRenderingMesh;
  153415. private _afterRenderingMesh;
  153416. }
  153417. }
  153418. declare module BABYLON {
  153419. /**
  153420. * Defines the basic options interface of a Sprite Frame Source Size.
  153421. */
  153422. export interface ISpriteJSONSpriteSourceSize {
  153423. /**
  153424. * number of the original width of the Frame
  153425. */
  153426. w: number;
  153427. /**
  153428. * number of the original height of the Frame
  153429. */
  153430. h: number;
  153431. }
  153432. /**
  153433. * Defines the basic options interface of a Sprite Frame Data.
  153434. */
  153435. export interface ISpriteJSONSpriteFrameData {
  153436. /**
  153437. * number of the x offset of the Frame
  153438. */
  153439. x: number;
  153440. /**
  153441. * number of the y offset of the Frame
  153442. */
  153443. y: number;
  153444. /**
  153445. * number of the width of the Frame
  153446. */
  153447. w: number;
  153448. /**
  153449. * number of the height of the Frame
  153450. */
  153451. h: number;
  153452. }
  153453. /**
  153454. * Defines the basic options interface of a JSON Sprite.
  153455. */
  153456. export interface ISpriteJSONSprite {
  153457. /**
  153458. * string name of the Frame
  153459. */
  153460. filename: string;
  153461. /**
  153462. * ISpriteJSONSpriteFrame basic object of the frame data
  153463. */
  153464. frame: ISpriteJSONSpriteFrameData;
  153465. /**
  153466. * boolean to flag is the frame was rotated.
  153467. */
  153468. rotated: boolean;
  153469. /**
  153470. * boolean to flag is the frame was trimmed.
  153471. */
  153472. trimmed: boolean;
  153473. /**
  153474. * ISpriteJSONSpriteFrame basic object of the source data
  153475. */
  153476. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153477. /**
  153478. * ISpriteJSONSpriteFrame basic object of the source data
  153479. */
  153480. sourceSize: ISpriteJSONSpriteSourceSize;
  153481. }
  153482. /**
  153483. * Defines the basic options interface of a JSON atlas.
  153484. */
  153485. export interface ISpriteJSONAtlas {
  153486. /**
  153487. * Array of objects that contain the frame data.
  153488. */
  153489. frames: Array<ISpriteJSONSprite>;
  153490. /**
  153491. * object basic object containing the sprite meta data.
  153492. */
  153493. meta?: object;
  153494. }
  153495. }
  153496. declare module BABYLON {
  153497. /** @hidden */
  153498. export var spriteMapPixelShader: {
  153499. name: string;
  153500. shader: string;
  153501. };
  153502. }
  153503. declare module BABYLON {
  153504. /** @hidden */
  153505. export var spriteMapVertexShader: {
  153506. name: string;
  153507. shader: string;
  153508. };
  153509. }
  153510. declare module BABYLON {
  153511. /**
  153512. * Defines the basic options interface of a SpriteMap
  153513. */
  153514. export interface ISpriteMapOptions {
  153515. /**
  153516. * Vector2 of the number of cells in the grid.
  153517. */
  153518. stageSize?: Vector2;
  153519. /**
  153520. * Vector2 of the size of the output plane in World Units.
  153521. */
  153522. outputSize?: Vector2;
  153523. /**
  153524. * Vector3 of the position of the output plane in World Units.
  153525. */
  153526. outputPosition?: Vector3;
  153527. /**
  153528. * Vector3 of the rotation of the output plane.
  153529. */
  153530. outputRotation?: Vector3;
  153531. /**
  153532. * number of layers that the system will reserve in resources.
  153533. */
  153534. layerCount?: number;
  153535. /**
  153536. * number of max animation frames a single cell will reserve in resources.
  153537. */
  153538. maxAnimationFrames?: number;
  153539. /**
  153540. * number cell index of the base tile when the system compiles.
  153541. */
  153542. baseTile?: number;
  153543. /**
  153544. * boolean flip the sprite after its been repositioned by the framing data.
  153545. */
  153546. flipU?: boolean;
  153547. /**
  153548. * Vector3 scalar of the global RGB values of the SpriteMap.
  153549. */
  153550. colorMultiply?: Vector3;
  153551. }
  153552. /**
  153553. * Defines the IDisposable interface in order to be cleanable from resources.
  153554. */
  153555. export interface ISpriteMap extends IDisposable {
  153556. /**
  153557. * String name of the SpriteMap.
  153558. */
  153559. name: string;
  153560. /**
  153561. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153562. */
  153563. atlasJSON: ISpriteJSONAtlas;
  153564. /**
  153565. * Texture of the SpriteMap.
  153566. */
  153567. spriteSheet: Texture;
  153568. /**
  153569. * The parameters to initialize the SpriteMap with.
  153570. */
  153571. options: ISpriteMapOptions;
  153572. }
  153573. /**
  153574. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153575. */
  153576. export class SpriteMap implements ISpriteMap {
  153577. /** The Name of the spriteMap */
  153578. name: string;
  153579. /** The JSON file with the frame and meta data */
  153580. atlasJSON: ISpriteJSONAtlas;
  153581. /** The systems Sprite Sheet Texture */
  153582. spriteSheet: Texture;
  153583. /** Arguments passed with the Constructor */
  153584. options: ISpriteMapOptions;
  153585. /** Public Sprite Storage array, parsed from atlasJSON */
  153586. sprites: Array<ISpriteJSONSprite>;
  153587. /** Returns the Number of Sprites in the System */
  153588. get spriteCount(): number;
  153589. /** Returns the Position of Output Plane*/
  153590. get position(): Vector3;
  153591. /** Returns the Position of Output Plane*/
  153592. set position(v: Vector3);
  153593. /** Returns the Rotation of Output Plane*/
  153594. get rotation(): Vector3;
  153595. /** Returns the Rotation of Output Plane*/
  153596. set rotation(v: Vector3);
  153597. /** Sets the AnimationMap*/
  153598. get animationMap(): RawTexture;
  153599. /** Sets the AnimationMap*/
  153600. set animationMap(v: RawTexture);
  153601. /** Scene that the SpriteMap was created in */
  153602. private _scene;
  153603. /** Texture Buffer of Float32 that holds tile frame data*/
  153604. private _frameMap;
  153605. /** Texture Buffers of Float32 that holds tileMap data*/
  153606. private _tileMaps;
  153607. /** Texture Buffer of Float32 that holds Animation Data*/
  153608. private _animationMap;
  153609. /** Custom ShaderMaterial Central to the System*/
  153610. private _material;
  153611. /** Custom ShaderMaterial Central to the System*/
  153612. private _output;
  153613. /** Systems Time Ticker*/
  153614. private _time;
  153615. /**
  153616. * Creates a new SpriteMap
  153617. * @param name defines the SpriteMaps Name
  153618. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153619. * @param spriteSheet is the Texture that the Sprites are on.
  153620. * @param options a basic deployment configuration
  153621. * @param scene The Scene that the map is deployed on
  153622. */
  153623. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153624. /**
  153625. * Returns tileID location
  153626. * @returns Vector2 the cell position ID
  153627. */
  153628. getTileID(): Vector2;
  153629. /**
  153630. * Gets the UV location of the mouse over the SpriteMap.
  153631. * @returns Vector2 the UV position of the mouse interaction
  153632. */
  153633. getMousePosition(): Vector2;
  153634. /**
  153635. * Creates the "frame" texture Buffer
  153636. * -------------------------------------
  153637. * Structure of frames
  153638. * "filename": "Falling-Water-2.png",
  153639. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153640. * "rotated": true,
  153641. * "trimmed": true,
  153642. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153643. * "sourceSize": {"w":32,"h":32}
  153644. * @returns RawTexture of the frameMap
  153645. */
  153646. private _createFrameBuffer;
  153647. /**
  153648. * Creates the tileMap texture Buffer
  153649. * @param buffer normally and array of numbers, or a false to generate from scratch
  153650. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153651. * @returns RawTexture of the tileMap
  153652. */
  153653. private _createTileBuffer;
  153654. /**
  153655. * Modifies the data of the tileMaps
  153656. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153657. * @param pos is the iVector2 Coordinates of the Tile
  153658. * @param tile The SpriteIndex of the new Tile
  153659. */
  153660. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153661. /**
  153662. * Creates the animationMap texture Buffer
  153663. * @param buffer normally and array of numbers, or a false to generate from scratch
  153664. * @returns RawTexture of the animationMap
  153665. */
  153666. private _createTileAnimationBuffer;
  153667. /**
  153668. * Modifies the data of the animationMap
  153669. * @param cellID is the Index of the Sprite
  153670. * @param _frame is the target Animation frame
  153671. * @param toCell is the Target Index of the next frame of the animation
  153672. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153673. * @param speed is a global scalar of the time variable on the map.
  153674. */
  153675. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153676. /**
  153677. * Exports the .tilemaps file
  153678. */
  153679. saveTileMaps(): void;
  153680. /**
  153681. * Imports the .tilemaps file
  153682. * @param url of the .tilemaps file
  153683. */
  153684. loadTileMaps(url: string): void;
  153685. /**
  153686. * Release associated resources
  153687. */
  153688. dispose(): void;
  153689. }
  153690. }
  153691. declare module BABYLON {
  153692. /**
  153693. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153694. * @see https://doc.babylonjs.com/babylon101/sprites
  153695. */
  153696. export class SpritePackedManager extends SpriteManager {
  153697. /** defines the packed manager's name */
  153698. name: string;
  153699. /**
  153700. * Creates a new sprite manager from a packed sprite sheet
  153701. * @param name defines the manager's name
  153702. * @param imgUrl defines the sprite sheet url
  153703. * @param capacity defines the maximum allowed number of sprites
  153704. * @param scene defines the hosting scene
  153705. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153706. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153707. * @param samplingMode defines the smapling mode to use with spritesheet
  153708. * @param fromPacked set to true; do not alter
  153709. */
  153710. constructor(
  153711. /** defines the packed manager's name */
  153712. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153713. }
  153714. }
  153715. declare module BABYLON {
  153716. /**
  153717. * Defines the list of states available for a task inside a AssetsManager
  153718. */
  153719. export enum AssetTaskState {
  153720. /**
  153721. * Initialization
  153722. */
  153723. INIT = 0,
  153724. /**
  153725. * Running
  153726. */
  153727. RUNNING = 1,
  153728. /**
  153729. * Done
  153730. */
  153731. DONE = 2,
  153732. /**
  153733. * Error
  153734. */
  153735. ERROR = 3
  153736. }
  153737. /**
  153738. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153739. */
  153740. export abstract class AbstractAssetTask {
  153741. /**
  153742. * Task name
  153743. */ name: string;
  153744. /**
  153745. * Callback called when the task is successful
  153746. */
  153747. onSuccess: (task: any) => void;
  153748. /**
  153749. * Callback called when the task is not successful
  153750. */
  153751. onError: (task: any, message?: string, exception?: any) => void;
  153752. /**
  153753. * Creates a new AssetsManager
  153754. * @param name defines the name of the task
  153755. */
  153756. constructor(
  153757. /**
  153758. * Task name
  153759. */ name: string);
  153760. private _isCompleted;
  153761. private _taskState;
  153762. private _errorObject;
  153763. /**
  153764. * Get if the task is completed
  153765. */
  153766. get isCompleted(): boolean;
  153767. /**
  153768. * Gets the current state of the task
  153769. */
  153770. get taskState(): AssetTaskState;
  153771. /**
  153772. * Gets the current error object (if task is in error)
  153773. */
  153774. get errorObject(): {
  153775. message?: string;
  153776. exception?: any;
  153777. };
  153778. /**
  153779. * Internal only
  153780. * @hidden
  153781. */
  153782. _setErrorObject(message?: string, exception?: any): void;
  153783. /**
  153784. * Execute the current task
  153785. * @param scene defines the scene where you want your assets to be loaded
  153786. * @param onSuccess is a callback called when the task is successfully executed
  153787. * @param onError is a callback called if an error occurs
  153788. */
  153789. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153790. /**
  153791. * Execute the current task
  153792. * @param scene defines the scene where you want your assets to be loaded
  153793. * @param onSuccess is a callback called when the task is successfully executed
  153794. * @param onError is a callback called if an error occurs
  153795. */
  153796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153797. /**
  153798. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153799. * This can be used with failed tasks that have the reason for failure fixed.
  153800. */
  153801. reset(): void;
  153802. private onErrorCallback;
  153803. private onDoneCallback;
  153804. }
  153805. /**
  153806. * Define the interface used by progress events raised during assets loading
  153807. */
  153808. export interface IAssetsProgressEvent {
  153809. /**
  153810. * Defines the number of remaining tasks to process
  153811. */
  153812. remainingCount: number;
  153813. /**
  153814. * Defines the total number of tasks
  153815. */
  153816. totalCount: number;
  153817. /**
  153818. * Defines the task that was just processed
  153819. */
  153820. task: AbstractAssetTask;
  153821. }
  153822. /**
  153823. * Class used to share progress information about assets loading
  153824. */
  153825. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153826. /**
  153827. * Defines the number of remaining tasks to process
  153828. */
  153829. remainingCount: number;
  153830. /**
  153831. * Defines the total number of tasks
  153832. */
  153833. totalCount: number;
  153834. /**
  153835. * Defines the task that was just processed
  153836. */
  153837. task: AbstractAssetTask;
  153838. /**
  153839. * Creates a AssetsProgressEvent
  153840. * @param remainingCount defines the number of remaining tasks to process
  153841. * @param totalCount defines the total number of tasks
  153842. * @param task defines the task that was just processed
  153843. */
  153844. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153845. }
  153846. /**
  153847. * Define a task used by AssetsManager to load assets into a container
  153848. */
  153849. export class ContainerAssetTask extends AbstractAssetTask {
  153850. /**
  153851. * Defines the name of the task
  153852. */
  153853. name: string;
  153854. /**
  153855. * Defines the list of mesh's names you want to load
  153856. */
  153857. meshesNames: any;
  153858. /**
  153859. * Defines the root url to use as a base to load your meshes and associated resources
  153860. */
  153861. rootUrl: string;
  153862. /**
  153863. * Defines the filename or File of the scene to load from
  153864. */
  153865. sceneFilename: string | File;
  153866. /**
  153867. * Get the loaded asset container
  153868. */
  153869. loadedContainer: AssetContainer;
  153870. /**
  153871. * Gets the list of loaded meshes
  153872. */
  153873. loadedMeshes: Array<AbstractMesh>;
  153874. /**
  153875. * Gets the list of loaded particle systems
  153876. */
  153877. loadedParticleSystems: Array<IParticleSystem>;
  153878. /**
  153879. * Gets the list of loaded skeletons
  153880. */
  153881. loadedSkeletons: Array<Skeleton>;
  153882. /**
  153883. * Gets the list of loaded animation groups
  153884. */
  153885. loadedAnimationGroups: Array<AnimationGroup>;
  153886. /**
  153887. * Callback called when the task is successful
  153888. */
  153889. onSuccess: (task: ContainerAssetTask) => void;
  153890. /**
  153891. * Callback called when the task is successful
  153892. */
  153893. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153894. /**
  153895. * Creates a new ContainerAssetTask
  153896. * @param name defines the name of the task
  153897. * @param meshesNames defines the list of mesh's names you want to load
  153898. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153899. * @param sceneFilename defines the filename or File of the scene to load from
  153900. */
  153901. constructor(
  153902. /**
  153903. * Defines the name of the task
  153904. */
  153905. name: string,
  153906. /**
  153907. * Defines the list of mesh's names you want to load
  153908. */
  153909. meshesNames: any,
  153910. /**
  153911. * Defines the root url to use as a base to load your meshes and associated resources
  153912. */
  153913. rootUrl: string,
  153914. /**
  153915. * Defines the filename or File of the scene to load from
  153916. */
  153917. sceneFilename: string | File);
  153918. /**
  153919. * Execute the current task
  153920. * @param scene defines the scene where you want your assets to be loaded
  153921. * @param onSuccess is a callback called when the task is successfully executed
  153922. * @param onError is a callback called if an error occurs
  153923. */
  153924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153925. }
  153926. /**
  153927. * Define a task used by AssetsManager to load meshes
  153928. */
  153929. export class MeshAssetTask extends AbstractAssetTask {
  153930. /**
  153931. * Defines the name of the task
  153932. */
  153933. name: string;
  153934. /**
  153935. * Defines the list of mesh's names you want to load
  153936. */
  153937. meshesNames: any;
  153938. /**
  153939. * Defines the root url to use as a base to load your meshes and associated resources
  153940. */
  153941. rootUrl: string;
  153942. /**
  153943. * Defines the filename or File of the scene to load from
  153944. */
  153945. sceneFilename: string | File;
  153946. /**
  153947. * Gets the list of loaded meshes
  153948. */
  153949. loadedMeshes: Array<AbstractMesh>;
  153950. /**
  153951. * Gets the list of loaded particle systems
  153952. */
  153953. loadedParticleSystems: Array<IParticleSystem>;
  153954. /**
  153955. * Gets the list of loaded skeletons
  153956. */
  153957. loadedSkeletons: Array<Skeleton>;
  153958. /**
  153959. * Gets the list of loaded animation groups
  153960. */
  153961. loadedAnimationGroups: Array<AnimationGroup>;
  153962. /**
  153963. * Callback called when the task is successful
  153964. */
  153965. onSuccess: (task: MeshAssetTask) => void;
  153966. /**
  153967. * Callback called when the task is successful
  153968. */
  153969. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153970. /**
  153971. * Creates a new MeshAssetTask
  153972. * @param name defines the name of the task
  153973. * @param meshesNames defines the list of mesh's names you want to load
  153974. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153975. * @param sceneFilename defines the filename or File of the scene to load from
  153976. */
  153977. constructor(
  153978. /**
  153979. * Defines the name of the task
  153980. */
  153981. name: string,
  153982. /**
  153983. * Defines the list of mesh's names you want to load
  153984. */
  153985. meshesNames: any,
  153986. /**
  153987. * Defines the root url to use as a base to load your meshes and associated resources
  153988. */
  153989. rootUrl: string,
  153990. /**
  153991. * Defines the filename or File of the scene to load from
  153992. */
  153993. sceneFilename: string | File);
  153994. /**
  153995. * Execute the current task
  153996. * @param scene defines the scene where you want your assets to be loaded
  153997. * @param onSuccess is a callback called when the task is successfully executed
  153998. * @param onError is a callback called if an error occurs
  153999. */
  154000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154001. }
  154002. /**
  154003. * Define a task used by AssetsManager to load text content
  154004. */
  154005. export class TextFileAssetTask extends AbstractAssetTask {
  154006. /**
  154007. * Defines the name of the task
  154008. */
  154009. name: string;
  154010. /**
  154011. * Defines the location of the file to load
  154012. */
  154013. url: string;
  154014. /**
  154015. * Gets the loaded text string
  154016. */
  154017. text: string;
  154018. /**
  154019. * Callback called when the task is successful
  154020. */
  154021. onSuccess: (task: TextFileAssetTask) => void;
  154022. /**
  154023. * Callback called when the task is successful
  154024. */
  154025. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154026. /**
  154027. * Creates a new TextFileAssetTask object
  154028. * @param name defines the name of the task
  154029. * @param url defines the location of the file to load
  154030. */
  154031. constructor(
  154032. /**
  154033. * Defines the name of the task
  154034. */
  154035. name: string,
  154036. /**
  154037. * Defines the location of the file to load
  154038. */
  154039. url: string);
  154040. /**
  154041. * Execute the current task
  154042. * @param scene defines the scene where you want your assets to be loaded
  154043. * @param onSuccess is a callback called when the task is successfully executed
  154044. * @param onError is a callback called if an error occurs
  154045. */
  154046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154047. }
  154048. /**
  154049. * Define a task used by AssetsManager to load binary data
  154050. */
  154051. export class BinaryFileAssetTask extends AbstractAssetTask {
  154052. /**
  154053. * Defines the name of the task
  154054. */
  154055. name: string;
  154056. /**
  154057. * Defines the location of the file to load
  154058. */
  154059. url: string;
  154060. /**
  154061. * Gets the lodaded data (as an array buffer)
  154062. */
  154063. data: ArrayBuffer;
  154064. /**
  154065. * Callback called when the task is successful
  154066. */
  154067. onSuccess: (task: BinaryFileAssetTask) => void;
  154068. /**
  154069. * Callback called when the task is successful
  154070. */
  154071. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154072. /**
  154073. * Creates a new BinaryFileAssetTask object
  154074. * @param name defines the name of the new task
  154075. * @param url defines the location of the file to load
  154076. */
  154077. constructor(
  154078. /**
  154079. * Defines the name of the task
  154080. */
  154081. name: string,
  154082. /**
  154083. * Defines the location of the file to load
  154084. */
  154085. url: string);
  154086. /**
  154087. * Execute the current task
  154088. * @param scene defines the scene where you want your assets to be loaded
  154089. * @param onSuccess is a callback called when the task is successfully executed
  154090. * @param onError is a callback called if an error occurs
  154091. */
  154092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154093. }
  154094. /**
  154095. * Define a task used by AssetsManager to load images
  154096. */
  154097. export class ImageAssetTask extends AbstractAssetTask {
  154098. /**
  154099. * Defines the name of the task
  154100. */
  154101. name: string;
  154102. /**
  154103. * Defines the location of the image to load
  154104. */
  154105. url: string;
  154106. /**
  154107. * Gets the loaded images
  154108. */
  154109. image: HTMLImageElement;
  154110. /**
  154111. * Callback called when the task is successful
  154112. */
  154113. onSuccess: (task: ImageAssetTask) => void;
  154114. /**
  154115. * Callback called when the task is successful
  154116. */
  154117. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154118. /**
  154119. * Creates a new ImageAssetTask
  154120. * @param name defines the name of the task
  154121. * @param url defines the location of the image to load
  154122. */
  154123. constructor(
  154124. /**
  154125. * Defines the name of the task
  154126. */
  154127. name: string,
  154128. /**
  154129. * Defines the location of the image to load
  154130. */
  154131. url: string);
  154132. /**
  154133. * Execute the current task
  154134. * @param scene defines the scene where you want your assets to be loaded
  154135. * @param onSuccess is a callback called when the task is successfully executed
  154136. * @param onError is a callback called if an error occurs
  154137. */
  154138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154139. }
  154140. /**
  154141. * Defines the interface used by texture loading tasks
  154142. */
  154143. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154144. /**
  154145. * Gets the loaded texture
  154146. */
  154147. texture: TEX;
  154148. }
  154149. /**
  154150. * Define a task used by AssetsManager to load 2D textures
  154151. */
  154152. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154153. /**
  154154. * Defines the name of the task
  154155. */
  154156. name: string;
  154157. /**
  154158. * Defines the location of the file to load
  154159. */
  154160. url: string;
  154161. /**
  154162. * Defines if mipmap should not be generated (default is false)
  154163. */
  154164. noMipmap?: boolean | undefined;
  154165. /**
  154166. * Defines if texture must be inverted on Y axis (default is true)
  154167. */
  154168. invertY: boolean;
  154169. /**
  154170. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154171. */
  154172. samplingMode: number;
  154173. /**
  154174. * Gets the loaded texture
  154175. */
  154176. texture: Texture;
  154177. /**
  154178. * Callback called when the task is successful
  154179. */
  154180. onSuccess: (task: TextureAssetTask) => void;
  154181. /**
  154182. * Callback called when the task is successful
  154183. */
  154184. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154185. /**
  154186. * Creates a new TextureAssetTask object
  154187. * @param name defines the name of the task
  154188. * @param url defines the location of the file to load
  154189. * @param noMipmap defines if mipmap should not be generated (default is false)
  154190. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154191. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154192. */
  154193. constructor(
  154194. /**
  154195. * Defines the name of the task
  154196. */
  154197. name: string,
  154198. /**
  154199. * Defines the location of the file to load
  154200. */
  154201. url: string,
  154202. /**
  154203. * Defines if mipmap should not be generated (default is false)
  154204. */
  154205. noMipmap?: boolean | undefined,
  154206. /**
  154207. * Defines if texture must be inverted on Y axis (default is true)
  154208. */
  154209. invertY?: boolean,
  154210. /**
  154211. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154212. */
  154213. samplingMode?: number);
  154214. /**
  154215. * Execute the current task
  154216. * @param scene defines the scene where you want your assets to be loaded
  154217. * @param onSuccess is a callback called when the task is successfully executed
  154218. * @param onError is a callback called if an error occurs
  154219. */
  154220. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154221. }
  154222. /**
  154223. * Define a task used by AssetsManager to load cube textures
  154224. */
  154225. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154226. /**
  154227. * Defines the name of the task
  154228. */
  154229. name: string;
  154230. /**
  154231. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154232. */
  154233. url: string;
  154234. /**
  154235. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154236. */
  154237. extensions?: string[] | undefined;
  154238. /**
  154239. * Defines if mipmaps should not be generated (default is false)
  154240. */
  154241. noMipmap?: boolean | undefined;
  154242. /**
  154243. * Defines the explicit list of files (undefined by default)
  154244. */
  154245. files?: string[] | undefined;
  154246. /**
  154247. * Gets the loaded texture
  154248. */
  154249. texture: CubeTexture;
  154250. /**
  154251. * Callback called when the task is successful
  154252. */
  154253. onSuccess: (task: CubeTextureAssetTask) => void;
  154254. /**
  154255. * Callback called when the task is successful
  154256. */
  154257. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154258. /**
  154259. * Creates a new CubeTextureAssetTask
  154260. * @param name defines the name of the task
  154261. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154262. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154263. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154264. * @param files defines the explicit list of files (undefined by default)
  154265. */
  154266. constructor(
  154267. /**
  154268. * Defines the name of the task
  154269. */
  154270. name: string,
  154271. /**
  154272. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154273. */
  154274. url: string,
  154275. /**
  154276. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154277. */
  154278. extensions?: string[] | undefined,
  154279. /**
  154280. * Defines if mipmaps should not be generated (default is false)
  154281. */
  154282. noMipmap?: boolean | undefined,
  154283. /**
  154284. * Defines the explicit list of files (undefined by default)
  154285. */
  154286. files?: string[] | undefined);
  154287. /**
  154288. * Execute the current task
  154289. * @param scene defines the scene where you want your assets to be loaded
  154290. * @param onSuccess is a callback called when the task is successfully executed
  154291. * @param onError is a callback called if an error occurs
  154292. */
  154293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154294. }
  154295. /**
  154296. * Define a task used by AssetsManager to load HDR cube textures
  154297. */
  154298. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154299. /**
  154300. * Defines the name of the task
  154301. */
  154302. name: string;
  154303. /**
  154304. * Defines the location of the file to load
  154305. */
  154306. url: string;
  154307. /**
  154308. * Defines the desired size (the more it increases the longer the generation will be)
  154309. */
  154310. size: number;
  154311. /**
  154312. * Defines if mipmaps should not be generated (default is false)
  154313. */
  154314. noMipmap: boolean;
  154315. /**
  154316. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154317. */
  154318. generateHarmonics: boolean;
  154319. /**
  154320. * 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)
  154321. */
  154322. gammaSpace: boolean;
  154323. /**
  154324. * Internal Use Only
  154325. */
  154326. reserved: boolean;
  154327. /**
  154328. * Gets the loaded texture
  154329. */
  154330. texture: HDRCubeTexture;
  154331. /**
  154332. * Callback called when the task is successful
  154333. */
  154334. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154335. /**
  154336. * Callback called when the task is successful
  154337. */
  154338. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154339. /**
  154340. * Creates a new HDRCubeTextureAssetTask object
  154341. * @param name defines the name of the task
  154342. * @param url defines the location of the file to load
  154343. * @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.
  154344. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154345. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154346. * @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)
  154347. * @param reserved Internal use only
  154348. */
  154349. constructor(
  154350. /**
  154351. * Defines the name of the task
  154352. */
  154353. name: string,
  154354. /**
  154355. * Defines the location of the file to load
  154356. */
  154357. url: string,
  154358. /**
  154359. * Defines the desired size (the more it increases the longer the generation will be)
  154360. */
  154361. size: number,
  154362. /**
  154363. * Defines if mipmaps should not be generated (default is false)
  154364. */
  154365. noMipmap?: boolean,
  154366. /**
  154367. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154368. */
  154369. generateHarmonics?: boolean,
  154370. /**
  154371. * 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)
  154372. */
  154373. gammaSpace?: boolean,
  154374. /**
  154375. * Internal Use Only
  154376. */
  154377. reserved?: boolean);
  154378. /**
  154379. * Execute the current task
  154380. * @param scene defines the scene where you want your assets to be loaded
  154381. * @param onSuccess is a callback called when the task is successfully executed
  154382. * @param onError is a callback called if an error occurs
  154383. */
  154384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154385. }
  154386. /**
  154387. * Define a task used by AssetsManager to load Equirectangular cube textures
  154388. */
  154389. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154390. /**
  154391. * Defines the name of the task
  154392. */
  154393. name: string;
  154394. /**
  154395. * Defines the location of the file to load
  154396. */
  154397. url: string;
  154398. /**
  154399. * Defines the desired size (the more it increases the longer the generation will be)
  154400. */
  154401. size: number;
  154402. /**
  154403. * Defines if mipmaps should not be generated (default is false)
  154404. */
  154405. noMipmap: boolean;
  154406. /**
  154407. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154408. * but the standard material would require them in Gamma space) (default is true)
  154409. */
  154410. gammaSpace: boolean;
  154411. /**
  154412. * Gets the loaded texture
  154413. */
  154414. texture: EquiRectangularCubeTexture;
  154415. /**
  154416. * Callback called when the task is successful
  154417. */
  154418. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154419. /**
  154420. * Callback called when the task is successful
  154421. */
  154422. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154423. /**
  154424. * Creates a new EquiRectangularCubeTextureAssetTask object
  154425. * @param name defines the name of the task
  154426. * @param url defines the location of the file to load
  154427. * @param size defines the desired size (the more it increases the longer the generation will be)
  154428. * If the size is omitted this implies you are using a preprocessed cubemap.
  154429. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154430. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154431. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154432. * (default is true)
  154433. */
  154434. constructor(
  154435. /**
  154436. * Defines the name of the task
  154437. */
  154438. name: string,
  154439. /**
  154440. * Defines the location of the file to load
  154441. */
  154442. url: string,
  154443. /**
  154444. * Defines the desired size (the more it increases the longer the generation will be)
  154445. */
  154446. size: number,
  154447. /**
  154448. * Defines if mipmaps should not be generated (default is false)
  154449. */
  154450. noMipmap?: boolean,
  154451. /**
  154452. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154453. * but the standard material would require them in Gamma space) (default is true)
  154454. */
  154455. gammaSpace?: boolean);
  154456. /**
  154457. * Execute the current task
  154458. * @param scene defines the scene where you want your assets to be loaded
  154459. * @param onSuccess is a callback called when the task is successfully executed
  154460. * @param onError is a callback called if an error occurs
  154461. */
  154462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154463. }
  154464. /**
  154465. * This class can be used to easily import assets into a scene
  154466. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154467. */
  154468. export class AssetsManager {
  154469. private _scene;
  154470. private _isLoading;
  154471. protected _tasks: AbstractAssetTask[];
  154472. protected _waitingTasksCount: number;
  154473. protected _totalTasksCount: number;
  154474. /**
  154475. * Callback called when all tasks are processed
  154476. */
  154477. onFinish: (tasks: AbstractAssetTask[]) => void;
  154478. /**
  154479. * Callback called when a task is successful
  154480. */
  154481. onTaskSuccess: (task: AbstractAssetTask) => void;
  154482. /**
  154483. * Callback called when a task had an error
  154484. */
  154485. onTaskError: (task: AbstractAssetTask) => void;
  154486. /**
  154487. * Callback called when a task is done (whatever the result is)
  154488. */
  154489. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154490. /**
  154491. * Observable called when all tasks are processed
  154492. */
  154493. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154494. /**
  154495. * Observable called when a task had an error
  154496. */
  154497. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154498. /**
  154499. * Observable called when all tasks were executed
  154500. */
  154501. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154502. /**
  154503. * Observable called when a task is done (whatever the result is)
  154504. */
  154505. onProgressObservable: Observable<IAssetsProgressEvent>;
  154506. /**
  154507. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154508. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154509. */
  154510. useDefaultLoadingScreen: boolean;
  154511. /**
  154512. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154513. * when all assets have been downloaded.
  154514. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154515. */
  154516. autoHideLoadingUI: boolean;
  154517. /**
  154518. * Creates a new AssetsManager
  154519. * @param scene defines the scene to work on
  154520. */
  154521. constructor(scene: Scene);
  154522. /**
  154523. * Add a ContainerAssetTask to the list of active tasks
  154524. * @param taskName defines the name of the new task
  154525. * @param meshesNames defines the name of meshes to load
  154526. * @param rootUrl defines the root url to use to locate files
  154527. * @param sceneFilename defines the filename of the scene file
  154528. * @returns a new ContainerAssetTask object
  154529. */
  154530. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154531. /**
  154532. * Add a MeshAssetTask to the list of active tasks
  154533. * @param taskName defines the name of the new task
  154534. * @param meshesNames defines the name of meshes to load
  154535. * @param rootUrl defines the root url to use to locate files
  154536. * @param sceneFilename defines the filename of the scene file
  154537. * @returns a new MeshAssetTask object
  154538. */
  154539. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154540. /**
  154541. * Add a TextFileAssetTask to the list of active tasks
  154542. * @param taskName defines the name of the new task
  154543. * @param url defines the url of the file to load
  154544. * @returns a new TextFileAssetTask object
  154545. */
  154546. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154547. /**
  154548. * Add a BinaryFileAssetTask to the list of active tasks
  154549. * @param taskName defines the name of the new task
  154550. * @param url defines the url of the file to load
  154551. * @returns a new BinaryFileAssetTask object
  154552. */
  154553. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154554. /**
  154555. * Add a ImageAssetTask to the list of active tasks
  154556. * @param taskName defines the name of the new task
  154557. * @param url defines the url of the file to load
  154558. * @returns a new ImageAssetTask object
  154559. */
  154560. addImageTask(taskName: string, url: string): ImageAssetTask;
  154561. /**
  154562. * Add a TextureAssetTask to the list of active tasks
  154563. * @param taskName defines the name of the new task
  154564. * @param url defines the url of the file to load
  154565. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154566. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154567. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154568. * @returns a new TextureAssetTask object
  154569. */
  154570. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154571. /**
  154572. * Add a CubeTextureAssetTask to the list of active tasks
  154573. * @param taskName defines the name of the new task
  154574. * @param url defines the url of the file to load
  154575. * @param extensions defines the extension to use to load the cube map (can be null)
  154576. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154577. * @param files defines the list of files to load (can be null)
  154578. * @returns a new CubeTextureAssetTask object
  154579. */
  154580. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154581. /**
  154582. *
  154583. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154584. * @param taskName defines the name of the new task
  154585. * @param url defines the url of the file to load
  154586. * @param size defines the size you want for the cubemap (can be null)
  154587. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154588. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154589. * @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)
  154590. * @param reserved Internal use only
  154591. * @returns a new HDRCubeTextureAssetTask object
  154592. */
  154593. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154594. /**
  154595. *
  154596. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154597. * @param taskName defines the name of the new task
  154598. * @param url defines the url of the file to load
  154599. * @param size defines the size you want for the cubemap (can be null)
  154600. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154601. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154602. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154603. * @returns a new EquiRectangularCubeTextureAssetTask object
  154604. */
  154605. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154606. /**
  154607. * Remove a task from the assets manager.
  154608. * @param task the task to remove
  154609. */
  154610. removeTask(task: AbstractAssetTask): void;
  154611. private _decreaseWaitingTasksCount;
  154612. private _runTask;
  154613. /**
  154614. * Reset the AssetsManager and remove all tasks
  154615. * @return the current instance of the AssetsManager
  154616. */
  154617. reset(): AssetsManager;
  154618. /**
  154619. * Start the loading process
  154620. * @return the current instance of the AssetsManager
  154621. */
  154622. load(): AssetsManager;
  154623. /**
  154624. * Start the loading process as an async operation
  154625. * @return a promise returning the list of failed tasks
  154626. */
  154627. loadAsync(): Promise<void>;
  154628. }
  154629. }
  154630. declare module BABYLON {
  154631. /**
  154632. * Wrapper class for promise with external resolve and reject.
  154633. */
  154634. export class Deferred<T> {
  154635. /**
  154636. * The promise associated with this deferred object.
  154637. */
  154638. readonly promise: Promise<T>;
  154639. private _resolve;
  154640. private _reject;
  154641. /**
  154642. * The resolve method of the promise associated with this deferred object.
  154643. */
  154644. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154645. /**
  154646. * The reject method of the promise associated with this deferred object.
  154647. */
  154648. get reject(): (reason?: any) => void;
  154649. /**
  154650. * Constructor for this deferred object.
  154651. */
  154652. constructor();
  154653. }
  154654. }
  154655. declare module BABYLON {
  154656. /**
  154657. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154658. */
  154659. export class MeshExploder {
  154660. private _centerMesh;
  154661. private _meshes;
  154662. private _meshesOrigins;
  154663. private _toCenterVectors;
  154664. private _scaledDirection;
  154665. private _newPosition;
  154666. private _centerPosition;
  154667. /**
  154668. * Explodes meshes from a center mesh.
  154669. * @param meshes The meshes to explode.
  154670. * @param centerMesh The mesh to be center of explosion.
  154671. */
  154672. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154673. private _setCenterMesh;
  154674. /**
  154675. * Get class name
  154676. * @returns "MeshExploder"
  154677. */
  154678. getClassName(): string;
  154679. /**
  154680. * "Exploded meshes"
  154681. * @returns Array of meshes with the centerMesh at index 0.
  154682. */
  154683. getMeshes(): Array<Mesh>;
  154684. /**
  154685. * Explodes meshes giving a specific direction
  154686. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154687. */
  154688. explode(direction?: number): void;
  154689. }
  154690. }
  154691. declare module BABYLON {
  154692. /**
  154693. * Class used to help managing file picking and drag'n'drop
  154694. */
  154695. export class FilesInput {
  154696. /**
  154697. * List of files ready to be loaded
  154698. */
  154699. static get FilesToLoad(): {
  154700. [key: string]: File;
  154701. };
  154702. /**
  154703. * Callback called when a file is processed
  154704. */
  154705. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154706. private _engine;
  154707. private _currentScene;
  154708. private _sceneLoadedCallback;
  154709. private _progressCallback;
  154710. private _additionalRenderLoopLogicCallback;
  154711. private _textureLoadingCallback;
  154712. private _startingProcessingFilesCallback;
  154713. private _onReloadCallback;
  154714. private _errorCallback;
  154715. private _elementToMonitor;
  154716. private _sceneFileToLoad;
  154717. private _filesToLoad;
  154718. /**
  154719. * Creates a new FilesInput
  154720. * @param engine defines the rendering engine
  154721. * @param scene defines the hosting scene
  154722. * @param sceneLoadedCallback callback called when scene is loaded
  154723. * @param progressCallback callback called to track progress
  154724. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154725. * @param textureLoadingCallback callback called when a texture is loading
  154726. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154727. * @param onReloadCallback callback called when a reload is requested
  154728. * @param errorCallback callback call if an error occurs
  154729. */
  154730. 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>);
  154731. private _dragEnterHandler;
  154732. private _dragOverHandler;
  154733. private _dropHandler;
  154734. /**
  154735. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154736. * @param elementToMonitor defines the DOM element to track
  154737. */
  154738. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154739. /** Gets the current list of files to load */
  154740. get filesToLoad(): File[];
  154741. /**
  154742. * Release all associated resources
  154743. */
  154744. dispose(): void;
  154745. private renderFunction;
  154746. private drag;
  154747. private drop;
  154748. private _traverseFolder;
  154749. private _processFiles;
  154750. /**
  154751. * Load files from a drop event
  154752. * @param event defines the drop event to use as source
  154753. */
  154754. loadFiles(event: any): void;
  154755. private _processReload;
  154756. /**
  154757. * Reload the current scene from the loaded files
  154758. */
  154759. reload(): void;
  154760. }
  154761. }
  154762. declare module BABYLON {
  154763. /**
  154764. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154765. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154766. */
  154767. export class SceneOptimization {
  154768. /**
  154769. * Defines the priority of this optimization (0 by default which means first in the list)
  154770. */
  154771. priority: number;
  154772. /**
  154773. * Gets a string describing the action executed by the current optimization
  154774. * @returns description string
  154775. */
  154776. getDescription(): string;
  154777. /**
  154778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154779. * @param scene defines the current scene where to apply this optimization
  154780. * @param optimizer defines the current optimizer
  154781. * @returns true if everything that can be done was applied
  154782. */
  154783. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154784. /**
  154785. * Creates the SceneOptimization object
  154786. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154787. * @param desc defines the description associated with the optimization
  154788. */
  154789. constructor(
  154790. /**
  154791. * Defines the priority of this optimization (0 by default which means first in the list)
  154792. */
  154793. priority?: number);
  154794. }
  154795. /**
  154796. * Defines an optimization used to reduce the size of render target textures
  154797. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154798. */
  154799. export class TextureOptimization extends SceneOptimization {
  154800. /**
  154801. * Defines the priority of this optimization (0 by default which means first in the list)
  154802. */
  154803. priority: number;
  154804. /**
  154805. * 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
  154806. */
  154807. maximumSize: number;
  154808. /**
  154809. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154810. */
  154811. step: number;
  154812. /**
  154813. * Gets a string describing the action executed by the current optimization
  154814. * @returns description string
  154815. */
  154816. getDescription(): string;
  154817. /**
  154818. * Creates the TextureOptimization object
  154819. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154820. * @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
  154821. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154822. */
  154823. constructor(
  154824. /**
  154825. * Defines the priority of this optimization (0 by default which means first in the list)
  154826. */
  154827. priority?: number,
  154828. /**
  154829. * 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
  154830. */
  154831. maximumSize?: number,
  154832. /**
  154833. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154834. */
  154835. step?: number);
  154836. /**
  154837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154838. * @param scene defines the current scene where to apply this optimization
  154839. * @param optimizer defines the current optimizer
  154840. * @returns true if everything that can be done was applied
  154841. */
  154842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154843. }
  154844. /**
  154845. * Defines an optimization used to increase or decrease the rendering resolution
  154846. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154847. */
  154848. export class HardwareScalingOptimization extends SceneOptimization {
  154849. /**
  154850. * Defines the priority of this optimization (0 by default which means first in the list)
  154851. */
  154852. priority: number;
  154853. /**
  154854. * Defines the maximum scale to use (2 by default)
  154855. */
  154856. maximumScale: number;
  154857. /**
  154858. * Defines the step to use between two passes (0.5 by default)
  154859. */
  154860. step: number;
  154861. private _currentScale;
  154862. private _directionOffset;
  154863. /**
  154864. * Gets a string describing the action executed by the current optimization
  154865. * @return description string
  154866. */
  154867. getDescription(): string;
  154868. /**
  154869. * Creates the HardwareScalingOptimization object
  154870. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154871. * @param maximumScale defines the maximum scale to use (2 by default)
  154872. * @param step defines the step to use between two passes (0.5 by default)
  154873. */
  154874. constructor(
  154875. /**
  154876. * Defines the priority of this optimization (0 by default which means first in the list)
  154877. */
  154878. priority?: number,
  154879. /**
  154880. * Defines the maximum scale to use (2 by default)
  154881. */
  154882. maximumScale?: number,
  154883. /**
  154884. * Defines the step to use between two passes (0.5 by default)
  154885. */
  154886. step?: number);
  154887. /**
  154888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154889. * @param scene defines the current scene where to apply this optimization
  154890. * @param optimizer defines the current optimizer
  154891. * @returns true if everything that can be done was applied
  154892. */
  154893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154894. }
  154895. /**
  154896. * Defines an optimization used to remove shadows
  154897. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154898. */
  154899. export class ShadowsOptimization extends SceneOptimization {
  154900. /**
  154901. * Gets a string describing the action executed by the current optimization
  154902. * @return description string
  154903. */
  154904. getDescription(): string;
  154905. /**
  154906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154907. * @param scene defines the current scene where to apply this optimization
  154908. * @param optimizer defines the current optimizer
  154909. * @returns true if everything that can be done was applied
  154910. */
  154911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154912. }
  154913. /**
  154914. * Defines an optimization used to turn post-processes off
  154915. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154916. */
  154917. export class PostProcessesOptimization extends SceneOptimization {
  154918. /**
  154919. * Gets a string describing the action executed by the current optimization
  154920. * @return description string
  154921. */
  154922. getDescription(): string;
  154923. /**
  154924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154925. * @param scene defines the current scene where to apply this optimization
  154926. * @param optimizer defines the current optimizer
  154927. * @returns true if everything that can be done was applied
  154928. */
  154929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154930. }
  154931. /**
  154932. * Defines an optimization used to turn lens flares off
  154933. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154934. */
  154935. export class LensFlaresOptimization extends SceneOptimization {
  154936. /**
  154937. * Gets a string describing the action executed by the current optimization
  154938. * @return description string
  154939. */
  154940. getDescription(): string;
  154941. /**
  154942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154943. * @param scene defines the current scene where to apply this optimization
  154944. * @param optimizer defines the current optimizer
  154945. * @returns true if everything that can be done was applied
  154946. */
  154947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154948. }
  154949. /**
  154950. * Defines an optimization based on user defined callback.
  154951. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154952. */
  154953. export class CustomOptimization extends SceneOptimization {
  154954. /**
  154955. * Callback called to apply the custom optimization.
  154956. */
  154957. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154958. /**
  154959. * Callback called to get custom description
  154960. */
  154961. onGetDescription: () => string;
  154962. /**
  154963. * Gets a string describing the action executed by the current optimization
  154964. * @returns description string
  154965. */
  154966. getDescription(): string;
  154967. /**
  154968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154969. * @param scene defines the current scene where to apply this optimization
  154970. * @param optimizer defines the current optimizer
  154971. * @returns true if everything that can be done was applied
  154972. */
  154973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154974. }
  154975. /**
  154976. * Defines an optimization used to turn particles off
  154977. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154978. */
  154979. export class ParticlesOptimization extends SceneOptimization {
  154980. /**
  154981. * Gets a string describing the action executed by the current optimization
  154982. * @return description string
  154983. */
  154984. getDescription(): string;
  154985. /**
  154986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154987. * @param scene defines the current scene where to apply this optimization
  154988. * @param optimizer defines the current optimizer
  154989. * @returns true if everything that can be done was applied
  154990. */
  154991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154992. }
  154993. /**
  154994. * Defines an optimization used to turn render targets off
  154995. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154996. */
  154997. export class RenderTargetsOptimization extends SceneOptimization {
  154998. /**
  154999. * Gets a string describing the action executed by the current optimization
  155000. * @return description string
  155001. */
  155002. getDescription(): string;
  155003. /**
  155004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155005. * @param scene defines the current scene where to apply this optimization
  155006. * @param optimizer defines the current optimizer
  155007. * @returns true if everything that can be done was applied
  155008. */
  155009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155010. }
  155011. /**
  155012. * Defines an optimization used to merge meshes with compatible materials
  155013. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155014. */
  155015. export class MergeMeshesOptimization extends SceneOptimization {
  155016. private static _UpdateSelectionTree;
  155017. /**
  155018. * Gets or sets a boolean which defines if optimization octree has to be updated
  155019. */
  155020. static get UpdateSelectionTree(): boolean;
  155021. /**
  155022. * Gets or sets a boolean which defines if optimization octree has to be updated
  155023. */
  155024. static set UpdateSelectionTree(value: boolean);
  155025. /**
  155026. * Gets a string describing the action executed by the current optimization
  155027. * @return description string
  155028. */
  155029. getDescription(): string;
  155030. private _canBeMerged;
  155031. /**
  155032. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155033. * @param scene defines the current scene where to apply this optimization
  155034. * @param optimizer defines the current optimizer
  155035. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155036. * @returns true if everything that can be done was applied
  155037. */
  155038. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155039. }
  155040. /**
  155041. * Defines a list of options used by SceneOptimizer
  155042. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155043. */
  155044. export class SceneOptimizerOptions {
  155045. /**
  155046. * Defines the target frame rate to reach (60 by default)
  155047. */
  155048. targetFrameRate: number;
  155049. /**
  155050. * Defines the interval between two checkes (2000ms by default)
  155051. */
  155052. trackerDuration: number;
  155053. /**
  155054. * Gets the list of optimizations to apply
  155055. */
  155056. optimizations: SceneOptimization[];
  155057. /**
  155058. * Creates a new list of options used by SceneOptimizer
  155059. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155060. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155061. */
  155062. constructor(
  155063. /**
  155064. * Defines the target frame rate to reach (60 by default)
  155065. */
  155066. targetFrameRate?: number,
  155067. /**
  155068. * Defines the interval between two checkes (2000ms by default)
  155069. */
  155070. trackerDuration?: number);
  155071. /**
  155072. * Add a new optimization
  155073. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155074. * @returns the current SceneOptimizerOptions
  155075. */
  155076. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155077. /**
  155078. * Add a new custom optimization
  155079. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155080. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155081. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155082. * @returns the current SceneOptimizerOptions
  155083. */
  155084. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155085. /**
  155086. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155087. * @param targetFrameRate defines the target frame rate (60 by default)
  155088. * @returns a SceneOptimizerOptions object
  155089. */
  155090. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155091. /**
  155092. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155093. * @param targetFrameRate defines the target frame rate (60 by default)
  155094. * @returns a SceneOptimizerOptions object
  155095. */
  155096. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155097. /**
  155098. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155099. * @param targetFrameRate defines the target frame rate (60 by default)
  155100. * @returns a SceneOptimizerOptions object
  155101. */
  155102. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155103. }
  155104. /**
  155105. * Class used to run optimizations in order to reach a target frame rate
  155106. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155107. */
  155108. export class SceneOptimizer implements IDisposable {
  155109. private _isRunning;
  155110. private _options;
  155111. private _scene;
  155112. private _currentPriorityLevel;
  155113. private _targetFrameRate;
  155114. private _trackerDuration;
  155115. private _currentFrameRate;
  155116. private _sceneDisposeObserver;
  155117. private _improvementMode;
  155118. /**
  155119. * Defines an observable called when the optimizer reaches the target frame rate
  155120. */
  155121. onSuccessObservable: Observable<SceneOptimizer>;
  155122. /**
  155123. * Defines an observable called when the optimizer enables an optimization
  155124. */
  155125. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155126. /**
  155127. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155128. */
  155129. onFailureObservable: Observable<SceneOptimizer>;
  155130. /**
  155131. * Gets a boolean indicating if the optimizer is in improvement mode
  155132. */
  155133. get isInImprovementMode(): boolean;
  155134. /**
  155135. * Gets the current priority level (0 at start)
  155136. */
  155137. get currentPriorityLevel(): number;
  155138. /**
  155139. * Gets the current frame rate checked by the SceneOptimizer
  155140. */
  155141. get currentFrameRate(): number;
  155142. /**
  155143. * Gets or sets the current target frame rate (60 by default)
  155144. */
  155145. get targetFrameRate(): number;
  155146. /**
  155147. * Gets or sets the current target frame rate (60 by default)
  155148. */
  155149. set targetFrameRate(value: number);
  155150. /**
  155151. * Gets or sets the current interval between two checks (every 2000ms by default)
  155152. */
  155153. get trackerDuration(): number;
  155154. /**
  155155. * Gets or sets the current interval between two checks (every 2000ms by default)
  155156. */
  155157. set trackerDuration(value: number);
  155158. /**
  155159. * Gets the list of active optimizations
  155160. */
  155161. get optimizations(): SceneOptimization[];
  155162. /**
  155163. * Creates a new SceneOptimizer
  155164. * @param scene defines the scene to work on
  155165. * @param options defines the options to use with the SceneOptimizer
  155166. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155167. * @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)
  155168. */
  155169. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155170. /**
  155171. * Stops the current optimizer
  155172. */
  155173. stop(): void;
  155174. /**
  155175. * Reset the optimizer to initial step (current priority level = 0)
  155176. */
  155177. reset(): void;
  155178. /**
  155179. * Start the optimizer. By default it will try to reach a specific framerate
  155180. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155181. */
  155182. start(): void;
  155183. private _checkCurrentState;
  155184. /**
  155185. * Release all resources
  155186. */
  155187. dispose(): void;
  155188. /**
  155189. * Helper function to create a SceneOptimizer with one single line of code
  155190. * @param scene defines the scene to work on
  155191. * @param options defines the options to use with the SceneOptimizer
  155192. * @param onSuccess defines a callback to call on success
  155193. * @param onFailure defines a callback to call on failure
  155194. * @returns the new SceneOptimizer object
  155195. */
  155196. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155197. }
  155198. }
  155199. declare module BABYLON {
  155200. /**
  155201. * Class used to serialize a scene into a string
  155202. */
  155203. export class SceneSerializer {
  155204. /**
  155205. * Clear cache used by a previous serialization
  155206. */
  155207. static ClearCache(): void;
  155208. /**
  155209. * Serialize a scene into a JSON compatible object
  155210. * @param scene defines the scene to serialize
  155211. * @returns a JSON compatible object
  155212. */
  155213. static Serialize(scene: Scene): any;
  155214. /**
  155215. * Serialize a mesh into a JSON compatible object
  155216. * @param toSerialize defines the mesh to serialize
  155217. * @param withParents defines if parents must be serialized as well
  155218. * @param withChildren defines if children must be serialized as well
  155219. * @returns a JSON compatible object
  155220. */
  155221. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155222. }
  155223. }
  155224. declare module BABYLON {
  155225. /**
  155226. * Class used to host texture specific utilities
  155227. */
  155228. export class TextureTools {
  155229. /**
  155230. * Uses the GPU to create a copy texture rescaled at a given size
  155231. * @param texture Texture to copy from
  155232. * @param width defines the desired width
  155233. * @param height defines the desired height
  155234. * @param useBilinearMode defines if bilinear mode has to be used
  155235. * @return the generated texture
  155236. */
  155237. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155238. }
  155239. }
  155240. declare module BABYLON {
  155241. /**
  155242. * This represents the different options available for the video capture.
  155243. */
  155244. export interface VideoRecorderOptions {
  155245. /** Defines the mime type of the video. */
  155246. mimeType: string;
  155247. /** Defines the FPS the video should be recorded at. */
  155248. fps: number;
  155249. /** Defines the chunk size for the recording data. */
  155250. recordChunckSize: number;
  155251. /** The audio tracks to attach to the recording. */
  155252. audioTracks?: MediaStreamTrack[];
  155253. }
  155254. /**
  155255. * This can help with recording videos from BabylonJS.
  155256. * This is based on the available WebRTC functionalities of the browser.
  155257. *
  155258. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155259. */
  155260. export class VideoRecorder {
  155261. private static readonly _defaultOptions;
  155262. /**
  155263. * Returns whether or not the VideoRecorder is available in your browser.
  155264. * @param engine Defines the Babylon Engine.
  155265. * @returns true if supported otherwise false.
  155266. */
  155267. static IsSupported(engine: Engine): boolean;
  155268. private readonly _options;
  155269. private _canvas;
  155270. private _mediaRecorder;
  155271. private _recordedChunks;
  155272. private _fileName;
  155273. private _resolve;
  155274. private _reject;
  155275. /**
  155276. * True when a recording is already in progress.
  155277. */
  155278. get isRecording(): boolean;
  155279. /**
  155280. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155281. * @param engine Defines the BabylonJS Engine you wish to record.
  155282. * @param options Defines options that can be used to customize the capture.
  155283. */
  155284. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155285. /**
  155286. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155287. */
  155288. stopRecording(): void;
  155289. /**
  155290. * Starts recording the canvas for a max duration specified in parameters.
  155291. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155292. * If null no automatic download will start and you can rely on the promise to get the data back.
  155293. * @param maxDuration Defines the maximum recording time in seconds.
  155294. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155295. * @return A promise callback at the end of the recording with the video data in Blob.
  155296. */
  155297. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155298. /**
  155299. * Releases internal resources used during the recording.
  155300. */
  155301. dispose(): void;
  155302. private _handleDataAvailable;
  155303. private _handleError;
  155304. private _handleStop;
  155305. }
  155306. }
  155307. declare module BABYLON {
  155308. /**
  155309. * Class containing a set of static utilities functions for screenshots
  155310. */
  155311. export class ScreenshotTools {
  155312. /**
  155313. * Captures a screenshot of the current rendering
  155314. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155315. * @param engine defines the rendering engine
  155316. * @param camera defines the source camera
  155317. * @param size This parameter can be set to a single number or to an object with the
  155318. * following (optional) properties: precision, width, height. If a single number is passed,
  155319. * it will be used for both width and height. If an object is passed, the screenshot size
  155320. * will be derived from the parameters. The precision property is a multiplier allowing
  155321. * rendering at a higher or lower resolution
  155322. * @param successCallback defines the callback receives a single parameter which contains the
  155323. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155324. * src parameter of an <img> to display it
  155325. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155326. * Check your browser for supported MIME types
  155327. */
  155328. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155329. /**
  155330. * Captures a screenshot of the current rendering
  155331. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155332. * @param engine defines the rendering engine
  155333. * @param camera defines the source camera
  155334. * @param size This parameter can be set to a single number or to an object with the
  155335. * following (optional) properties: precision, width, height. If a single number is passed,
  155336. * it will be used for both width and height. If an object is passed, the screenshot size
  155337. * will be derived from the parameters. The precision property is a multiplier allowing
  155338. * rendering at a higher or lower resolution
  155339. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155340. * Check your browser for supported MIME types
  155341. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155342. * to the src parameter of an <img> to display it
  155343. */
  155344. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155345. /**
  155346. * Generates an image screenshot from the specified camera.
  155347. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155348. * @param engine The engine to use for rendering
  155349. * @param camera The camera to use for rendering
  155350. * @param size This parameter can be set to a single number or to an object with the
  155351. * following (optional) properties: precision, width, height. If a single number is passed,
  155352. * it will be used for both width and height. If an object is passed, the screenshot size
  155353. * will be derived from the parameters. The precision property is a multiplier allowing
  155354. * rendering at a higher or lower resolution
  155355. * @param successCallback The callback receives a single parameter which contains the
  155356. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155357. * src parameter of an <img> to display it
  155358. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155359. * Check your browser for supported MIME types
  155360. * @param samples Texture samples (default: 1)
  155361. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155362. * @param fileName A name for for the downloaded file.
  155363. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155364. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155365. */
  155366. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  155367. /**
  155368. * Generates an image screenshot from the specified camera.
  155369. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155370. * @param engine The engine to use for rendering
  155371. * @param camera The camera to use for rendering
  155372. * @param size This parameter can be set to a single number or to an object with the
  155373. * following (optional) properties: precision, width, height. If a single number is passed,
  155374. * it will be used for both width and height. If an object is passed, the screenshot size
  155375. * will be derived from the parameters. The precision property is a multiplier allowing
  155376. * rendering at a higher or lower resolution
  155377. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155378. * Check your browser for supported MIME types
  155379. * @param samples Texture samples (default: 1)
  155380. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155381. * @param fileName A name for for the downloaded file.
  155382. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155383. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155384. * to the src parameter of an <img> to display it
  155385. */
  155386. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155387. /**
  155388. * Gets height and width for screenshot size
  155389. * @private
  155390. */
  155391. private static _getScreenshotSize;
  155392. }
  155393. }
  155394. declare module BABYLON {
  155395. /**
  155396. * Interface for a data buffer
  155397. */
  155398. export interface IDataBuffer {
  155399. /**
  155400. * Reads bytes from the data buffer.
  155401. * @param byteOffset The byte offset to read
  155402. * @param byteLength The byte length to read
  155403. * @returns A promise that resolves when the bytes are read
  155404. */
  155405. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155406. /**
  155407. * The byte length of the buffer.
  155408. */
  155409. readonly byteLength: number;
  155410. }
  155411. /**
  155412. * Utility class for reading from a data buffer
  155413. */
  155414. export class DataReader {
  155415. /**
  155416. * The data buffer associated with this data reader.
  155417. */
  155418. readonly buffer: IDataBuffer;
  155419. /**
  155420. * The current byte offset from the beginning of the data buffer.
  155421. */
  155422. byteOffset: number;
  155423. private _dataView;
  155424. private _dataByteOffset;
  155425. /**
  155426. * Constructor
  155427. * @param buffer The buffer to read
  155428. */
  155429. constructor(buffer: IDataBuffer);
  155430. /**
  155431. * Loads the given byte length.
  155432. * @param byteLength The byte length to load
  155433. * @returns A promise that resolves when the load is complete
  155434. */
  155435. loadAsync(byteLength: number): Promise<void>;
  155436. /**
  155437. * Read a unsigned 32-bit integer from the currently loaded data range.
  155438. * @returns The 32-bit integer read
  155439. */
  155440. readUint32(): number;
  155441. /**
  155442. * Read a byte array from the currently loaded data range.
  155443. * @param byteLength The byte length to read
  155444. * @returns The byte array read
  155445. */
  155446. readUint8Array(byteLength: number): Uint8Array;
  155447. /**
  155448. * Read a string from the currently loaded data range.
  155449. * @param byteLength The byte length to read
  155450. * @returns The string read
  155451. */
  155452. readString(byteLength: number): string;
  155453. /**
  155454. * Skips the given byte length the currently loaded data range.
  155455. * @param byteLength The byte length to skip
  155456. */
  155457. skipBytes(byteLength: number): void;
  155458. }
  155459. }
  155460. declare module BABYLON {
  155461. /**
  155462. * Class for storing data to local storage if available or in-memory storage otherwise
  155463. */
  155464. export class DataStorage {
  155465. private static _Storage;
  155466. private static _GetStorage;
  155467. /**
  155468. * Reads a string from the data storage
  155469. * @param key The key to read
  155470. * @param defaultValue The value if the key doesn't exist
  155471. * @returns The string value
  155472. */
  155473. static ReadString(key: string, defaultValue: string): string;
  155474. /**
  155475. * Writes a string to the data storage
  155476. * @param key The key to write
  155477. * @param value The value to write
  155478. */
  155479. static WriteString(key: string, value: string): void;
  155480. /**
  155481. * Reads a boolean from the data storage
  155482. * @param key The key to read
  155483. * @param defaultValue The value if the key doesn't exist
  155484. * @returns The boolean value
  155485. */
  155486. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155487. /**
  155488. * Writes a boolean to the data storage
  155489. * @param key The key to write
  155490. * @param value The value to write
  155491. */
  155492. static WriteBoolean(key: string, value: boolean): void;
  155493. /**
  155494. * Reads a number from the data storage
  155495. * @param key The key to read
  155496. * @param defaultValue The value if the key doesn't exist
  155497. * @returns The number value
  155498. */
  155499. static ReadNumber(key: string, defaultValue: number): number;
  155500. /**
  155501. * Writes a number to the data storage
  155502. * @param key The key to write
  155503. * @param value The value to write
  155504. */
  155505. static WriteNumber(key: string, value: number): void;
  155506. }
  155507. }
  155508. declare module BABYLON {
  155509. /**
  155510. * Class used to record delta files between 2 scene states
  155511. */
  155512. export class SceneRecorder {
  155513. private _trackedScene;
  155514. private _savedJSON;
  155515. /**
  155516. * Track a given scene. This means the current scene state will be considered the original state
  155517. * @param scene defines the scene to track
  155518. */
  155519. track(scene: Scene): void;
  155520. /**
  155521. * Get the delta between current state and original state
  155522. * @returns a string containing the delta
  155523. */
  155524. getDelta(): any;
  155525. private _compareArray;
  155526. private _compareObjects;
  155527. private _compareCollections;
  155528. private static GetShadowGeneratorById;
  155529. /**
  155530. * Apply a given delta to a given scene
  155531. * @param deltaJSON defines the JSON containing the delta
  155532. * @param scene defines the scene to apply the delta to
  155533. */
  155534. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155535. private static _ApplyPropertiesToEntity;
  155536. private static _ApplyDeltaForEntity;
  155537. }
  155538. }
  155539. declare module BABYLON {
  155540. /**
  155541. * A 3D trajectory consisting of an order list of vectors describing a
  155542. * path of motion through 3D space.
  155543. */
  155544. export class Trajectory {
  155545. private _points;
  155546. private readonly _segmentLength;
  155547. /**
  155548. * Serialize to JSON.
  155549. * @returns serialized JSON string
  155550. */
  155551. serialize(): string;
  155552. /**
  155553. * Deserialize from JSON.
  155554. * @param json serialized JSON string
  155555. * @returns deserialized Trajectory
  155556. */
  155557. static Deserialize(json: string): Trajectory;
  155558. /**
  155559. * Create a new empty Trajectory.
  155560. * @param segmentLength radius of discretization for Trajectory points
  155561. */
  155562. constructor(segmentLength?: number);
  155563. /**
  155564. * Get the length of the Trajectory.
  155565. * @returns length of the Trajectory
  155566. */
  155567. getLength(): number;
  155568. /**
  155569. * Append a new point to the Trajectory.
  155570. * NOTE: This implementation has many allocations.
  155571. * @param point point to append to the Trajectory
  155572. */
  155573. add(point: DeepImmutable<Vector3>): void;
  155574. /**
  155575. * Create a new Trajectory with a segment length chosen to make it
  155576. * probable that the new Trajectory will have a specified number of
  155577. * segments. This operation is imprecise.
  155578. * @param targetResolution number of segments desired
  155579. * @returns new Trajectory with approximately the requested number of segments
  155580. */
  155581. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155582. /**
  155583. * Convert Trajectory segments into tokenized representation. This
  155584. * representation is an array of numbers where each nth number is the
  155585. * index of the token which is most similar to the nth segment of the
  155586. * Trajectory.
  155587. * @param tokens list of vectors which serve as discrete tokens
  155588. * @returns list of indices of most similar token per segment
  155589. */
  155590. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155591. private static _forwardDir;
  155592. private static _inverseFromVec;
  155593. private static _upDir;
  155594. private static _fromToVec;
  155595. private static _lookMatrix;
  155596. /**
  155597. * Transform the rotation (i.e., direction) of a segment to isolate
  155598. * the relative transformation represented by the segment. This operation
  155599. * may or may not succeed due to singularities in the equations that define
  155600. * motion relativity in this context.
  155601. * @param priorVec the origin of the prior segment
  155602. * @param fromVec the origin of the current segment
  155603. * @param toVec the destination of the current segment
  155604. * @param result reference to output variable
  155605. * @returns whether or not transformation was successful
  155606. */
  155607. private static _transformSegmentDirToRef;
  155608. private static _bestMatch;
  155609. private static _score;
  155610. private static _bestScore;
  155611. /**
  155612. * Determine which token vector is most similar to the
  155613. * segment vector.
  155614. * @param segment segment vector
  155615. * @param tokens token vector list
  155616. * @returns index of the most similar token to the segment
  155617. */
  155618. private static _tokenizeSegment;
  155619. }
  155620. /**
  155621. * Class representing a set of known, named trajectories to which Trajectories can be
  155622. * added and using which Trajectories can be recognized.
  155623. */
  155624. export class TrajectoryClassifier {
  155625. private _maximumAllowableMatchCost;
  155626. private _vector3Alphabet;
  155627. private _levenshteinAlphabet;
  155628. private _nameToDescribedTrajectory;
  155629. /**
  155630. * Serialize to JSON.
  155631. * @returns JSON serialization
  155632. */
  155633. serialize(): string;
  155634. /**
  155635. * Deserialize from JSON.
  155636. * @param json JSON serialization
  155637. * @returns deserialized TrajectorySet
  155638. */
  155639. static Deserialize(json: string): TrajectoryClassifier;
  155640. /**
  155641. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155642. * VERY naive, need to be generating these things from known
  155643. * sets. Better version later, probably eliminating this one.
  155644. * @returns auto-generated TrajectorySet
  155645. */
  155646. static Generate(): TrajectoryClassifier;
  155647. private constructor();
  155648. /**
  155649. * Add a new Trajectory to the set with a given name.
  155650. * @param trajectory new Trajectory to be added
  155651. * @param classification name to which to add the Trajectory
  155652. */
  155653. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155654. /**
  155655. * Remove a known named trajectory and all Trajectories associated with it.
  155656. * @param classification name to remove
  155657. * @returns whether anything was removed
  155658. */
  155659. deleteClassification(classification: string): boolean;
  155660. /**
  155661. * Attempt to recognize a Trajectory from among all the classifications
  155662. * already known to the classifier.
  155663. * @param trajectory Trajectory to be recognized
  155664. * @returns classification of Trajectory if recognized, null otherwise
  155665. */
  155666. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155667. }
  155668. }
  155669. declare module BABYLON {
  155670. /**
  155671. * An interface for all Hit test features
  155672. */
  155673. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155674. /**
  155675. * Triggered when new babylon (transformed) hit test results are available
  155676. */
  155677. onHitTestResultObservable: Observable<T[]>;
  155678. }
  155679. /**
  155680. * Options used for hit testing
  155681. */
  155682. export interface IWebXRLegacyHitTestOptions {
  155683. /**
  155684. * Only test when user interacted with the scene. Default - hit test every frame
  155685. */
  155686. testOnPointerDownOnly?: boolean;
  155687. /**
  155688. * The node to use to transform the local results to world coordinates
  155689. */
  155690. worldParentNode?: TransformNode;
  155691. }
  155692. /**
  155693. * Interface defining the babylon result of raycasting/hit-test
  155694. */
  155695. export interface IWebXRLegacyHitResult {
  155696. /**
  155697. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155698. */
  155699. transformationMatrix: Matrix;
  155700. /**
  155701. * The native hit test result
  155702. */
  155703. xrHitResult: XRHitResult | XRHitTestResult;
  155704. }
  155705. /**
  155706. * The currently-working hit-test module.
  155707. * Hit test (or Ray-casting) is used to interact with the real world.
  155708. * For further information read here - https://github.com/immersive-web/hit-test
  155709. */
  155710. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155711. /**
  155712. * options to use when constructing this feature
  155713. */
  155714. readonly options: IWebXRLegacyHitTestOptions;
  155715. private _direction;
  155716. private _mat;
  155717. private _onSelectEnabled;
  155718. private _origin;
  155719. /**
  155720. * The module's name
  155721. */
  155722. static readonly Name: string;
  155723. /**
  155724. * The (Babylon) version of this module.
  155725. * This is an integer representing the implementation version.
  155726. * This number does not correspond to the WebXR specs version
  155727. */
  155728. static readonly Version: number;
  155729. /**
  155730. * Populated with the last native XR Hit Results
  155731. */
  155732. lastNativeXRHitResults: XRHitResult[];
  155733. /**
  155734. * Triggered when new babylon (transformed) hit test results are available
  155735. */
  155736. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155737. /**
  155738. * Creates a new instance of the (legacy version) hit test feature
  155739. * @param _xrSessionManager an instance of WebXRSessionManager
  155740. * @param options options to use when constructing this feature
  155741. */
  155742. constructor(_xrSessionManager: WebXRSessionManager,
  155743. /**
  155744. * options to use when constructing this feature
  155745. */
  155746. options?: IWebXRLegacyHitTestOptions);
  155747. /**
  155748. * execute a hit test with an XR Ray
  155749. *
  155750. * @param xrSession a native xrSession that will execute this hit test
  155751. * @param xrRay the ray (position and direction) to use for ray-casting
  155752. * @param referenceSpace native XR reference space to use for the hit-test
  155753. * @param filter filter function that will filter the results
  155754. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155755. */
  155756. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155757. /**
  155758. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155759. * @param event the (select) event to use to select with
  155760. * @param referenceSpace the reference space to use for this hit test
  155761. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155762. */
  155763. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155764. /**
  155765. * attach this feature
  155766. * Will usually be called by the features manager
  155767. *
  155768. * @returns true if successful.
  155769. */
  155770. attach(): boolean;
  155771. /**
  155772. * detach this feature.
  155773. * Will usually be called by the features manager
  155774. *
  155775. * @returns true if successful.
  155776. */
  155777. detach(): boolean;
  155778. /**
  155779. * Dispose this feature and all of the resources attached
  155780. */
  155781. dispose(): void;
  155782. protected _onXRFrame(frame: XRFrame): void;
  155783. private _onHitTestResults;
  155784. private _onSelect;
  155785. }
  155786. }
  155787. declare module BABYLON {
  155788. /**
  155789. * Options used for hit testing (version 2)
  155790. */
  155791. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155792. /**
  155793. * Do not create a permanent hit test. Will usually be used when only
  155794. * transient inputs are needed.
  155795. */
  155796. disablePermanentHitTest?: boolean;
  155797. /**
  155798. * Enable transient (for example touch-based) hit test inspections
  155799. */
  155800. enableTransientHitTest?: boolean;
  155801. /**
  155802. * Offset ray for the permanent hit test
  155803. */
  155804. offsetRay?: Vector3;
  155805. /**
  155806. * Offset ray for the transient hit test
  155807. */
  155808. transientOffsetRay?: Vector3;
  155809. /**
  155810. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155811. */
  155812. useReferenceSpace?: boolean;
  155813. /**
  155814. * Override the default entity type(s) of the hit-test result
  155815. */
  155816. entityTypes?: XRHitTestTrackableType[];
  155817. }
  155818. /**
  155819. * Interface defining the babylon result of hit-test
  155820. */
  155821. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155822. /**
  155823. * The input source that generated this hit test (if transient)
  155824. */
  155825. inputSource?: XRInputSource;
  155826. /**
  155827. * Is this a transient hit test
  155828. */
  155829. isTransient?: boolean;
  155830. /**
  155831. * Position of the hit test result
  155832. */
  155833. position: Vector3;
  155834. /**
  155835. * Rotation of the hit test result
  155836. */
  155837. rotationQuaternion: Quaternion;
  155838. /**
  155839. * The native hit test result
  155840. */
  155841. xrHitResult: XRHitTestResult;
  155842. }
  155843. /**
  155844. * The currently-working hit-test module.
  155845. * Hit test (or Ray-casting) is used to interact with the real world.
  155846. * For further information read here - https://github.com/immersive-web/hit-test
  155847. *
  155848. * Tested on chrome (mobile) 80.
  155849. */
  155850. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155851. /**
  155852. * options to use when constructing this feature
  155853. */
  155854. readonly options: IWebXRHitTestOptions;
  155855. private _tmpMat;
  155856. private _tmpPos;
  155857. private _tmpQuat;
  155858. private _transientXrHitTestSource;
  155859. private _xrHitTestSource;
  155860. private initHitTestSource;
  155861. /**
  155862. * The module's name
  155863. */
  155864. static readonly Name: string;
  155865. /**
  155866. * The (Babylon) version of this module.
  155867. * This is an integer representing the implementation version.
  155868. * This number does not correspond to the WebXR specs version
  155869. */
  155870. static readonly Version: number;
  155871. /**
  155872. * When set to true, each hit test will have its own position/rotation objects
  155873. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155874. * the developers will clone them or copy them as they see fit.
  155875. */
  155876. autoCloneTransformation: boolean;
  155877. /**
  155878. * Triggered when new babylon (transformed) hit test results are available
  155879. * Note - this will be called when results come back from the device. It can be an empty array!!
  155880. */
  155881. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155882. /**
  155883. * Use this to temporarily pause hit test checks.
  155884. */
  155885. paused: boolean;
  155886. /**
  155887. * Creates a new instance of the hit test feature
  155888. * @param _xrSessionManager an instance of WebXRSessionManager
  155889. * @param options options to use when constructing this feature
  155890. */
  155891. constructor(_xrSessionManager: WebXRSessionManager,
  155892. /**
  155893. * options to use when constructing this feature
  155894. */
  155895. options?: IWebXRHitTestOptions);
  155896. /**
  155897. * attach this feature
  155898. * Will usually be called by the features manager
  155899. *
  155900. * @returns true if successful.
  155901. */
  155902. attach(): boolean;
  155903. /**
  155904. * detach this feature.
  155905. * Will usually be called by the features manager
  155906. *
  155907. * @returns true if successful.
  155908. */
  155909. detach(): boolean;
  155910. /**
  155911. * Dispose this feature and all of the resources attached
  155912. */
  155913. dispose(): void;
  155914. protected _onXRFrame(frame: XRFrame): void;
  155915. private _processWebXRHitTestResult;
  155916. }
  155917. }
  155918. declare module BABYLON {
  155919. /**
  155920. * Configuration options of the anchor system
  155921. */
  155922. export interface IWebXRAnchorSystemOptions {
  155923. /**
  155924. * a node that will be used to convert local to world coordinates
  155925. */
  155926. worldParentNode?: TransformNode;
  155927. /**
  155928. * If set to true a reference of the created anchors will be kept until the next session starts
  155929. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155930. */
  155931. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155932. }
  155933. /**
  155934. * A babylon container for an XR Anchor
  155935. */
  155936. export interface IWebXRAnchor {
  155937. /**
  155938. * A babylon-assigned ID for this anchor
  155939. */
  155940. id: number;
  155941. /**
  155942. * Transformation matrix to apply to an object attached to this anchor
  155943. */
  155944. transformationMatrix: Matrix;
  155945. /**
  155946. * The native anchor object
  155947. */
  155948. xrAnchor: XRAnchor;
  155949. /**
  155950. * if defined, this object will be constantly updated by the anchor's position and rotation
  155951. */
  155952. attachedNode?: TransformNode;
  155953. }
  155954. /**
  155955. * An implementation of the anchor system for WebXR.
  155956. * For further information see https://github.com/immersive-web/anchors/
  155957. */
  155958. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155959. private _options;
  155960. private _lastFrameDetected;
  155961. private _trackedAnchors;
  155962. private _referenceSpaceForFrameAnchors;
  155963. private _futureAnchors;
  155964. /**
  155965. * The module's name
  155966. */
  155967. static readonly Name: string;
  155968. /**
  155969. * The (Babylon) version of this module.
  155970. * This is an integer representing the implementation version.
  155971. * This number does not correspond to the WebXR specs version
  155972. */
  155973. static readonly Version: number;
  155974. /**
  155975. * Observers registered here will be executed when a new anchor was added to the session
  155976. */
  155977. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155978. /**
  155979. * Observers registered here will be executed when an anchor was removed from the session
  155980. */
  155981. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155982. /**
  155983. * Observers registered here will be executed when an existing anchor updates
  155984. * This can execute N times every frame
  155985. */
  155986. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155987. /**
  155988. * Set the reference space to use for anchor creation, when not using a hit test.
  155989. * Will default to the session's reference space if not defined
  155990. */
  155991. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155992. /**
  155993. * constructs a new anchor system
  155994. * @param _xrSessionManager an instance of WebXRSessionManager
  155995. * @param _options configuration object for this feature
  155996. */
  155997. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155998. private _tmpVector;
  155999. private _tmpQuaternion;
  156000. private _populateTmpTransformation;
  156001. /**
  156002. * Create a new anchor point using a hit test result at a specific point in the scene
  156003. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156004. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156005. *
  156006. * @param hitTestResult The hit test result to use for this anchor creation
  156007. * @param position an optional position offset for this anchor
  156008. * @param rotationQuaternion an optional rotation offset for this anchor
  156009. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156010. */
  156011. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156012. /**
  156013. * Add a new anchor at a specific position and rotation
  156014. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156015. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156016. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156017. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156018. *
  156019. * @param position the position in which to add an anchor
  156020. * @param rotationQuaternion an optional rotation for the anchor transformation
  156021. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156022. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156023. */
  156024. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156025. /**
  156026. * detach this feature.
  156027. * Will usually be called by the features manager
  156028. *
  156029. * @returns true if successful.
  156030. */
  156031. detach(): boolean;
  156032. /**
  156033. * Dispose this feature and all of the resources attached
  156034. */
  156035. dispose(): void;
  156036. protected _onXRFrame(frame: XRFrame): void;
  156037. /**
  156038. * avoiding using Array.find for global support.
  156039. * @param xrAnchor the plane to find in the array
  156040. */
  156041. private _findIndexInAnchorArray;
  156042. private _updateAnchorWithXRFrame;
  156043. private _createAnchorAtTransformation;
  156044. }
  156045. }
  156046. declare module BABYLON {
  156047. /**
  156048. * Options used in the plane detector module
  156049. */
  156050. export interface IWebXRPlaneDetectorOptions {
  156051. /**
  156052. * The node to use to transform the local results to world coordinates
  156053. */
  156054. worldParentNode?: TransformNode;
  156055. /**
  156056. * If set to true a reference of the created planes will be kept until the next session starts
  156057. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156058. */
  156059. doNotRemovePlanesOnSessionEnded?: boolean;
  156060. }
  156061. /**
  156062. * A babylon interface for a WebXR plane.
  156063. * A Plane is actually a polygon, built from N points in space
  156064. *
  156065. * Supported in chrome 79, not supported in canary 81 ATM
  156066. */
  156067. export interface IWebXRPlane {
  156068. /**
  156069. * a babylon-assigned ID for this polygon
  156070. */
  156071. id: number;
  156072. /**
  156073. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156074. */
  156075. polygonDefinition: Array<Vector3>;
  156076. /**
  156077. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156078. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156079. */
  156080. transformationMatrix: Matrix;
  156081. /**
  156082. * the native xr-plane object
  156083. */
  156084. xrPlane: XRPlane;
  156085. }
  156086. /**
  156087. * The plane detector is used to detect planes in the real world when in AR
  156088. * For more information see https://github.com/immersive-web/real-world-geometry/
  156089. */
  156090. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156091. private _options;
  156092. private _detectedPlanes;
  156093. private _enabled;
  156094. private _lastFrameDetected;
  156095. /**
  156096. * The module's name
  156097. */
  156098. static readonly Name: string;
  156099. /**
  156100. * The (Babylon) version of this module.
  156101. * This is an integer representing the implementation version.
  156102. * This number does not correspond to the WebXR specs version
  156103. */
  156104. static readonly Version: number;
  156105. /**
  156106. * Observers registered here will be executed when a new plane was added to the session
  156107. */
  156108. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156109. /**
  156110. * Observers registered here will be executed when a plane is no longer detected in the session
  156111. */
  156112. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156113. /**
  156114. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156115. * This can execute N times every frame
  156116. */
  156117. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156118. /**
  156119. * construct a new Plane Detector
  156120. * @param _xrSessionManager an instance of xr Session manager
  156121. * @param _options configuration to use when constructing this feature
  156122. */
  156123. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156124. /**
  156125. * detach this feature.
  156126. * Will usually be called by the features manager
  156127. *
  156128. * @returns true if successful.
  156129. */
  156130. detach(): boolean;
  156131. /**
  156132. * Dispose this feature and all of the resources attached
  156133. */
  156134. dispose(): void;
  156135. protected _onXRFrame(frame: XRFrame): void;
  156136. private _init;
  156137. private _updatePlaneWithXRPlane;
  156138. /**
  156139. * avoiding using Array.find for global support.
  156140. * @param xrPlane the plane to find in the array
  156141. */
  156142. private findIndexInPlaneArray;
  156143. }
  156144. }
  156145. declare module BABYLON {
  156146. /**
  156147. * Options interface for the background remover plugin
  156148. */
  156149. export interface IWebXRBackgroundRemoverOptions {
  156150. /**
  156151. * Further background meshes to disable when entering AR
  156152. */
  156153. backgroundMeshes?: AbstractMesh[];
  156154. /**
  156155. * flags to configure the removal of the environment helper.
  156156. * If not set, the entire background will be removed. If set, flags should be set as well.
  156157. */
  156158. environmentHelperRemovalFlags?: {
  156159. /**
  156160. * Should the skybox be removed (default false)
  156161. */
  156162. skyBox?: boolean;
  156163. /**
  156164. * Should the ground be removed (default false)
  156165. */
  156166. ground?: boolean;
  156167. };
  156168. /**
  156169. * don't disable the environment helper
  156170. */
  156171. ignoreEnvironmentHelper?: boolean;
  156172. }
  156173. /**
  156174. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156175. */
  156176. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156177. /**
  156178. * read-only options to be used in this module
  156179. */
  156180. readonly options: IWebXRBackgroundRemoverOptions;
  156181. /**
  156182. * The module's name
  156183. */
  156184. static readonly Name: string;
  156185. /**
  156186. * The (Babylon) version of this module.
  156187. * This is an integer representing the implementation version.
  156188. * This number does not correspond to the WebXR specs version
  156189. */
  156190. static readonly Version: number;
  156191. /**
  156192. * registered observers will be triggered when the background state changes
  156193. */
  156194. onBackgroundStateChangedObservable: Observable<boolean>;
  156195. /**
  156196. * constructs a new background remover module
  156197. * @param _xrSessionManager the session manager for this module
  156198. * @param options read-only options to be used in this module
  156199. */
  156200. constructor(_xrSessionManager: WebXRSessionManager,
  156201. /**
  156202. * read-only options to be used in this module
  156203. */
  156204. options?: IWebXRBackgroundRemoverOptions);
  156205. /**
  156206. * attach this feature
  156207. * Will usually be called by the features manager
  156208. *
  156209. * @returns true if successful.
  156210. */
  156211. attach(): boolean;
  156212. /**
  156213. * detach this feature.
  156214. * Will usually be called by the features manager
  156215. *
  156216. * @returns true if successful.
  156217. */
  156218. detach(): boolean;
  156219. /**
  156220. * Dispose this feature and all of the resources attached
  156221. */
  156222. dispose(): void;
  156223. protected _onXRFrame(_xrFrame: XRFrame): void;
  156224. private _setBackgroundState;
  156225. }
  156226. }
  156227. declare module BABYLON {
  156228. /**
  156229. * Options for the controller physics feature
  156230. */
  156231. export class IWebXRControllerPhysicsOptions {
  156232. /**
  156233. * Should the headset get its own impostor
  156234. */
  156235. enableHeadsetImpostor?: boolean;
  156236. /**
  156237. * Optional parameters for the headset impostor
  156238. */
  156239. headsetImpostorParams?: {
  156240. /**
  156241. * The type of impostor to create. Default is sphere
  156242. */
  156243. impostorType: number;
  156244. /**
  156245. * the size of the impostor. Defaults to 10cm
  156246. */
  156247. impostorSize?: number | {
  156248. width: number;
  156249. height: number;
  156250. depth: number;
  156251. };
  156252. /**
  156253. * Friction definitions
  156254. */
  156255. friction?: number;
  156256. /**
  156257. * Restitution
  156258. */
  156259. restitution?: number;
  156260. };
  156261. /**
  156262. * The physics properties of the future impostors
  156263. */
  156264. physicsProperties?: {
  156265. /**
  156266. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156267. * Note that this requires a physics engine that supports mesh impostors!
  156268. */
  156269. useControllerMesh?: boolean;
  156270. /**
  156271. * The type of impostor to create. Default is sphere
  156272. */
  156273. impostorType?: number;
  156274. /**
  156275. * the size of the impostor. Defaults to 10cm
  156276. */
  156277. impostorSize?: number | {
  156278. width: number;
  156279. height: number;
  156280. depth: number;
  156281. };
  156282. /**
  156283. * Friction definitions
  156284. */
  156285. friction?: number;
  156286. /**
  156287. * Restitution
  156288. */
  156289. restitution?: number;
  156290. };
  156291. /**
  156292. * the xr input to use with this pointer selection
  156293. */
  156294. xrInput: WebXRInput;
  156295. }
  156296. /**
  156297. * Add physics impostor to your webxr controllers,
  156298. * including naive calculation of their linear and angular velocity
  156299. */
  156300. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156301. private readonly _options;
  156302. private _attachController;
  156303. private _controllers;
  156304. private _debugMode;
  156305. private _delta;
  156306. private _headsetImpostor?;
  156307. private _headsetMesh?;
  156308. private _lastTimestamp;
  156309. private _tmpQuaternion;
  156310. private _tmpVector;
  156311. /**
  156312. * The module's name
  156313. */
  156314. static readonly Name: string;
  156315. /**
  156316. * The (Babylon) version of this module.
  156317. * This is an integer representing the implementation version.
  156318. * This number does not correspond to the webxr specs version
  156319. */
  156320. static readonly Version: number;
  156321. /**
  156322. * Construct a new Controller Physics Feature
  156323. * @param _xrSessionManager the corresponding xr session manager
  156324. * @param _options options to create this feature with
  156325. */
  156326. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156327. /**
  156328. * @hidden
  156329. * enable debugging - will show console outputs and the impostor mesh
  156330. */
  156331. _enablePhysicsDebug(): void;
  156332. /**
  156333. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156334. * @param xrController the controller to add
  156335. */
  156336. addController(xrController: WebXRInputSource): void;
  156337. /**
  156338. * attach this feature
  156339. * Will usually be called by the features manager
  156340. *
  156341. * @returns true if successful.
  156342. */
  156343. attach(): boolean;
  156344. /**
  156345. * detach this feature.
  156346. * Will usually be called by the features manager
  156347. *
  156348. * @returns true if successful.
  156349. */
  156350. detach(): boolean;
  156351. /**
  156352. * Get the headset impostor, if enabled
  156353. * @returns the impostor
  156354. */
  156355. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156356. /**
  156357. * Get the physics impostor of a specific controller.
  156358. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156359. * @param controller the controller or the controller id of which to get the impostor
  156360. * @returns the impostor or null
  156361. */
  156362. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156363. /**
  156364. * Update the physics properties provided in the constructor
  156365. * @param newProperties the new properties object
  156366. */
  156367. setPhysicsProperties(newProperties: {
  156368. impostorType?: number;
  156369. impostorSize?: number | {
  156370. width: number;
  156371. height: number;
  156372. depth: number;
  156373. };
  156374. friction?: number;
  156375. restitution?: number;
  156376. }): void;
  156377. protected _onXRFrame(_xrFrame: any): void;
  156378. private _detachController;
  156379. }
  156380. }
  156381. declare module BABYLON {
  156382. /**
  156383. * A babylon interface for a "WebXR" feature point.
  156384. * Represents the position and confidence value of a given feature point.
  156385. */
  156386. export interface IWebXRFeaturePoint {
  156387. /**
  156388. * Represents the position of the feature point in world space.
  156389. */
  156390. position: Vector3;
  156391. /**
  156392. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156393. */
  156394. confidenceValue: number;
  156395. }
  156396. /**
  156397. * The feature point system is used to detect feature points from real world geometry.
  156398. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156399. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156400. */
  156401. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156402. private _enabled;
  156403. private _featurePointCloud;
  156404. /**
  156405. * The module's name
  156406. */
  156407. static readonly Name: string;
  156408. /**
  156409. * The (Babylon) version of this module.
  156410. * This is an integer representing the implementation version.
  156411. * This number does not correspond to the WebXR specs version
  156412. */
  156413. static readonly Version: number;
  156414. /**
  156415. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156416. * Will notify the observers about which feature points have been added.
  156417. */
  156418. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156419. /**
  156420. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156421. * Will notify the observers about which feature points have been updated.
  156422. */
  156423. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156424. /**
  156425. * The current feature point cloud maintained across frames.
  156426. */
  156427. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156428. /**
  156429. * construct the feature point system
  156430. * @param _xrSessionManager an instance of xr Session manager
  156431. */
  156432. constructor(_xrSessionManager: WebXRSessionManager);
  156433. /**
  156434. * Detach this feature.
  156435. * Will usually be called by the features manager
  156436. *
  156437. * @returns true if successful.
  156438. */
  156439. detach(): boolean;
  156440. /**
  156441. * Dispose this feature and all of the resources attached
  156442. */
  156443. dispose(): void;
  156444. /**
  156445. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156446. */
  156447. protected _onXRFrame(frame: XRFrame): void;
  156448. /**
  156449. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156450. */
  156451. private _init;
  156452. }
  156453. }
  156454. declare module BABYLON {
  156455. /**
  156456. * Configuration interface for the hand tracking feature
  156457. */
  156458. export interface IWebXRHandTrackingOptions {
  156459. /**
  156460. * The xrInput that will be used as source for new hands
  156461. */
  156462. xrInput: WebXRInput;
  156463. /**
  156464. * Configuration object for the joint meshes
  156465. */
  156466. jointMeshes?: {
  156467. /**
  156468. * Should the meshes created be invisible (defaults to false)
  156469. */
  156470. invisible?: boolean;
  156471. /**
  156472. * A source mesh to be used to create instances. Defaults to a sphere.
  156473. * This mesh will be the source for all other (25) meshes.
  156474. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156475. */
  156476. sourceMesh?: Mesh;
  156477. /**
  156478. * This function will be called after a mesh was created for a specific joint.
  156479. * Using this function you can either manipulate the instance or return a new mesh.
  156480. * When returning a new mesh the instance created before will be disposed
  156481. */
  156482. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156483. /**
  156484. * Should the source mesh stay visible. Defaults to false
  156485. */
  156486. keepOriginalVisible?: boolean;
  156487. /**
  156488. * Scale factor for all instances (defaults to 2)
  156489. */
  156490. scaleFactor?: number;
  156491. /**
  156492. * Should each instance have its own physics impostor
  156493. */
  156494. enablePhysics?: boolean;
  156495. /**
  156496. * If enabled, override default physics properties
  156497. */
  156498. physicsProps?: {
  156499. friction?: number;
  156500. restitution?: number;
  156501. impostorType?: number;
  156502. };
  156503. /**
  156504. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156505. */
  156506. handMesh?: AbstractMesh;
  156507. };
  156508. }
  156509. /**
  156510. * Parts of the hands divided to writs and finger names
  156511. */
  156512. export const enum HandPart {
  156513. /**
  156514. * HandPart - Wrist
  156515. */
  156516. WRIST = "wrist",
  156517. /**
  156518. * HandPart - The THumb
  156519. */
  156520. THUMB = "thumb",
  156521. /**
  156522. * HandPart - Index finger
  156523. */
  156524. INDEX = "index",
  156525. /**
  156526. * HandPart - Middle finger
  156527. */
  156528. MIDDLE = "middle",
  156529. /**
  156530. * HandPart - Ring finger
  156531. */
  156532. RING = "ring",
  156533. /**
  156534. * HandPart - Little finger
  156535. */
  156536. LITTLE = "little"
  156537. }
  156538. /**
  156539. * Representing a single hand (with its corresponding native XRHand object)
  156540. */
  156541. export class WebXRHand implements IDisposable {
  156542. /** the controller to which the hand correlates */
  156543. readonly xrController: WebXRInputSource;
  156544. /** the meshes to be used to track the hand joints */
  156545. readonly trackedMeshes: AbstractMesh[];
  156546. /**
  156547. * Hand-parts definition (key is HandPart)
  156548. */
  156549. handPartsDefinition: {
  156550. [key: string]: number[];
  156551. };
  156552. /**
  156553. * Populate the HandPartsDefinition object.
  156554. * This is called as a side effect since certain browsers don't have XRHand defined.
  156555. */
  156556. private generateHandPartsDefinition;
  156557. /**
  156558. * Construct a new hand object
  156559. * @param xrController the controller to which the hand correlates
  156560. * @param trackedMeshes the meshes to be used to track the hand joints
  156561. */
  156562. constructor(
  156563. /** the controller to which the hand correlates */
  156564. xrController: WebXRInputSource,
  156565. /** the meshes to be used to track the hand joints */
  156566. trackedMeshes: AbstractMesh[]);
  156567. /**
  156568. * Update this hand from the latest xr frame
  156569. * @param xrFrame xrFrame to update from
  156570. * @param referenceSpace The current viewer reference space
  156571. * @param scaleFactor optional scale factor for the meshes
  156572. */
  156573. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156574. /**
  156575. * Get meshes of part of the hand
  156576. * @param part the part of hand to get
  156577. * @returns An array of meshes that correlate to the hand part requested
  156578. */
  156579. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156580. /**
  156581. * Dispose this Hand object
  156582. */
  156583. dispose(): void;
  156584. }
  156585. /**
  156586. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156587. */
  156588. export class WebXRHandTracking extends WebXRAbstractFeature {
  156589. /**
  156590. * options to use when constructing this feature
  156591. */
  156592. readonly options: IWebXRHandTrackingOptions;
  156593. private static _idCounter;
  156594. /**
  156595. * The module's name
  156596. */
  156597. static readonly Name: string;
  156598. /**
  156599. * The (Babylon) version of this module.
  156600. * This is an integer representing the implementation version.
  156601. * This number does not correspond to the WebXR specs version
  156602. */
  156603. static readonly Version: number;
  156604. /**
  156605. * This observable will notify registered observers when a new hand object was added and initialized
  156606. */
  156607. onHandAddedObservable: Observable<WebXRHand>;
  156608. /**
  156609. * This observable will notify its observers right before the hand object is disposed
  156610. */
  156611. onHandRemovedObservable: Observable<WebXRHand>;
  156612. private _hands;
  156613. /**
  156614. * Creates a new instance of the hit test feature
  156615. * @param _xrSessionManager an instance of WebXRSessionManager
  156616. * @param options options to use when constructing this feature
  156617. */
  156618. constructor(_xrSessionManager: WebXRSessionManager,
  156619. /**
  156620. * options to use when constructing this feature
  156621. */
  156622. options: IWebXRHandTrackingOptions);
  156623. /**
  156624. * Check if the needed objects are defined.
  156625. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156626. */
  156627. isCompatible(): boolean;
  156628. /**
  156629. * attach this feature
  156630. * Will usually be called by the features manager
  156631. *
  156632. * @returns true if successful.
  156633. */
  156634. attach(): boolean;
  156635. /**
  156636. * detach this feature.
  156637. * Will usually be called by the features manager
  156638. *
  156639. * @returns true if successful.
  156640. */
  156641. detach(): boolean;
  156642. /**
  156643. * Dispose this feature and all of the resources attached
  156644. */
  156645. dispose(): void;
  156646. /**
  156647. * Get the hand object according to the controller id
  156648. * @param controllerId the controller id to which we want to get the hand
  156649. * @returns null if not found or the WebXRHand object if found
  156650. */
  156651. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156652. /**
  156653. * Get a hand object according to the requested handedness
  156654. * @param handedness the handedness to request
  156655. * @returns null if not found or the WebXRHand object if found
  156656. */
  156657. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156658. protected _onXRFrame(_xrFrame: XRFrame): void;
  156659. private _attachHand;
  156660. private _detachHand;
  156661. }
  156662. }
  156663. declare module BABYLON {
  156664. /**
  156665. * The motion controller class for all microsoft mixed reality controllers
  156666. */
  156667. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156668. protected readonly _mapping: {
  156669. defaultButton: {
  156670. valueNodeName: string;
  156671. unpressedNodeName: string;
  156672. pressedNodeName: string;
  156673. };
  156674. defaultAxis: {
  156675. valueNodeName: string;
  156676. minNodeName: string;
  156677. maxNodeName: string;
  156678. };
  156679. buttons: {
  156680. "xr-standard-trigger": {
  156681. rootNodeName: string;
  156682. componentProperty: string;
  156683. states: string[];
  156684. };
  156685. "xr-standard-squeeze": {
  156686. rootNodeName: string;
  156687. componentProperty: string;
  156688. states: string[];
  156689. };
  156690. "xr-standard-touchpad": {
  156691. rootNodeName: string;
  156692. labelAnchorNodeName: string;
  156693. touchPointNodeName: string;
  156694. };
  156695. "xr-standard-thumbstick": {
  156696. rootNodeName: string;
  156697. componentProperty: string;
  156698. states: string[];
  156699. };
  156700. };
  156701. axes: {
  156702. "xr-standard-touchpad": {
  156703. "x-axis": {
  156704. rootNodeName: string;
  156705. };
  156706. "y-axis": {
  156707. rootNodeName: string;
  156708. };
  156709. };
  156710. "xr-standard-thumbstick": {
  156711. "x-axis": {
  156712. rootNodeName: string;
  156713. };
  156714. "y-axis": {
  156715. rootNodeName: string;
  156716. };
  156717. };
  156718. };
  156719. };
  156720. /**
  156721. * The base url used to load the left and right controller models
  156722. */
  156723. static MODEL_BASE_URL: string;
  156724. /**
  156725. * The name of the left controller model file
  156726. */
  156727. static MODEL_LEFT_FILENAME: string;
  156728. /**
  156729. * The name of the right controller model file
  156730. */
  156731. static MODEL_RIGHT_FILENAME: string;
  156732. profileId: string;
  156733. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156734. protected _getFilenameAndPath(): {
  156735. filename: string;
  156736. path: string;
  156737. };
  156738. protected _getModelLoadingConstraints(): boolean;
  156739. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156740. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156741. protected _updateModel(): void;
  156742. }
  156743. }
  156744. declare module BABYLON {
  156745. /**
  156746. * The motion controller class for oculus touch (quest, rift).
  156747. * This class supports legacy mapping as well the standard xr mapping
  156748. */
  156749. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156750. private _forceLegacyControllers;
  156751. private _modelRootNode;
  156752. /**
  156753. * The base url used to load the left and right controller models
  156754. */
  156755. static MODEL_BASE_URL: string;
  156756. /**
  156757. * The name of the left controller model file
  156758. */
  156759. static MODEL_LEFT_FILENAME: string;
  156760. /**
  156761. * The name of the right controller model file
  156762. */
  156763. static MODEL_RIGHT_FILENAME: string;
  156764. /**
  156765. * Base Url for the Quest controller model.
  156766. */
  156767. static QUEST_MODEL_BASE_URL: string;
  156768. profileId: string;
  156769. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156770. protected _getFilenameAndPath(): {
  156771. filename: string;
  156772. path: string;
  156773. };
  156774. protected _getModelLoadingConstraints(): boolean;
  156775. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156776. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156777. protected _updateModel(): void;
  156778. /**
  156779. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156780. * between the touch and touch 2.
  156781. */
  156782. private _isQuest;
  156783. }
  156784. }
  156785. declare module BABYLON {
  156786. /**
  156787. * The motion controller class for the standard HTC-Vive controllers
  156788. */
  156789. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156790. private _modelRootNode;
  156791. /**
  156792. * The base url used to load the left and right controller models
  156793. */
  156794. static MODEL_BASE_URL: string;
  156795. /**
  156796. * File name for the controller model.
  156797. */
  156798. static MODEL_FILENAME: string;
  156799. profileId: string;
  156800. /**
  156801. * Create a new Vive motion controller object
  156802. * @param scene the scene to use to create this controller
  156803. * @param gamepadObject the corresponding gamepad object
  156804. * @param handedness the handedness of the controller
  156805. */
  156806. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156807. protected _getFilenameAndPath(): {
  156808. filename: string;
  156809. path: string;
  156810. };
  156811. protected _getModelLoadingConstraints(): boolean;
  156812. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156813. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156814. protected _updateModel(): void;
  156815. }
  156816. }
  156817. declare module BABYLON {
  156818. /**
  156819. * A cursor which tracks a point on a path
  156820. */
  156821. export class PathCursor {
  156822. private path;
  156823. /**
  156824. * Stores path cursor callbacks for when an onchange event is triggered
  156825. */
  156826. private _onchange;
  156827. /**
  156828. * The value of the path cursor
  156829. */
  156830. value: number;
  156831. /**
  156832. * The animation array of the path cursor
  156833. */
  156834. animations: Animation[];
  156835. /**
  156836. * Initializes the path cursor
  156837. * @param path The path to track
  156838. */
  156839. constructor(path: Path2);
  156840. /**
  156841. * Gets the cursor point on the path
  156842. * @returns A point on the path cursor at the cursor location
  156843. */
  156844. getPoint(): Vector3;
  156845. /**
  156846. * Moves the cursor ahead by the step amount
  156847. * @param step The amount to move the cursor forward
  156848. * @returns This path cursor
  156849. */
  156850. moveAhead(step?: number): PathCursor;
  156851. /**
  156852. * Moves the cursor behind by the step amount
  156853. * @param step The amount to move the cursor back
  156854. * @returns This path cursor
  156855. */
  156856. moveBack(step?: number): PathCursor;
  156857. /**
  156858. * Moves the cursor by the step amount
  156859. * If the step amount is greater than one, an exception is thrown
  156860. * @param step The amount to move the cursor
  156861. * @returns This path cursor
  156862. */
  156863. move(step: number): PathCursor;
  156864. /**
  156865. * Ensures that the value is limited between zero and one
  156866. * @returns This path cursor
  156867. */
  156868. private ensureLimits;
  156869. /**
  156870. * Runs onchange callbacks on change (used by the animation engine)
  156871. * @returns This path cursor
  156872. */
  156873. private raiseOnChange;
  156874. /**
  156875. * Executes a function on change
  156876. * @param f A path cursor onchange callback
  156877. * @returns This path cursor
  156878. */
  156879. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156880. }
  156881. }
  156882. declare module BABYLON {
  156883. /** @hidden */
  156884. export var blurPixelShader: {
  156885. name: string;
  156886. shader: string;
  156887. };
  156888. }
  156889. declare module BABYLON {
  156890. /** @hidden */
  156891. export var pointCloudVertexDeclaration: {
  156892. name: string;
  156893. shader: string;
  156894. };
  156895. }
  156896. // Mixins
  156897. interface Window {
  156898. mozIndexedDB: IDBFactory;
  156899. webkitIndexedDB: IDBFactory;
  156900. msIndexedDB: IDBFactory;
  156901. webkitURL: typeof URL;
  156902. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156903. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156904. WebGLRenderingContext: WebGLRenderingContext;
  156905. MSGesture: MSGesture;
  156906. CANNON: any;
  156907. AudioContext: AudioContext;
  156908. webkitAudioContext: AudioContext;
  156909. PointerEvent: any;
  156910. Math: Math;
  156911. Uint8Array: Uint8ArrayConstructor;
  156912. Float32Array: Float32ArrayConstructor;
  156913. mozURL: typeof URL;
  156914. msURL: typeof URL;
  156915. VRFrameData: any; // WebVR, from specs 1.1
  156916. DracoDecoderModule: any;
  156917. setImmediate(handler: (...args: any[]) => void): number;
  156918. }
  156919. interface HTMLCanvasElement {
  156920. requestPointerLock(): void;
  156921. msRequestPointerLock?(): void;
  156922. mozRequestPointerLock?(): void;
  156923. webkitRequestPointerLock?(): void;
  156924. /** Track wether a record is in progress */
  156925. isRecording: boolean;
  156926. /** Capture Stream method defined by some browsers */
  156927. captureStream(fps?: number): MediaStream;
  156928. }
  156929. interface CanvasRenderingContext2D {
  156930. msImageSmoothingEnabled: boolean;
  156931. }
  156932. interface MouseEvent {
  156933. mozMovementX: number;
  156934. mozMovementY: number;
  156935. webkitMovementX: number;
  156936. webkitMovementY: number;
  156937. msMovementX: number;
  156938. msMovementY: number;
  156939. }
  156940. interface Navigator {
  156941. mozGetVRDevices: (any: any) => any;
  156942. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156943. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156944. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156945. webkitGetGamepads(): Gamepad[];
  156946. msGetGamepads(): Gamepad[];
  156947. webkitGamepads(): Gamepad[];
  156948. }
  156949. interface HTMLVideoElement {
  156950. mozSrcObject: any;
  156951. }
  156952. interface Math {
  156953. fround(x: number): number;
  156954. imul(a: number, b: number): number;
  156955. }
  156956. interface WebGLRenderingContext {
  156957. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156958. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156959. vertexAttribDivisor(index: number, divisor: number): void;
  156960. createVertexArray(): any;
  156961. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156962. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156963. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156964. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156965. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156966. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156967. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156968. // Queries
  156969. createQuery(): WebGLQuery;
  156970. deleteQuery(query: WebGLQuery): void;
  156971. beginQuery(target: number, query: WebGLQuery): void;
  156972. endQuery(target: number): void;
  156973. getQueryParameter(query: WebGLQuery, pname: number): any;
  156974. getQuery(target: number, pname: number): any;
  156975. MAX_SAMPLES: number;
  156976. RGBA8: number;
  156977. READ_FRAMEBUFFER: number;
  156978. DRAW_FRAMEBUFFER: number;
  156979. UNIFORM_BUFFER: number;
  156980. HALF_FLOAT_OES: number;
  156981. RGBA16F: number;
  156982. RGBA32F: number;
  156983. R32F: number;
  156984. RG32F: number;
  156985. RGB32F: number;
  156986. R16F: number;
  156987. RG16F: number;
  156988. RGB16F: number;
  156989. RED: number;
  156990. RG: number;
  156991. R8: number;
  156992. RG8: number;
  156993. UNSIGNED_INT_24_8: number;
  156994. DEPTH24_STENCIL8: number;
  156995. MIN: number;
  156996. MAX: number;
  156997. /* Multiple Render Targets */
  156998. drawBuffers(buffers: number[]): void;
  156999. readBuffer(src: number): void;
  157000. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157001. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157002. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157003. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157004. // Occlusion Query
  157005. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157006. ANY_SAMPLES_PASSED: number;
  157007. QUERY_RESULT_AVAILABLE: number;
  157008. QUERY_RESULT: number;
  157009. }
  157010. interface WebGLProgram {
  157011. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157012. }
  157013. interface EXT_disjoint_timer_query {
  157014. QUERY_COUNTER_BITS_EXT: number;
  157015. TIME_ELAPSED_EXT: number;
  157016. TIMESTAMP_EXT: number;
  157017. GPU_DISJOINT_EXT: number;
  157018. QUERY_RESULT_EXT: number;
  157019. QUERY_RESULT_AVAILABLE_EXT: number;
  157020. queryCounterEXT(query: WebGLQuery, target: number): void;
  157021. createQueryEXT(): WebGLQuery;
  157022. beginQueryEXT(target: number, query: WebGLQuery): void;
  157023. endQueryEXT(target: number): void;
  157024. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157025. deleteQueryEXT(query: WebGLQuery): void;
  157026. }
  157027. interface WebGLUniformLocation {
  157028. _currentState: any;
  157029. }
  157030. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157031. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157032. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157033. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157034. interface WebGLRenderingContext {
  157035. readonly RASTERIZER_DISCARD: number;
  157036. readonly DEPTH_COMPONENT24: number;
  157037. readonly TEXTURE_3D: number;
  157038. readonly TEXTURE_2D_ARRAY: number;
  157039. readonly TEXTURE_COMPARE_FUNC: number;
  157040. readonly TEXTURE_COMPARE_MODE: number;
  157041. readonly COMPARE_REF_TO_TEXTURE: number;
  157042. readonly TEXTURE_WRAP_R: number;
  157043. readonly HALF_FLOAT: number;
  157044. readonly RGB8: number;
  157045. readonly RED_INTEGER: number;
  157046. readonly RG_INTEGER: number;
  157047. readonly RGB_INTEGER: number;
  157048. readonly RGBA_INTEGER: number;
  157049. readonly R8_SNORM: number;
  157050. readonly RG8_SNORM: number;
  157051. readonly RGB8_SNORM: number;
  157052. readonly RGBA8_SNORM: number;
  157053. readonly R8I: number;
  157054. readonly RG8I: number;
  157055. readonly RGB8I: number;
  157056. readonly RGBA8I: number;
  157057. readonly R8UI: number;
  157058. readonly RG8UI: number;
  157059. readonly RGB8UI: number;
  157060. readonly RGBA8UI: number;
  157061. readonly R16I: number;
  157062. readonly RG16I: number;
  157063. readonly RGB16I: number;
  157064. readonly RGBA16I: number;
  157065. readonly R16UI: number;
  157066. readonly RG16UI: number;
  157067. readonly RGB16UI: number;
  157068. readonly RGBA16UI: number;
  157069. readonly R32I: number;
  157070. readonly RG32I: number;
  157071. readonly RGB32I: number;
  157072. readonly RGBA32I: number;
  157073. readonly R32UI: number;
  157074. readonly RG32UI: number;
  157075. readonly RGB32UI: number;
  157076. readonly RGBA32UI: number;
  157077. readonly RGB10_A2UI: number;
  157078. readonly R11F_G11F_B10F: number;
  157079. readonly RGB9_E5: number;
  157080. readonly RGB10_A2: number;
  157081. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157082. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157083. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157084. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157085. readonly DEPTH_COMPONENT32F: number;
  157086. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157087. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157088. 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;
  157089. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157090. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157091. readonly TRANSFORM_FEEDBACK: number;
  157092. readonly INTERLEAVED_ATTRIBS: number;
  157093. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157094. createTransformFeedback(): WebGLTransformFeedback;
  157095. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157096. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157097. beginTransformFeedback(primitiveMode: number): void;
  157098. endTransformFeedback(): void;
  157099. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157100. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157101. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157102. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157103. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157104. }
  157105. interface ImageBitmap {
  157106. readonly width: number;
  157107. readonly height: number;
  157108. close(): void;
  157109. }
  157110. interface WebGLQuery extends WebGLObject {
  157111. }
  157112. declare var WebGLQuery: {
  157113. prototype: WebGLQuery;
  157114. new(): WebGLQuery;
  157115. };
  157116. interface WebGLSampler extends WebGLObject {
  157117. }
  157118. declare var WebGLSampler: {
  157119. prototype: WebGLSampler;
  157120. new(): WebGLSampler;
  157121. };
  157122. interface WebGLSync extends WebGLObject {
  157123. }
  157124. declare var WebGLSync: {
  157125. prototype: WebGLSync;
  157126. new(): WebGLSync;
  157127. };
  157128. interface WebGLTransformFeedback extends WebGLObject {
  157129. }
  157130. declare var WebGLTransformFeedback: {
  157131. prototype: WebGLTransformFeedback;
  157132. new(): WebGLTransformFeedback;
  157133. };
  157134. interface WebGLVertexArrayObject extends WebGLObject {
  157135. }
  157136. declare var WebGLVertexArrayObject: {
  157137. prototype: WebGLVertexArrayObject;
  157138. new(): WebGLVertexArrayObject;
  157139. };
  157140. // Type definitions for WebVR API
  157141. // Project: https://w3c.github.io/webvr/
  157142. // Definitions by: six a <https://github.com/lostfictions>
  157143. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157144. interface VRDisplay extends EventTarget {
  157145. /**
  157146. * Dictionary of capabilities describing the VRDisplay.
  157147. */
  157148. readonly capabilities: VRDisplayCapabilities;
  157149. /**
  157150. * z-depth defining the far plane of the eye view frustum
  157151. * enables mapping of values in the render target depth
  157152. * attachment to scene coordinates. Initially set to 10000.0.
  157153. */
  157154. depthFar: number;
  157155. /**
  157156. * z-depth defining the near plane of the eye view frustum
  157157. * enables mapping of values in the render target depth
  157158. * attachment to scene coordinates. Initially set to 0.01.
  157159. */
  157160. depthNear: number;
  157161. /**
  157162. * An identifier for this distinct VRDisplay. Used as an
  157163. * association point in the Gamepad API.
  157164. */
  157165. readonly displayId: number;
  157166. /**
  157167. * A display name, a user-readable name identifying it.
  157168. */
  157169. readonly displayName: string;
  157170. readonly isConnected: boolean;
  157171. readonly isPresenting: boolean;
  157172. /**
  157173. * If this VRDisplay supports room-scale experiences, the optional
  157174. * stage attribute contains details on the room-scale parameters.
  157175. */
  157176. readonly stageParameters: VRStageParameters | null;
  157177. /**
  157178. * Passing the value returned by `requestAnimationFrame` to
  157179. * `cancelAnimationFrame` will unregister the callback.
  157180. * @param handle Define the hanle of the request to cancel
  157181. */
  157182. cancelAnimationFrame(handle: number): void;
  157183. /**
  157184. * Stops presenting to the VRDisplay.
  157185. * @returns a promise to know when it stopped
  157186. */
  157187. exitPresent(): Promise<void>;
  157188. /**
  157189. * Return the current VREyeParameters for the given eye.
  157190. * @param whichEye Define the eye we want the parameter for
  157191. * @returns the eye parameters
  157192. */
  157193. getEyeParameters(whichEye: string): VREyeParameters;
  157194. /**
  157195. * Populates the passed VRFrameData with the information required to render
  157196. * the current frame.
  157197. * @param frameData Define the data structure to populate
  157198. * @returns true if ok otherwise false
  157199. */
  157200. getFrameData(frameData: VRFrameData): boolean;
  157201. /**
  157202. * Get the layers currently being presented.
  157203. * @returns the list of VR layers
  157204. */
  157205. getLayers(): VRLayer[];
  157206. /**
  157207. * Return a VRPose containing the future predicted pose of the VRDisplay
  157208. * when the current frame will be presented. The value returned will not
  157209. * change until JavaScript has returned control to the browser.
  157210. *
  157211. * The VRPose will contain the position, orientation, velocity,
  157212. * and acceleration of each of these properties.
  157213. * @returns the pose object
  157214. */
  157215. getPose(): VRPose;
  157216. /**
  157217. * Return the current instantaneous pose of the VRDisplay, with no
  157218. * prediction applied.
  157219. * @returns the current instantaneous pose
  157220. */
  157221. getImmediatePose(): VRPose;
  157222. /**
  157223. * The callback passed to `requestAnimationFrame` will be called
  157224. * any time a new frame should be rendered. When the VRDisplay is
  157225. * presenting the callback will be called at the native refresh
  157226. * rate of the HMD. When not presenting this function acts
  157227. * identically to how window.requestAnimationFrame acts. Content should
  157228. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157229. * asynchronously from other displays and at differing refresh rates.
  157230. * @param callback Define the eaction to run next frame
  157231. * @returns the request handle it
  157232. */
  157233. requestAnimationFrame(callback: FrameRequestCallback): number;
  157234. /**
  157235. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157236. * Repeat calls while already presenting will update the VRLayers being displayed.
  157237. * @param layers Define the list of layer to present
  157238. * @returns a promise to know when the request has been fulfilled
  157239. */
  157240. requestPresent(layers: VRLayer[]): Promise<void>;
  157241. /**
  157242. * Reset the pose for this display, treating its current position and
  157243. * orientation as the "origin/zero" values. VRPose.position,
  157244. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157245. * updated when calling resetPose(). This should be called in only
  157246. * sitting-space experiences.
  157247. */
  157248. resetPose(): void;
  157249. /**
  157250. * The VRLayer provided to the VRDisplay will be captured and presented
  157251. * in the HMD. Calling this function has the same effect on the source
  157252. * canvas as any other operation that uses its source image, and canvases
  157253. * created without preserveDrawingBuffer set to true will be cleared.
  157254. * @param pose Define the pose to submit
  157255. */
  157256. submitFrame(pose?: VRPose): void;
  157257. }
  157258. declare var VRDisplay: {
  157259. prototype: VRDisplay;
  157260. new(): VRDisplay;
  157261. };
  157262. interface VRLayer {
  157263. leftBounds?: number[] | Float32Array | null;
  157264. rightBounds?: number[] | Float32Array | null;
  157265. source?: HTMLCanvasElement | null;
  157266. }
  157267. interface VRDisplayCapabilities {
  157268. readonly canPresent: boolean;
  157269. readonly hasExternalDisplay: boolean;
  157270. readonly hasOrientation: boolean;
  157271. readonly hasPosition: boolean;
  157272. readonly maxLayers: number;
  157273. }
  157274. interface VREyeParameters {
  157275. /** @deprecated */
  157276. readonly fieldOfView: VRFieldOfView;
  157277. readonly offset: Float32Array;
  157278. readonly renderHeight: number;
  157279. readonly renderWidth: number;
  157280. }
  157281. interface VRFieldOfView {
  157282. readonly downDegrees: number;
  157283. readonly leftDegrees: number;
  157284. readonly rightDegrees: number;
  157285. readonly upDegrees: number;
  157286. }
  157287. interface VRFrameData {
  157288. readonly leftProjectionMatrix: Float32Array;
  157289. readonly leftViewMatrix: Float32Array;
  157290. readonly pose: VRPose;
  157291. readonly rightProjectionMatrix: Float32Array;
  157292. readonly rightViewMatrix: Float32Array;
  157293. readonly timestamp: number;
  157294. }
  157295. interface VRPose {
  157296. readonly angularAcceleration: Float32Array | null;
  157297. readonly angularVelocity: Float32Array | null;
  157298. readonly linearAcceleration: Float32Array | null;
  157299. readonly linearVelocity: Float32Array | null;
  157300. readonly orientation: Float32Array | null;
  157301. readonly position: Float32Array | null;
  157302. readonly timestamp: number;
  157303. }
  157304. interface VRStageParameters {
  157305. sittingToStandingTransform?: Float32Array;
  157306. sizeX?: number;
  157307. sizeY?: number;
  157308. }
  157309. interface Navigator {
  157310. getVRDisplays(): Promise<VRDisplay[]>;
  157311. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157312. }
  157313. interface Window {
  157314. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157315. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157316. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157317. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157318. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157319. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157320. }
  157321. interface Gamepad {
  157322. readonly displayId: number;
  157323. }
  157324. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157325. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157326. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157327. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157328. type XRHandedness = "none" | "left" | "right";
  157329. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157330. type XREye = "none" | "left" | "right";
  157331. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157332. interface XRSpace extends EventTarget {}
  157333. interface XRRenderState {
  157334. depthNear?: number;
  157335. depthFar?: number;
  157336. inlineVerticalFieldOfView?: number;
  157337. baseLayer?: XRWebGLLayer;
  157338. }
  157339. interface XRInputSource {
  157340. handedness: XRHandedness;
  157341. targetRayMode: XRTargetRayMode;
  157342. targetRaySpace: XRSpace;
  157343. gripSpace: XRSpace | undefined;
  157344. gamepad: Gamepad | undefined;
  157345. profiles: Array<string>;
  157346. hand: XRHand | undefined;
  157347. }
  157348. interface XRSessionInit {
  157349. optionalFeatures?: string[];
  157350. requiredFeatures?: string[];
  157351. }
  157352. interface XRSession {
  157353. addEventListener: Function;
  157354. removeEventListener: Function;
  157355. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157356. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157357. requestAnimationFrame: Function;
  157358. end(): Promise<void>;
  157359. renderState: XRRenderState;
  157360. inputSources: Array<XRInputSource>;
  157361. // hit test
  157362. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157363. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157364. // legacy AR hit test
  157365. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157366. // legacy plane detection
  157367. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157368. }
  157369. interface XRReferenceSpace extends XRSpace {
  157370. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157371. onreset: any;
  157372. }
  157373. type XRPlaneSet = Set<XRPlane>;
  157374. type XRAnchorSet = Set<XRAnchor>;
  157375. interface XRFrame {
  157376. session: XRSession;
  157377. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157378. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157379. // AR
  157380. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157381. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157382. // Anchors
  157383. trackedAnchors?: XRAnchorSet;
  157384. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157385. // Planes
  157386. worldInformation: {
  157387. detectedPlanes?: XRPlaneSet;
  157388. };
  157389. // Hand tracking
  157390. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157391. }
  157392. interface XRViewerPose extends XRPose {
  157393. views: Array<XRView>;
  157394. }
  157395. interface XRPose {
  157396. transform: XRRigidTransform;
  157397. emulatedPosition: boolean;
  157398. }
  157399. interface XRWebGLLayerOptions {
  157400. antialias?: boolean;
  157401. depth?: boolean;
  157402. stencil?: boolean;
  157403. alpha?: boolean;
  157404. multiview?: boolean;
  157405. framebufferScaleFactor?: number;
  157406. }
  157407. declare var XRWebGLLayer: {
  157408. prototype: XRWebGLLayer;
  157409. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157410. };
  157411. interface XRWebGLLayer {
  157412. framebuffer: WebGLFramebuffer;
  157413. framebufferWidth: number;
  157414. framebufferHeight: number;
  157415. getViewport: Function;
  157416. }
  157417. declare class XRRigidTransform {
  157418. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157419. position: DOMPointReadOnly;
  157420. orientation: DOMPointReadOnly;
  157421. matrix: Float32Array;
  157422. inverse: XRRigidTransform;
  157423. }
  157424. interface XRView {
  157425. eye: XREye;
  157426. projectionMatrix: Float32Array;
  157427. transform: XRRigidTransform;
  157428. }
  157429. interface XRInputSourceChangeEvent {
  157430. session: XRSession;
  157431. removed: Array<XRInputSource>;
  157432. added: Array<XRInputSource>;
  157433. }
  157434. interface XRInputSourceEvent extends Event {
  157435. readonly frame: XRFrame;
  157436. readonly inputSource: XRInputSource;
  157437. }
  157438. // Experimental(er) features
  157439. declare class XRRay {
  157440. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157441. origin: DOMPointReadOnly;
  157442. direction: DOMPointReadOnly;
  157443. matrix: Float32Array;
  157444. }
  157445. declare enum XRHitTestTrackableType {
  157446. "point",
  157447. "plane",
  157448. "mesh",
  157449. }
  157450. interface XRHitResult {
  157451. hitMatrix: Float32Array;
  157452. }
  157453. interface XRTransientInputHitTestResult {
  157454. readonly inputSource: XRInputSource;
  157455. readonly results: Array<XRHitTestResult>;
  157456. }
  157457. interface XRHitTestResult {
  157458. getPose(baseSpace: XRSpace): XRPose | undefined;
  157459. // When anchor system is enabled
  157460. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157461. }
  157462. interface XRHitTestSource {
  157463. cancel(): void;
  157464. }
  157465. interface XRTransientInputHitTestSource {
  157466. cancel(): void;
  157467. }
  157468. interface XRHitTestOptionsInit {
  157469. space: XRSpace;
  157470. entityTypes?: Array<XRHitTestTrackableType>;
  157471. offsetRay?: XRRay;
  157472. }
  157473. interface XRTransientInputHitTestOptionsInit {
  157474. profile: string;
  157475. entityTypes?: Array<XRHitTestTrackableType>;
  157476. offsetRay?: XRRay;
  157477. }
  157478. interface XRAnchor {
  157479. anchorSpace: XRSpace;
  157480. delete(): void;
  157481. }
  157482. interface XRPlane {
  157483. orientation: "Horizontal" | "Vertical";
  157484. planeSpace: XRSpace;
  157485. polygon: Array<DOMPointReadOnly>;
  157486. lastChangedTime: number;
  157487. }
  157488. interface XRJointSpace extends XRSpace {}
  157489. interface XRJointPose extends XRPose {
  157490. radius: number | undefined;
  157491. }
  157492. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157493. readonly length: number;
  157494. [index: number]: XRJointSpace;
  157495. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157496. readonly WRIST: number;
  157497. readonly THUMB_METACARPAL: number;
  157498. readonly THUMB_PHALANX_PROXIMAL: number;
  157499. readonly THUMB_PHALANX_DISTAL: number;
  157500. readonly THUMB_PHALANX_TIP: number;
  157501. readonly INDEX_METACARPAL: number;
  157502. readonly INDEX_PHALANX_PROXIMAL: number;
  157503. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157504. readonly INDEX_PHALANX_DISTAL: number;
  157505. readonly INDEX_PHALANX_TIP: number;
  157506. readonly MIDDLE_METACARPAL: number;
  157507. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157508. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157509. readonly MIDDLE_PHALANX_DISTAL: number;
  157510. readonly MIDDLE_PHALANX_TIP: number;
  157511. readonly RING_METACARPAL: number;
  157512. readonly RING_PHALANX_PROXIMAL: number;
  157513. readonly RING_PHALANX_INTERMEDIATE: number;
  157514. readonly RING_PHALANX_DISTAL: number;
  157515. readonly RING_PHALANX_TIP: number;
  157516. readonly LITTLE_METACARPAL: number;
  157517. readonly LITTLE_PHALANX_PROXIMAL: number;
  157518. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157519. readonly LITTLE_PHALANX_DISTAL: number;
  157520. readonly LITTLE_PHALANX_TIP: number;
  157521. }
  157522. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157523. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157524. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157525. interface XRSession {
  157526. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157527. }
  157528. interface XRFrame {
  157529. featurePointCloud? : Array<number>;
  157530. }